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

Rename GitPushSSHProxy to GitSSHProxy

GitSSHProxy will be a more accurate name because
it will be handling not just push operations.
parent befd7a23
...@@ -75,7 +75,7 @@ module API ...@@ -75,7 +75,7 @@ module API
authenticate_by_gitlab_shell_token! authenticate_by_gitlab_shell_token!
params.delete(:secret_token) params.delete(:secret_token)
response = Gitlab::Geo::GitPushSSHProxy.new(params['data']).info_refs response = Gitlab::Geo::GitSSHProxy.new(params['data']).info_refs
status(response.code) status(response.code)
response.body response.body
end end
...@@ -95,7 +95,7 @@ module API ...@@ -95,7 +95,7 @@ module API
authenticate_by_gitlab_shell_token! authenticate_by_gitlab_shell_token!
params.delete(:secret_token) params.delete(:secret_token)
response = Gitlab::Geo::GitPushSSHProxy.new(params['data']).push(params['output']) response = Gitlab::Geo::GitSSHProxy.new(params['data']).push(params['output'])
status(response.code) status(response.code)
response.body response.body
end end
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
module Gitlab module Gitlab
module Geo module Geo
class GitPushSSHProxy class GitSSHProxy
HTTP_READ_TIMEOUT = 60 HTTP_READ_TIMEOUT = 60
INFO_REFS_CONTENT_TYPE = 'application/x-git-upload-pack-request'.freeze INFO_REFS_CONTENT_TYPE = 'application/x-git-upload-pack-request'.freeze
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
require 'spec_helper' require 'spec_helper'
describe Gitlab::Geo::GitPushSSHProxy, :geo do describe Gitlab::Geo::GitSSHProxy, :geo do
include ::EE::GeoHelpers include ::EE::GeoHelpers
# TODO This spec doesn't work with a relative_url_root https://gitlab.com/gitlab-org/gitlab/issues/11173 # TODO This spec doesn't work with a relative_url_root https://gitlab.com/gitlab-org/gitlab/issues/11173
...@@ -86,8 +86,8 @@ describe Gitlab::Geo::GitPushSSHProxy, :geo do ...@@ -86,8 +86,8 @@ describe Gitlab::Geo::GitPushSSHProxy, :geo do
stub_request(:get, full_info_refs_url).to_timeout stub_request(:get, full_info_refs_url).to_timeout
end end
it 'returns a Gitlab::Geo::GitPushSSHProxy::FailedAPIResponse' do it 'returns a Gitlab::Geo::GitSSHProxy::FailedAPIResponse' do
expect(subject.info_refs).to be_a(Gitlab::Geo::GitPushSSHProxy::FailedAPIResponse) expect(subject.info_refs).to be_a(Gitlab::Geo::GitSSHProxy::FailedAPIResponse)
end end
it 'has a code of 500' do it 'has a code of 500' do
...@@ -114,8 +114,8 @@ describe Gitlab::Geo::GitPushSSHProxy, :geo do ...@@ -114,8 +114,8 @@ describe Gitlab::Geo::GitPushSSHProxy, :geo do
stub_request(:get, full_info_refs_url).to_return(status: 502, body: error_msg, headers: info_refs_headers) stub_request(:get, full_info_refs_url).to_return(status: 502, body: error_msg, headers: info_refs_headers)
end end
it 'returns a Gitlab::Geo::GitPushSSHProxy::FailedAPIResponse' do it 'returns a Gitlab::Geo::GitSSHProxy::FailedAPIResponse' do
expect(subject.info_refs).to be_a(Gitlab::Geo::GitPushSSHProxy::APIResponse) expect(subject.info_refs).to be_a(Gitlab::Geo::GitSSHProxy::APIResponse)
end end
it 'has a code of 502' do it 'has a code of 502' do
...@@ -140,8 +140,8 @@ describe Gitlab::Geo::GitPushSSHProxy, :geo do ...@@ -140,8 +140,8 @@ describe Gitlab::Geo::GitPushSSHProxy, :geo do
stub_request(:get, full_info_refs_url).to_return(status: 200, body: info_refs_http_body_full, headers: info_refs_headers) stub_request(:get, full_info_refs_url).to_return(status: 200, body: info_refs_http_body_full, headers: info_refs_headers)
end end
it 'returns a Gitlab::Geo::GitPushSSHProxy::APIResponse' do it 'returns a Gitlab::Geo::GitSSHProxy::APIResponse' do
expect(subject.info_refs).to be_a(Gitlab::Geo::GitPushSSHProxy::APIResponse) expect(subject.info_refs).to be_a(Gitlab::Geo::GitSSHProxy::APIResponse)
end end
it 'has a code of 200' do it 'has a code of 200' do
...@@ -192,8 +192,8 @@ describe Gitlab::Geo::GitPushSSHProxy, :geo do ...@@ -192,8 +192,8 @@ describe Gitlab::Geo::GitPushSSHProxy, :geo do
stub_request(:post, full_git_receive_pack_url).to_timeout stub_request(:post, full_git_receive_pack_url).to_timeout
end end
it 'returns a Gitlab::Geo::GitPushSSHProxy::FailedAPIResponse' do it 'returns a Gitlab::Geo::GitSSHProxy::FailedAPIResponse' do
expect(subject.push(info_refs_body_short)).to be_a(Gitlab::Geo::GitPushSSHProxy::FailedAPIResponse) expect(subject.push(info_refs_body_short)).to be_a(Gitlab::Geo::GitSSHProxy::FailedAPIResponse)
end end
it 'has a messsage' do it 'has a messsage' do
...@@ -212,8 +212,8 @@ describe Gitlab::Geo::GitPushSSHProxy, :geo do ...@@ -212,8 +212,8 @@ describe Gitlab::Geo::GitPushSSHProxy, :geo do
stub_request(:post, full_git_receive_pack_url).to_return(status: 502, body: error_msg, headers: push_headers) stub_request(:post, full_git_receive_pack_url).to_return(status: 502, body: error_msg, headers: push_headers)
end end
it 'returns a Gitlab::Geo::GitPushSSHProxy::FailedAPIResponse' do it 'returns a Gitlab::Geo::GitSSHProxy::FailedAPIResponse' do
expect(subject.push(info_refs_body_short)).to be_a(Gitlab::Geo::GitPushSSHProxy::APIResponse) expect(subject.push(info_refs_body_short)).to be_a(Gitlab::Geo::GitSSHProxy::APIResponse)
end end
it 'has a messsage' do it 'has a messsage' do
...@@ -233,8 +233,8 @@ describe Gitlab::Geo::GitPushSSHProxy, :geo do ...@@ -233,8 +233,8 @@ describe Gitlab::Geo::GitPushSSHProxy, :geo do
stub_request(:post, full_git_receive_pack_url).to_return(status: 201, body: body, headers: push_headers) stub_request(:post, full_git_receive_pack_url).to_return(status: 201, body: body, headers: push_headers)
end end
it 'returns a Gitlab::Geo::GitPushSSHProxy::APIResponse' do it 'returns a Gitlab::Geo::GitSSHProxy::APIResponse' do
expect(subject.push(info_refs_body_short)).to be_a(Gitlab::Geo::GitPushSSHProxy::APIResponse) expect(subject.push(info_refs_body_short)).to be_a(Gitlab::Geo::GitSSHProxy::APIResponse)
end end
it 'has a code of 201' do it 'has a code of 201' do
......
...@@ -409,10 +409,10 @@ describe API::Geo do ...@@ -409,10 +409,10 @@ describe API::Geo do
end end
context 'with all required params' do context 'with all required params' do
let(:git_push_ssh_proxy) { double(Gitlab::Geo::GitPushSSHProxy) } let(:git_push_ssh_proxy) { double(Gitlab::Geo::GitSSHProxy) }
before do before do
allow(Gitlab::Geo::GitPushSSHProxy).to receive(:new).with(data).and_return(git_push_ssh_proxy) allow(Gitlab::Geo::GitSSHProxy).to receive(:new).with(data).and_return(git_push_ssh_proxy)
end end
context 'with an invalid secret_token' do context 'with an invalid secret_token' do
...@@ -438,7 +438,7 @@ describe API::Geo do ...@@ -438,7 +438,7 @@ describe API::Geo do
context 'with a valid secret token' do context 'with a valid secret token' do
let(:http_response) { double(Net::HTTPOK, code: 200, body: 'something here') } let(:http_response) { double(Net::HTTPOK, code: 200, body: 'something here') }
let(:api_response) { Gitlab::Geo::GitPushSSHProxy::APIResponse.from_http_response(http_response, primary_repo) } let(:api_response) { Gitlab::Geo::GitSSHProxy::APIResponse.from_http_response(http_response, primary_repo) }
before do before do
# Mocking a real Net::HTTPSuccess is very difficult as it's not # Mocking a real Net::HTTPSuccess is very difficult as it's not
...@@ -470,10 +470,10 @@ describe API::Geo do ...@@ -470,10 +470,10 @@ describe API::Geo do
context 'with all required params' do context 'with all required params' do
let(:output) { Base64.encode64('info_refs content') } let(:output) { Base64.encode64('info_refs content') }
let(:git_push_ssh_proxy) { double(Gitlab::Geo::GitPushSSHProxy) } let(:git_push_ssh_proxy) { double(Gitlab::Geo::GitSSHProxy) }
before do before do
allow(Gitlab::Geo::GitPushSSHProxy).to receive(:new).with(data).and_return(git_push_ssh_proxy) allow(Gitlab::Geo::GitSSHProxy).to receive(:new).with(data).and_return(git_push_ssh_proxy)
end end
context 'with an invalid secret_token' do context 'with an invalid secret_token' do
...@@ -498,7 +498,7 @@ describe API::Geo do ...@@ -498,7 +498,7 @@ describe API::Geo do
context 'with a valid secret token' do context 'with a valid secret token' do
let(:http_response) { double(Net::HTTPCreated, code: 201, body: 'something here', class: Net::HTTPCreated) } let(:http_response) { double(Net::HTTPCreated, code: 201, body: 'something here', class: Net::HTTPCreated) }
let(:api_response) { Gitlab::Geo::GitPushSSHProxy::APIResponse.from_http_response(http_response, primary_repo) } let(:api_response) { Gitlab::Geo::GitSSHProxy::APIResponse.from_http_response(http_response, primary_repo) }
before do before do
# Mocking a real Net::HTTPSuccess is very difficult as it's not # Mocking a real Net::HTTPSuccess is very difficult as it's not
......
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