diff options
author | Timothy Andrew <mail@timothyandrew.net> | 2017-06-30 07:32:25 +0000 |
---|---|---|
committer | Timothy Andrew <mail@timothyandrew.net> | 2017-06-30 07:32:25 +0000 |
commit | afbc7520c296196d0f3f95d4a24a9e42c0e41f3c (patch) | |
tree | b24fcb7fff29f362cfe1976bf4e12a5330d83cb9 /spec/services | |
parent | b8ec1f4201c74c500e4f7010b238c7920599da7a (diff) | |
download | gitlab-ce-afbc7520c296196d0f3f95d4a24a9e42c0e41f3c.tar.gz |
`AccessTokenValidationService` accepts `String` or `API::Scope` scopes.
- There's no need to use `API::Scope` for scopes that don't have `if`
conditions, such as in `lib/gitlab/auth.rb`.
Diffstat (limited to 'spec/services')
-rw-r--r-- | spec/services/access_token_validation_service_spec.rb | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/spec/services/access_token_validation_service_spec.rb b/spec/services/access_token_validation_service_spec.rb index 660a05e0b6d..11225fad18a 100644 --- a/spec/services/access_token_validation_service_spec.rb +++ b/spec/services/access_token_validation_service_spec.rb @@ -6,28 +6,28 @@ describe AccessTokenValidationService, services: true do it "returns true if the required scope is present in the token's scopes" do token = double("token", scopes: [:api, :read_user]) - scopes = [API::Scope.new(:api)] + scopes = [:api] expect(described_class.new(token, request: request).include_any_scope?(scopes)).to be(true) end it "returns true if more than one of the required scopes is present in the token's scopes" do token = double("token", scopes: [:api, :read_user, :other_scope]) - scopes = [API::Scope.new(:api), API::Scope.new(:other_scope)] + scopes = [:api, :other_scope] expect(described_class.new(token, request: request).include_any_scope?(scopes)).to be(true) end it "returns true if the list of required scopes is an exact match for the token's scopes" do token = double("token", scopes: [:api, :read_user, :other_scope]) - scopes = [API::Scope.new(:api), API::Scope.new(:read_user), API::Scope.new(:other_scope)] + scopes = [:api, :read_user, :other_scope] expect(described_class.new(token, request: request).include_any_scope?(scopes)).to be(true) end it "returns true if the list of required scopes contains all of the token's scopes, in addition to others" do token = double("token", scopes: [:api, :read_user]) - scopes = [API::Scope.new(:api), API::Scope.new(:read_user), API::Scope.new(:other_scope)] + scopes = [:api, :read_user, :other_scope] expect(described_class.new(token, request: request).include_any_scope?(scopes)).to be(true) end @@ -41,7 +41,7 @@ describe AccessTokenValidationService, services: true do it "returns false if there are no scopes in common between the required scopes and the token scopes" do token = double("token", scopes: [:api, :read_user]) - scopes = [API::Scope.new(:other_scope)] + scopes = [:other_scope] expect(described_class.new(token, request: request).include_any_scope?(scopes)).to be(false) end @@ -56,7 +56,7 @@ describe AccessTokenValidationService, services: true do it "does not ignore scopes whose `if` condition is not set" do token = double("token", scopes: [:api, :read_user]) - scopes = [API::Scope.new(:api, if: ->(_) { false }), API::Scope.new(:read_user)] + scopes = [API::Scope.new(:api, if: ->(_) { false }), :read_user] expect(described_class.new(token, request: request).include_any_scope?(scopes)).to be(true) end |