Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/gitlab/auth/auth_finders_spec.rb')
-rw-r--r--spec/lib/gitlab/auth/auth_finders_spec.rb24
1 files changed, 20 insertions, 4 deletions
diff --git a/spec/lib/gitlab/auth/auth_finders_spec.rb b/spec/lib/gitlab/auth/auth_finders_spec.rb
index 774a87752b9..2aef206c7fd 100644
--- a/spec/lib/gitlab/auth/auth_finders_spec.rb
+++ b/spec/lib/gitlab/auth/auth_finders_spec.rb
@@ -4,6 +4,7 @@ require 'spec_helper'
describe Gitlab::Auth::AuthFinders do
include described_class
+ include HttpBasicAuthHelpers
let(:user) { create(:user) }
let(:env) do
@@ -22,10 +23,7 @@ describe Gitlab::Auth::AuthFinders do
end
def set_basic_auth_header(username, password)
- set_header(
- 'HTTP_AUTHORIZATION',
- ActionController::HttpAuthentication::Basic.encode_credentials(username, password)
- )
+ env.merge!(basic_auth_header(username, password))
end
describe '#find_user_from_warden' do
@@ -653,6 +651,24 @@ describe Gitlab::Auth::AuthFinders do
it_behaves_like 'job token params', described_class::JOB_TOKEN_PARAM
it_behaves_like 'job token params', described_class::RUNNER_JOB_TOKEN_PARAM
end
+
+ context 'when the job token is provided via basic auth' do
+ let(:route_authentication_setting) { { job_token_allowed: :basic_auth } }
+ let(:username) { Ci::Build::CI_REGISTRY_USER }
+ let(:token) { job.token }
+
+ before do
+ set_basic_auth_header(username, token)
+ end
+
+ it { is_expected.to eq(user) }
+
+ context 'credentials are provided but route setting is incorrect' do
+ let(:route_authentication_setting) { { job_token_allowed: :unknown } }
+
+ it { is_expected.to be_nil }
+ end
+ end
end
describe '#find_runner_from_token' do