diff options
Diffstat (limited to 'spec/requests/git_http_spec.rb')
-rw-r--r-- | spec/requests/git_http_spec.rb | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/spec/requests/git_http_spec.rb b/spec/requests/git_http_spec.rb index 02b99eba8ce..5b50e8a1021 100644 --- a/spec/requests/git_http_spec.rb +++ b/spec/requests/git_http_spec.rb @@ -230,6 +230,17 @@ RSpec.describe 'Git HTTP requests', feature_category: :source_code_management do context 'when authenticated' do it 'creates a new project under the existing namespace' do + # current scenario does not matter with the user activity case, + # so stub/double it to escape more sql running times limit + activity_service = instance_double(::Users::ActivityService) + allow(::Users::ActivityService).to receive(:new).and_return(activity_service) + allow(activity_service).to receive(:execute) + + # During project creation, we need to track the project wiki + # repository. So it is over the query limit threshold, and we + # have to adjust it. + allow(Gitlab::QueryLimiting::Transaction).to receive(:threshold).and_return(101) + expect do upload(path, user: user.username, password: user.password) do |response| expect(response).to have_gitlab_http_status(:ok) @@ -472,10 +483,11 @@ RSpec.describe 'Git HTTP requests', feature_category: :source_code_management do end context 'when the request is not from gitlab-workhorse' do - it 'raises an exception' do - expect do - get("/#{project.full_path}.git/info/refs?service=git-upload-pack") - end.to raise_error(JWT::DecodeError) + it 'responds with 403 Forbidden' do + get("/#{project.full_path}.git/info/refs?service=git-upload-pack") + + expect(response).to have_gitlab_http_status(:forbidden) + expect(response.body).to eq('Nil JSON web token') end end @@ -1112,10 +1124,11 @@ RSpec.describe 'Git HTTP requests', feature_category: :source_code_management do end context 'when the request is not from gitlab-workhorse' do - it 'raises an exception' do - expect do - get("/#{project.full_path}.git/info/refs?service=git-upload-pack") - end.to raise_error(JWT::DecodeError) + it 'responds with 403 Forbidden' do + get("/#{project.full_path}.git/info/refs?service=git-upload-pack") + + expect(response).to have_gitlab_http_status(:forbidden) + expect(response.body).to eq('Nil JSON web token') end end |