Skip to content

Commit

Permalink
Fixes #37107 - Refresh RHEL lifecycle status on facts update (#10863)
Browse files Browse the repository at this point in the history
  • Loading branch information
parthaa authored Jan 26, 2024
1 parent 7091b11 commit 3dcae86
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ def facts
User.current = User.anonymous_admin
@host.update_candlepin_associations(rhsm_params)
update_host_registered_through(@host, request.headers)
@host.refresh_statuses([::Katello::RhelLifecycleStatus])
render :json => {:content => _("Facts successfully updated.")}, :status => :ok
end

Expand Down
28 changes: 28 additions & 0 deletions test/controllers/api/rhsm/candlepin_proxies_controller_test.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# encoding: utf-8

require "katello_test_helper"
require 'fact_importer_test_helper'

#rubocop:disable Metrics/ModuleLength
module Katello
Expand Down Expand Up @@ -446,6 +447,33 @@ def test_regenerate_indentity_certificates
end
end

describe "consumer_facts" do
include FactImporterIsolation

it "can update the rhel lifecycle status" do
allow_transactions_for_any_importer
os = operatingsystems(:redhat)
os.update!(major: "8", minor: "6")
@host.update(:operatingsystem => os)
uuid = @host.subscription_facet.uuid
stub_cp_consumer_with_uuid(uuid)
@controller.stubs(:update_host_registered_through)
Katello::Resources::Candlepin::Consumer.stubs(:update)
Katello::Resources::Candlepin::Consumer.stubs(:refresh_entitlements)
Katello::Host::SubscriptionFacet.any_instance.stubs(:update_from_consumer_attributes)
::Host::Managed.any_instance.stubs(:refresh_global_status!)
assert_equal ::Katello::RhelLifecycleStatus::UNKNOWN, @host.get_status(::Katello::RhelLifecycleStatus).status
facts = {
"distribution.id" => "Ootpa",
"distribution::version" => "8.6",
"distribution::name" => "Red Hat Enterprise Linux"
}
put :facts, params: { :id => uuid, :facts => facts }
assert_response 200
assert_equal ::Katello::RhelLifecycleStatus::FULL_SUPPORT, @host.reload.get_status(::Katello::RhelLifecycleStatus).status
end
end

describe "get parent host" do
it "can get parent host" do
capsule = "foocapsule.example.com"
Expand Down

0 comments on commit 3dcae86

Please sign in to comment.