Move LFS auth hash creation into GitLab::LfsToken
This commit is contained in:
parent
9ab268b9c1
commit
c4f1e8ed10
|
@ -117,13 +117,7 @@ module API
|
||||||
raise ActiveRecord::RecordNotFound.new("No key_id or user_id passed!")
|
raise ActiveRecord::RecordNotFound.new("No key_id or user_id passed!")
|
||||||
end
|
end
|
||||||
|
|
||||||
token_handler = Gitlab::LfsToken.new(actor)
|
Gitlab::LfsToken.new(actor).for_gitlab_shell(project.http_url_to_repo)
|
||||||
|
|
||||||
{
|
|
||||||
username: token_handler.actor_name,
|
|
||||||
lfs_token: token_handler.token,
|
|
||||||
repository_http_path: project.http_url_to_repo
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
# rubocop: enable CodeReuse/ActiveRecord
|
# rubocop: enable CodeReuse/ActiveRecord
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,14 @@ module Gitlab
|
||||||
user? ? :lfs_token : :lfs_deploy_token
|
user? ? :lfs_token : :lfs_deploy_token
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def for_gitlab_shell(repository_http_path)
|
||||||
|
{
|
||||||
|
username: actor_name,
|
||||||
|
lfs_token: token,
|
||||||
|
repository_http_path: repository_http_path
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
private # rubocop:disable Lint/UselessAccessModifier
|
private # rubocop:disable Lint/UselessAccessModifier
|
||||||
|
|
||||||
class HMACToken
|
class HMACToken
|
||||||
|
|
|
@ -226,4 +226,18 @@ describe Gitlab::LfsToken, :clean_gitlab_redis_shared_state do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#for_gitlab_shell' do
|
||||||
|
let(:actor) { create(:user) }
|
||||||
|
let(:lfs_token) { described_class.new(actor) }
|
||||||
|
let(:repo_http_path) { 'http://localhost/user/repo.git' }
|
||||||
|
|
||||||
|
it 'returns a Hash desgined for gitlab-shell' do
|
||||||
|
hash = lfs_token.for_gitlab_shell(repo_http_path)
|
||||||
|
|
||||||
|
expect(hash[:username]).to eq(actor.username)
|
||||||
|
expect(hash[:repository_http_path]).to eq(repo_http_path)
|
||||||
|
expect(hash[:lfs_token]).to be_a String
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue