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
440a9d75
Commit
440a9d75
authored
May 18, 2021
by
Małgorzata Ksionek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs for personal access token case
parent
c2725384
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
0 deletions
+53
-0
ee/spec/requests/git_http_spec.rb
ee/spec/requests/git_http_spec.rb
+53
-0
No files found.
ee/spec/requests/git_http_spec.rb
View file @
440a9d75
...
...
@@ -187,6 +187,59 @@ RSpec.describe 'Git HTTP requests' do
expect
(
response
).
to
have_gitlab_http_status
(
:unauthorized
)
end
end
context
'when user has 2FA enabled'
do
let
(
:user
)
{
create
(
:user
,
:two_factor
,
provisioned_by_group:
group
)
}
let
(
:access_token
)
{
create
(
:personal_access_token
,
user:
user
)
}
context
'when username and personal access token are provided'
do
let
(
:env
)
{
{
user:
user
.
username
,
password:
access_token
.
token
}
}
it_behaves_like
'pulls are allowed'
it_behaves_like
'pushes are allowed'
it
'rejects the push attempt for read_repository scope'
do
read_access_token
=
create
(
:personal_access_token
,
user:
user
,
scopes:
[
:read_repository
])
upload
(
path
,
user:
user
.
username
,
password:
read_access_token
.
token
)
do
|
response
|
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
expect
(
response
.
body
).
to
include
(
'You are not allowed to upload code'
)
end
end
it
'accepts the push attempt for write_repository scope'
do
write_access_token
=
create
(
:personal_access_token
,
user:
user
,
scopes:
[
:write_repository
])
upload
(
path
,
user:
user
.
username
,
password:
write_access_token
.
token
)
do
|
response
|
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
it
'accepts the pull attempt for read_repository scope'
do
read_access_token
=
create
(
:personal_access_token
,
user:
user
,
scopes:
[
:read_repository
])
download
(
path
,
user:
user
.
username
,
password:
read_access_token
.
token
)
do
|
response
|
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
it
'accepts the pull attempt for api scope'
do
read_access_token
=
create
(
:personal_access_token
,
user:
user
,
scopes:
[
:api
])
download
(
path
,
user:
user
.
username
,
password:
read_access_token
.
token
)
do
|
response
|
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
it
'accepts the push attempt for api scope'
do
write_access_token
=
create
(
:personal_access_token
,
user:
user
,
scopes:
[
:api
])
upload
(
path
,
user:
user
.
username
,
password:
write_access_token
.
token
)
do
|
response
|
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
end
end
end
end
end
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