Commit 8b1865e9 authored by Patrick Bajao's avatar Patrick Bajao

Merge branch 'sh-fix-ruby-2.7-kwargs-git-http' into 'master'

Fix Ruby 2.7 keyword parameter deprecations in Git HTTP tests

See merge request gitlab-org/gitlab!43739
parents 34bc2bb7 dce7e224
...@@ -90,7 +90,7 @@ RSpec.describe 'Git HTTP requests' do ...@@ -90,7 +90,7 @@ RSpec.describe 'Git HTTP requests' do
shared_examples_for 'pulls are allowed' do shared_examples_for 'pulls are allowed' do
it 'allows pulls' do it 'allows pulls' do
download(path, env) do |response| download(path, **env) do |response|
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(response.media_type).to eq(Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE) expect(response.media_type).to eq(Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE)
end end
...@@ -99,7 +99,7 @@ RSpec.describe 'Git HTTP requests' do ...@@ -99,7 +99,7 @@ RSpec.describe 'Git HTTP requests' do
shared_examples_for 'pushes are allowed' do shared_examples_for 'pushes are allowed' do
it 'allows pushes', :sidekiq_might_not_need_inline do it 'allows pushes', :sidekiq_might_not_need_inline do
upload(path, env) do |response| upload(path, **env) do |response|
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(response.media_type).to eq(Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE) expect(response.media_type).to eq(Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE)
end end
...@@ -259,7 +259,7 @@ RSpec.describe 'Git HTTP requests' do ...@@ -259,7 +259,7 @@ RSpec.describe 'Git HTTP requests' do
it_behaves_like 'pulls are allowed' it_behaves_like 'pulls are allowed'
it 'rejects pushes with 403 Forbidden' do it 'rejects pushes with 403 Forbidden' do
upload(path, env) do |response| upload(path, **env) do |response|
expect(response).to have_gitlab_http_status(:forbidden) expect(response).to have_gitlab_http_status(:forbidden)
expect(response.body).to eq(git_access_wiki_error(:write_to_wiki)) expect(response.body).to eq(git_access_wiki_error(:write_to_wiki))
end end
...@@ -347,7 +347,7 @@ RSpec.describe 'Git HTTP requests' do ...@@ -347,7 +347,7 @@ RSpec.describe 'Git HTTP requests' do
end end
it 'rejects pushes with 403 Forbidden' do it 'rejects pushes with 403 Forbidden' do
upload(path, env) do |response| upload(path, **env) do |response|
expect(response).to have_gitlab_http_status(:forbidden) expect(response).to have_gitlab_http_status(:forbidden)
expect(response.body).to eq(git_access_error(:receive_pack_disabled_over_http)) expect(response.body).to eq(git_access_error(:receive_pack_disabled_over_http))
end end
...@@ -358,7 +358,7 @@ RSpec.describe 'Git HTTP requests' do ...@@ -358,7 +358,7 @@ RSpec.describe 'Git HTTP requests' do
it "rejects pushes with 403 Forbidden" do it "rejects pushes with 403 Forbidden" do
allow(Gitlab.config.gitlab_shell).to receive(:upload_pack).and_return(false) allow(Gitlab.config.gitlab_shell).to receive(:upload_pack).and_return(false)
download(path, env) do |response| download(path, **env) do |response|
expect(response).to have_gitlab_http_status(:forbidden) expect(response).to have_gitlab_http_status(:forbidden)
expect(response.body).to eq(git_access_error(:upload_pack_disabled_over_http)) expect(response.body).to eq(git_access_error(:upload_pack_disabled_over_http))
end end
...@@ -370,7 +370,7 @@ RSpec.describe 'Git HTTP requests' do ...@@ -370,7 +370,7 @@ RSpec.describe 'Git HTTP requests' do
it_behaves_like 'pulls are allowed' it_behaves_like 'pulls are allowed'
it 'rejects pushes with 403 Forbidden' do it 'rejects pushes with 403 Forbidden' do
upload(path, env) do |response| upload(path, **env) do |response|
expect(response).to have_gitlab_http_status(:forbidden) expect(response).to have_gitlab_http_status(:forbidden)
expect(response.body).to eq('You are not allowed to push code to this project.') expect(response.body).to eq('You are not allowed to push code to this project.')
end end
...@@ -485,7 +485,7 @@ RSpec.describe 'Git HTTP requests' do ...@@ -485,7 +485,7 @@ RSpec.describe 'Git HTTP requests' do
user.block user.block
project.add_maintainer(user) project.add_maintainer(user)
download(path, env) do |response| download(path, **env) do |response|
expect(response).to have_gitlab_http_status(:unauthorized) expect(response).to have_gitlab_http_status(:unauthorized)
end end
end end
...@@ -507,7 +507,7 @@ RSpec.describe 'Git HTTP requests' do ...@@ -507,7 +507,7 @@ RSpec.describe 'Git HTTP requests' do
it "resets the IP in Rack Attack on download" do it "resets the IP in Rack Attack on download" do
expect(Rack::Attack::Allow2Ban).to receive(:reset).twice expect(Rack::Attack::Allow2Ban).to receive(:reset).twice
download(path, env) do download(path, **env) do
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(response.media_type).to eq(Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE) expect(response.media_type).to eq(Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE)
end end
...@@ -516,7 +516,7 @@ RSpec.describe 'Git HTTP requests' do ...@@ -516,7 +516,7 @@ RSpec.describe 'Git HTTP requests' do
it "resets the IP in Rack Attack on upload" do it "resets the IP in Rack Attack on upload" do
expect(Rack::Attack::Allow2Ban).to receive(:reset).twice expect(Rack::Attack::Allow2Ban).to receive(:reset).twice
upload(path, env) do upload(path, **env) do
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
expect(response.media_type).to eq(Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE) expect(response.media_type).to eq(Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE)
end end
...@@ -525,7 +525,7 @@ RSpec.describe 'Git HTTP requests' do ...@@ -525,7 +525,7 @@ RSpec.describe 'Git HTTP requests' do
it 'updates the user last activity', :clean_gitlab_redis_shared_state do it 'updates the user last activity', :clean_gitlab_redis_shared_state do
expect(user.last_activity_on).to be_nil expect(user.last_activity_on).to be_nil
download(path, env) do |response| download(path, **env) do |response|
expect(user.reload.last_activity_on).to eql(Date.today) expect(user.reload.last_activity_on).to eql(Date.today)
end end
end end
...@@ -699,7 +699,7 @@ RSpec.describe 'Git HTTP requests' do ...@@ -699,7 +699,7 @@ RSpec.describe 'Git HTTP requests' do
end end
it 'uploads get status 404 with "project was moved" message' do it 'uploads get status 404 with "project was moved" message' do
upload(path, env) do |response| upload(path, **env) do |response|
expect(response).to have_gitlab_http_status(:ok) expect(response).to have_gitlab_http_status(:ok)
end end
end end
...@@ -917,11 +917,11 @@ RSpec.describe 'Git HTTP requests' do ...@@ -917,11 +917,11 @@ RSpec.describe 'Git HTTP requests' do
expect(response).to have_gitlab_http_status(:forbidden) expect(response).to have_gitlab_http_status(:forbidden)
end end
download(path, env) do |response| download(path, **env) do |response|
expect(response).to have_gitlab_http_status(:forbidden) expect(response).to have_gitlab_http_status(:forbidden)
end end
upload(path, env) do |response| upload(path, **env) do |response|
expect(response).to have_gitlab_http_status(:forbidden) expect(response).to have_gitlab_http_status(:forbidden)
end end
end end
......
...@@ -22,28 +22,28 @@ module GitHttpHelpers ...@@ -22,28 +22,28 @@ module GitHttpHelpers
end end
def download(project, user: nil, password: nil, spnego_request_token: nil) def download(project, user: nil, password: nil, spnego_request_token: nil)
args = [project, { user: user, password: password, spnego_request_token: spnego_request_token }] args = { user: user, password: password, spnego_request_token: spnego_request_token }
clone_get(*args) clone_get(project, **args)
yield response yield response
clone_post(*args) clone_post(project, **args)
yield response yield response
end end
def upload(project, user: nil, password: nil, spnego_request_token: nil) def upload(project, user: nil, password: nil, spnego_request_token: nil)
args = [project, { user: user, password: password, spnego_request_token: spnego_request_token }] args = { user: user, password: password, spnego_request_token: spnego_request_token }
push_get(*args) push_get(project, **args)
yield response yield response
push_post(*args) push_post(project, **args)
yield response yield response
end end
def download_or_upload(*args, &block) def download_or_upload(project, **args, &block)
download(*args, &block) download(project, **args, &block)
upload(*args, &block) upload(project, **args, &block)
end end
def auth_env(user, password, spnego_request_token) def auth_env(user, password, spnego_request_token)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment