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
5da2f42d
Commit
5da2f42d
authored
Nov 07, 2018
by
Kamil Trzciński
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
backport: Always proxy reports downloads
This makes to always proxy reports
parent
829e4525
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
17 deletions
+51
-17
app/controllers/concerns/send_file_upload.rb
app/controllers/concerns/send_file_upload.rb
+2
-2
app/controllers/projects/artifacts_controller.rb
app/controllers/projects/artifacts_controller.rb
+1
-1
spec/controllers/concerns/send_file_upload_spec.rb
spec/controllers/concerns/send_file_upload_spec.rb
+20
-9
spec/controllers/projects/artifacts_controller_spec.rb
spec/controllers/projects/artifacts_controller_spec.rb
+28
-5
No files found.
app/controllers/concerns/send_file_upload.rb
View file @
5da2f42d
# frozen_string_literal: true
# frozen_string_literal: true
module
SendFileUpload
module
SendFileUpload
def
send_upload
(
file_upload
,
send_params:
{},
redirect_params:
{},
attachment:
nil
,
disposition:
'attachment'
)
def
send_upload
(
file_upload
,
send_params:
{},
redirect_params:
{},
attachment:
nil
,
proxy:
false
,
disposition:
'attachment'
)
if
attachment
if
attachment
# Response-Content-Type will not override an existing Content-Type in
# Response-Content-Type will not override an existing Content-Type in
# Google Cloud Storage, so the metadata needs to be cleared on GCS for
# Google Cloud Storage, so the metadata needs to be cleared on GCS for
...
@@ -17,7 +17,7 @@ module SendFileUpload
...
@@ -17,7 +17,7 @@ module SendFileUpload
if
file_upload
.
file_storage?
if
file_upload
.
file_storage?
send_file
file_upload
.
path
,
send_params
send_file
file_upload
.
path
,
send_params
elsif
file_upload
.
class
.
proxy_download_enabled?
elsif
file_upload
.
class
.
proxy_download_enabled?
||
proxy
headers
.
store
(
*
Gitlab
::
Workhorse
.
send_url
(
file_upload
.
url
(
**
redirect_params
)))
headers
.
store
(
*
Gitlab
::
Workhorse
.
send_url
(
file_upload
.
url
(
**
redirect_params
)))
head
:ok
head
:ok
else
else
...
...
app/controllers/projects/artifacts_controller.rb
View file @
5da2f42d
...
@@ -16,7 +16,7 @@ class Projects::ArtifactsController < Projects::ApplicationController
...
@@ -16,7 +16,7 @@ class Projects::ArtifactsController < Projects::ApplicationController
def
download
def
download
return
render_404
unless
artifacts_file
return
render_404
unless
artifacts_file
send_upload
(
artifacts_file
,
attachment:
artifacts_file
.
filename
)
send_upload
(
artifacts_file
,
attachment:
artifacts_file
.
filename
,
proxy:
params
[
:proxy
]
)
end
end
def
browse
def
browse
...
...
spec/controllers/concerns/send_file_upload_spec.rb
View file @
5da2f42d
...
@@ -28,8 +28,9 @@ describe SendFileUpload do
...
@@ -28,8 +28,9 @@ describe SendFileUpload do
describe
'#send_upload'
do
describe
'#send_upload'
do
let
(
:controller
)
{
controller_class
.
new
}
let
(
:controller
)
{
controller_class
.
new
}
let
(
:temp_file
)
{
Tempfile
.
new
(
'test'
)
}
let
(
:temp_file
)
{
Tempfile
.
new
(
'test'
)
}
let
(
:params
)
{
{}
}
subject
{
controller
.
send_upload
(
uploader
)
}
subject
{
controller
.
send_upload
(
uploader
,
**
params
)
}
before
do
before
do
FileUtils
.
touch
(
temp_file
)
FileUtils
.
touch
(
temp_file
)
...
@@ -52,7 +53,7 @@ describe SendFileUpload do
...
@@ -52,7 +53,7 @@ describe SendFileUpload do
end
end
context
'with attachment'
do
context
'with attachment'
do
let
(
:
send_attachment
)
{
controller
.
send_upload
(
uploader
,
attachment:
'test.js'
)
}
let
(
:
params
)
{
{
attachment:
'test.js'
}
}
it
'sends a file with content-type of text/plain'
do
it
'sends a file with content-type of text/plain'
do
expected_params
=
{
expected_params
=
{
...
@@ -62,7 +63,7 @@ describe SendFileUpload do
...
@@ -62,7 +63,7 @@ describe SendFileUpload do
}
}
expect
(
controller
).
to
receive
(
:send_file
).
with
(
uploader
.
path
,
expected_params
)
expect
(
controller
).
to
receive
(
:send_file
).
with
(
uploader
.
path
,
expected_params
)
s
end_attachmen
t
s
ubjec
t
end
end
context
'with a proxied file in object storage'
do
context
'with a proxied file in object storage'
do
...
@@ -83,7 +84,7 @@ describe SendFileUpload do
...
@@ -83,7 +84,7 @@ describe SendFileUpload do
expect
(
controller
).
to
receive
(
:headers
)
{
headers
}
expect
(
controller
).
to
receive
(
:headers
)
{
headers
}
expect
(
controller
).
to
receive
(
:head
).
with
(
:ok
)
expect
(
controller
).
to
receive
(
:head
).
with
(
:ok
)
s
end_attachmen
t
s
ubjec
t
end
end
end
end
end
end
...
@@ -95,11 +96,7 @@ describe SendFileUpload do
...
@@ -95,11 +96,7 @@ describe SendFileUpload do
uploader
.
store!
(
temp_file
)
uploader
.
store!
(
temp_file
)
end
end
context
'and proxying is enabled'
do
shared_examples
'proxied file'
do
before
do
allow
(
Gitlab
.
config
.
uploads
.
object_store
).
to
receive
(
:proxy_download
)
{
true
}
end
it
'sends a file'
do
it
'sends a file'
do
headers
=
double
headers
=
double
expect
(
Gitlab
::
Workhorse
).
not_to
receive
(
:send_url
).
with
(
/response-content-disposition/
)
expect
(
Gitlab
::
Workhorse
).
not_to
receive
(
:send_url
).
with
(
/response-content-disposition/
)
...
@@ -115,6 +112,14 @@ describe SendFileUpload do
...
@@ -115,6 +112,14 @@ describe SendFileUpload do
end
end
end
end
context
'and proxying is enabled'
do
before
do
allow
(
Gitlab
.
config
.
uploads
.
object_store
).
to
receive
(
:proxy_download
)
{
true
}
end
it_behaves_like
'proxied file'
end
context
'and proxying is disabled'
do
context
'and proxying is disabled'
do
before
do
before
do
allow
(
Gitlab
.
config
.
uploads
.
object_store
).
to
receive
(
:proxy_download
)
{
false
}
allow
(
Gitlab
.
config
.
uploads
.
object_store
).
to
receive
(
:proxy_download
)
{
false
}
...
@@ -125,6 +130,12 @@ describe SendFileUpload do
...
@@ -125,6 +130,12 @@ describe SendFileUpload do
subject
subject
end
end
context
'with proxy requested'
do
let
(
:params
)
{
{
proxy:
true
}
}
it_behaves_like
'proxied file'
end
end
end
end
end
end
end
...
...
spec/controllers/projects/artifacts_controller_spec.rb
View file @
5da2f42d
...
@@ -47,14 +47,37 @@ describe Projects::ArtifactsController do
...
@@ -47,14 +47,37 @@ describe Projects::ArtifactsController do
context
'when codequality file type is supplied'
do
context
'when codequality file type is supplied'
do
let
(
:file_type
)
{
'codequality'
}
let
(
:file_type
)
{
'codequality'
}
before
do
context
'when file is stored locally'
do
create
(
:ci_job_artifact
,
:codequality
,
job:
job
)
before
do
create
(
:ci_job_artifact
,
:codequality
,
job:
job
)
end
it
'sends the codequality report'
do
expect
(
controller
).
to
receive
(
:send_file
).
with
(
job
.
job_artifacts_codequality
.
file
.
path
,
hash_including
(
disposition:
'attachment'
)).
and_call_original
download_artifact
(
file_type:
file_type
)
end
end
end
it
'sends the codequality report'
do
context
'when file is stored remotely'
do
expect
(
controller
).
to
receive
(
:send_file
).
with
(
job
.
job_artifacts_codequality
.
file
.
path
,
hash_including
(
disposition:
'attachment'
)).
and_call_original
before
do
stub_artifacts_object_storage
create
(
:ci_job_artifact
,
:remote_store
,
:codequality
,
job:
job
)
end
it
'sends the codequality report'
do
expect
(
controller
).
to
receive
(
:redirect_to
).
and_call_original
download_artifact
(
file_type:
file_type
)
download_artifact
(
file_type:
file_type
)
end
context
'when proxied'
do
it
'sends the codequality report'
do
expect
(
Gitlab
::
Workhorse
).
to
receive
(
:send_url
).
and_call_original
download_artifact
(
file_type:
file_type
,
proxy:
true
)
end
end
end
end
end
end
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