As we reevaluate how to best support and maintain Staging Ref in the future, we encourage development teams using this environment to highlight their use cases in the following issue: https://gitlab.com/gitlab-com/gl-infra/software-delivery/framework/software-delivery-framework-issue-tracker/-/issues/36.

Skip to content
Snippets Groups Projects
Commit c3a98b03 authored by Adam Niedzielski's avatar Adam Niedzielski
Browse files

Remove references to V3 internal API

In the main Rails app we use exactly the same code for
/api/v3/internal and /api/v4/internal
This means that we can move gitlab-shell to V4 in preparation
for sunsetting V3
parent 1472f046
No related branches found
No related tags found
No related merge requests found
Showing
with 28 additions and 42 deletions
Loading
Loading
@@ -33,7 +33,7 @@ class GitlabNet
params.merge!(user_id: actor.gsub("user-", ""))
end
url = "#{host_v3}/allowed"
url = "#{host}/allowed"
resp = post(url, params)
if resp.code == '200'
Loading
Loading
@@ -45,7 +45,7 @@ class GitlabNet
def discover(key)
key_id = key.gsub("key-", "")
resp = get("#{host_v3}/discover?key_id=#{key_id}")
resp = get("#{host}/discover?key_id=#{key_id}")
JSON.parse(resp.body) rescue nil
end
Loading
Loading
@@ -55,7 +55,7 @@ class GitlabNet
key_id: key.gsub('key-', '')
}
resp = post("#{host_v3}/lfs_authenticate", params)
resp = post("#{host}/lfs_authenticate", params)
if resp.code == '200'
GitlabLfsAuthentication.build_from_json(resp.body)
Loading
Loading
@@ -63,25 +63,25 @@ class GitlabNet
end
def broadcast_message
resp = get("#{host_v3}/broadcast_message")
resp = get("#{host}/broadcast_message")
JSON.parse(resp.body) rescue {}
end
def merge_request_urls(gl_repository, repo_path, changes)
changes = changes.join("\n") unless changes.kind_of?(String)
changes = changes.encode('UTF-8', 'ASCII', invalid: :replace, replace: '')
url = "#{host_v3}/merge_request_urls?project=#{URI.escape(repo_path)}&changes=#{URI.escape(changes)}"
url = "#{host}/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)
JSON.parse(resp.body) rescue []
end
def check
get("#{host_v3}/check", read_timeout: CHECK_TIMEOUT)
get("#{host}/check", read_timeout: CHECK_TIMEOUT)
end
def authorized_key(key)
resp = get("#{host_v3}/authorized_keys?key=#{URI.escape(key, '+/=')}")
resp = get("#{host}/authorized_keys?key=#{URI.escape(key, '+/=')}")
JSON.parse(resp.body) if resp.code == "200"
rescue
nil
Loading
Loading
@@ -89,7 +89,7 @@ class GitlabNet
def two_factor_recovery_codes(key)
key_id = key.gsub('key-', '')
resp = post("#{host_v3}/two_factor_recovery_codes", key_id: key_id)
resp = post("#{host}/two_factor_recovery_codes", key_id: key_id)
JSON.parse(resp.body) if resp.code == '200'
rescue
Loading
Loading
@@ -139,10 +139,6 @@ class GitlabNet
@config ||= GitlabConfig.new
end
def host_v3
"#{config.gitlab_url}/api/v3/internal"
end
def host
"#{config.gitlab_url}/api/v4/internal"
end
Loading
Loading
Loading
Loading
@@ -6,11 +6,9 @@ require_relative '../lib/gitlab_access_status'
describe GitlabNet, vcr: true do
let(:gitlab_net) { GitlabNet.new }
let(:changes) { ['0000000000000000000000000000000000000000 92d0970eefd7acb6d548878925ce2208cfe2d2ec refs/heads/branch4'] }
let(:host_v3) { 'https://dev.gitlab.org/api/v3/internal' }
let(:host) { 'https://dev.gitlab.org/api/v4/internal' }
before do
gitlab_net.stub(:host_v3).and_return(host_v3)
gitlab_net.stub(:host).and_return(host)
gitlab_net.stub(:secret_token).and_return('a123')
end
Loading
Loading
@@ -100,13 +98,13 @@ describe GitlabNet, vcr: true do
let(:encoded_changes) { "123456%20789012%20refs/heads/test%0A654321%20210987%20refs/tags/tag" }
it "sends the given arguments as encoded URL parameters" do
gitlab_net.should_receive(:get).with("#{host_v3}/merge_request_urls?project=#{repo_path}&changes=#{encoded_changes}&gl_repository=#{gl_repository}")
gitlab_net.should_receive(:get).with("#{host}/merge_request_urls?project=#{repo_path}&changes=#{encoded_changes}&gl_repository=#{gl_repository}")
gitlab_net.merge_request_urls(gl_repository, repo_path, changes)
end
it "omits the gl_repository parameter if it's nil" do
gitlab_net.should_receive(:get).with("#{host_v3}/merge_request_urls?project=#{repo_path}&changes=#{encoded_changes}")
gitlab_net.should_receive(:get).with("#{host}/merge_request_urls?project=#{repo_path}&changes=#{encoded_changes}")
gitlab_net.merge_request_urls(nil, repo_path, changes)
end
Loading
Loading
@@ -280,14 +278,6 @@ describe GitlabNet, vcr: true do
it("uses API version 4") { should include("api/v4") }
end
describe :host_v3 do
let(:net) { GitlabNet.new }
subject { net.send :host_v3 }
it { should include(net.send(:config).gitlab_url) }
it("uses API version 3") { should include("api/v3") }
end
describe :http_client_for do
subject { gitlab_net.send :http_client_for, URI('https://localhost/') }
before do
Loading
Loading
Loading
Loading
@@ -2,7 +2,7 @@
http_interactions:
- request:
method: post
uri: https://dev.gitlab.org/api/v3/internal/allowed
uri: https://dev.gitlab.org/api/v4/internal/allowed
body:
encoding: US-ASCII
string: action=git-receive-pack&changes=0000000000000000000000000000000000000000+92d0970eefd7acb6d548878925ce2208cfe2d2ec+refs%2Fheads%2Fbranch4&project=gitlab%2Fgitlabhq&key_id=126&secret_token=a123
Loading
Loading
Loading
Loading
@@ -2,7 +2,7 @@
http_interactions:
- request:
method: post
uri: https://dev.gitlab.org/api/v3/internal/allowed
uri: https://dev.gitlab.org/api/v4/internal/allowed
body:
encoding: US-ASCII
string: action=git-upload-pack&changes=0000000000000000000000000000000000000000+92d0970eefd7acb6d548878925ce2208cfe2d2ec+refs%2Fheads%2Fbranch4&project=gitlab%2Fgitlabhq&key_id=126&secret_token=a123
Loading
Loading
Loading
Loading
@@ -2,7 +2,7 @@
http_interactions:
- request:
method: get
uri: https://dev.gitlab.org/api/v3/internal/broadcast_message
uri: https://dev.gitlab.org/api/v4/internal/broadcast_message
body:
encoding: US-ASCII
string: secret_token=a123
Loading
Loading
Loading
Loading
@@ -2,7 +2,7 @@
http_interactions:
- request:
method: get
uri: https://dev.gitlab.org/api/v3/internal/broadcast_message
uri: https://dev.gitlab.org/api/v4/internal/broadcast_message
body:
encoding: US-ASCII
string: secret_token=a123
Loading
Loading
Loading
Loading
@@ -2,7 +2,7 @@
http_interactions:
- request:
method: get
uri: https://dev.gitlab.org/api/v3/internal/check
uri: https://dev.gitlab.org/api/v4/internal/check
body:
encoding: US-ASCII
string: secret_token=a123
Loading
Loading
@@ -40,7 +40,7 @@ http_interactions:
- '0.958718'
body:
encoding: UTF-8
string: '{"api_version":"v3","gitlab_version":"7.3.0.pre","gitlab_rev":"e8f1331"}'
string: '{"api_version":"v4","gitlab_version":"7.3.0.pre","gitlab_rev":"e8f1331"}'
http_version:
recorded_at: Wed, 03 Sep 2014 11:27:35 GMT
recorded_with: VCR 2.4.0
Loading
Loading
@@ -2,7 +2,7 @@
http_interactions:
- request:
method: post
uri: https://dev.gitlab.org/api/v3/internal/allowed
uri: https://dev.gitlab.org/api/v4/internal/allowed
body:
encoding: US-ASCII
string: action=git-receive-pack&changes=0000000000000000000000000000000000000000+92d0970eefd7acb6d548878925ce2208cfe2d2ec+refs%2Fheads%2Fbranch4&project=gitlab%2Fgitlabhq&key_id=2&secret_token=a123
Loading
Loading
Loading
Loading
@@ -2,7 +2,7 @@
http_interactions:
- request:
method: post
uri: https://dev.gitlab.org/api/v3/internal/allowed
uri: https://dev.gitlab.org/api/v4/internal/allowed
body:
encoding: US-ASCII
string: action=git-upload-pack&changes=0000000000000000000000000000000000000000+92d0970eefd7acb6d548878925ce2208cfe2d2ec+refs%2Fheads%2Fbranch4&project=gitlab%2Fgitlabhq&user_id=1&secret_token=a123
Loading
Loading
Loading
Loading
@@ -2,7 +2,7 @@
http_interactions:
- request:
method: post
uri: https://dev.gitlab.org/api/v3/internal/allowed
uri: https://dev.gitlab.org/api/v4/internal/allowed
body:
encoding: US-ASCII
string: action=git-upload-pack&changes=0000000000000000000000000000000000000000+92d0970eefd7acb6d548878925ce2208cfe2d2ec+refs%2Fheads%2Fbranch4&project=gitlab%2Fgitlabhq&key_id=2&secret_token=a123
Loading
Loading
Loading
Loading
@@ -2,7 +2,7 @@
http_interactions:
- request:
method: get
uri: https://dev.gitlab.org/api/v3/internal/discover?key_id=126
uri: https://dev.gitlab.org/api/v4/internal/discover?key_id=126
body:
encoding: US-ASCII
string: secret_token=a123
Loading
Loading
Loading
Loading
@@ -2,7 +2,7 @@
http_interactions:
- request:
method: post
uri: https://dev.gitlab.org/api/v3/internal/allowed
uri: https://dev.gitlab.org/api/v4/internal/allowed
body:
encoding: US-ASCII
string: action=git-receive-pack&changes=0000000000000000000000000000000000000000+92d0970eefd7acb6d548878925ce2208cfe2d2ec+refs%2Fheads%2Fbranch4&project=gitlab%2Fgitlabhq&protocol=http&key_id=2&secret_token=a123
Loading
Loading
Loading
Loading
@@ -2,7 +2,7 @@
http_interactions:
- request:
method: post
uri: https://dev.gitlab.org/api/v3/internal/lfs_authenticate
uri: https://dev.gitlab.org/api/v4/internal/lfs_authenticate
body:
encoding: US-ASCII
string: project=gitlab%2Fgitlabhq&key_id=126&secret_token=a123
Loading
Loading
Loading
Loading
@@ -2,7 +2,7 @@
http_interactions:
- request:
method: post
uri: https://dev.gitlab.org/api/v3/internal/allowed
uri: https://dev.gitlab.org/api/v4/internal/allowed
body:
encoding: US-ASCII
string: action=git-receive-pack&changes=0000000000000000000000000000000000000000+92d0970eefd7acb6d548878925ce2208cfe2d2ec+refs%2Fheads%2Fbranch4&project=gitlab%2Fgitlabhq&protocol=ssh&key_id=2&secret_token=a123
Loading
Loading
Loading
Loading
@@ -2,7 +2,7 @@
http_interactions:
- request:
method: get
uri: https://dev.gitlab.org/api/v3/internal/authorized_keys?key=whatever
uri: https://dev.gitlab.org/api/v4/internal/authorized_keys?key=whatever
body:
encoding: US-ASCII
string: secret_token=a123
Loading
Loading
Loading
Loading
@@ -2,7 +2,7 @@
http_interactions:
- request:
method: get
uri: https://dev.gitlab.org/api/v3/internal/authorized_keys?key=whatever
uri: https://dev.gitlab.org/api/v4/internal/authorized_keys?key=whatever
body:
encoding: US-ASCII
string: secret_token=a123
Loading
Loading
Loading
Loading
@@ -2,7 +2,7 @@
http_interactions:
- request:
method: get
uri: https://dev.gitlab.org/api/v3/internal/authorized_keys?key=AAAAB3NzaC1yc2EAAAADAQABAAACAQDPKPqqnqQ9PDFw65cO7iHXrKw6ucSZg8Bd2CZ150Yy1YRDPJOWeRNCnddS+M/Lk
uri: https://dev.gitlab.org/api/v4/internal/authorized_keys?key=AAAAB3NzaC1yc2EAAAADAQABAAACAQDPKPqqnqQ9PDFw65cO7iHXrKw6ucSZg8Bd2CZ150Yy1YRDPJOWeRNCnddS+M/Lk
body:
encoding: US-ASCII
string: secret_token=a123
Loading
Loading
Loading
Loading
@@ -2,7 +2,7 @@
http_interactions:
- request:
method: post
uri: https://dev.gitlab.org/api/v3/internal/two_factor_recovery_codes
uri: https://dev.gitlab.org/api/v4/internal/two_factor_recovery_codes
body:
encoding: US-ASCII
string: username=user-1&secret_token=a123
Loading
Loading
Loading
Loading
@@ -2,7 +2,7 @@
http_interactions:
- request:
method: post
uri: https://dev.gitlab.org/api/v3/internal/two_factor_recovery_codes
uri: https://dev.gitlab.org/api/v4/internal/two_factor_recovery_codes
body:
encoding: US-ASCII
string: username=user-1&secret_token=a123
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment