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
bbd2a964
Commit
bbd2a964
authored
Aug 01, 2017
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix accessing individual files when artifacts are on object storage
parent
02c9babf
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
11 deletions
+57
-11
changelogs/unreleased-ee/fix-accessing-files-on-object-storage.yml
...s/unreleased-ee/fix-accessing-files-on-object-storage.yml
+4
-0
lib/gitlab/workhorse.rb
lib/gitlab/workhorse.rb
+9
-1
spec/controllers/projects/artifacts_controller_spec.rb
spec/controllers/projects/artifacts_controller_spec.rb
+44
-10
No files found.
changelogs/unreleased-ee/fix-accessing-files-on-object-storage.yml
0 → 100644
View file @
bbd2a964
---
title
:
Fix accessing individual files on Object Storage
merge_request
:
author
:
lib/gitlab/workhorse.rb
View file @
bbd2a964
...
@@ -123,8 +123,16 @@ module Gitlab
...
@@ -123,8 +123,16 @@ module Gitlab
end
end
def
send_artifacts_entry
(
build
,
entry
)
def
send_artifacts_entry
(
build
,
entry
)
file
=
build
.
artifacts_file
archive
=
if
file
.
file_storage?
file
.
path
else
file
.
url
end
params
=
{
params
=
{
'Archive'
=>
build
.
artifacts_file
.
path
,
'Archive'
=>
archive
,
'Entry'
=>
Base64
.
encode64
(
entry
.
path
)
'Entry'
=>
Base64
.
encode64
(
entry
.
path
)
}
}
...
...
spec/controllers/projects/artifacts_controller_spec.rb
View file @
bbd2a964
...
@@ -65,26 +65,60 @@ describe Projects::ArtifactsController do
...
@@ -65,26 +65,60 @@ describe Projects::ArtifactsController do
end
end
describe
'GET raw'
do
describe
'GET raw'
do
subject
{
get
(
:raw
,
namespace_id:
project
.
namespace
,
project_id:
project
,
job_id:
job
,
path:
path
)
}
context
'when the file exists'
do
context
'when the file exists'
do
it
'serves the file using workhorse'
do
let
(
:path
)
{
'ci_artifacts.txt'
}
get
:raw
,
namespace_id:
project
.
namespace
,
project_id:
project
,
job_id:
job
,
path:
'ci_artifacts.txt'
let
(
:job
)
{
create
(
:ci_build
,
:success
,
:artifacts
,
pipeline:
pipeline
,
artifacts_file_store:
store
,
artifacts_metadata_store:
store
)
}
shared_examples
'a valid file'
do
it
'serves the file using workhorse'
do
subject
expect
(
send_data
).
to
start_with
(
'artifacts-entry:'
)
expect
(
params
.
keys
).
to
eq
(
%w(Archive Entry)
)
expect
(
params
[
'Archive'
]).
to
start_with
(
archive_path
)
expect
(
params
[
'Archive'
]).
to
end_with
(
'build_artifacts.zip'
)
expect
(
params
[
'Entry'
]).
to
eq
(
Base64
.
encode64
(
'ci_artifacts.txt'
))
end
def
send_data
response
.
headers
[
Gitlab
::
Workhorse
::
SEND_DATA_HEADER
]
end
send_data
=
response
.
headers
[
Gitlab
::
Workhorse
::
SEND_DATA_HEADER
]
def
params
@params
||=
begin
base64_params
=
send_data
.
sub
(
/\Aartifacts\-entry:/
,
''
)
JSON
.
parse
(
Base64
.
urlsafe_decode64
(
base64_params
))
end
end
end
expect
(
send_data
).
to
start_with
(
'artifacts-entry:'
)
context
'when using local file storage'
do
it_behaves_like
'a valid file'
do
let
(
:store
)
{
ObjectStoreUploader
::
LOCAL_STORE
}
let
(
:archive_path
)
{
ArtifactUploader
.
local_artifacts_store
}
end
end
base64_params
=
send_data
.
sub
(
/\Aartifacts\-entry:/
,
''
)
context
'when using remote file storage'
do
params
=
JSON
.
parse
(
Base64
.
urlsafe_decode64
(
base64_params
))
before
do
stub_artifacts_object_storage
end
expect
(
params
.
keys
).
to
eq
(
%w(Archive Entry)
)
it_behaves_like
'a valid file'
do
expect
(
params
[
'Archive'
]).
to
end_with
(
'build_artifacts.zip'
)
let
(
:store
)
{
ObjectStoreUploader
::
REMOTE_STORE
}
expect
(
params
[
'Entry'
]).
to
eq
(
Base64
.
encode64
(
'ci_artifacts.txt'
))
let
(
:archive_path
)
{
'https://'
}
end
end
end
end
end
context
'when the file does not exist'
do
context
'when the file does not exist'
do
let
(
:path
)
{
'unknown'
}
it
'responds Not Found'
do
it
'responds Not Found'
do
get
:raw
,
namespace_id:
project
.
namespace
,
project_id:
project
,
job_id:
job
,
path:
'unknown'
subject
expect
(
response
).
to
be_not_found
expect
(
response
).
to
be_not_found
end
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