Skip to content

Commit 589d7f3

Browse files
committed
Support empty rhsm_url setting on proxies
This drops the compatibility fallbacks that were in place for pre-3.1 installations. Since then the value has been present. Now it becomes possible to not set a value which means the RHSM URL is on the Foreman instance itself. This is useful for Pulp-only installations without any RHSM reverse proxy setup.
1 parent 308d91b commit 589d7f3

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

Diff for: app/models/katello/concerns/smart_proxy_extensions.rb

+7-8
Original file line numberDiff line numberDiff line change
@@ -611,14 +611,13 @@ def up_to_date?(environment = nil, content_view = nil)
611611
end
612612

613613
def rhsm_url
614-
# Since Foreman 3.1 this setting is set
615-
if (rhsm_url = setting(SmartProxy::PULP3_FEATURE, 'rhsm_url'))
616-
URI(rhsm_url)
617-
# Compatibility fall back
618-
elsif pulp_primary?
619-
URI("https://#{URI.parse(url).host}/rhsm")
620-
elsif pulp_mirror?
621-
URI("https://#{URI.parse(url).host}:8443/rhsm")
614+
if (rhsm_url_setting = setting(SmartProxy::PULP3_FEATURE, 'rhsm_url').presence)
615+
URI(rhsm_url_setting)
616+
else
617+
# TODO: get this from routes
618+
uri = URI.parse(Setting[:foreman_url])
619+
uri.path = '/rhsm'
620+
uri
622621
end
623622
end
624623

Diff for: test/models/concerns/smart_proxy_extensions_test.rb

+10-5
Original file line numberDiff line numberDiff line change
@@ -399,13 +399,18 @@ def test_save_with_organization_location
399399
assert_equal @proxy_mirror.lifecycle_environments.all.count, 0
400400
end
401401

402-
def test_rhsm_url_pulp_primary
403-
assert_includes @proxy.rhsm_url.to_s, "/rhsm"
404-
assert_not_includes @proxy.rhsm_url.to_s, ":8443"
402+
def test_rhsm_url_without_rhsm_url_setting
403+
Setting[:foreman_url] = 'https://foreman.example.com/'
404+
proxy = FactoryBot.build(:smart_proxy, :with_pulp3)
405+
assert_equal proxy.rhsm_url.to_s, "https://foreman.example.com/rhsm"
405406
end
406407

407-
def test_rhsm_url_pulp_mirror
408-
assert_includes @proxy_mirror.rhsm_url.to_s, ":8443/rhsm"
408+
def test_rhsm_url_with_rhsm_url_setting
409+
proxy = FactoryBot.create(:smart_proxy, :with_pulp3)
410+
feature = proxy.smart_proxy_features.find_by(feature: Feature.find_by(name: ::SmartProxy::PULP3_FEATURE))
411+
feature.settings[:rhsm_url] = 'https://rhsm.example.com/rhsm'
412+
feature.save!
413+
assert_equal proxy.rhsm_url.to_s, 'https://rhsm.example.com/rhsm'
409414
end
410415

411416
def test_sync_container_gateway

0 commit comments

Comments
 (0)