summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/auth_spec.rb
diff options
context:
space:
mode:
authorKrasimir Angelov <kangelov@gitlab.com>2019-07-02 18:56:48 +0000
committerMayra Cabrera <mcabrera@gitlab.com>2019-07-02 18:56:48 +0000
commitd745ff0431130a760a7a59899c26410dc887f77a (patch)
tree8f12c60eaad6a5eb897be9cd03d048e971218511 /spec/lib/gitlab/auth_spec.rb
parent4b050fc283fcc0f703d219a54dab4a02f10e475d (diff)
downloadgitlab-ce-d745ff0431130a760a7a59899c26410dc887f77a.tar.gz
Add username to deploy tokens
This new attribute is optional and used when set instead of the default format `gitlab+deploy-token-#{id}`. Empty usernames will be saved as null in the database. Related to https://gitlab.com/gitlab-org/gitlab-ce/issues/50228.
Diffstat (limited to 'spec/lib/gitlab/auth_spec.rb')
-rw-r--r--spec/lib/gitlab/auth_spec.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/spec/lib/gitlab/auth_spec.rb b/spec/lib/gitlab/auth_spec.rb
index 3b5ca7c950c..d9c73cff01e 100644
--- a/spec/lib/gitlab/auth_spec.rb
+++ b/spec/lib/gitlab/auth_spec.rb
@@ -309,6 +309,15 @@ describe Gitlab::Auth do
.to eq(auth_success)
end
+ it 'succeeds when custom login and token are valid' do
+ deploy_token = create(:deploy_token, username: 'deployer', read_registry: false, projects: [project])
+ auth_success = Gitlab::Auth::Result.new(deploy_token, project, :deploy_token, [:download_code])
+
+ expect(gl_auth).to receive(:rate_limit!).with('ip', success: true, login: 'deployer')
+ expect(gl_auth.find_for_git_client('deployer', deploy_token.token, project: project, ip: 'ip'))
+ .to eq(auth_success)
+ end
+
it 'fails when login is not valid' do
expect(gl_auth).to receive(:rate_limit!).with('ip', success: false, login: 'random_login')
expect(gl_auth.find_for_git_client('random_login', deploy_token.token, project: project, ip: 'ip'))