diff options
Diffstat (limited to 'spec/lib/gitlab/auth_spec.rb')
-rw-r--r-- | spec/lib/gitlab/auth_spec.rb | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/spec/lib/gitlab/auth_spec.rb b/spec/lib/gitlab/auth_spec.rb index 0b391c8cba9..a73c6317f31 100644 --- a/spec/lib/gitlab/auth_spec.rb +++ b/spec/lib/gitlab/auth_spec.rb @@ -149,7 +149,9 @@ RSpec.describe Gitlab::Auth, :use_clean_rails_memory_store_caching do end context 'build token' do - subject { gl_auth.find_for_git_client('gitlab-ci-token', build.token, project: project, ip: 'ip') } + subject { gl_auth.find_for_git_client(username, build.token, project: project, ip: 'ip') } + + let(:username) { 'gitlab-ci-token' } context 'for running build' do let!(:build) { create(:ci_build, :running) } @@ -170,6 +172,14 @@ RSpec.describe Gitlab::Auth, :use_clean_rails_memory_store_caching do expect(subject).to eq(Gitlab::Auth::Result.new(nil, nil, nil, nil)) end + + context 'username is not gitlab-ci-token' do + let(:username) { 'another_username' } + + it 'fails to authenticate' do + expect(subject).to eq(Gitlab::Auth::Result.new(nil, nil, nil, nil)) + end + end end (Ci::HasStatus::AVAILABLE_STATUSES - ['running']).each do |build_status| |