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
Boxiang Sun
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
Hide 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
...
@@ -6,14 +6,15 @@ describe Auth::ContainerRegistryAuthenticationService, services: true do
let
(
:current_params
)
{
{}
}
let
(
:current_params
)
{
{}
}
let
(
:rsa_key
)
{
OpenSSL
::
PKey
::
RSA
.
generate
(
512
)
}
let
(
:rsa_key
)
{
OpenSSL
::
PKey
::
RSA
.
generate
(
512
)
}
let
(
:payload
)
{
JWT
.
decode
(
subject
[
:token
],
rsa_key
).
first
}
let
(
:payload
)
{
JWT
.
decode
(
subject
[
:token
],
rsa_key
).
first
}
let
(
:authentication_abilities
)
do
let
(
:authentication_abilities
)
do
[
[
:read_container_image
,
:create_container_image
]
:read_container_image
,
:create_container_image
]
end
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
before
do
allow
(
Gitlab
.
config
.
registry
).
to
receive_messages
(
enabled:
true
,
issuer:
'rspec'
,
key:
nil
)
allow
(
Gitlab
.
config
.
registry
).
to
receive_messages
(
enabled:
true
,
issuer:
'rspec'
,
key:
nil
)
...
@@ -40,13 +41,11 @@ describe Auth::ContainerRegistryAuthenticationService, services: true do
...
@@ -40,13 +41,11 @@ describe Auth::ContainerRegistryAuthenticationService, services: true do
end
end
end
end
shared_examples
'a accessible'
do
shared_examples
'a
n
accessible'
do
let
(
:access
)
do
let
(
:access
)
do
[{
[{
'type'
=>
'repository'
,
'type'
=>
'repository'
,
'name'
=>
project
.
path_with_namespace
,
'name'
=>
project
.
path_with_namespace
,
'actions'
=>
actions
,
'actions'
=>
actions
}]
}]
end
end
it_behaves_like
'a valid token'
it_behaves_like
'a valid token'
...
@@ -59,19 +58,19 @@ describe Auth::ContainerRegistryAuthenticationService, services: true do
...
@@ -59,19 +58,19 @@ describe Auth::ContainerRegistryAuthenticationService, services: true do
end
end
shared_examples
'a pullable'
do
shared_examples
'a pullable'
do
it_behaves_like
'a accessible'
do
it_behaves_like
'a
n
accessible'
do
let
(
:actions
)
{
[
'pull'
]
}
let
(
:actions
)
{
[
'pull'
]
}
end
end
end
end
shared_examples
'a pushable'
do
shared_examples
'a pushable'
do
it_behaves_like
'a accessible'
do
it_behaves_like
'a
n
accessible'
do
let
(
:actions
)
{
[
'push'
]
}
let
(
:actions
)
{
[
'push'
]
}
end
end
end
end
shared_examples
'a pullable and pushable'
do
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)
}
let
(
:actions
)
{
%w(pull push)
}
end
end
end
end
...
@@ -87,7 +86,7 @@ describe Auth::ContainerRegistryAuthenticationService, services: true do
...
@@ -87,7 +86,7 @@ describe Auth::ContainerRegistryAuthenticationService, services: true do
subject
{
{
token:
token
}
}
subject
{
{
token:
token
}
}
it_behaves_like
'a accessible'
do
it_behaves_like
'a
n
accessible'
do
let
(
:actions
)
{
[
'*'
]
}
let
(
:actions
)
{
[
'*'
]
}
end
end
end
end
...
@@ -198,11 +197,9 @@ describe Auth::ContainerRegistryAuthenticationService, services: true do
...
@@ -198,11 +197,9 @@ describe Auth::ContainerRegistryAuthenticationService, services: true do
context
'build authorized as user'
do
context
'build authorized as user'
do
let
(
:current_project
)
{
create
(
:empty_project
)
}
let
(
:current_project
)
{
create
(
:empty_project
)
}
let
(
:current_user
)
{
create
(
:user
)
}
let
(
:current_user
)
{
create
(
:user
)
}
let
(
:authentication_abilities
)
do
let
(
:authentication_abilities
)
do
[
[
:build_read_container_image
,
:build_create_container_image
]
:build_read_container_image
,
:build_create_container_image
]
end
end
before
do
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