Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
c948c590
Commit
c948c590
authored
Jul 17, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
8558547b
558f41dd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
64 additions
and
0 deletions
+64
-0
spec/lib/gitlab/auth_spec.rb
spec/lib/gitlab/auth_spec.rb
+64
-0
No files found.
spec/lib/gitlab/auth_spec.rb
View file @
c948c590
...
...
@@ -297,6 +297,70 @@ describe Gitlab::Auth do
let
(
:project
)
{
create
(
:project
)
}
let
(
:auth_failure
)
{
Gitlab
::
Auth
::
Result
.
new
(
nil
,
nil
)
}
context
'when deploy token and user have the same username'
do
let
(
:username
)
{
'normal_user'
}
let
(
:user
)
{
create
(
:user
,
username:
username
,
password:
'my-secret'
)
}
let
(
:deploy_token
)
{
create
(
:deploy_token
,
username:
username
,
read_registry:
false
,
projects:
[
project
])
}
before
do
expect
(
gl_auth
).
to
receive
(
:rate_limit!
).
with
(
'ip'
,
success:
true
,
login:
username
)
end
it
'succeeds for the token'
do
auth_success
=
Gitlab
::
Auth
::
Result
.
new
(
deploy_token
,
project
,
:deploy_token
,
[
:download_code
])
expect
(
gl_auth
.
find_for_git_client
(
username
,
deploy_token
.
token
,
project:
project
,
ip:
'ip'
))
.
to
eq
(
auth_success
)
end
it
'succeeds for the user'
do
auth_success
=
Gitlab
::
Auth
::
Result
.
new
(
user
,
nil
,
:gitlab_or_ldap
,
full_authentication_abilities
)
expect
(
gl_auth
.
find_for_git_client
(
username
,
'my-secret'
,
project:
project
,
ip:
'ip'
))
.
to
eq
(
auth_success
)
end
end
context
'when deploy tokens have the same username'
do
context
'and belong to the same project'
do
let!
(
:read_registry
)
{
create
(
:deploy_token
,
username:
'deployer'
,
read_repository:
false
,
projects:
[
project
])
}
let!
(
:read_repository
)
{
create
(
:deploy_token
,
username:
read_registry
.
username
,
read_registry:
false
,
projects:
[
project
])
}
it
'succeeds for the right token'
do
auth_success
=
Gitlab
::
Auth
::
Result
.
new
(
read_repository
,
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'
,
read_repository
.
token
,
project:
project
,
ip:
'ip'
))
.
to
eq
(
auth_success
)
end
it
'fails for the wrong token'
do
expect
(
gl_auth
).
to
receive
(
:rate_limit!
).
with
(
'ip'
,
success:
false
,
login:
'deployer'
)
expect
(
gl_auth
.
find_for_git_client
(
'deployer'
,
read_registry
.
token
,
project:
project
,
ip:
'ip'
))
.
to
eq
(
auth_failure
)
end
end
context
'and belong to different projects'
do
let!
(
:read_registry
)
{
create
(
:deploy_token
,
username:
'deployer'
,
read_repository:
false
,
projects:
[
create
(
:project
)])
}
let!
(
:read_repository
)
{
create
(
:deploy_token
,
username:
read_registry
.
username
,
read_registry:
false
,
projects:
[
project
])
}
it
'succeeds for the right token'
do
auth_success
=
Gitlab
::
Auth
::
Result
.
new
(
read_repository
,
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'
,
read_repository
.
token
,
project:
project
,
ip:
'ip'
))
.
to
eq
(
auth_success
)
end
it
'fails for the wrong token'
do
expect
(
gl_auth
).
to
receive
(
:rate_limit!
).
with
(
'ip'
,
success:
false
,
login:
'deployer'
)
expect
(
gl_auth
.
find_for_git_client
(
'deployer'
,
read_registry
.
token
,
project:
project
,
ip:
'ip'
))
.
to
eq
(
auth_failure
)
end
end
end
context
'when the deploy token has read_repository as scope'
do
let
(
:deploy_token
)
{
create
(
:deploy_token
,
read_registry:
false
,
projects:
[
project
])
}
let
(
:login
)
{
deploy_token
.
username
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment