diff options
Diffstat (limited to 'spec/lib/gitlab/auth_spec.rb')
-rw-r--r-- | spec/lib/gitlab/auth_spec.rb | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/spec/lib/gitlab/auth_spec.rb b/spec/lib/gitlab/auth_spec.rb index b62f9b55b64..dcaaa8d4188 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| @@ -628,6 +638,7 @@ RSpec.describe Gitlab::Auth, :use_clean_rails_memory_store_caching do password: password, password_confirmation: password) end + let(:username) { 'John' } # username isn't lowercase, test this let(:password) { 'my-secret' } |