From 3cb6578d2a8fc4b66c12fee3e65578391e291494 Mon Sep 17 00:00:00 2001 From: Jesus Bermudez Velazquez Date: Wed, 4 Sep 2024 09:37:15 +0100 Subject: [PATCH 1/3] Set old proxy BYOS value until we drop that column --- engines/scc_proxy/lib/scc_proxy/engine.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/engines/scc_proxy/lib/scc_proxy/engine.rb b/engines/scc_proxy/lib/scc_proxy/engine.rb index 52532ad7b..378b87a99 100644 --- a/engines/scc_proxy/lib/scc_proxy/engine.rb +++ b/engines/scc_proxy/lib/scc_proxy/engine.rb @@ -312,6 +312,7 @@ def announce_system password: response['password'], hostname: params[:hostname], proxy_byos_mode: :byos, + proxy_byos: true, system_information: system_information, instance_data: instance_data ) From c2f30af04fcd0db9809dc3fe3a8644ba3935e5e7 Mon Sep 17 00:00:00 2001 From: Jesus Bermudez Velazquez Date: Wed, 4 Sep 2024 11:06:07 +0100 Subject: [PATCH 2/3] Update the product serializer Before LTSS, the product serializer returned true for the free field of any product That is no longer true in the Public Cloud scenario, where LTSS is not free This Fixes that case --- app/serializers/v3/product_serializer.rb | 5 ++++- .../api/connect/v3/systems/products_controller_spec.rb | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/serializers/v3/product_serializer.rb b/app/serializers/v3/product_serializer.rb index d0ccea8b4..90747f838 100644 --- a/app/serializers/v3/product_serializer.rb +++ b/app/serializers/v3/product_serializer.rb @@ -33,8 +33,11 @@ def eula_url end def free - # Everything is free on RMT :-) + # Everything is free on RMT :-) outside of the Public Cloud (i.e. LTSS) # Otherwise Yast and SUSEConnect will request a regcode when activating an extension + # FIXME + return object.free if defined?(SccProxy::Engine) && object.extension? + true end diff --git a/engines/instance_verification/spec/requests/api/connect/v3/systems/products_controller_spec.rb b/engines/instance_verification/spec/requests/api/connect/v3/systems/products_controller_spec.rb index 3a002f4d1..6d6e15d97 100644 --- a/engines/instance_verification/spec/requests/api/connect/v3/systems/products_controller_spec.rb +++ b/engines/instance_verification/spec/requests/api/connect/v3/systems/products_controller_spec.rb @@ -540,6 +540,7 @@ context 'when no regcode is provided' do it 'activates the product' do data = JSON.parse(response.body) + expect(data['product']['free']).to eq(false) expect(data['id']).to eq(product.id) end end From 98a473c7c76f85496acfb7c7e9a36a947f86afea Mon Sep 17 00:00:00 2001 From: Jesus Bermudez Velazquez Date: Wed, 4 Sep 2024 12:31:36 +0100 Subject: [PATCH 3/3] Check only extensions for SCC activations When checking the registry access if system is hybrid, the check with SCC for the state of its activations should be done only with non free extensions, as base product is not free This Fixes that scenario --- engines/registry/app/models/access_scope.rb | 2 +- engines/registry/spec/app/models/access_scope_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/registry/app/models/access_scope.rb b/engines/registry/app/models/access_scope.rb index 7e5c7b7ad..511dbbca5 100644 --- a/engines/registry/app/models/access_scope.rb +++ b/engines/registry/app/models/access_scope.rb @@ -87,7 +87,7 @@ def allowed_paths(system = nil) allowed_product_classes = (active_product_classes & access_policies_yml.keys) if system && system.hybrid? # if the system is hybrid => check if the non free product subscription is still valid for accessing images - allowed_non_free_product_classes = allowed_product_classes.map { |s| s unless Product.find_by(product_class: s).free? } + allowed_non_free_product_classes = allowed_product_classes.map { |s| s unless Product.find_by(product_class: s, product_type: 'extension').free? }.compact unless allowed_non_free_product_classes.empty? auth_header = { 'HTTP_AUTHORIZATION' => ActionController::HttpAuthentication::Basic.encode_credentials(system.login, system.password) diff --git a/engines/registry/spec/app/models/access_scope_spec.rb b/engines/registry/spec/app/models/access_scope_spec.rb index 9b0f6dff0..1448388e7 100644 --- a/engines/registry/spec/app/models/access_scope_spec.rb +++ b/engines/registry/spec/app/models/access_scope_spec.rb @@ -194,7 +194,7 @@ system end let(:product1) do - product = FactoryBot.create(:product, :with_mirrored_repositories) + product = FactoryBot.create(:product, :with_mirrored_repositories, :extension) product.repositories.where(enabled: false).update(mirroring_enabled: false) product.update(product_class: 'SLES15-SP4-LTSS-X86') product