diff --git a/app/services/katello/registration_manager.rb b/app/services/katello/registration_manager.rb index 80a4f05acb6..29ce57a6865 100644 --- a/app/services/katello/registration_manager.rb +++ b/app/services/katello/registration_manager.rb @@ -306,6 +306,7 @@ def remove_host_artifacts(host, clear_content_facet: true) host.content_facet.applicable_errata = [] host.content_facet.uuid = nil host.content_facet.content_view_environments = [] + host.content_facet.content_source = ::SmartProxy.pulp_primary host.content_facet.save! Rails.logger.debug "remove_host_artifacts: marking CVEs unchanged to prevent backend update" host.content_facet.mark_cves_unchanged diff --git a/test/services/katello/registration_manager_test.rb b/test/services/katello/registration_manager_test.rb index 8afcd545522..ab71df39461 100644 --- a/test/services/katello/registration_manager_test.rb +++ b/test/services/katello/registration_manager_test.rb @@ -308,6 +308,19 @@ def test_unregister_host_rhsm_facts assert_empty @host.rhsm_fact_values end + def test_unregister_host_resets_content_source + @host = FactoryBot.create(:host, :with_content, :with_subscription, :content_view => @content_view, + :lifecycle_environment => @library, :organization => @content_view.organization) + pulp3_proxy = FactoryBot.create(:smart_proxy, :with_pulp3) + @host.content_facet.update(:content_source_id => pulp3_proxy.id) + ::Katello::Resources::Candlepin::Consumer.expects(:destroy) + + ::Katello::RegistrationManager.unregister_host(@host, unregistering: true) + + refute_nil @host.content_facet.content_source + assert_equal ::SmartProxy.pulp_primary, @host.content_facet.content_source + end + def test_destroy_host_not_found @host = FactoryBot.create(:host, :with_content, :with_subscription, :content_view => @content_view, :lifecycle_environment => @library, :organization => @content_view.organization) diff --git a/webpack/components/extensions/HostDetails/DetailsTabCards/RegistrationCard.js b/webpack/components/extensions/HostDetails/DetailsTabCards/RegistrationCard.js index 91b252efdef..cb9cddda82c 100644 --- a/webpack/components/extensions/HostDetails/DetailsTabCards/RegistrationCard.js +++ b/webpack/components/extensions/HostDetails/DetailsTabCards/RegistrationCard.js @@ -55,9 +55,12 @@ const RegistrationCard = ({ isExpandedGlobal, hostDetails }) => { const subscriptionFacetAttributes = propsToCamelCase(hostDetails?.subscription_facet_attributes || {}); const { - registeredAt, registeredThrough, activationKeys, user, + registeredAt, activationKeys, user, } = subscriptionFacetAttributes; + const contentFacetAttributes + = propsToCamelCase(hostDetails?.content_facet_attributes || {}); + const { contentSourceName } = contentFacetAttributes; const login = user?.login; if (!registeredAt) return null; return ( @@ -78,7 +81,7 @@ const RegistrationCard = ({ isExpandedGlobal, hostDetails }) => { {__('Content source')} - {registeredThrough} + {contentSourceName} @@ -99,6 +102,9 @@ RegistrationCard.propTypes = { name: PropTypes.string, })), }), + content_facet_attributes: PropTypes.shape({ + content_source_name: PropTypes.string, + }), }), };