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

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • idrozdov/gitlab-shell
  • mmj/gitlab-shell
2 results
Show changes
Commits on Source (1)
Loading
@@ -4,3 +4,5 @@ tmp/*
Loading
@@ -4,3 +4,5 @@ tmp/*
/*.log* /*.log*
authorized_keys.lock authorized_keys.lock
coverage/ coverage/
.gitlab_shell_secret
.bundle
Loading
@@ -76,6 +76,7 @@ class GitlabNet
Loading
@@ -76,6 +76,7 @@ class GitlabNet
url = URI.parse(url) url = URI.parse(url)
http = http_client_for url http = http_client_for url
request = http_request_for url request = http_request_for url
request.set_form_data(secret_token: secret_token)
http.start { |http| http.request(request) }.tap do |resp| http.start { |http| http.request(request) }.tap do |resp|
if resp.code == "200" if resp.code == "200"
Loading
@@ -92,7 +93,7 @@ class GitlabNet
Loading
@@ -92,7 +93,7 @@ class GitlabNet
url = URI.parse(url) url = URI.parse(url)
http = http_client_for(url) http = http_client_for(url)
request = http_request_for(url, :post) request = http_request_for(url, :post)
request.set_form_data(params) request.set_form_data(params.merge(secret_token: secret_token))
http.start { |http| http.request(request) }.tap do |resp| http.start { |http| http.request(request) }.tap do |resp|
if resp.code == "200" if resp.code == "200"
Loading
@@ -116,4 +117,8 @@ class GitlabNet
Loading
@@ -116,4 +117,8 @@ class GitlabNet
end end
end end
end end
def secret_token
@secret_token ||= File.read File.join(ROOT_PATH, '.gitlab_shell_secret')
end
end end
Loading
@@ -8,6 +8,7 @@ describe GitlabNet, vcr: true do
Loading
@@ -8,6 +8,7 @@ describe GitlabNet, vcr: true do
before do before do
gitlab_net.stub!(:host).and_return('https://dev.gitlab.org/api/v3/internal') gitlab_net.stub!(:host).and_return('https://dev.gitlab.org/api/v3/internal')
gitlab_net.stub!(:secret_token).and_return('a123')
end end
describe :check do describe :check do
Loading
@@ -17,6 +18,13 @@ describe GitlabNet, vcr: true do
Loading
@@ -17,6 +18,13 @@ describe GitlabNet, vcr: true do
result.code.should == '200' result.code.should == '200'
end end
end end
it 'adds the secret_token to request' do
VCR.use_cassette("check-ok") do
Net::HTTP::Get.any_instance.should_receive(:set_form_data).with(hash_including(secret_token: 'a123'))
gitlab_net.check
end
end
end end
describe :discover do describe :discover do
Loading
@@ -26,6 +34,13 @@ describe GitlabNet, vcr: true do
Loading
@@ -26,6 +34,13 @@ describe GitlabNet, vcr: true do
user['name'].should == 'Dmitriy Zaporozhets' user['name'].should == 'Dmitriy Zaporozhets'
end end
end end
it 'adds the secret_token to request' do
VCR.use_cassette("discover-ok") do
Net::HTTP::Get.any_instance.should_receive(:set_form_data).with(hash_including(secret_token: 'a123'))
gitlab_net.discover('key-126')
end
end
end end
describe :allowed? do describe :allowed? do
Loading
@@ -37,6 +52,13 @@ describe GitlabNet, vcr: true do
Loading
@@ -37,6 +52,13 @@ describe GitlabNet, vcr: true do
end end
end end
it 'adds the secret_token theo request' do
VCR.use_cassette("allowed-pull") do
Net::HTTP::Post.any_instance.should_receive(:set_form_data).with(hash_including(secret_token: 'a123'))
gitlab_net.allowed?('git-receive-pack', 'gitlab/gitlabhq.git', 'key-126', changes)
end
end
it 'should allow push access for dev.gitlab.org' do it 'should allow push access for dev.gitlab.org' do
VCR.use_cassette("allowed-push") do VCR.use_cassette("allowed-push") do
access = gitlab_net.allowed?('git-upload-pack', 'gitlab/gitlabhq.git', 'key-126', changes) access = gitlab_net.allowed?('git-upload-pack', 'gitlab/gitlabhq.git', 'key-126', changes)
Loading
Loading
Loading
@@ -5,7 +5,7 @@ http_interactions:
Loading
@@ -5,7 +5,7 @@ http_interactions:
uri: https://dev.gitlab.org/api/v3/internal/allowed uri: https://dev.gitlab.org/api/v3/internal/allowed
body: body:
encoding: US-ASCII encoding: US-ASCII
string: action=git-receive-pack&changes=0000000000000000000000000000000000000000+92d0970eefd7acb6d548878925ce2208cfe2d2ec+refs%2Fheads%2Fbranch4&project=gitlab%2Fgitlabhq&key_id=126 string: action=git-receive-pack&changes=0000000000000000000000000000000000000000+92d0970eefd7acb6d548878925ce2208cfe2d2ec+refs%2Fheads%2Fbranch4&project=gitlab%2Fgitlabhq&key_id=126&secret_token=a123
headers: headers:
Accept-Encoding: Accept-Encoding:
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3 - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
Loading
Loading
Loading
@@ -5,7 +5,7 @@ http_interactions:
Loading
@@ -5,7 +5,7 @@ http_interactions:
uri: https://dev.gitlab.org/api/v3/internal/allowed uri: https://dev.gitlab.org/api/v3/internal/allowed
body: body:
encoding: US-ASCII encoding: US-ASCII
string: action=git-upload-pack&changes=0000000000000000000000000000000000000000+92d0970eefd7acb6d548878925ce2208cfe2d2ec+refs%2Fheads%2Fbranch4&project=gitlab%2Fgitlabhq&key_id=126 string: action=git-upload-pack&changes=0000000000000000000000000000000000000000+92d0970eefd7acb6d548878925ce2208cfe2d2ec+refs%2Fheads%2Fbranch4&project=gitlab%2Fgitlabhq&key_id=126&secret_token=a123
headers: headers:
Accept-Encoding: Accept-Encoding:
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3 - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
Loading
Loading
Loading
@@ -5,7 +5,7 @@ http_interactions:
Loading
@@ -5,7 +5,7 @@ http_interactions:
uri: https://dev.gitlab.org/api/v3/internal/check uri: https://dev.gitlab.org/api/v3/internal/check
body: body:
encoding: US-ASCII encoding: US-ASCII
string: '' string: secret_token=a123
headers: headers:
Accept-Encoding: Accept-Encoding:
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3 - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
Loading
Loading
Loading
@@ -5,7 +5,7 @@ http_interactions:
Loading
@@ -5,7 +5,7 @@ http_interactions:
uri: https://dev.gitlab.org/api/v3/internal/allowed uri: https://dev.gitlab.org/api/v3/internal/allowed
body: body:
encoding: US-ASCII encoding: US-ASCII
string: action=git-receive-pack&changes=0000000000000000000000000000000000000000+92d0970eefd7acb6d548878925ce2208cfe2d2ec+refs%2Fheads%2Fbranch4&project=gitlab%2Fgitlabhq&key_id=2 string: action=git-receive-pack&changes=0000000000000000000000000000000000000000+92d0970eefd7acb6d548878925ce2208cfe2d2ec+refs%2Fheads%2Fbranch4&project=gitlab%2Fgitlabhq&key_id=2&secret_token=a123
headers: headers:
Accept-Encoding: Accept-Encoding:
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3 - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
Loading
Loading
Loading
@@ -5,7 +5,7 @@ http_interactions:
Loading
@@ -5,7 +5,7 @@ http_interactions:
uri: https://dev.gitlab.org/api/v3/internal/allowed uri: https://dev.gitlab.org/api/v3/internal/allowed
body: body:
encoding: US-ASCII encoding: US-ASCII
string: action=git-upload-pack&changes=0000000000000000000000000000000000000000+92d0970eefd7acb6d548878925ce2208cfe2d2ec+refs%2Fheads%2Fbranch4&project=gitlab%2Fgitlabhq&user_id=1 string: action=git-upload-pack&changes=0000000000000000000000000000000000000000+92d0970eefd7acb6d548878925ce2208cfe2d2ec+refs%2Fheads%2Fbranch4&project=gitlab%2Fgitlabhq&user_id=1&secret_token=a123
headers: headers:
Accept-Encoding: Accept-Encoding:
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3 - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
Loading
Loading
Loading
@@ -5,7 +5,7 @@ http_interactions:
Loading
@@ -5,7 +5,7 @@ http_interactions:
uri: https://dev.gitlab.org/api/v3/internal/allowed uri: https://dev.gitlab.org/api/v3/internal/allowed
body: body:
encoding: US-ASCII encoding: US-ASCII
string: action=git-upload-pack&changes=0000000000000000000000000000000000000000+92d0970eefd7acb6d548878925ce2208cfe2d2ec+refs%2Fheads%2Fbranch4&project=gitlab%2Fgitlabhq&key_id=2 string: action=git-upload-pack&changes=0000000000000000000000000000000000000000+92d0970eefd7acb6d548878925ce2208cfe2d2ec+refs%2Fheads%2Fbranch4&project=gitlab%2Fgitlabhq&key_id=2&secret_token=a123
headers: headers:
Accept-Encoding: Accept-Encoding:
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3 - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
Loading
Loading
Loading
@@ -5,7 +5,7 @@ http_interactions:
Loading
@@ -5,7 +5,7 @@ http_interactions:
uri: https://dev.gitlab.org/api/v3/internal/discover?key_id=126 uri: https://dev.gitlab.org/api/v3/internal/discover?key_id=126
body: body:
encoding: US-ASCII encoding: US-ASCII
string: '' string: secret_token=a123
headers: headers:
Accept-Encoding: Accept-Encoding:
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3 - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
Loading
Loading