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:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-06-18 14:18:50 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-06-18 14:18:50 +0300
commit8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781 (patch)
treea77e7fe7a93de11213032ed4ab1f33a3db51b738 /spec/lib/gitlab/auth
parent00b35af3db1abfe813a778f643dad221aad51fca (diff)
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'spec/lib/gitlab/auth')
-rw-r--r--spec/lib/gitlab/auth/auth_finders_spec.rb24
-rw-r--r--spec/lib/gitlab/auth/ldap/person_spec.rb7
2 files changed, 25 insertions, 6 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
diff --git a/spec/lib/gitlab/auth/ldap/person_spec.rb b/spec/lib/gitlab/auth/ldap/person_spec.rb
index e90917cfce1..403a48d40ef 100644
--- a/spec/lib/gitlab/auth/ldap/person_spec.rb
+++ b/spec/lib/gitlab/auth/ldap/person_spec.rb
@@ -57,14 +57,17 @@ describe Gitlab::Auth::Ldap::Person do
'attributes' => {
'name' => 'cn',
'email' => 'mail',
- 'username' => %w(uid mail memberof)
+ 'username' => %w(uid mail),
+ 'first_name' => ''
}
}
)
config = Gitlab::Auth::Ldap::Config.new('ldapmain')
ldap_attributes = described_class.ldap_attributes(config)
- expect(ldap_attributes).to match_array(%w(dn uid cn mail memberof))
+ expect(ldap_attributes).to include('dn', 'uid', 'cn', 'mail')
+ expect(ldap_attributes).to be_present
+ expect(ldap_attributes.uniq!).to eq(nil)
end
end