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
5a7f8cb5
Commit
5a7f8cb5
authored
Mar 29, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add readability improvements to registry auth specs
parent
a222486c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
18 deletions
+15
-18
spec/services/auth/container_registry_authentication_service_spec.rb
...es/auth/container_registry_authentication_service_spec.rb
+15
-18
No files found.
spec/services/auth/container_registry_authentication_service_spec.rb
View file @
5a7f8cb5
...
...
@@ -6,14 +6,15 @@ describe Auth::ContainerRegistryAuthenticationService, services: true do
let
(
:current_params
)
{
{}
}
let
(
:rsa_key
)
{
OpenSSL
::
PKey
::
RSA
.
generate
(
512
)
}
let
(
:payload
)
{
JWT
.
decode
(
subject
[
:token
],
rsa_key
).
first
}
let
(
:authentication_abilities
)
do
[
:read_container_image
,
:create_container_image
]
[
:read_container_image
,
:create_container_image
]
end
subject
{
described_class
.
new
(
current_project
,
current_user
,
current_params
).
execute
(
authentication_abilities:
authentication_abilities
)
}
subject
do
described_class
.
new
(
current_project
,
current_user
,
current_params
)
.
execute
(
authentication_abilities:
authentication_abilities
)
end
before
do
allow
(
Gitlab
.
config
.
registry
).
to
receive_messages
(
enabled:
true
,
issuer:
'rspec'
,
key:
nil
)
...
...
@@ -40,13 +41,11 @@ describe Auth::ContainerRegistryAuthenticationService, services: true do
end
end
shared_examples
'a accessible'
do
shared_examples
'a
n
accessible'
do
let
(
:access
)
do
[{
'type'
=>
'repository'
,
[{
'type'
=>
'repository'
,
'name'
=>
project
.
path_with_namespace
,
'actions'
=>
actions
,
}]
'actions'
=>
actions
}]
end
it_behaves_like
'a valid token'
...
...
@@ -59,19 +58,19 @@ describe Auth::ContainerRegistryAuthenticationService, services: true do
end
shared_examples
'a pullable'
do
it_behaves_like
'a accessible'
do
it_behaves_like
'a
n
accessible'
do
let
(
:actions
)
{
[
'pull'
]
}
end
end
shared_examples
'a pushable'
do
it_behaves_like
'a accessible'
do
it_behaves_like
'a
n
accessible'
do
let
(
:actions
)
{
[
'push'
]
}
end
end
shared_examples
'a pullable and pushable'
do
it_behaves_like
'a accessible'
do
it_behaves_like
'a
n
accessible'
do
let
(
:actions
)
{
%w(pull push)
}
end
end
...
...
@@ -87,7 +86,7 @@ describe Auth::ContainerRegistryAuthenticationService, services: true do
subject
{
{
token:
token
}
}
it_behaves_like
'a accessible'
do
it_behaves_like
'a
n
accessible'
do
let
(
:actions
)
{
[
'*'
]
}
end
end
...
...
@@ -198,11 +197,9 @@ describe Auth::ContainerRegistryAuthenticationService, services: true do
context
'build authorized as user'
do
let
(
:current_project
)
{
create
(
:empty_project
)
}
let
(
:current_user
)
{
create
(
:user
)
}
let
(
:authentication_abilities
)
do
[
:build_read_container_image
,
:build_create_container_image
]
[
:build_read_container_image
,
:build_create_container_image
]
end
before
do
...
...
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