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
Léo-Paul Géneau
gitlab-ce
Commits
048b4469
Commit
048b4469
authored
Jun 11, 2018
by
Alexis Reigel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup runners api specs
parent
4b6619cf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
84 additions
and
64 deletions
+84
-64
spec/requests/api/runners_spec.rb
spec/requests/api/runners_spec.rb
+84
-64
No files found.
spec/requests/api/runners_spec.rb
View file @
048b4469
...
...
@@ -25,30 +25,34 @@ describe API::Runners do
describe
'GET /runners'
do
context
'authorized user'
do
it
'returns
user available runn
ers'
do
it
'returns
response status and head
ers'
do
get
api
(
'/runners'
,
user
)
shared
=
json_response
.
any?
{
|
r
|
r
[
'is_shared'
]
}
descriptions
=
json_response
.
map
{
|
runner
|
runner
[
'description'
]
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
[
0
]).
to
have_key
(
'ip_address'
)
expect
(
descriptions
).
to
contain_exactly
(
'Project runner'
,
'Two projects runner'
,
'Group runner'
)
expect
(
shared
).
to
be_falsey
end
it
'returns user available runners'
do
get
api
(
'/runners'
,
user
)
expect
(
json_response
).
to
match_array
[
a_hash_including
(
'description'
=>
'Project runner'
),
a_hash_including
(
'description'
=>
'Two projects runner'
),
a_hash_including
(
'description'
=>
'Group runner'
)
]
end
it
'filters runners by scope'
do
get
api
(
'/runners?scope=active'
,
user
)
create
(
:ci_runner
,
:project
,
:inactive
,
description:
'Inactive project runner'
,
projects:
[
project
])
get
api
(
'/runners?scope=paused'
,
user
)
shared
=
json_response
.
any?
{
|
r
|
r
[
'is_shared'
]
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
[
0
]).
to
have_key
(
'ip_address'
)
expect
(
shared
).
to
be_falsey
expect
(
json_response
).
to
match_array
[
a_hash_including
(
'description'
=>
'Inactive project runner'
)
]
end
it
'avoids filtering if scope is invalid'
do
...
...
@@ -84,66 +88,75 @@ describe API::Runners do
describe
'GET /runners/all'
do
context
'authorized user'
do
context
'with admin privileges'
do
it
'returns response status and headers'
do
get
api
(
'/runners/all'
,
admin
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
end
it
'returns all runners'
do
get
api
(
'/runners/all'
,
admin
)
shared
=
json_response
.
any?
{
|
r
|
r
[
'is_shared'
]
}
expect
(
json_response
).
to
match_array
[
a_hash_including
(
'description'
=>
'Project runner'
),
a_hash_including
(
'description'
=>
'Two projects runner'
),
a_hash_including
(
'description'
=>
'Group runner'
),
a_hash_including
(
'description'
=>
'Shared runner'
)
]
end
it
'filters runners by scope'
do
get
api
(
'/runners/all?scope=shared'
,
admin
)
shared
=
json_response
.
all?
{
|
r
|
r
[
'is_shared'
]
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
[
0
]).
to
have_key
(
'ip_address'
)
expect
(
shared
).
to
be_truthy
end
end
context
'without admin privileges'
do
it
'does not return runners list'
do
get
api
(
'/runners/all'
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
end
end
it
'filters runners by scope'
do
get
api
(
'/runners/all?scope=specific'
,
admin
)
it
'filters runners by scope'
do
get
api
(
'/runners/all?scope=shared'
,
admin
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
shared
=
json_response
.
all?
{
|
r
|
r
[
'is_shared'
]
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
[
0
]).
to
have_key
(
'ip_address'
)
expect
(
shared
).
to
be_truthy
end
expect
(
json_response
).
to
match_array
[
a_hash_including
(
'description'
=>
'Project runner'
),
a_hash_including
(
'description'
=>
'Two projects runner'
),
a_hash_including
(
'description'
=>
'Group runner'
)
]
end
it
'filters runners by scope'
do
get
api
(
'/runners/all?scope=specific'
,
admin
)
it
'avoids filtering if scope is invalid'
do
get
api
(
'/runners/all?scope=unknown'
,
admin
)
expect
(
response
).
to
have_gitlab_http_status
(
400
)
end
shared
=
json_response
.
any?
{
|
r
|
r
[
'is_shared'
]
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
[
0
]).
to
have_key
(
'ip_address'
)
expect
(
shared
).
to
be_falsey
end
it
'filters runners by type'
do
get
api
(
'/runners/all?type=project_type'
,
admin
)
it
'avoids filtering if scope is invalid'
do
get
api
(
'/runners/all?scope=unknown'
,
admin
)
expect
(
response
).
to
have_gitlab_http_status
(
400
)
end
expect
(
json_response
).
to
match_array
[
a_hash_including
(
'description'
=>
'Project runner'
),
a_hash_including
(
'description'
=>
'Two projects runner'
)
]
end
it
'filters runners by
type'
do
get
api
(
'/runners/all?type=project_type
'
,
admin
)
it
'does not filter by invalid
type'
do
get
api
(
'/runners/all?type=bogus
'
,
admin
)
expect
(
json_response
).
to
match_array
[
a_hash_including
(
'description'
=>
'Project runner'
),
a_hash_including
(
'description'
=>
'Two projects runner'
)
]
expect
(
response
).
to
have_gitlab_http_status
(
400
)
end
end
it
'does not filter by invalid type'
do
get
api
(
'/runners/all?type=bogus'
,
admin
)
context
'without admin privileges'
do
it
'does not return runners list'
do
get
api
(
'/runners/all'
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
response
).
to
have_gitlab_http_status
(
403
)
end
end
end
...
...
@@ -607,26 +620,33 @@ describe API::Runners do
describe
'GET /projects/:id/runners'
do
context
'authorized user with maintainer privileges'
do
it
"returns project's runners"
do
get
api
(
"/projects/
#{
project
.
id
}
/runners"
,
user
)
it
'returns response status and headers'
do
get
api
(
'/runners/all'
,
admin
)
shared
=
json_response
.
any?
{
|
r
|
r
[
'is_shared'
]
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
[
0
]).
to
have_key
(
'ip_address'
)
expect
(
shared
).
to
be_truthy
end
it
'returns all runners'
do
get
api
(
"/projects/
#{
project
.
id
}
/runners"
,
user
)
expect
(
json_response
).
to
match_array
[
a_hash_including
(
'description'
=>
'Project runner'
),
a_hash_including
(
'description'
=>
'Two projects runner'
),
a_hash_including
(
'description'
=>
'Shared runner'
)
]
end
it
'filters runners by scope'
do
get
api
(
"/projects/
#{
project
.
id
}
/runners?scope=specific"
,
user
)
shared
=
json_response
.
any?
{
|
r
|
r
[
'is_shared'
]
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
include_pagination_headers
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
[
0
]).
to
have_key
(
'ip_address'
)
expect
(
shared
).
to
be_falsey
expect
(
json_response
).
to
match_array
[
a_hash_including
(
'description'
=>
'Project runner'
),
a_hash_including
(
'description'
=>
'Two projects runner'
)
]
end
it
'avoids filtering if scope is invalid'
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