diff options
author | Zeger-Jan van de Weg <git@zjvandeweg.nl> | 2020-04-09 11:45:42 +0300 |
---|---|---|
committer | Zeger-Jan van de Weg <git@zjvandeweg.nl> | 2020-04-09 11:45:42 +0300 |
commit | b1fdebed35730b7a3abfdba5d038951d5c351224 (patch) | |
tree | dbb69bd75c982898d3dcc8f68594fb8ff94ddbcf | |
parent | 1fd1ce9054aed7172438794c1d797a255f6d4610 (diff) | |
parent | 657eeeea3e5de2854084d8d8651754cf8a6668d1 (diff) |
Merge branch '2631-remove-unused-api-call' into 'master'
Resolve "Remove unused notify_post_receive api call"
Closes #2631
See merge request gitlab-org/gitaly!2031
5 files changed, 0 insertions, 241 deletions
diff --git a/ruby/gitlab-shell/lib/gitlab_net.rb b/ruby/gitlab-shell/lib/gitlab_net.rb index 74996e712..812be9ae8 100644 --- a/ruby/gitlab-shell/lib/gitlab_net.rb +++ b/ruby/gitlab-shell/lib/gitlab_net.rb @@ -41,40 +41,10 @@ class GitlabNet # rubocop:disable Metrics/ClassLength GitAccessStatus.new(false, resp.code, API_INACCESSIBLE_MESSAGE) end - def broadcast_message - resp = get("#{internal_api_endpoint}/broadcast_message") - JSON.parse(resp.body) rescue {} - end - - def merge_request_urls(gl_repository, repo_path, changes) - changes = changes.join("\n") unless changes.is_a?(String) - changes = changes.encode('UTF-8', 'ASCII', invalid: :replace, replace: '') - url = "#{internal_api_endpoint}/merge_request_urls?project=#{URI.escape(repo_path)}&changes=#{URI.escape(changes)}" - url += "&gl_repository=#{URI.escape(gl_repository)}" if gl_repository - resp = get(url) - - if resp.code == '200' - JSON.parse(resp.body) - else - [] - end - rescue - [] - end - def check get("#{internal_api_endpoint}/check", options: { read_timeout: CHECK_TIMEOUT }) end - def notify_post_receive(gl_repository, repo_path) - params = { gl_repository: gl_repository, project: repo_path } - resp = post("#{internal_api_endpoint}/notify_post_receive", params) - - resp.code == '200' - rescue - false - end - def post_receive(gl_repository, gl_id, changes, push_options) params = { gl_repository: gl_repository, diff --git a/ruby/gitlab-shell/spec/gitlab_net_spec.rb b/ruby/gitlab-shell/spec/gitlab_net_spec.rb index a6f3cd8e9..f8161e222 100644 --- a/ruby/gitlab-shell/spec/gitlab_net_spec.rb +++ b/ruby/gitlab-shell/spec/gitlab_net_spec.rb @@ -41,58 +41,6 @@ describe GitlabNet, vcr: true do end end - describe '#broadcast_message' do - context "broadcast message exists" do - it 'should return message' do - VCR.use_cassette("broadcast_message-ok") do - result = gitlab_net.broadcast_message - expect(result["message"]).to eq("Message") - end - end - end - - context "broadcast message doesn't exist" do - it 'should return nil' do - VCR.use_cassette("broadcast_message-none") do - result = gitlab_net.broadcast_message - expect(result).to eq({}) - end - end - end - end - - describe '#merge_request_urls' do - let(:gl_repository) { "project-1" } - let(:changes) { "123456 789012 refs/heads/test\n654321 210987 refs/tags/tag" } - let(:encoded_changes) { "123456%20789012%20refs/heads/test%0A654321%20210987%20refs/tags/tag" } - - it "sends the given arguments as encoded URL parameters" do - expect(gitlab_net).to receive(:get).with("#{internal_api_endpoint}/merge_request_urls?project=#{project}&changes=#{encoded_changes}&gl_repository=#{gl_repository}") - - gitlab_net.merge_request_urls(gl_repository, project, changes) - end - - it "omits the gl_repository parameter if it's nil" do - expect(gitlab_net).to receive(:get).with("#{internal_api_endpoint}/merge_request_urls?project=#{project}&changes=#{encoded_changes}") - - gitlab_net.merge_request_urls(nil, project, changes) - end - - it "returns an empty array when the result cannot be parsed as JSON" do - response = double(:response, code: '200', body: '') - allow(gitlab_net).to receive(:get).and_return(response) - - expect(gitlab_net.merge_request_urls(gl_repository, project, changes)).to eq([]) - end - - it "returns an empty array when the result's status is not 200" do - response = double(:response, code: '500', body: '[{}]') - allow(gitlab_net).to receive(:get).and_return(response) - - expect(gitlab_net.merge_request_urls(gl_repository, project, changes)).to eq([]) - end - end - describe '#pre_receive' do let(:gl_repository) { "project-1" } let(:params) { { gl_repository: gl_repository } } @@ -160,27 +108,6 @@ describe GitlabNet, vcr: true do end end - describe '#notify_post_receive' do - let(:gl_repository) { 'project-1' } - let(:repo_path) { '/path/to/my/repo.git' } - let(:params) do - { gl_repository: gl_repository, project: repo_path } - end - - it 'sets the arguments as form parameters' do - VCR.use_cassette('notify-post-receive') do - expect_any_instance_of(Net::HTTP::Post).to receive(:set_form_data).with(hash_including(params)) - gitlab_net.notify_post_receive(gl_repository, repo_path) - end - end - - it 'returns true if notification was succesful' do - VCR.use_cassette('notify-post-receive') do - expect(gitlab_net.notify_post_receive(gl_repository, repo_path)).to be_truthy - end - end - end - describe '#check_access' do context 'ssh key with access nil, to project' do it 'should allow push access for host' do diff --git a/ruby/gitlab-shell/spec/vcr_cassettes/broadcast_message-none.yml b/ruby/gitlab-shell/spec/vcr_cassettes/broadcast_message-none.yml deleted file mode 100644 index 8162343c2..000000000 --- a/ruby/gitlab-shell/spec/vcr_cassettes/broadcast_message-none.yml +++ /dev/null @@ -1,46 +0,0 @@ ---- -http_interactions: -- request: - method: get - uri: http://localhost:3000/api/v4/internal/broadcast_message - body: - encoding: US-ASCII - string: secret_token=0a3938d9d95d807e94d937af3a4fbbea%0A - headers: - Accept-Encoding: - - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 - Accept: - - "*/*" - User-Agent: - - Ruby - Content-Type: - - application/x-www-form-urlencoded - response: - status: - code: 200 - message: OK - headers: - Cache-Control: - - max-age=0, private, must-revalidate - Content-Length: - - '2' - Content-Type: - - application/json - Date: - - Wed, 21 Jun 2017 10:44:50 GMT - Etag: - - W/"99914b932bd37a50b983c5e7c90ae93b" - Vary: - - Origin - X-Frame-Options: - - SAMEORIGIN - X-Request-Id: - - d31271ab-e21f-4349-a4c3-54f238c075c3 - X-Runtime: - - '0.254031' - body: - encoding: UTF-8 - string: "{}" - http_version: - recorded_at: Wed, 21 Jun 2017 10:44:50 GMT -recorded_with: VCR 2.4.0 diff --git a/ruby/gitlab-shell/spec/vcr_cassettes/broadcast_message-ok.yml b/ruby/gitlab-shell/spec/vcr_cassettes/broadcast_message-ok.yml deleted file mode 100644 index a309c7ed3..000000000 --- a/ruby/gitlab-shell/spec/vcr_cassettes/broadcast_message-ok.yml +++ /dev/null @@ -1,46 +0,0 @@ ---- -http_interactions: -- request: - method: get - uri: http://localhost:3000/api/v4/internal/broadcast_message - body: - encoding: US-ASCII - string: secret_token=0a3938d9d95d807e94d937af3a4fbbea%0A - headers: - Accept-Encoding: - - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 - Accept: - - "*/*" - User-Agent: - - Ruby - Content-Type: - - application/x-www-form-urlencoded - response: - status: - code: 200 - message: OK - headers: - Cache-Control: - - max-age=0, private, must-revalidate - Content-Length: - - '153' - Content-Type: - - application/json - Date: - - Wed, 21 Jun 2017 12:29:13 GMT - Etag: - - W/"ce6de457fcc884f50125e81a10f165ce" - Vary: - - Origin - X-Frame-Options: - - SAMEORIGIN - X-Request-Id: - - ebaaf2c2-112e-4b3c-9182-e8714cd2a29c - X-Runtime: - - '0.276085' - body: - encoding: UTF-8 - string: '{"message":"Message","starts_at":"2017-06-21T12:28:00.000Z","ends_at":"2017-06-21T12:35:00.000Z","color":"#e75e40","font":"#ffffff","id":1,"active":true}' - http_version: - recorded_at: Wed, 21 Jun 2017 12:29:13 GMT -recorded_with: VCR 2.4.0 diff --git a/ruby/gitlab-shell/spec/vcr_cassettes/notify-post-receive.yml b/ruby/gitlab-shell/spec/vcr_cassettes/notify-post-receive.yml deleted file mode 100644 index 255f41516..000000000 --- a/ruby/gitlab-shell/spec/vcr_cassettes/notify-post-receive.yml +++ /dev/null @@ -1,46 +0,0 @@ ---- -http_interactions: -- request: - method: post - uri: http://localhost:3000/api/v4/internal/notify_post_receive - body: - encoding: US-ASCII - string: gl_repository=project-1&project=%2Fpath%2Fto%2Fmy%2Frepo.git&secret_token=0a3938d9d95d807e94d937af3a4fbbea%0A - headers: - Accept-Encoding: - - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 - Accept: - - "*/*" - User-Agent: - - Ruby - Content-Type: - - application/x-www-form-urlencoded - response: - status: - code: 200 - message: OK - headers: - Cache-Control: - - max-age=0, private, must-revalidate - Content-Length: - - '3' - Content-Type: - - application/json - Date: - - Wed, 21 Jun 2017 12:47:48 GMT - Etag: - - W/"3644a684f98ea8fe223c713b77189a77" - Vary: - - Origin - X-Frame-Options: - - SAMEORIGIN - X-Request-Id: - - 407b184d-d6cf-43db-93fa-3f2d97112948 - X-Runtime: - - '6.626186' - body: - encoding: UTF-8 - string: '200' - http_version: - recorded_at: Wed, 21 Jun 2017 12:47:48 GMT -recorded_with: VCR 2.4.0 |