Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
5da2f42d
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
5da2f42d
编写于
11月 07, 2018
作者:
K
Kamil Trzciński
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
backport: Always proxy reports downloads
This makes to always proxy reports
上级
829e4525
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
51 addition
and
17 deletion
+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
未找到文件。
app/controllers/concerns/send_file_upload.rb
浏览文件 @
5da2f42d
# frozen_string_literal: true
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
# Response-Content-Type will not override an existing Content-Type in
# Google Cloud Storage, so the metadata needs to be cleared on GCS for
...
...
@@ -17,7 +17,7 @@ module SendFileUpload
if
file_upload
.
file_storage?
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
)))
head
:ok
else
...
...
app/controllers/projects/artifacts_controller.rb
浏览文件 @
5da2f42d
...
...
@@ -16,7 +16,7 @@ class Projects::ArtifactsController < Projects::ApplicationController
def
download
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
def
browse
...
...
spec/controllers/concerns/send_file_upload_spec.rb
浏览文件 @
5da2f42d
...
...
@@ -28,8 +28,9 @@ describe SendFileUpload do
describe
'#send_upload'
do
let
(
:controller
)
{
controller_class
.
new
}
let
(
:temp_file
)
{
Tempfile
.
new
(
'test'
)
}
let
(
:params
)
{
{}
}
subject
{
controller
.
send_upload
(
uploader
)
}
subject
{
controller
.
send_upload
(
uploader
,
**
params
)
}
before
do
FileUtils
.
touch
(
temp_file
)
...
...
@@ -52,7 +53,7 @@ describe SendFileUpload do
end
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
expected_params
=
{
...
...
@@ -62,7 +63,7 @@ describe SendFileUpload do
}
expect
(
controller
).
to
receive
(
:send_file
).
with
(
uploader
.
path
,
expected_params
)
s
end_attachmen
t
s
ubjec
t
end
context
'with a proxied file in object storage'
do
...
...
@@ -83,7 +84,7 @@ describe SendFileUpload do
expect
(
controller
).
to
receive
(
:headers
)
{
headers
}
expect
(
controller
).
to
receive
(
:head
).
with
(
:ok
)
s
end_attachmen
t
s
ubjec
t
end
end
end
...
...
@@ -95,11 +96,7 @@ describe SendFileUpload do
uploader
.
store!
(
temp_file
)
end
context
'and proxying is enabled'
do
before
do
allow
(
Gitlab
.
config
.
uploads
.
object_store
).
to
receive
(
:proxy_download
)
{
true
}
end
shared_examples
'proxied file'
do
it
'sends a file'
do
headers
=
double
expect
(
Gitlab
::
Workhorse
).
not_to
receive
(
:send_url
).
with
(
/response-content-disposition/
)
...
...
@@ -115,6 +112,14 @@ describe SendFileUpload do
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
before
do
allow
(
Gitlab
.
config
.
uploads
.
object_store
).
to
receive
(
:proxy_download
)
{
false
}
...
...
@@ -125,6 +130,12 @@ describe SendFileUpload do
subject
end
context
'with proxy requested'
do
let
(
:params
)
{
{
proxy:
true
}
}
it_behaves_like
'proxied file'
end
end
end
end
...
...
spec/controllers/projects/artifacts_controller_spec.rb
浏览文件 @
5da2f42d
...
...
@@ -47,14 +47,37 @@ describe Projects::ArtifactsController do
context
'when codequality file type is supplied'
do
let
(
:file_type
)
{
'codequality'
}
before
do
create
(
:ci_job_artifact
,
:codequality
,
job:
job
)
context
'when file is stored locally'
do
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
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
context
'when file is stored remotely'
do
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
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录