Skip to content

Commit

Permalink
THREESCALE-8990: CMS access token scope: make public (#3135)
Browse files Browse the repository at this point in the history
* Clean up code from the CMS API rolling update
* Access Tokens: remove support for private APIs
* Access Token scopes: cleanup for private apis
  • Loading branch information
jlledom authored Jan 18, 2023
1 parent aab025b commit 48dcc0b
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 55 deletions.
10 changes: 0 additions & 10 deletions app/lib/logic/rolling_updates.rb
Original file line number Diff line number Diff line change
Expand Up @@ -234,16 +234,6 @@ def missing_config
end
end

class CMSApi < Base
def enabled?
super || master?
end

def missing_config
false
end
end

class ApicastV2 < Base
def missing_config
master?
Expand Down
22 changes: 1 addition & 21 deletions app/models/access_token.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,6 @@ def permission_name
else value.to_s.to_sym
end
end

def public?
non_public_scopes.exclude?(value.to_s)
end

private

def non_public_scopes
%w(cms).freeze
end
end

class Scopes
Expand All @@ -57,16 +47,6 @@ def allowed_for(owner)
end
end

def visible_for(account)
select_and_build do |scope|
if scope.public?
true
else
account.provider_can_use?("#{scope.value}_api")
end
end
end

def keys
scopes.map(&:key)
end
Expand Down Expand Up @@ -169,7 +149,7 @@ def show_value?(*)
end

def available_scopes
owner.allowed_access_token_scopes.visible_for(owner.account)
owner.allowed_access_token_scopes
end

def human_scopes
Expand Down
1 change: 0 additions & 1 deletion config/docker/rolling_updates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ base: &default
require_cc_on_signup: false
apicast_per_service: true
new_notification_system: true
cms_api: false
forum: false
policy_registry: false
apicast_v2: true
Expand Down
1 change: 0 additions & 1 deletion config/examples/rolling_updates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ base: &default
require_cc_on_signup: false
apicast_per_service: true
new_notification_system: true
cms_api: false
forum: false
policy_registry: true
proxy_private_base_path: true
Expand Down
1 change: 0 additions & 1 deletion openshift/system/config/rolling_updates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ base: &default
require_cc_on_signup: false
apicast_per_service: true
new_notification_system: true
cms_api: false
apicast_v2: true
forum: false
published_service_plan_signup: true
Expand Down
13 changes: 0 additions & 13 deletions test/models/access_token_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,6 @@ def test_destroy_dependency
end
end

def test_non_public_scopes
member.admin_sections = [:monitoring, :portal]
member.save!
@token.owner = member
@token.save!

Account.any_instance.expects(:provider_can_use?).with('cms_api').returns(false)
assert_equal ['stats'], @token.available_scopes.values

Account.any_instance.expects(:provider_can_use?).with('cms_api').returns(true)
assert_equal ['cms', 'stats'], @token.available_scopes.values
end

def test_available_permissions
assert_kind_of Hash, @token.available_permissions
end
Expand Down
8 changes: 0 additions & 8 deletions test/unit/logic/rolling_updates_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,6 @@ def test_forum
refute account.provider_can_use?(:forum)
end

def test_cms_api
account = FactoryBot.build_stubbed(:simple_account)

Rails.configuration.three_scale.rolling_updates.stubs(features: { cms_api: [account.id] })
assert account.provider_can_use?(:cms_api)
assert account.provider_can_use?('cms_api')
end

def test_feature
assert Logic::RollingUpdates.feature(:service_permissions)

Expand Down

0 comments on commit 48dcc0b

Please sign in to comment.