Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,31 @@ def host_setup_extension

super
end

def context_urls
super.merge(rhsm_url: rhsm_url, pulp_content_url: pulp_content_url)
end

private

def smart_proxy
@smart_proxy ||= begin
proxy = params[:url] ? SmartProxy.find_by(url: params[:url]) : SmartProxy.pulp_primary

fail Foreman::Exception, N_('Smart proxy content source not found!') unless proxy
fail Foreman::Exception, N_('Pulp 3 is not enabled on Smart proxy!') unless proxy.pulp3_enabled?

proxy
end
end

def rhsm_url
URI(smart_proxy.rhsm_url)
end

def pulp_content_url
smart_proxy.setting(SmartProxy::PULP3_FEATURE, 'content_app_url')
end
end
end
end
8 changes: 8 additions & 0 deletions app/models/katello/concerns/smart_proxy_extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,14 @@ def repos_pending_sync(environment = nil, content_view = nil)
def smart_proxy_service
@smart_proxy_service ||= Pulp::SmartProxyRepository.new(self)
end

def rhsm_url
if pulp_primary?
"https://#{URI.parse(url).host}/rhsm"
elsif pulp_mirror?
"https://#{URI.parse(url).host}:8443/rhsm"
end
end
end
end
end
9 changes: 9 additions & 0 deletions test/models/concerns/smart_proxy_extensions_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ def test_save_with_organization_location
assert_equal @proxy.lifecycle_environments.all, Katello::KTEnvironment.all
assert_equal @proxy_mirror.lifecycle_environments.all.count, 0
end

def test_rhsm_url_pulp_primary
assert_includes @proxy.rhsm_url, "/rhsm"
assert_not_includes @proxy.rhsm_url, ":8443"
end

def test_rhsm_url_pulp_mirror
assert_includes @proxy_mirror.rhsm_url, ":8443/rhsm"
end
end

class SmartProxyPulp3Test < ActiveSupport::TestCase
Expand Down