diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-28 03:07:51 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-28 03:07:51 +0300 |
commit | bba3aae6262b45e5457d0fcaa23e99f815114b4b (patch) | |
tree | 9510a08bba9514faf620b4244f382c4fc9599637 /spec/lib/gitlab/auth_spec.rb | |
parent | f50b93c373428d624cc2cabe98e4022dce846e67 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/auth_spec.rb')
-rw-r--r-- | spec/lib/gitlab/auth_spec.rb | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/spec/lib/gitlab/auth_spec.rb b/spec/lib/gitlab/auth_spec.rb index 528019bb9ff..dcc4d277f5c 100644 --- a/spec/lib/gitlab/auth_spec.rb +++ b/spec/lib/gitlab/auth_spec.rb @@ -250,6 +250,13 @@ describe Gitlab::Auth, :use_clean_rails_memory_store_caching do let(:token_w_api_scope) { Doorkeeper::AccessToken.create!(application_id: application.id, resource_owner_id: user.id, scopes: 'api') } let(:application) { Doorkeeper::Application.create!(name: 'MyApp', redirect_uri: 'https://app.com', owner: user) } + shared_examples 'an oauth failure' do + it 'fails' do + expect(gl_auth.find_for_git_client("oauth2", token_w_api_scope.token, project: nil, ip: 'ip')) + .to eq(Gitlab::Auth::Result.new(nil, nil, nil, nil)) + end + end + it 'succeeds for OAuth tokens with the `api` scope' do expect(gl_auth.find_for_git_client("oauth2", token_w_api_scope.token, project: nil, ip: 'ip')).to eq(Gitlab::Auth::Result.new(user, nil, :oauth, described_class.full_authentication_abilities)) end @@ -269,10 +276,15 @@ describe Gitlab::Auth, :use_clean_rails_memory_store_caching do context 'blocked user' do let(:user) { create(:user, :blocked) } - it 'fails' do - expect(gl_auth.find_for_git_client("oauth2", token_w_api_scope.token, project: nil, ip: 'ip')) - .to eq(Gitlab::Auth::Result.new(nil, nil, nil, nil)) + it_behaves_like 'an oauth failure' + end + + context 'orphaned token' do + before do + user.destroy end + + it_behaves_like 'an oauth failure' end end |