Skip to content

Commit

Permalink
Fixes #35961 - Simple Content Access API shouldn't check upstream con…
Browse files Browse the repository at this point in the history
…nection (#10422)
  • Loading branch information
jeremylenz committed Jan 23, 2023
1 parent 22db652 commit 186a503
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 70 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module Katello
class Api::V2::SimpleContentAccessController < Api::V2::ApiController
before_action :find_organization
before_action :check_upstream_connection

resource_description do
description "Red Hat subscriptions management platform."
Expand All @@ -11,7 +10,8 @@ class Api::V2::SimpleContentAccessController < Api::V2::ApiController
api :GET, "/organizations/:organization_id/simple_content_access/eligible",
N_("Check if the specified organization is eligible for Simple Content Access")
def eligible
eligible = @organization.upstream_consumer.simple_content_access_eligible?
::Foreman::Deprecation.api_deprecation_warning("This endpoint is deprecated and will be removed in a future release. All organizations are now eligible for Simple Content Access.")
eligible = @organization.simple_content_access_eligible?
render json: { simple_content_access_eligible: eligible }
end

Expand Down
8 changes: 4 additions & 4 deletions app/models/katello/concerns/organization_extensions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ def anonymous_provider
self.providers.anonymous.first
end

def simple_content_access_eligible?
self.content_access_mode_list.include?('org_environment')
end

def manifest_imported?(cached: false)
Rails.cache.fetch("#{self.label}_manifest_imported?", expires_in: 1.minute, force: !cached) do
owner_details['upstreamConsumer'].present?
Expand Down Expand Up @@ -238,10 +242,6 @@ def audit_manifest_action(message)
# doesn't provide much benefit for the frustration it creates.
self.save(validate: false)
end

def upstream_consumer
Katello::Candlepin::UpstreamConsumer.new(self)
end
end
end
end
Expand Down
4 changes: 4 additions & 0 deletions app/models/katello/glue/candlepin/owner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ def content_access_mode
self.owner_details['contentAccessMode']
end

def content_access_mode_list
self.owner_details['contentAccessModeList'].split(',')
end

def simple_content_access?(cached: true)
Rails.cache.fetch("#{self.label}_simple_content_access?", expires_in: 1.minute, force: !cached) do
content_access_mode == "org_environment"
Expand Down
28 changes: 0 additions & 28 deletions app/services/katello/candlepin/upstream_consumer.rb

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ def setup
setup_controller_defaults_api
login_user(User.find(users(:admin).id))
models
Katello::UpstreamConnectionChecker.any_instance.expects(:assert_connection)
end

def test_enable_protected
Expand Down Expand Up @@ -104,7 +103,7 @@ def test_status_protected
end

def test_eligible
Katello::Candlepin::UpstreamConsumer.any_instance.expects(:simple_content_access_eligible?).returns(true)
Organization.any_instance.expects(:simple_content_access_eligible?).returns(true)

get :eligible, params: { organization_id: @organization.id }

Expand Down
4 changes: 0 additions & 4 deletions test/models/concerns/organization_extensions_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,5 @@ def test_manifest_history
@org.expects(:imports).returns([{'foo' => 'bar' }, {'foo' => 'bar'}])
assert_equal 'bar', @org.manifest_history[0].foo
end

def test_upstream_consumer
assert @org.upstream_consumer
end
end
end
30 changes: 0 additions & 30 deletions test/services/katello/candlepin/upstream_consumer_test.rb

This file was deleted.

0 comments on commit 186a503

Please sign in to comment.