diff options
author | Patricio Cano <suprnova32@gmail.com> | 2016-09-27 21:23:51 +0300 |
---|---|---|
committer | Patricio Cano <suprnova32@gmail.com> | 2016-09-27 21:23:51 +0300 |
commit | a4944fb7155fc8aa4d1541d9f1e4e80c00f49292 (patch) | |
tree | 27672a9cf98fcf1b0475d2eeb808ea4a15d92d8d /spec/requests | |
parent | 90578f4ad091f80428a661005060af65a0c7151e (diff) |
Do not regenerate the `lfs_token` every time `git-lfs-authenticate` is called, instead return the saved token if one is present.
Diffstat (limited to 'spec/requests')
-rw-r--r-- | spec/requests/lfs_http_spec.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/requests/lfs_http_spec.rb b/spec/requests/lfs_http_spec.rb index 09e4e265dd1..a84be1b7c9e 100644 --- a/spec/requests/lfs_http_spec.rb +++ b/spec/requests/lfs_http_spec.rb @@ -257,6 +257,29 @@ describe 'Git LFS API and storage' do it_behaves_like 'responds with a file' end + describe 'when using a user key' do + let(:authorization) { authorize_user_key } + + context 'when user allowed' do + let(:update_permissions) do + project.team << [user, :master] + project.lfs_objects << lfs_object + end + + it_behaves_like 'responds with a file' + end + + context 'when user not allowed' do + let(:update_permissions) do + project.lfs_objects << lfs_object + end + + it 'responds with status 404' do + expect(response).to have_http_status(404) + end + end + end + context 'when build is authorized as' do let(:authorization) { authorize_ci_project } @@ -1113,6 +1136,10 @@ describe 'Git LFS API and storage' do ActionController::HttpAuthentication::Basic.encode_credentials("lfs+deploy-key-#{key.id}", Gitlab::LfsToken.new(key).generate) end + def authorize_user_key + ActionController::HttpAuthentication::Basic.encode_credentials(user.username, Gitlab::LfsToken.new(user).generate) + end + def fork_project(project, user, object = nil) allow(RepositoryForkWorker).to receive(:perform_async).and_return(true) Projects::ForkService.new(project, user, {}).execute |