Skip to content

Commit

Permalink
Merge pull request #590 from yast/update_tests_sp3
Browse files Browse the repository at this point in the history
[SLE15-SP3] Update unit tests to work with the new suseconnect-ng
  • Loading branch information
lslezak authored Sep 13, 2023
2 parents 1d005d2 + 97207bd commit b0749fb
Show file tree
Hide file tree
Showing 29 changed files with 129 additions and 136 deletions.
2 changes: 2 additions & 0 deletions package/yast2-registration.changes
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ Wed Aug 2 08:44:51 UTC 2023 - Ladislav Slezák <[email protected]>

- Switch to the new SUSEConnect-ng (bsc#1212799)
- Includes a SSL reload fix (bsc#1195220)
- Depends on a new suseconnect-ruby-bindings package instead of
the old rubygem-suseconnect
- 4.3.27

-------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions src/lib/registration/autoyast_addons.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
module Registration
# This class handles the AutoYaST addons
class AutoyastAddons
include Yast::Logger
include Yast::I18n

attr_accessor :requested_addons, :selected_addons
Expand Down
1 change: 1 addition & 0 deletions src/lib/registration/controllers/package_search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ module Registration
module Controllers
# Implements the actions and keeps the state for the package search feature
class PackageSearch
include Yast::Logger
include Yast::I18n

# @return [Array<RemotePackage>] List of selected packages
Expand Down
6 changes: 3 additions & 3 deletions src/lib/registration/registration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ def activated_products
end

# get the list of migration products
# @param [Array<SUSE::Connect::Remote::Product>] installed_products
# @return [Array<Array<SUSE::Connect::Remote::Product>>] list of possible migrations,
# @param [Array<OpenStruct>] installed_products
# @return [Array<Array<OpenStruct>>] list of possible migrations,
# each migration contains a list of target products
def migration_products(installed_products)
log.info "Loading migration products for: #{installed_products}"
Expand Down Expand Up @@ -359,7 +359,7 @@ def connect_params(params = {})
end

# collect product renames
# @param products [Array<SUSE::Connect::Remote::Product>] remote products received from SCC
# @param products [Array<OpenStruct>] remote products received from SCC
# @return [Hash] hash with product renames: { old_name => new_name }
def collect_renames(products)
renames = {}
Expand Down
2 changes: 2 additions & 0 deletions src/lib/registration/ssl_certificate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ module Registration
# class handling SSL certificate
# TODO: move it to yast2 to share it?
class SslCertificate
include Yast::Logger

Yast.import "Stage"

# Path to the registration certificate in the instsys
Expand Down
4 changes: 2 additions & 2 deletions src/lib/registration/sw_mgmt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,9 @@ def self.installed_products
products.map { |p| resolvable_to_h(p) }
end

# convert a libzypp Product Hash to a SUSE::Connect::Remote::Product object
# convert a libzypp Product Hash to a OpenStruct object
# @param product [Hash] product Hash obtained from pkg-bindings
# @return [SUSE::Connect::Remote::Product] the remote product
# @return [OpenStruct] the remote product
def self.remote_product(product, version_release: true)
# default value if it does not exist
product["version_version"] ||= product["version"]
Expand Down
2 changes: 1 addition & 1 deletion src/lib/registration/ui/migration_repos_workflow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ def load_migrations_for_products(products, remote_product)
# check if the target producte has been already activated, if yes
# require user confirmation for the migration (though it will very likely fail)
# @param base_product [Y2Packager::Product] the base product to which migrate to
# @param activations [Array<SUSE::Connect::Remote::Product>] already activated
# @param activations [Array<OpenStruct>] already activated
# products on the server
# @return [Boolean] true = continue with the migration, false = stop
def migration_confirmed?(base_product, activations)
Expand Down
4 changes: 2 additions & 2 deletions src/lib/registration/ui/migration_selection_dialog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ class MigrationSelectionDialog
attr_accessor :selected_migration, :manual_repo_selection, :installed_products

# run the dialog
# @param [Array<SUSE::Connect::Remote::Product>] migrations the available migration targets
# @param [Array<OpenStruct>] migrations the available migration targets
# @param [Array<Hash>] installed_products the currently installed products
def self.run(migrations, installed_products)
dialog = MigrationSelectionDialog.new(migrations, installed_products)
dialog.run
end

# constructor
# @param [Array<SUSE::Connect::Remote::Product>] migrations the available migration targets
# @param [Array<OpenStruct>] migrations the available migration targets
# @param [Array<Hash>] installed_products the currently installed products
def initialize(migrations, installed_products)
textdomain "registration"
Expand Down
2 changes: 2 additions & 0 deletions src/lib/registration/widgets/registration_code.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
module Registration
module Widgets
class RegistrationCode < CWM::InputField
include Yast::Logger

VALID_URL_SCHEMES = ["http", "https"].freeze

def initialize
Expand Down
6 changes: 3 additions & 3 deletions test/factories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ def suse_connect_product_generator(attrs = {})
end

def addon_generator(params = {})
SUSE::Connect::Remote::Product.new(suse_connect_product_generator(params))
OpenStruct.new(suse_connect_product_generator(params))
end

def addon_with_child_generator(parent_params = {})
prod_child = suse_connect_product_generator
SUSE::Connect::Remote::Product.new(
prod_child = OpenStruct.new(suse_connect_product_generator)
OpenStruct.new(
suse_connect_product_generator(parent_params.merge("extensions" => [prod_child]))
)
end
Expand Down
24 changes: 12 additions & 12 deletions test/fixtures/activated_products.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
- !ruby/object:SUSE::Connect::Remote::Product
- !ruby/object:OpenStruct
table:
:id: 1157
:name: SUSE Linux Enterprise High Availability GEO Extension
Expand Down Expand Up @@ -34,7 +34,7 @@
enabled: true
autorefresh: true
modifiable: true
- !ruby/object:SUSE::Connect::Remote::Product
- !ruby/object:OpenStruct
table:
:id: 1245
:name: SUSE Linux Enterprise High Availability Extension
Expand All @@ -53,7 +53,7 @@
- 1539
- 1500
:extensions:
- !ruby/object:SUSE::Connect::Remote::Product
- !ruby/object:OpenStruct
table:
:id: 1157
:name: SUSE Linux Enterprise High Availability GEO Extension
Expand Down Expand Up @@ -105,7 +105,7 @@
enabled: true
autorefresh: true
modifiable: true
- !ruby/object:SUSE::Connect::Remote::Product
- !ruby/object:OpenStruct
table:
:id: 1117
:name: SUSE Linux Enterprise Server
Expand All @@ -128,7 +128,7 @@
- 1219
- 1478
:extensions:
- !ruby/object:SUSE::Connect::Remote::Product
- !ruby/object:OpenStruct
table:
:id: 1222
:name: SUSE Linux Enterprise Workstation Extension
Expand Down Expand Up @@ -189,7 +189,7 @@
enabled: true
autorefresh: true
modifiable: true
- !ruby/object:SUSE::Connect::Remote::Product
- !ruby/object:OpenStruct
table:
:id: 1223
:name: SUSE Linux Enterprise Software Development Kit
Expand Down Expand Up @@ -233,7 +233,7 @@
enabled: true
autorefresh: true
modifiable: true
- !ruby/object:SUSE::Connect::Remote::Product
- !ruby/object:OpenStruct
table:
:id: 1150
:name: Legacy Module
Expand Down Expand Up @@ -276,7 +276,7 @@
enabled: true
autorefresh: true
modifiable: true
- !ruby/object:SUSE::Connect::Remote::Product
- !ruby/object:OpenStruct
table:
:id: 1153
:name: Web and Scripting Module
Expand Down Expand Up @@ -320,7 +320,7 @@
enabled: true
autorefresh: true
modifiable: true
- !ruby/object:SUSE::Connect::Remote::Product
- !ruby/object:OpenStruct
table:
:id: 1220
:name: Public Cloud Module
Expand Down Expand Up @@ -362,7 +362,7 @@
enabled: true
autorefresh: true
modifiable: true
- !ruby/object:SUSE::Connect::Remote::Product
- !ruby/object:OpenStruct
table:
:id: 1212
:name: Advanced Systems Management Module
Expand Down Expand Up @@ -402,7 +402,7 @@
enabled: true
autorefresh: true
modifiable: true
- !ruby/object:SUSE::Connect::Remote::Product
- !ruby/object:OpenStruct
table:
:id: 1245
:name: SUSE Linux Enterprise High Availability Extension
Expand All @@ -421,7 +421,7 @@
- 1539
- 1500
:extensions:
- !ruby/object:SUSE::Connect::Remote::Product
- !ruby/object:OpenStruct
table:
:id: 1157
:name: SUSE Linux Enterprise High Availability GEO Extension
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/available_addons.yml
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@
:successor_ids:
- 1324
:extensions:
- &1 !ruby/object:SUSE::Connect::Remote::Product
- &1 !ruby/object:OpenStruct
table:
:id: 1157
:name: SUSE Linux Enterprise High Availability GEO Extension
Expand Down
12 changes: 6 additions & 6 deletions test/fixtures/available_unknown_addons.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- !ruby/object:Registration::Addon
pure_addon: !ruby/object:SUSE::Connect::Remote::Product
pure_addon: !ruby/object:OpenStruct
table:
:id: 1153
:name: Web and Scripting Module
Expand Down Expand Up @@ -43,7 +43,7 @@
modifiable: true
children: []
- !ruby/object:Registration::Addon
pure_addon: !ruby/object:SUSE::Connect::Remote::Product
pure_addon: !ruby/object:OpenStruct
table:
:id: 1212
:name: Advanced Systems Management Module
Expand Down Expand Up @@ -84,7 +84,7 @@
modifiable: true
children: []
- !ruby/object:Registration::Addon
pure_addon: !ruby/object:SUSE::Connect::Remote::Product
pure_addon: !ruby/object:OpenStruct
table:
:id: 1223
:name: SUSE Linux Enterprise Software Development Kit
Expand Down Expand Up @@ -128,7 +128,7 @@
modifiable: true
children: []
- !ruby/object:Registration::Addon
pure_addon: !ruby/object:SUSE::Connect::Remote::Product
pure_addon: !ruby/object:OpenStruct
table:
:id: 1150
:name: Legacy Module
Expand Down Expand Up @@ -171,7 +171,7 @@
modifiable: true
children: []
- !ruby/object:Registration::Addon
pure_addon: !ruby/object:SUSE::Connect::Remote::Product
pure_addon: !ruby/object:OpenStruct
table:
:id: 1220
:name: Public Cloud Module
Expand Down Expand Up @@ -213,7 +213,7 @@
modifiable: true
children: []
- !ruby/object:Registration::Addon
pure_addon: !ruby/object:SUSE::Connect::Remote::Product
pure_addon: !ruby/object:OpenStruct
table:
:id: 1222
:name: SUSE Linux Enterprise Workstation Extension
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/installed_sles12_product.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
- !ruby/object:SUSE::Connect::Remote::Product
- !ruby/object:OpenStruct
table:
:arch: x86_64
:identifier: SLES
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures/legacy_module_services.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
- !ruby/object:SUSE::Connect::Remote::Service
- !ruby/object:OpenStruct
table:
:id: 1140
:name: Legacy_Module_12_x86_64
:url: https://scc.suse.com/access/services/1140?credentials=Legacy_Module_12_x86_64
:product: !ruby/object:SUSE::Connect::Remote::Product
:product: !ruby/object:OpenStruct
table:
:id: 1150
:name: Legacy Module
Expand Down
8 changes: 4 additions & 4 deletions test/fixtures/migration_service.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
--- !ruby/object:SUSE::Connect::Remote::Service
--- !ruby/object:OpenStruct
table:
:id: 1311
:name: SUSE_Linux_Enterprise_Server_12_SP1_12.1_x86_64
:url: https://scc.suse.com/access/services/1311?credentials=SUSE_Linux_Enterprise_Server_12_SP1_12.1_x86_64
:product: !ruby/object:SUSE::Connect::Remote::Product
:product: !ruby/object:OpenStruct
table:
:id: 1322
:name: SUSE Linux Enterprise Server 12 SP1
Expand Down Expand Up @@ -54,7 +54,7 @@ table:
autorefresh: false
:product_type: base
:extensions:
- !ruby/object:SUSE::Connect::Remote::Product
- !ruby/object:OpenStruct
table:
:id: 1323
:name: SUSE Linux Enterprise Software Development Kit
Expand Down Expand Up @@ -110,7 +110,7 @@ table:
:product_type: extension
:extensions: []
modifiable: true
- !ruby/object:SUSE::Connect::Remote::Product
- !ruby/object:OpenStruct
table:
:id: 1324
:name: SUSE Linux Enterprise High Availability Extension
Expand Down
Loading

0 comments on commit b0749fb

Please sign in to comment.