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
470e83ee
Commit
470e83ee
authored
Jan 31, 2018
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make those files as close as EE to reduce conflicts
parent
b886a75d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
73 additions
and
52 deletions
+73
-52
spec/requests/api/jobs_spec.rb
spec/requests/api/jobs_spec.rb
+41
-30
spec/requests/api/v3/builds_spec.rb
spec/requests/api/v3/builds_spec.rb
+32
-22
No files found.
spec/requests/api/jobs_spec.rb
View file @
470e83ee
...
@@ -300,14 +300,7 @@ describe API::Jobs do
...
@@ -300,14 +300,7 @@ describe API::Jobs do
end
end
describe
'GET /projects/:id/jobs/:job_id/artifacts'
do
describe
'GET /projects/:id/jobs/:job_id/artifacts'
do
before
do
shared_examples
'downloads artifact'
do
get
api
(
"/projects/
#{
project
.
id
}
/jobs/
#{
job
.
id
}
/artifacts"
,
api_user
)
end
context
'job with artifacts'
do
let
(
:job
)
{
create
(
:ci_build
,
:artifacts
,
pipeline:
pipeline
)
}
context
'authorized user'
do
let
(
:download_headers
)
do
let
(
:download_headers
)
do
{
'Content-Transfer-Encoding'
=>
'binary'
,
{
'Content-Transfer-Encoding'
=>
'binary'
,
'Content-Disposition'
=>
'attachment; filename=ci_build_artifacts.zip'
}
'Content-Disposition'
=>
'attachment; filename=ci_build_artifacts.zip'
}
...
@@ -320,24 +313,40 @@ describe API::Jobs do
...
@@ -320,24 +313,40 @@ describe API::Jobs do
end
end
end
end
context
'when anonymous user is accessing private artifacts'
do
context
'normal authentication'
do
context
'job with artifacts'
do
context
'when artifacts are stored locally'
do
let
(
:job
)
{
create
(
:ci_build
,
:artifacts
,
pipeline:
pipeline
)
}
before
do
get
api
(
"/projects/
#{
project
.
id
}
/jobs/
#{
job
.
id
}
/artifacts"
,
api_user
)
end
context
'authorized user'
do
it_behaves_like
'downloads artifact'
end
context
'unauthorized user'
do
let
(
:api_user
)
{
nil
}
let
(
:api_user
)
{
nil
}
it
'hides artifacts and rejects request'
do
it
'does not return specific job artifacts'
do
expect
(
project
).
to
be_private
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
end
end
end
end
end
end
it
'does not return job artifacts if not uploaded'
do
it
'does not return job artifacts if not uploaded'
do
get
api
(
"/projects/
#{
project
.
id
}
/jobs/
#{
job
.
id
}
/artifacts"
,
api_user
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
expect
(
response
).
to
have_gitlab_http_status
(
404
)
end
end
end
end
end
end
describe
'GET /projects/:id/artifacts/:ref_name/download?job=name'
do
describe
'GET /projects/:id/artifacts/:ref_name/download?job=name'
do
let
(
:api_user
)
{
reporter
}
let
(
:api_user
)
{
reporter
}
let
(
:job
)
{
create
(
:ci_build
,
:artifacts
,
pipeline:
pipeline
)
}
let
(
:job
)
{
create
(
:ci_build
,
:artifacts
,
pipeline:
pipeline
,
user:
api_user
)
}
before
do
before
do
job
.
success
job
.
success
...
@@ -396,6 +405,7 @@ describe API::Jobs do
...
@@ -396,6 +405,7 @@ describe API::Jobs do
context
'find proper job'
do
context
'find proper job'
do
shared_examples
'a valid file'
do
shared_examples
'a valid file'
do
context
'when artifacts are stored locally'
do
let
(
:download_headers
)
do
let
(
:download_headers
)
do
{
'Content-Transfer-Encoding'
=>
'binary'
,
{
'Content-Transfer-Encoding'
=>
'binary'
,
'Content-Disposition'
=>
'Content-Disposition'
=>
...
@@ -405,6 +415,7 @@ describe API::Jobs do
...
@@ -405,6 +415,7 @@ describe API::Jobs do
it
{
expect
(
response
).
to
have_gitlab_http_status
(
200
)
}
it
{
expect
(
response
).
to
have_gitlab_http_status
(
200
)
}
it
{
expect
(
response
.
headers
).
to
include
(
download_headers
)
}
it
{
expect
(
response
.
headers
).
to
include
(
download_headers
)
}
end
end
end
context
'with regular branch'
do
context
'with regular branch'
do
before
do
before
do
...
...
spec/requests/api/v3/builds_spec.rb
View file @
470e83ee
...
@@ -4,16 +4,18 @@ describe API::V3::Builds do
...
@@ -4,16 +4,18 @@ describe API::V3::Builds do
set
(
:user
)
{
create
(
:user
)
}
set
(
:user
)
{
create
(
:user
)
}
let
(
:api_user
)
{
user
}
let
(
:api_user
)
{
user
}
set
(
:project
)
{
create
(
:project
,
:repository
,
creator:
user
,
public_builds:
false
)
}
set
(
:project
)
{
create
(
:project
,
:repository
,
creator:
user
,
public_builds:
false
)
}
set
(
:developer
)
{
create
(
:project_member
,
:developer
,
user:
user
,
project:
project
)
}
let!
(
:developer
)
{
create
(
:project_member
,
:developer
,
user:
user
,
project:
project
)
}
s
et
(
:reporter
)
{
create
(
:project_member
,
:reporter
,
project:
project
)
}
l
et
(
:reporter
)
{
create
(
:project_member
,
:reporter
,
project:
project
)
}
s
et
(
:guest
)
{
create
(
:project_member
,
:guest
,
project:
project
)
}
l
et
(
:guest
)
{
create
(
:project_member
,
:guest
,
project:
project
)
}
s
et
(
:pipeline
)
{
create
(
:ci_empty_pipeline
,
project:
project
,
sha:
project
.
commit
.
id
,
ref:
project
.
default_branch
)
}
l
et
(
:pipeline
)
{
create
(
:ci_empty_pipeline
,
project:
project
,
sha:
project
.
commit
.
id
,
ref:
project
.
default_branch
)
}
let
!
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
let
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
describe
'GET /projects/:id/builds '
do
describe
'GET /projects/:id/builds '
do
let
(
:query
)
{
''
}
let
(
:query
)
{
''
}
before
do
|
example
|
before
do
|
example
|
build
create
(
:ci_build
,
:skipped
,
pipeline:
pipeline
)
create
(
:ci_build
,
:skipped
,
pipeline:
pipeline
)
unless
example
.
metadata
[
:skip_before_request
]
unless
example
.
metadata
[
:skip_before_request
]
...
@@ -110,6 +112,10 @@ describe API::V3::Builds do
...
@@ -110,6 +112,10 @@ describe API::V3::Builds do
end
end
describe
'GET /projects/:id/repository/commits/:sha/builds'
do
describe
'GET /projects/:id/repository/commits/:sha/builds'
do
before
do
build
end
context
'when commit does not exist in repository'
do
context
'when commit does not exist in repository'
do
before
do
before
do
get
v3_api
(
"/projects/
#{
project
.
id
}
/repository/commits/1a271fd1/builds"
,
api_user
)
get
v3_api
(
"/projects/
#{
project
.
id
}
/repository/commits/1a271fd1/builds"
,
api_user
)
...
@@ -214,6 +220,7 @@ describe API::V3::Builds do
...
@@ -214,6 +220,7 @@ describe API::V3::Builds do
end
end
context
'job with artifacts'
do
context
'job with artifacts'
do
context
'when artifacts are stored locally'
do
let
(
:build
)
{
create
(
:ci_build
,
:artifacts
,
pipeline:
pipeline
)
}
let
(
:build
)
{
create
(
:ci_build
,
:artifacts
,
pipeline:
pipeline
)
}
context
'authorized user'
do
context
'authorized user'
do
...
@@ -228,6 +235,7 @@ describe API::V3::Builds do
...
@@ -228,6 +235,7 @@ describe API::V3::Builds do
expect
(
response
.
body
).
to
match_file
(
build
.
artifacts_file
.
file
.
file
)
expect
(
response
.
body
).
to
match_file
(
build
.
artifacts_file
.
file
.
file
)
end
end
end
end
end
context
'unauthorized user'
do
context
'unauthorized user'
do
let
(
:api_user
)
{
nil
}
let
(
:api_user
)
{
nil
}
...
@@ -303,6 +311,7 @@ describe API::V3::Builds do
...
@@ -303,6 +311,7 @@ describe API::V3::Builds do
context
'find proper job'
do
context
'find proper job'
do
shared_examples
'a valid file'
do
shared_examples
'a valid file'
do
context
'when artifacts are stored locally'
do
let
(
:download_headers
)
do
let
(
:download_headers
)
do
{
'Content-Transfer-Encoding'
=>
'binary'
,
{
'Content-Transfer-Encoding'
=>
'binary'
,
'Content-Disposition'
=>
'Content-Disposition'
=>
...
@@ -312,6 +321,7 @@ describe API::V3::Builds do
...
@@ -312,6 +321,7 @@ describe API::V3::Builds do
it
{
expect
(
response
).
to
have_gitlab_http_status
(
200
)
}
it
{
expect
(
response
).
to
have_gitlab_http_status
(
200
)
}
it
{
expect
(
response
.
headers
).
to
include
(
download_headers
)
}
it
{
expect
(
response
.
headers
).
to
include
(
download_headers
)
}
end
end
end
context
'with regular branch'
do
context
'with regular branch'
do
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