Commit fa2edec2 authored by Ash McKenzie's avatar Ash McKenzie Committed by Douglas Barbosa Alexandre

Rename Geo proxy_git_push_ssh to proxy_git_ssh

Method names now more closely match the actual
git commands that are being executed under the
hood.
parent 43eae78d
......@@ -56,9 +56,9 @@ module API
end
end
# git push over SSH secondary -> primary related proxying logic
# git over SSH secondary endpoints -> primary related proxying logic
#
resource 'proxy_git_push_ssh' do
resource 'proxy_git_ssh' do
format :json
# Responsible for making HTTP GET /repo.git/info/refs?service=git-receive-pack
......
......@@ -87,8 +87,8 @@ module EE
def custom_action_api_endpoints
[
api_v4_geo_proxy_git_push_ssh_info_receive_pack_path,
api_v4_geo_proxy_git_push_ssh_receive_pack_path
api_v4_geo_proxy_git_ssh_info_refs_receive_pack_path,
api_v4_geo_proxy_git_ssh_receive_pack_path
]
end
end
......
......@@ -20,7 +20,7 @@ module EE
override :whitelisted_routes
def whitelisted_routes
super || geo_node_update_route? || geo_proxy_git_push_ssh_route? || geo_api_route?
super || geo_node_update_route? || geo_proxy_git_ssh_route? || geo_api_route?
end
def geo_node_update_route?
......@@ -37,11 +37,11 @@ module EE
end
end
def geo_proxy_git_push_ssh_route?
def geo_proxy_git_ssh_route?
routes = ::Gitlab::Middleware::ReadOnly::API_VERSIONS.map do |version|
%W(
/api/v#{version}/geo/proxy_git_push_ssh/info_refs_receive_pack
/api/v#{version}/geo/proxy_git_push_ssh/receive_pack
/api/v#{version}/geo/proxy_git_ssh/info_refs_receive_pack
/api/v#{version}/geo/proxy_git_ssh/receive_pack
)
end
......
......@@ -389,7 +389,7 @@ describe API::Geo do
end
end
describe '/geo/proxy_git_push_ssh' do
describe '/geo/proxy_git_ssh' do
let(:secret_token) { Gitlab::Shell.secret_token }
let(:primary_repo) { 'http://localhost:3001/testuser/repo.git' }
let(:data) { { primary_repo: primary_repo, gl_id: 'key-1', gl_username: 'testuser' } }
......@@ -398,10 +398,10 @@ describe API::Geo do
stub_current_geo_node(secondary_node)
end
describe 'POST /geo/proxy_git_push_ssh/info_refs' do
describe 'POST /geo/proxy_git_ssh/info_refs_receive_pack' do
context 'with all required params missing' do
it 'responds with 400' do
post api('/geo/proxy_git_push_ssh/info_refs'), params: nil
post api('/geo/proxy_git_ssh/info_refs_receive_pack'), params: nil
expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['error']).to eql('secret_token is missing, data is missing, data[gl_id] is missing, data[primary_repo] is missing')
......@@ -417,7 +417,7 @@ describe API::Geo do
context 'with an invalid secret_token' do
it 'responds with 401' do
post(api('/geo/proxy_git_push_ssh/info_refs'), params: { secret_token: 'invalid', data: data })
post(api('/geo/proxy_git_ssh/info_refs_receive_pack'), params: { secret_token: 'invalid', data: data })
expect(response).to have_gitlab_http_status(:unauthorized)
expect(json_response['error']).to be_nil
......@@ -428,7 +428,7 @@ describe API::Geo do
it 'responds with 500' do
expect(git_push_ssh_proxy).to receive(:info_refs_receive_pack).and_raise('deliberate exception raised')
post api('/geo/proxy_git_push_ssh/info_refs'), params: { secret_token: secret_token, data: data }
post api('/geo/proxy_git_ssh/info_refs_receive_pack'), params: { secret_token: secret_token, data: data }
expect(response).to have_gitlab_http_status(:internal_server_error)
expect(json_response['message']).to include('RuntimeError (deliberate exception raised)')
......@@ -449,7 +449,7 @@ describe API::Geo do
it 'responds with 200' do
expect(git_push_ssh_proxy).to receive(:info_refs_receive_pack).and_return(api_response)
post api('/geo/proxy_git_push_ssh/info_refs'), params: { secret_token: secret_token, data: data }
post api('/geo/proxy_git_ssh/info_refs_receive_pack'), params: { secret_token: secret_token, data: data }
expect(response).to have_gitlab_http_status(:ok)
expect(Base64.decode64(json_response['result'])).to eql('something here')
......@@ -458,10 +458,10 @@ describe API::Geo do
end
end
describe 'POST /geo/proxy_git_push_ssh/push' do
describe 'POST /geo/proxy_git_ssh/receive_pack' do
context 'with all required params missing' do
it 'responds with 400' do
post api('/geo/proxy_git_push_ssh/push'), params: nil
post api('/geo/proxy_git_ssh/receive_pack'), params: nil
expect(response).to have_gitlab_http_status(:bad_request)
expect(json_response['error']).to eql('secret_token is missing, data is missing, data[gl_id] is missing, data[primary_repo] is missing, output is missing')
......@@ -478,7 +478,7 @@ describe API::Geo do
context 'with an invalid secret_token' do
it 'responds with 401' do
post(api('/geo/proxy_git_push_ssh/push'), params: { secret_token: 'invalid', data: data, output: output })
post(api('/geo/proxy_git_ssh/receive_pack'), params: { secret_token: 'invalid', data: data, output: output })
expect(response).to have_gitlab_http_status(:unauthorized)
expect(json_response['error']).to be_nil
......@@ -509,7 +509,7 @@ describe API::Geo do
it 'responds with 201' do
expect(git_push_ssh_proxy).to receive(:receive_pack).with(output).and_return(api_response)
post api('/geo/proxy_git_push_ssh/push'), params: { secret_token: secret_token, data: data, output: output }
post api('/geo/proxy_git_ssh/receive_pack'), params: { secret_token: secret_token, data: data, output: output }
expect(response).to have_gitlab_http_status(:created)
expect(Base64.decode64(json_response['result'])).to eql('something here')
......
......@@ -32,7 +32,7 @@ RSpec.shared_examples 'a read-only GitLab instance' do
{
'action' => 'geo_proxy_to_primary',
'data' => {
'api_endpoints' => %w{/api/v4/geo/proxy_git_push_ssh/info_refs /api/v4/geo/proxy_git_push_ssh/push},
'api_endpoints' => %w{/api/v4/geo/proxy_git_ssh/info_refs_receive_pack /api/v4/geo/proxy_git_ssh/receive_pack},
'primary_repo' => primary_repo_url
}
}
......
......@@ -10,7 +10,7 @@ module Gitlab
# {
# 'action' => 'geo_proxy_to_primary',
# 'data' => {
# 'api_endpoints' => %w{geo/proxy_git_push_ssh/info_refs geo/proxy_git_push_ssh/push},
# 'api_endpoints' => %w{geo/proxy_git_ssh/info_refs_receive_pack geo/proxy_git_ssh/receive_pack},
# 'gl_username' => user.username,
# 'primary_repo' => geo_primary_http_url_to_repo(project_or_wiki)
# }
......
......@@ -582,7 +582,7 @@ describe API::Internal::Base do
{
'action' => 'geo_proxy_to_primary',
'data' => {
'api_endpoints' => %w{geo/proxy_git_push_ssh/info_refs geo/proxy_git_push_ssh/push},
'api_endpoints' => %w{geo/proxy_git_ssh/info_refs_receive_pack geo/proxy_git_ssh/receive_pack},
'gl_username' => 'testuser',
'primary_repo' => 'http://localhost:3000/testuser/repo.git'
}
......
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