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
0
Merge Requests
0
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
iv
gitlab-ce
Commits
938d5b6f
Commit
938d5b6f
authored
May 15, 2016
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix http status codes for container registry authentication service
parent
3d18b3a0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
13 deletions
+8
-13
app/services/auth/container_registry_authentication_service.rb
...ervices/auth/container_registry_authentication_service.rb
+2
-2
spec/services/auth/container_registry_authentication_service_spec.rb
...es/auth/container_registry_authentication_service_spec.rb
+6
-11
No files found.
app/services/auth/container_registry_authentication_service.rb
View file @
938d5b6f
...
...
@@ -6,9 +6,9 @@ module Auth
return
error
(
'not found'
,
404
)
unless
registry
.
enabled
if
params
[
:offline_token
]
return
error
(
'forbidden'
,
40
3
)
unless
current_user
return
error
(
'forbidden'
,
40
1
)
unless
current_user
else
return
error
(
'forbidden'
,
40
1
)
unless
scope
return
error
(
'forbidden'
,
40
3
)
unless
scope
end
{
token:
authorized_token
(
scope
).
encoded
}
...
...
spec/services/auth/container_registry_authentication_service_spec.rb
View file @
938d5b6f
...
...
@@ -57,11 +57,6 @@ describe Auth::ContainerRegistryAuthenticationService, services: true do
end
end
shared_examples
'a unauthorized'
do
it
{
is_expected
.
to
include
(
http_status:
401
)
}
it
{
is_expected
.
to_not
include
(
:token
)
}
end
shared_examples
'a forbidden'
do
it
{
is_expected
.
to
include
(
http_status:
403
)
}
it
{
is_expected
.
to_not
include
(
:token
)
}
...
...
@@ -116,7 +111,7 @@ describe Auth::ContainerRegistryAuthenticationService, services: true do
{
scope:
"repository:
#{
project
.
path_with_namespace
}
:pull,push"
}
end
it_behaves_like
'a
unauthorized
'
it_behaves_like
'a
forbidden
'
end
end
...
...
@@ -154,7 +149,7 @@ describe Auth::ContainerRegistryAuthenticationService, services: true do
context
'disallow for private'
do
let
(
:project
)
{
create
(
:empty_project
,
:private
)
}
it_behaves_like
'a
unauthorized
'
it_behaves_like
'a
forbidden
'
end
end
...
...
@@ -165,7 +160,7 @@ describe Auth::ContainerRegistryAuthenticationService, services: true do
context
'disallow for all'
do
let
(
:project
)
{
create
(
:empty_project
,
:public
)
}
it_behaves_like
'a
unauthorized
'
it_behaves_like
'a
forbidden
'
end
end
end
...
...
@@ -199,7 +194,7 @@ describe Auth::ContainerRegistryAuthenticationService, services: true do
{
scope:
'invalid:aa:bb'
}
end
it_behaves_like
'a
unauthorized
'
it_behaves_like
'a
forbidden
'
end
context
'for private project'
do
...
...
@@ -209,7 +204,7 @@ describe Auth::ContainerRegistryAuthenticationService, services: true do
{
scope:
"repository:
#{
project
.
path_with_namespace
}
:pull"
}
end
it_behaves_like
'a
unauthorized
'
it_behaves_like
'a
forbidden
'
end
context
'for public project'
do
...
...
@@ -228,7 +223,7 @@ describe Auth::ContainerRegistryAuthenticationService, services: true do
{
scope:
"repository:
#{
project
.
path_with_namespace
}
:push"
}
end
it_behaves_like
'a
unauthorized
'
it_behaves_like
'a
forbidden
'
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