summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-28 00:07:51 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-28 00:07:51 +0000
commitbba3aae6262b45e5457d0fcaa23e99f815114b4b (patch)
tree9510a08bba9514faf620b4244f382c4fc9599637 /spec
parentf50b93c373428d624cc2cabe98e4022dce846e67 (diff)
downloadgitlab-ce-bba3aae6262b45e5457d0fcaa23e99f815114b4b.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/gitlab/auth_spec.rb18
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