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
e9bf0042
Commit
e9bf0042
authored
Oct 06, 2020
by
Matija Čupić
Committed by
Shinya Maeda
Oct 06, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expand project CI lint API specs
parent
45e36a5e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
91 additions
and
2 deletions
+91
-2
spec/requests/api/lint_spec.rb
spec/requests/api/lint_spec.rb
+91
-2
No files found.
spec/requests/api/lint_spec.rb
View file @
e9bf0042
...
...
@@ -79,7 +79,6 @@ RSpec.describe API::Lint do
describe
'GET /projects/:id/ci/lint'
do
subject
(
:ci_lint
)
{
get
api
(
"/projects/
#{
project
.
id
}
/ci/lint"
,
api_user
),
params:
{
dry_run:
dry_run
}
}
let_it_be
(
:api_user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:dry_run
)
{
nil
}
...
...
@@ -111,6 +110,8 @@ RSpec.describe API::Lint do
end
context
'when unauthenticated'
do
let_it_be
(
:api_user
)
{
nil
}
it
'returns authentication error'
do
ci_lint
...
...
@@ -118,7 +119,95 @@ RSpec.describe API::Lint do
end
end
context
'when authenticated as project member'
do
context
'when authenticated as non-member'
do
let_it_be
(
:api_user
)
{
create
(
:user
)
}
let
(
:yaml_content
)
do
{
include:
{
local:
'another-gitlab-ci.yml'
},
test:
{
stage:
'test'
,
script:
'echo 1'
}
}.
to_yaml
end
context
'when project is private'
do
before
do
project
.
update!
(
visibility_level:
Gitlab
::
VisibilityLevel
::
PRIVATE
)
stub_ci_pipeline_yaml_file
(
yaml_content
)
end
it
'returns authentication error'
do
ci_lint
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
context
'when project is public'
do
before
do
project
.
update!
(
visibility_level:
Gitlab
::
VisibilityLevel
::
PUBLIC
)
end
context
'when running as dry run'
do
let
(
:dry_run
)
{
true
}
before
do
stub_ci_pipeline_yaml_file
(
yaml_content
)
end
it
'returns pipeline creation error'
do
ci_lint
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'merged_yaml'
]).
to
eq
(
nil
)
expect
(
json_response
[
'valid'
]).
to
eq
(
false
)
expect
(
json_response
[
'errors'
]).
to
eq
([
'Insufficient permissions to create a new pipeline'
])
end
end
context
'when running static validation'
do
let
(
:dry_run
)
{
false
}
let
(
:included_content
)
do
{
another_test:
{
stage:
'test'
,
script:
'echo 1'
}
}.
to_yaml
end
before
do
project
.
repository
.
create_file
(
project
.
creator
,
'.gitlab-ci.yml'
,
yaml_content
,
message:
'Automatically created .gitlab-ci.yml'
,
branch_name:
'master'
)
project
.
repository
.
create_file
(
project
.
creator
,
'another-gitlab-ci.yml'
,
included_content
,
message:
'Automatically created another-gitlab-ci.yml'
,
branch_name:
'master'
)
end
it_behaves_like
'valid config'
end
end
end
context
'when authenticated as project guest'
do
let_it_be
(
:api_user
)
{
create
(
:user
)
}
before
do
project
.
add_guest
(
api_user
)
end
it
'returns authentication error'
do
ci_lint
expect
(
response
).
to
have_gitlab_http_status
(
:forbidden
)
end
end
context
'when authenticated as project developer'
do
let_it_be
(
:api_user
)
{
create
(
:user
)
}
before
do
project
.
add_developer
(
api_user
)
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