Skip to content
代码片段 群组 项目
未验证 提交 58c58cac 编辑于 作者: Carla Drago's avatar Carla Drago 提交者: GitLab
浏览文件

Include headers in LfsDownloadObject

Adds the headers included in the github response so that
the authorization token can be passed in the request for
the file.

Changelog: fixed
上级 588c5f70
No related branches found
No related tags found
无相关合并请求
......@@ -14,7 +14,8 @@ def initialize(lfs_object, project, _)
end
def lfs_download_object
LfsDownloadObject.new(oid: lfs_object.oid, size: lfs_object.size, link: lfs_object.link)
LfsDownloadObject.new(oid: lfs_object.oid, size: lfs_object.size, link: lfs_object.link,
headers: lfs_object.headers)
end
def execute
......
......@@ -6,14 +6,15 @@ module Representation
class LfsObject
include Representable
expose_attribute :oid, :link, :size
expose_attribute :oid, :link, :size, :headers
# Builds a lfs_object
def self.from_api_response(lfs_object, additional_data = {})
new(
oid: lfs_object.oid,
link: lfs_object.link,
size: lfs_object.size
size: lfs_object.size,
headers: lfs_object.headers
)
end
......
......@@ -4,11 +4,13 @@
RSpec.describe Gitlab::GithubImport::Importer::LfsObjectImporter do
let(:project) { create(:project) }
let(:headers) { { 'Authorization' => 'RemoteAuth 12345' } }
let(:lfs_attributes) do
{
oid: 'oid',
size: 1,
link: 'http://www.gitlab.com/lfs_objects/oid'
link: 'http://www.gitlab.com/lfs_objects/oid',
headers: headers
}
end
......@@ -28,4 +30,10 @@
importer.execute
end
end
describe '#lfs_download_object' do
it 'creates the download object with the correct attributes' do
expect(importer.lfs_download_object).to have_attributes(lfs_attributes)
end
end
end
......@@ -9,10 +9,11 @@
oid: 42,
size: 123456
}
other_attributes = { something_else: '_something_else_' }
other_attributes = { headers: { Authorization: 'RemoteAuth 123456' } }
lfs_object = described_class.new(github_identifiers.merge(other_attributes))
expect(lfs_object.github_identifiers).to eq(github_identifiers)
expect(lfs_object.headers).to eq({ Authorization: 'RemoteAuth 123456' })
end
end
end
......@@ -19,7 +19,10 @@ def objects_response(oids)
{
'oid' => oid, 'size' => size,
'actions' => {
'download' => { 'href' => "#{import_url}/gitlab-lfs/objects/#{oid}", header: headers }
'download' => {
'href' => "#{import_url}/gitlab-lfs/objects/#{oid}",
'header' => headers
}
}
}
end
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册