summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAsh McKenzie <amckenzie@gitlab.com>2019-02-11 15:05:00 +1100
committerAsh McKenzie <amckenzie@gitlab.com>2019-02-15 09:29:52 +1100
commit1cfa3c76a151a1c7ddf2099e3547fe1f5d691c25 (patch)
tree8076d6a5b16d1ff2b17e452b308fd7dec0a353b9
parent6dab9ce34308ac735672c48dd199df7f57f1cce7 (diff)
downloadgitlab-ce-57353-git-push-fails-on-large-lfs-files-where-the-push-take-a-long-time.tar.gz
Include expires_in for LFS authentication payload57353-git-push-fails-on-large-lfs-files-where-the-push-take-a-long-time
When using git-lfs with SSH we weren't passing in the expires_header header which is allows large transfers to succeed in the event the current default of 30 mins expires. https://github.com/git-lfs/git-lfs/blob/master/docs/api/server-discovery.md#ssh
-rw-r--r--changelogs/unreleased/57353-git-push-fails-on-large-lfs-files-where-the-push-take-a-long-time.yml5
-rw-r--r--lib/api/internal.rb2
-rw-r--r--lib/gitlab/lfs_token.rb5
-rw-r--r--spec/lib/gitlab/lfs_token_spec.rb22
-rw-r--r--spec/requests/api/internal_spec.rb1
5 files changed, 21 insertions, 14 deletions
diff --git a/changelogs/unreleased/57353-git-push-fails-on-large-lfs-files-where-the-push-take-a-long-time.yml b/changelogs/unreleased/57353-git-push-fails-on-large-lfs-files-where-the-push-take-a-long-time.yml
new file mode 100644
index 00000000000..46f82afda62
--- /dev/null
+++ b/changelogs/unreleased/57353-git-push-fails-on-large-lfs-files-where-the-push-take-a-long-time.yml
@@ -0,0 +1,5 @@
+---
+title: Provide expires_in in LFS authentication payload
+merge_request: 25082
+author:
+type: fixed
diff --git a/lib/api/internal.rb b/lib/api/internal.rb
index ede84dba42d..b44ef2a6ea4 100644
--- a/lib/api/internal.rb
+++ b/lib/api/internal.rb
@@ -117,7 +117,7 @@ module API
raise ActiveRecord::RecordNotFound.new("No key_id or user_id passed!")
end
- Gitlab::LfsToken.new(actor).for_gitlab_shell(project.http_url_to_repo)
+ Gitlab::LfsToken.new(actor).authentication_payload(project.http_url_to_repo)
end
# rubocop: enable CodeReuse/ActiveRecord
diff --git a/lib/gitlab/lfs_token.rb b/lib/gitlab/lfs_token.rb
index 5eefc3c0d7a..31e6fc9d8c7 100644
--- a/lib/gitlab/lfs_token.rb
+++ b/lib/gitlab/lfs_token.rb
@@ -47,11 +47,12 @@ module Gitlab
user? ? :lfs_token : :lfs_deploy_token
end
- def for_gitlab_shell(repository_http_path)
+ def authentication_payload(repository_http_path)
{
username: actor_name,
lfs_token: token,
- repository_http_path: repository_http_path
+ repository_http_path: repository_http_path,
+ expires_in: DEFAULT_EXPIRE_TIME
}
end
diff --git a/spec/lib/gitlab/lfs_token_spec.rb b/spec/lib/gitlab/lfs_token_spec.rb
index b4d42a47263..8961ecc4be0 100644
--- a/spec/lib/gitlab/lfs_token_spec.rb
+++ b/spec/lib/gitlab/lfs_token_spec.rb
@@ -227,17 +227,17 @@ describe Gitlab::LfsToken, :clean_gitlab_redis_shared_state do
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
+ describe '#authentication_payload' do
+ it 'returns a Hash designed for gitlab-shell' do
+ actor = create(:user)
+ lfs_token = described_class.new(actor)
+ repo_http_path = 'http://localhost/user/repo.git'
+ authentication_payload = lfs_token.authentication_payload(repo_http_path)
+
+ expect(authentication_payload[:username]).to eq(actor.username)
+ expect(authentication_payload[:repository_http_path]).to eq(repo_http_path)
+ expect(authentication_payload[:lfs_token]).to be_a String
+ expect(authentication_payload[:expires_in]).to eq(described_class::DEFAULT_EXPIRE_TIME)
end
end
end
diff --git a/spec/requests/api/internal_spec.rb b/spec/requests/api/internal_spec.rb
index 6a943b5237a..11d9ce354f1 100644
--- a/spec/requests/api/internal_spec.rb
+++ b/spec/requests/api/internal_spec.rb
@@ -167,6 +167,7 @@ describe API::Internal do
expect(response).to have_gitlab_http_status(200)
expect(json_response['username']).to eq(user.username)
expect(json_response['repository_http_path']).to eq(project.http_url_to_repo)
+ expect(json_response['expires_in']).to eq(Gitlab::LfsToken::DEFAULT_EXPIRE_TIME)
expect(Gitlab::LfsToken.new(key).token_valid?(json_response['lfs_token'])).to be_truthy
end