diff options
author | Timothy Andrew <mail@timothyandrew.net> | 2017-06-21 09:22:39 +0000 |
---|---|---|
committer | Timothy Andrew <mail@timothyandrew.net> | 2017-06-28 07:17:13 +0000 |
commit | 1b8223dd51345f6075172a92dab610f9dee89d84 (patch) | |
tree | 426b9b5e599e074724941baf1ce3fbade6e3b4e8 /lib | |
parent | 8b399b185cf72f396be8d6b7caae37f2a3aa4279 (diff) | |
download | gitlab-ce-1b8223dd51345f6075172a92dab610f9dee89d84.tar.gz |
Fix remaining spec failures for !12300.
1. Get the spec for `lib/gitlab/auth.rb` passing.
- Make the `request` argument to `AccessTokenValidationService` optional -
`auth.rb` doesn't need to pass in a request.
- Pass in scopes in the format `[{ name: 'api' }]` rather than `['api']`, which
is what `AccessTokenValidationService` now expects.
2. Get the spec for `API::V3::Users` passing
2. Get the spec for `AccessTokenValidationService` passing
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/api_guard.rb | 4 | ||||
-rw-r--r-- | lib/gitlab/auth.rb | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/lib/api/api_guard.rb b/lib/api/api_guard.rb index 29ca760ec25..d4599aaeed0 100644 --- a/lib/api/api_guard.rb +++ b/lib/api/api_guard.rb @@ -66,7 +66,7 @@ module API access_token = find_access_token return nil unless access_token - case AccessTokenValidationService.new(access_token, request).validate(scopes: scopes) + case AccessTokenValidationService.new(access_token, request: request).validate(scopes: scopes) when AccessTokenValidationService::INSUFFICIENT_SCOPE raise InsufficientScopeError.new(scopes) @@ -103,7 +103,7 @@ module API access_token = PersonalAccessToken.active.find_by_token(token_string) return unless access_token - if AccessTokenValidationService.new(access_token, request).include_any_scope?(scopes) + if AccessTokenValidationService.new(access_token, request: request).include_any_scope?(scopes) User.find(access_token.user_id) end end diff --git a/lib/gitlab/auth.rb b/lib/gitlab/auth.rb index 3933c3b04dd..37ac8ecc2f0 100644 --- a/lib/gitlab/auth.rb +++ b/lib/gitlab/auth.rb @@ -130,13 +130,13 @@ module Gitlab token = PersonalAccessTokensFinder.new(state: 'active').find_by(token: password) - if token && valid_scoped_token?(token, AVAILABLE_SCOPES.map(&:to_s)) + if token && valid_scoped_token?(token, AVAILABLE_SCOPES.map { |scope| { name: scope.to_s }}) Gitlab::Auth::Result.new(token.user, nil, :personal_token, abilities_for_scope(token.scopes)) end end def valid_oauth_token?(token) - token && token.accessible? && valid_scoped_token?(token, ["api"]) + token && token.accessible? && valid_scoped_token?(token, [{ name: "api" }]) end def valid_scoped_token?(token, scopes) |