summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAsh McKenzie <amckenzie@gitlab.com>2018-09-11 11:05:24 +0000
committerNick Thomas <nick@gitlab.com>2018-09-11 11:05:24 +0000
commit624a97d654ed02bd7fb65b6205b1533cfbe2cfbc (patch)
treec71e79f03b1ac7e21a7966d01cbce90f24d690dd
parente5b6e8e2550e203978cd25d3e07ca468b4d06c91 (diff)
downloadgitlab-shell-624a97d654ed02bd7fb65b6205b1533cfbe2cfbc.tar.gz
Ensure text/plain & text/html content typs are handled and add missing specs for handled HTTP status codes
-rw-r--r--Gemfile1
-rw-r--r--Gemfile.lock36
-rw-r--r--lib/action/custom.rb2
-rw-r--r--lib/gitlab_net.rb14
-rw-r--r--lib/http_helper.rb1
-rw-r--r--spec/gitlab_net_spec.rb67
-rw-r--r--spec/spec_helper.rb1
-rw-r--r--spec/vcr_cassettes/allowed-pull.yml6
-rw-r--r--spec/vcr_cassettes/allowed-push-project-not-found-404-text-html.yml46
-rw-r--r--spec/vcr_cassettes/allowed-push-project-not-found-404-text-plain.yml46
-rw-r--r--spec/vcr_cassettes/allowed-push-project-not-found-404.yml46
-rw-r--r--spec/vcr_cassettes/allowed-push-project-not-found-text-html.yml46
-rw-r--r--spec/vcr_cassettes/allowed-push-project-not-found-text-plain.yml46
-rw-r--r--spec/vcr_cassettes/allowed-push-project-not-found.yml46
-rw-r--r--spec/vcr_cassettes/allowed-push.yml6
-rw-r--r--spec/vcr_cassettes/ssh-pull-project-denied-401-text-html.yml46
-rw-r--r--spec/vcr_cassettes/ssh-pull-project-denied-401-text-plain.yml46
-rw-r--r--spec/vcr_cassettes/ssh-pull-project-denied-401.yml46
-rw-r--r--spec/vcr_cassettes/ssh-pull-project-denied-with-user.yml (renamed from spec/vcr_cassettes/ssh-push-project-denied-with-user.yml)0
-rw-r--r--spec/vcr_cassettes/ssh-pull-project-denied.yml6
-rw-r--r--spec/vcr_cassettes/ssh-push-project-denied-401-text-html.yml46
-rw-r--r--spec/vcr_cassettes/ssh-push-project-denied-401-text-plain.yml46
-rw-r--r--spec/vcr_cassettes/ssh-push-project-denied-401.yml46
-rw-r--r--spec/vcr_cassettes/ssh-push-project-denied.yml6
24 files changed, 662 insertions, 36 deletions
diff --git a/Gemfile b/Gemfile
index 0321760..4166d50 100644
--- a/Gemfile
+++ b/Gemfile
@@ -3,6 +3,7 @@ source 'https://rubygems.org'
group :development, :test do
gem 'listen', '~> 0.5.0'
gem 'rspec', '~> 3.8.0'
+ gem 'rspec-parameterized', '~> 0.4.0'
gem 'rubocop', '0.49.1', require: false
gem 'simplecov', '~> 0.9.0', require: false
gem 'vcr', '~> 4.0.0'
diff --git a/Gemfile.lock b/Gemfile.lock
index eb6dfea..f23d781 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,20 +1,40 @@
GEM
remote: https://rubygems.org/
specs:
+ abstract_type (0.0.7)
+ adamantium (0.2.0)
+ ice_nine (~> 0.11.0)
+ memoizable (~> 0.4.0)
addressable (2.5.2)
public_suffix (>= 2.0.2, < 4.0)
ast (2.4.0)
+ binding_of_caller (0.8.0)
+ debug_inspector (>= 0.0.1)
+ coderay (1.1.2)
+ concord (0.1.5)
+ adamantium (~> 0.2.0)
+ equalizer (~> 0.0.9)
crack (0.4.3)
safe_yaml (~> 1.0.0)
+ debug_inspector (0.0.3)
diff-lcs (1.3)
docile (1.1.5)
+ equalizer (0.0.11)
hashdiff (0.3.7)
+ ice_nine (0.11.2)
listen (0.5.3)
+ memoizable (0.4.2)
+ thread_safe (~> 0.3, >= 0.3.1)
multi_json (1.13.1)
parallel (1.12.1)
parser (2.5.1.2)
ast (~> 2.4.0)
powerpack (0.1.2)
+ proc_to_ast (0.1.0)
+ coderay
+ parser
+ unparser
+ procto (0.0.3)
public_suffix (3.0.3)
rainbow (2.2.2)
rake
@@ -31,6 +51,12 @@ GEM
rspec-mocks (3.8.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.8.0)
+ rspec-parameterized (0.4.0)
+ binding_of_caller
+ parser
+ proc_to_ast
+ rspec (>= 2.13, < 4)
+ unparser
rspec-support (3.8.0)
rubocop (0.49.1)
parallel (~> 1.10)
@@ -46,7 +72,16 @@ GEM
multi_json (~> 1.0)
simplecov-html (~> 0.9.0)
simplecov-html (0.9.0)
+ thread_safe (0.3.6)
unicode-display_width (1.4.0)
+ unparser (0.2.8)
+ abstract_type (~> 0.0.7)
+ adamantium (~> 0.2.0)
+ concord (~> 0.1.5)
+ diff-lcs (~> 1.3)
+ equalizer (~> 0.0.9)
+ parser (>= 2.3.1.2, < 2.6)
+ procto (~> 0.0.2)
vcr (4.0.0)
webmock (3.4.2)
addressable (>= 2.3.6)
@@ -59,6 +94,7 @@ PLATFORMS
DEPENDENCIES
listen (~> 0.5.0)
rspec (~> 3.8.0)
+ rspec-parameterized (~> 0.4.0)
rubocop (= 0.49.1)
simplecov (~> 0.9.0)
vcr (~> 4.0.0)
diff --git a/lib/action/custom.rb b/lib/action/custom.rb
index ba0e650..c781f00 100644
--- a/lib/action/custom.rb
+++ b/lib/action/custom.rb
@@ -13,7 +13,7 @@ module Action
class UnsuccessfulError < BaseError; end
NO_MESSAGE_TEXT = 'No message'.freeze
- DEFAULT_HEADERS = { 'Content-Type' => 'application/json' }.freeze
+ DEFAULT_HEADERS = { 'Content-Type' => CONTENT_TYPE_JSON }.freeze
def initialize(gl_id, payload)
@gl_id = gl_id
diff --git a/lib/gitlab_net.rb b/lib/gitlab_net.rb
index 57ae452..b460f46 100644
--- a/lib/gitlab_net.rb
+++ b/lib/gitlab_net.rb
@@ -14,6 +14,7 @@ class GitlabNet # rubocop:disable Metrics/ClassLength
class NotFound < StandardError; end
CHECK_TIMEOUT = 5
+ API_INACCESSIBLE_MESSAGE = 'API is not accessible'.freeze
def check_access(cmd, gl_repository, repo, who, changes, protocol, env: {})
changes = changes.join("\n") unless changes.is_a?(String)
@@ -33,12 +34,15 @@ class GitlabNet # rubocop:disable Metrics/ClassLength
url = "#{internal_api_endpoint}/allowed"
resp = post(url, params)
- case resp.code
- when HTTP_SUCCESS, HTTP_MULTIPLE_CHOICES, HTTP_UNAUTHORIZED, HTTP_NOT_FOUND
- GitAccessStatus.create_from_json(resp.body, resp.code)
- else
- GitAccessStatus.new(false, resp.code, 'API is not accessible')
+ case resp
+ when Net::HTTPSuccess, Net::HTTPMultipleChoices, Net::HTTPUnauthorized,
+ Net::HTTPNotFound
+ if resp.content_type == CONTENT_TYPE_JSON
+ return GitAccessStatus.create_from_json(resp.body, resp.code)
+ end
end
+
+ GitAccessStatus.new(false, resp.code, API_INACCESSIBLE_MESSAGE)
end
def discover(who)
diff --git a/lib/http_helper.rb b/lib/http_helper.rb
index 55c504c..a7e7b23 100644
--- a/lib/http_helper.rb
+++ b/lib/http_helper.rb
@@ -6,6 +6,7 @@ module HTTPHelper
include HTTPCodes
READ_TIMEOUT = 300
+ CONTENT_TYPE_JSON = 'application/json'.freeze
protected
diff --git a/spec/gitlab_net_spec.rb b/spec/gitlab_net_spec.rb
index e14fd83..0656084 100644
--- a/spec/gitlab_net_spec.rb
+++ b/spec/gitlab_net_spec.rb
@@ -3,6 +3,8 @@ require_relative '../lib/gitlab_net'
require_relative '../lib/gitlab_access_status'
describe GitlabNet, vcr: true do
+ using RSpec::Parameterized::TableSyntax
+
let(:gitlab_net) { described_class.new }
let(:changes) { ['0000000000000000000000000000000000000000 92d0970eefd7acb6d548878925ce2208cfe2d2ec refs/heads/branch4'] }
let(:base_api_endpoint) { 'http://localhost:3000/api/v4' }
@@ -266,22 +268,43 @@ describe GitlabNet, vcr: true do
describe '#check_access' do
context 'ssh key with access nil, to project' do
- it 'should allow pull access for host' do
- VCR.use_cassette("allowed-pull") do
+ it 'should allow push access for host' do
+ VCR.use_cassette("allowed-push") do
access = gitlab_net.check_access('git-receive-pack', nil, project, key, changes, 'ssh')
expect(access.allowed?).to be_truthy
end
end
+ context 'but project not found' do
+ where(:desc, :cassette, :message) do
+ 'deny push access for host' | 'allowed-push-project-not-found' | 'The project you were looking for could not be found.'
+ 'deny push access for host (when text/html)' | 'allowed-push-project-not-found-text-html' | 'API is not accessible'
+ 'deny push access for host (when text/plain)' | 'allowed-push-project-not-found-text-plain' | 'API is not accessible'
+ 'deny push access for host (when 404 is returned)' | 'allowed-push-project-not-found-404' | 'The project you were looking for could not be found.'
+ 'deny push access for host (when 404 is returned with text/html)' | 'allowed-push-project-not-found-404-text-html' | 'API is not accessible'
+ 'deny push access for host (when 404 is returned with text/plain)' | 'allowed-push-project-not-found-404-text-plain' | 'API is not accessible'
+ end
+
+ with_them do
+ it 'should deny push access for host' do
+ VCR.use_cassette(cassette) do
+ access = gitlab_net.check_access('git-receive-pack', nil, project, key, changes, 'ssh')
+ expect(access.allowed?).to be_falsey
+ expect(access.message).to eql(message)
+ end
+ end
+ end
+ end
+
it 'adds the secret_token to the request' do
- VCR.use_cassette("allowed-pull") do
+ VCR.use_cassette("allowed-push") do
expect_any_instance_of(Net::HTTP::Post).to receive(:set_form_data).with(hash_including(secret_token: secret))
gitlab_net.check_access('git-receive-pack', nil, project, key, changes, 'ssh')
end
end
- it 'should allow push access for host' do
- VCR.use_cassette("allowed-push") do
+ it 'should allow pull access for host' do
+ VCR.use_cassette("allowed-pull") do
access = gitlab_net.check_access('git-upload-pack', nil, project, key, changes, 'ssh')
expect(access.allowed?).to be_truthy
end
@@ -325,24 +348,32 @@ describe GitlabNet, vcr: true do
end
context 'ssh key without access to project' do
- it 'should deny pull access for host' do
- VCR.use_cassette("ssh-pull-project-denied") do
- access = gitlab_net.check_access('git-receive-pack', nil, project, key2, changes, 'ssh')
- expect(access.allowed?).to be_falsey
- end
- end
-
- it 'should deny push access for host' do
- VCR.use_cassette("ssh-push-project-denied") do
- access = gitlab_net.check_access('git-upload-pack', nil, project, key2, changes, 'ssh')
- expect(access.allowed?).to be_falsey
+ where(:desc, :cassette, :message) do
+ 'deny push access for host' | 'ssh-push-project-denied' | 'Git access over SSH is not allowed'
+ 'deny push access for host (when 401 is returned)' | 'ssh-push-project-denied-401' | 'Git access over SSH is not allowed'
+ 'deny push access for host (when 401 is returned with text/html)' | 'ssh-push-project-denied-401-text-html' | 'API is not accessible'
+ 'deny push access for host (when 401 is returned with text/plain)' | 'ssh-push-project-denied-401-text-plain' | 'API is not accessible'
+ 'deny pull access for host' | 'ssh-pull-project-denied' | 'Git access over SSH is not allowed'
+ 'deny pull access for host (when 401 is returned)' | 'ssh-pull-project-denied-401' | 'Git access over SSH is not allowed'
+ 'deny pull access for host (when 401 is returned with text/html)' | 'ssh-pull-project-denied-401-text-html' | 'API is not accessible'
+ 'deny pull access for host (when 401 is returned with text/plain)' | 'ssh-pull-project-denied-401-text-plain' | 'API is not accessible'
+ end
+
+ with_them do
+ it 'should deny push access for host' do
+ VCR.use_cassette(cassette) do
+ access = gitlab_net.check_access('git-receive-pack', nil, project, key2, changes, 'ssh')
+ expect(access.allowed?).to be_falsey
+ expect(access.message).to eql(message)
+ end
end
end
- it 'should deny push access for host (with user)' do
- VCR.use_cassette("ssh-push-project-denied-with-user") do
+ it 'should deny pull access for host (with user)' do
+ VCR.use_cassette("ssh-pull-project-denied-with-user") do
access = gitlab_net.check_access('git-upload-pack', nil, project, 'user-2', changes, 'ssh')
expect(access.allowed?).to be_falsey
+ expect(access.message).to eql('Git access over SSH is not allowed')
end
end
end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 4a9c15e..dfdf449 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -1,3 +1,4 @@
+require 'rspec-parameterized'
require 'simplecov'
SimpleCov.start
diff --git a/spec/vcr_cassettes/allowed-pull.yml b/spec/vcr_cassettes/allowed-pull.yml
index 1636fd5..b073476 100644
--- a/spec/vcr_cassettes/allowed-pull.yml
+++ b/spec/vcr_cassettes/allowed-pull.yml
@@ -5,7 +5,7 @@ http_interactions:
uri: http://localhost:3000/api/v4/internal/allowed
body:
encoding: US-ASCII
- string: action=git-receive-pack&changes=0000000000000000000000000000000000000000+92d0970eefd7acb6d548878925ce2208cfe2d2ec+refs%2Fheads%2Fbranch4&gl_repository&project=gitlab-org%2Fgitlab-test.git&protocol=ssh&env=%7B%7D&key_id=1&secret_token=0a3938d9d95d807e94d937af3a4fbbea%0A
+ string: action=git-upload-pack&changes=0000000000000000000000000000000000000000+92d0970eefd7acb6d548878925ce2208cfe2d2ec+refs%2Fheads%2Fbranch4&gl_repository&project=gitlab-org%2Fgitlab-test.git&protocol=ssh&env=%7B%7D&key_id=1&secret_token=0a3938d9d95d807e94d937af3a4fbbea%0A
headers:
Accept-Encoding:
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
@@ -35,9 +35,9 @@ http_interactions:
X-Frame-Options:
- SAMEORIGIN
X-Request-Id:
- - 8d4b8b06-fb6e-4f94-832f-72f8e0afad5f
+ - 67ab4954-19e6-42ce-aae6-55c8ae5a365e
X-Runtime:
- - '0.289759'
+ - '0.230871'
body:
encoding: UTF-8
string: '{"status":true,"gl_repository":"project-3","repository_path":"/Users/dzaporozhets/Projects/gitlab-development-kit/repositories/gitlab-org/gitlab-test.git"}'
diff --git a/spec/vcr_cassettes/allowed-push-project-not-found-404-text-html.yml b/spec/vcr_cassettes/allowed-push-project-not-found-404-text-html.yml
new file mode 100644
index 0000000..4adb088
--- /dev/null
+++ b/spec/vcr_cassettes/allowed-push-project-not-found-404-text-html.yml
@@ -0,0 +1,46 @@
+---
+http_interactions:
+- request:
+ method: post
+ uri: http://localhost:3000/api/v4/internal/allowed
+ body:
+ encoding: US-ASCII
+ string: action=git-receive-pack&changes=0000000000000000000000000000000000000000+92d0970eefd7acb6d548878925ce2208cfe2d2ec+refs%2Fheads%2Fbranch4&gl_repository&project=gitlab-org%2Fgitlab-test.git&protocol=ssh&env=%7B%7D&key_id=1&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: 404
+ message: Not Found
+ headers:
+ Cache-Control:
+ - max-age=0, private, must-revalidate
+ Content-Length:
+ - '155'
+ Content-Type:
+ - text/html
+ Date:
+ - Wed, 21 Jun 2017 10:44:52 GMT
+ Etag:
+ - W/"45654cae433b5a9c5fbba1d45d382e52"
+ Vary:
+ - Origin
+ X-Frame-Options:
+ - SAMEORIGIN
+ X-Request-Id:
+ - 8d4b8b06-fb6e-4f94-832f-72f8e0afad5f
+ X-Runtime:
+ - '0.289759'
+ body:
+ encoding: UTF-8
+ string: '<p>The project you were looking for could not be found.</p>'
+ http_version:
+ recorded_at: Wed, 21 Jun 2017 10:44:52 GMT
+recorded_with: VCR 2.4.0
diff --git a/spec/vcr_cassettes/allowed-push-project-not-found-404-text-plain.yml b/spec/vcr_cassettes/allowed-push-project-not-found-404-text-plain.yml
new file mode 100644
index 0000000..a84b7d2
--- /dev/null
+++ b/spec/vcr_cassettes/allowed-push-project-not-found-404-text-plain.yml
@@ -0,0 +1,46 @@
+---
+http_interactions:
+- request:
+ method: post
+ uri: http://localhost:3000/api/v4/internal/allowed
+ body:
+ encoding: US-ASCII
+ string: action=git-receive-pack&changes=0000000000000000000000000000000000000000+92d0970eefd7acb6d548878925ce2208cfe2d2ec+refs%2Fheads%2Fbranch4&gl_repository&project=gitlab-org%2Fgitlab-test.git&protocol=ssh&env=%7B%7D&key_id=1&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: 404
+ message: Not Found
+ headers:
+ Cache-Control:
+ - max-age=0, private, must-revalidate
+ Content-Length:
+ - '155'
+ Content-Type:
+ - text/plain
+ Date:
+ - Wed, 21 Jun 2017 10:44:52 GMT
+ Etag:
+ - W/"45654cae433b5a9c5fbba1d45d382e52"
+ Vary:
+ - Origin
+ X-Frame-Options:
+ - SAMEORIGIN
+ X-Request-Id:
+ - 8d4b8b06-fb6e-4f94-832f-72f8e0afad5f
+ X-Runtime:
+ - '0.289759'
+ body:
+ encoding: UTF-8
+ string: 'The project you were looking for could not be found.'
+ http_version:
+ recorded_at: Wed, 21 Jun 2017 10:44:52 GMT
+recorded_with: VCR 2.4.0
diff --git a/spec/vcr_cassettes/allowed-push-project-not-found-404.yml b/spec/vcr_cassettes/allowed-push-project-not-found-404.yml
new file mode 100644
index 0000000..e531fcb
--- /dev/null
+++ b/spec/vcr_cassettes/allowed-push-project-not-found-404.yml
@@ -0,0 +1,46 @@
+---
+http_interactions:
+- request:
+ method: post
+ uri: http://localhost:3000/api/v4/internal/allowed
+ body:
+ encoding: US-ASCII
+ string: action=git-receive-pack&changes=0000000000000000000000000000000000000000+92d0970eefd7acb6d548878925ce2208cfe2d2ec+refs%2Fheads%2Fbranch4&gl_repository&project=gitlab-org%2Fgitlab-test.git&protocol=ssh&env=%7B%7D&key_id=1&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: 404
+ message: Not Found
+ headers:
+ Cache-Control:
+ - max-age=0, private, must-revalidate
+ Content-Length:
+ - '155'
+ Content-Type:
+ - application/json
+ Date:
+ - Wed, 21 Jun 2017 10:44:52 GMT
+ Etag:
+ - W/"45654cae433b5a9c5fbba1d45d382e52"
+ Vary:
+ - Origin
+ X-Frame-Options:
+ - SAMEORIGIN
+ X-Request-Id:
+ - 8d4b8b06-fb6e-4f94-832f-72f8e0afad5f
+ X-Runtime:
+ - '0.289759'
+ body:
+ encoding: UTF-8
+ string: '{"status":false,"message":"The project you were looking for could not be found."}'
+ http_version:
+ recorded_at: Wed, 21 Jun 2017 10:44:52 GMT
+recorded_with: VCR 2.4.0
diff --git a/spec/vcr_cassettes/allowed-push-project-not-found-text-html.yml b/spec/vcr_cassettes/allowed-push-project-not-found-text-html.yml
new file mode 100644
index 0000000..b2738fe
--- /dev/null
+++ b/spec/vcr_cassettes/allowed-push-project-not-found-text-html.yml
@@ -0,0 +1,46 @@
+---
+http_interactions:
+- request:
+ method: post
+ uri: http://localhost:3000/api/v4/internal/allowed
+ body:
+ encoding: US-ASCII
+ string: action=git-receive-pack&changes=0000000000000000000000000000000000000000+92d0970eefd7acb6d548878925ce2208cfe2d2ec+refs%2Fheads%2Fbranch4&gl_repository&project=gitlab-org%2Fgitlab-test.git&protocol=ssh&env=%7B%7D&key_id=1&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:
+ - '155'
+ Content-Type:
+ - text/html
+ Date:
+ - Wed, 21 Jun 2017 10:44:52 GMT
+ Etag:
+ - W/"45654cae433b5a9c5fbba1d45d382e52"
+ Vary:
+ - Origin
+ X-Frame-Options:
+ - SAMEORIGIN
+ X-Request-Id:
+ - 8d4b8b06-fb6e-4f94-832f-72f8e0afad5f
+ X-Runtime:
+ - '0.289759'
+ body:
+ encoding: UTF-8
+ string: '<p>The project you were looking for could not be found.</p>'
+ http_version:
+ recorded_at: Wed, 21 Jun 2017 10:44:52 GMT
+recorded_with: VCR 2.4.0
diff --git a/spec/vcr_cassettes/allowed-push-project-not-found-text-plain.yml b/spec/vcr_cassettes/allowed-push-project-not-found-text-plain.yml
new file mode 100644
index 0000000..34532ce
--- /dev/null
+++ b/spec/vcr_cassettes/allowed-push-project-not-found-text-plain.yml
@@ -0,0 +1,46 @@
+---
+http_interactions:
+- request:
+ method: post
+ uri: http://localhost:3000/api/v4/internal/allowed
+ body:
+ encoding: US-ASCII
+ string: action=git-receive-pack&changes=0000000000000000000000000000000000000000+92d0970eefd7acb6d548878925ce2208cfe2d2ec+refs%2Fheads%2Fbranch4&gl_repository&project=gitlab-org%2Fgitlab-test.git&protocol=ssh&env=%7B%7D&key_id=1&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:
+ - '155'
+ Content-Type:
+ - text/plain
+ Date:
+ - Wed, 21 Jun 2017 10:44:52 GMT
+ Etag:
+ - W/"45654cae433b5a9c5fbba1d45d382e52"
+ Vary:
+ - Origin
+ X-Frame-Options:
+ - SAMEORIGIN
+ X-Request-Id:
+ - 8d4b8b06-fb6e-4f94-832f-72f8e0afad5f
+ X-Runtime:
+ - '0.289759'
+ body:
+ encoding: UTF-8
+ string: 'The project you were looking for could not be found.'
+ http_version:
+ recorded_at: Wed, 21 Jun 2017 10:44:52 GMT
+recorded_with: VCR 2.4.0
diff --git a/spec/vcr_cassettes/allowed-push-project-not-found.yml b/spec/vcr_cassettes/allowed-push-project-not-found.yml
new file mode 100644
index 0000000..f25fa7e
--- /dev/null
+++ b/spec/vcr_cassettes/allowed-push-project-not-found.yml
@@ -0,0 +1,46 @@
+---
+http_interactions:
+- request:
+ method: post
+ uri: http://localhost:3000/api/v4/internal/allowed
+ body:
+ encoding: US-ASCII
+ string: action=git-receive-pack&changes=0000000000000000000000000000000000000000+92d0970eefd7acb6d548878925ce2208cfe2d2ec+refs%2Fheads%2Fbranch4&gl_repository&project=gitlab-org%2Fgitlab-test.git&protocol=ssh&env=%7B%7D&key_id=1&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:
+ - '155'
+ Content-Type:
+ - application/json
+ Date:
+ - Wed, 21 Jun 2017 10:44:52 GMT
+ Etag:
+ - W/"45654cae433b5a9c5fbba1d45d382e52"
+ Vary:
+ - Origin
+ X-Frame-Options:
+ - SAMEORIGIN
+ X-Request-Id:
+ - 8d4b8b06-fb6e-4f94-832f-72f8e0afad5f
+ X-Runtime:
+ - '0.289759'
+ body:
+ encoding: UTF-8
+ string: '{"status":false,"message":"The project you were looking for could not be found."}'
+ http_version:
+ recorded_at: Wed, 21 Jun 2017 10:44:52 GMT
+recorded_with: VCR 2.4.0
diff --git a/spec/vcr_cassettes/allowed-push.yml b/spec/vcr_cassettes/allowed-push.yml
index b073476..1636fd5 100644
--- a/spec/vcr_cassettes/allowed-push.yml
+++ b/spec/vcr_cassettes/allowed-push.yml
@@ -5,7 +5,7 @@ http_interactions:
uri: http://localhost:3000/api/v4/internal/allowed
body:
encoding: US-ASCII
- string: action=git-upload-pack&changes=0000000000000000000000000000000000000000+92d0970eefd7acb6d548878925ce2208cfe2d2ec+refs%2Fheads%2Fbranch4&gl_repository&project=gitlab-org%2Fgitlab-test.git&protocol=ssh&env=%7B%7D&key_id=1&secret_token=0a3938d9d95d807e94d937af3a4fbbea%0A
+ string: action=git-receive-pack&changes=0000000000000000000000000000000000000000+92d0970eefd7acb6d548878925ce2208cfe2d2ec+refs%2Fheads%2Fbranch4&gl_repository&project=gitlab-org%2Fgitlab-test.git&protocol=ssh&env=%7B%7D&key_id=1&secret_token=0a3938d9d95d807e94d937af3a4fbbea%0A
headers:
Accept-Encoding:
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
@@ -35,9 +35,9 @@ http_interactions:
X-Frame-Options:
- SAMEORIGIN
X-Request-Id:
- - 67ab4954-19e6-42ce-aae6-55c8ae5a365e
+ - 8d4b8b06-fb6e-4f94-832f-72f8e0afad5f
X-Runtime:
- - '0.230871'
+ - '0.289759'
body:
encoding: UTF-8
string: '{"status":true,"gl_repository":"project-3","repository_path":"/Users/dzaporozhets/Projects/gitlab-development-kit/repositories/gitlab-org/gitlab-test.git"}'
diff --git a/spec/vcr_cassettes/ssh-pull-project-denied-401-text-html.yml b/spec/vcr_cassettes/ssh-pull-project-denied-401-text-html.yml
new file mode 100644
index 0000000..d334108
--- /dev/null
+++ b/spec/vcr_cassettes/ssh-pull-project-denied-401-text-html.yml
@@ -0,0 +1,46 @@
+---
+http_interactions:
+- request:
+ method: post
+ uri: http://localhost:3000/api/v4/internal/allowed
+ body:
+ encoding: US-ASCII
+ string: action=git-upload-pack&changes=0000000000000000000000000000000000000000+92d0970eefd7acb6d548878925ce2208cfe2d2ec+refs%2Fheads%2Fbranch4&gl_repository&project=gitlab-org%2Fgitlab-test.git&protocol=ssh&env=%7B%7D&key_id=2&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: 401
+ message: Unauthorized
+ headers:
+ Cache-Control:
+ - max-age=0, private, must-revalidate
+ Content-Length:
+ - '63'
+ Content-Type:
+ - text/html
+ Date:
+ - Wed, 21 Jun 2017 12:24:04 GMT
+ Etag:
+ - W/"76a32010244f80700d5e1ba8a55d094c"
+ Vary:
+ - Origin
+ X-Frame-Options:
+ - SAMEORIGIN
+ X-Request-Id:
+ - 8ce54f29-9ed0-46e5-aedb-37edaa3d52da
+ X-Runtime:
+ - '0.228256'
+ body:
+ encoding: UTF-8
+ string: '<p>Git access over SSH is not allowed</p>'
+ http_version:
+ recorded_at: Wed, 21 Jun 2017 12:24:04 GMT
+recorded_with: VCR 2.4.0
diff --git a/spec/vcr_cassettes/ssh-pull-project-denied-401-text-plain.yml b/spec/vcr_cassettes/ssh-pull-project-denied-401-text-plain.yml
new file mode 100644
index 0000000..e072493
--- /dev/null
+++ b/spec/vcr_cassettes/ssh-pull-project-denied-401-text-plain.yml
@@ -0,0 +1,46 @@
+---
+http_interactions:
+- request:
+ method: post
+ uri: http://localhost:3000/api/v4/internal/allowed
+ body:
+ encoding: US-ASCII
+ string: action=git-upload-pack&changes=0000000000000000000000000000000000000000+92d0970eefd7acb6d548878925ce2208cfe2d2ec+refs%2Fheads%2Fbranch4&gl_repository&project=gitlab-org%2Fgitlab-test.git&protocol=ssh&env=%7B%7D&key_id=2&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: 401
+ message: Unauthorized
+ headers:
+ Cache-Control:
+ - max-age=0, private, must-revalidate
+ Content-Length:
+ - '63'
+ Content-Type:
+ - text/plain
+ Date:
+ - Wed, 21 Jun 2017 12:24:04 GMT
+ Etag:
+ - W/"76a32010244f80700d5e1ba8a55d094c"
+ Vary:
+ - Origin
+ X-Frame-Options:
+ - SAMEORIGIN
+ X-Request-Id:
+ - 8ce54f29-9ed0-46e5-aedb-37edaa3d52da
+ X-Runtime:
+ - '0.228256'
+ body:
+ encoding: UTF-8
+ string: 'Git access over SSH is not allowed'
+ http_version:
+ recorded_at: Wed, 21 Jun 2017 12:24:04 GMT
+recorded_with: VCR 2.4.0
diff --git a/spec/vcr_cassettes/ssh-pull-project-denied-401.yml b/spec/vcr_cassettes/ssh-pull-project-denied-401.yml
new file mode 100644
index 0000000..4a9305a
--- /dev/null
+++ b/spec/vcr_cassettes/ssh-pull-project-denied-401.yml
@@ -0,0 +1,46 @@
+---
+http_interactions:
+- request:
+ method: post
+ uri: http://localhost:3000/api/v4/internal/allowed
+ body:
+ encoding: US-ASCII
+ string: action=git-upload-pack&changes=0000000000000000000000000000000000000000+92d0970eefd7acb6d548878925ce2208cfe2d2ec+refs%2Fheads%2Fbranch4&gl_repository&project=gitlab-org%2Fgitlab-test.git&protocol=ssh&env=%7B%7D&key_id=2&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: 401
+ message: Unauthorized
+ headers:
+ Cache-Control:
+ - max-age=0, private, must-revalidate
+ Content-Length:
+ - '63'
+ Content-Type:
+ - application/json
+ Date:
+ - Wed, 21 Jun 2017 12:24:04 GMT
+ Etag:
+ - W/"76a32010244f80700d5e1ba8a55d094c"
+ Vary:
+ - Origin
+ X-Frame-Options:
+ - SAMEORIGIN
+ X-Request-Id:
+ - 8ce54f29-9ed0-46e5-aedb-37edaa3d52da
+ X-Runtime:
+ - '0.228256'
+ body:
+ encoding: UTF-8
+ string: '{"status":false,"message":"Git access over SSH is not allowed"}'
+ http_version:
+ recorded_at: Wed, 21 Jun 2017 12:24:04 GMT
+recorded_with: VCR 2.4.0
diff --git a/spec/vcr_cassettes/ssh-push-project-denied-with-user.yml b/spec/vcr_cassettes/ssh-pull-project-denied-with-user.yml
index b461b5b..b461b5b 100644
--- a/spec/vcr_cassettes/ssh-push-project-denied-with-user.yml
+++ b/spec/vcr_cassettes/ssh-pull-project-denied-with-user.yml
diff --git a/spec/vcr_cassettes/ssh-pull-project-denied.yml b/spec/vcr_cassettes/ssh-pull-project-denied.yml
index c16e608..5107d15 100644
--- a/spec/vcr_cassettes/ssh-pull-project-denied.yml
+++ b/spec/vcr_cassettes/ssh-pull-project-denied.yml
@@ -5,7 +5,7 @@ http_interactions:
uri: http://localhost:3000/api/v4/internal/allowed
body:
encoding: US-ASCII
- string: action=git-receive-pack&changes=0000000000000000000000000000000000000000+92d0970eefd7acb6d548878925ce2208cfe2d2ec+refs%2Fheads%2Fbranch4&gl_repository&project=gitlab-org%2Fgitlab-test.git&protocol=ssh&env=%7B%7D&key_id=2&secret_token=0a3938d9d95d807e94d937af3a4fbbea%0A
+ string: action=git-upload-pack&changes=0000000000000000000000000000000000000000+92d0970eefd7acb6d548878925ce2208cfe2d2ec+refs%2Fheads%2Fbranch4&gl_repository&project=gitlab-org%2Fgitlab-test.git&protocol=ssh&env=%7B%7D&key_id=2&secret_token=0a3938d9d95d807e94d937af3a4fbbea%0A
headers:
Accept-Encoding:
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
@@ -35,9 +35,9 @@ http_interactions:
X-Frame-Options:
- SAMEORIGIN
X-Request-Id:
- - c843a5a3-fc08-46eb-aa45-caceae515638
+ - 8ce54f29-9ed0-46e5-aedb-37edaa3d52da
X-Runtime:
- - '7.359835'
+ - '0.228256'
body:
encoding: UTF-8
string: '{"status":false,"message":"Git access over SSH is not allowed"}'
diff --git a/spec/vcr_cassettes/ssh-push-project-denied-401-text-html.yml b/spec/vcr_cassettes/ssh-push-project-denied-401-text-html.yml
new file mode 100644
index 0000000..08dea91
--- /dev/null
+++ b/spec/vcr_cassettes/ssh-push-project-denied-401-text-html.yml
@@ -0,0 +1,46 @@
+---
+http_interactions:
+- request:
+ method: post
+ uri: http://localhost:3000/api/v4/internal/allowed
+ body:
+ encoding: US-ASCII
+ string: action=git-receive-pack&changes=0000000000000000000000000000000000000000+92d0970eefd7acb6d548878925ce2208cfe2d2ec+refs%2Fheads%2Fbranch4&gl_repository&project=gitlab-org%2Fgitlab-test.git&protocol=ssh&env=%7B%7D&key_id=2&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: 401
+ message: Unauthorized
+ headers:
+ Cache-Control:
+ - max-age=0, private, must-revalidate
+ Content-Length:
+ - '63'
+ Content-Type:
+ - text/html
+ Date:
+ - Wed, 21 Jun 2017 12:24:04 GMT
+ Etag:
+ - W/"76a32010244f80700d5e1ba8a55d094c"
+ Vary:
+ - Origin
+ X-Frame-Options:
+ - SAMEORIGIN
+ X-Request-Id:
+ - c843a5a3-fc08-46eb-aa45-caceae515638
+ X-Runtime:
+ - '7.359835'
+ body:
+ encoding: UTF-8
+ string: '<p>Git access over SSH is not allowed</p>'
+ http_version:
+ recorded_at: Wed, 21 Jun 2017 12:24:04 GMT
+recorded_with: VCR 2.4.0
diff --git a/spec/vcr_cassettes/ssh-push-project-denied-401-text-plain.yml b/spec/vcr_cassettes/ssh-push-project-denied-401-text-plain.yml
new file mode 100644
index 0000000..46d9a1d
--- /dev/null
+++ b/spec/vcr_cassettes/ssh-push-project-denied-401-text-plain.yml
@@ -0,0 +1,46 @@
+---
+http_interactions:
+- request:
+ method: post
+ uri: http://localhost:3000/api/v4/internal/allowed
+ body:
+ encoding: US-ASCII
+ string: action=git-receive-pack&changes=0000000000000000000000000000000000000000+92d0970eefd7acb6d548878925ce2208cfe2d2ec+refs%2Fheads%2Fbranch4&gl_repository&project=gitlab-org%2Fgitlab-test.git&protocol=ssh&env=%7B%7D&key_id=2&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: 401
+ message: Unauthorized
+ headers:
+ Cache-Control:
+ - max-age=0, private, must-revalidate
+ Content-Length:
+ - '63'
+ Content-Type:
+ - text/plain
+ Date:
+ - Wed, 21 Jun 2017 12:24:04 GMT
+ Etag:
+ - W/"76a32010244f80700d5e1ba8a55d094c"
+ Vary:
+ - Origin
+ X-Frame-Options:
+ - SAMEORIGIN
+ X-Request-Id:
+ - c843a5a3-fc08-46eb-aa45-caceae515638
+ X-Runtime:
+ - '7.359835'
+ body:
+ encoding: UTF-8
+ string: 'Git access over SSH is not allowed'
+ http_version:
+ recorded_at: Wed, 21 Jun 2017 12:24:04 GMT
+recorded_with: VCR 2.4.0
diff --git a/spec/vcr_cassettes/ssh-push-project-denied-401.yml b/spec/vcr_cassettes/ssh-push-project-denied-401.yml
new file mode 100644
index 0000000..77248e2
--- /dev/null
+++ b/spec/vcr_cassettes/ssh-push-project-denied-401.yml
@@ -0,0 +1,46 @@
+---
+http_interactions:
+- request:
+ method: post
+ uri: http://localhost:3000/api/v4/internal/allowed
+ body:
+ encoding: US-ASCII
+ string: action=git-receive-pack&changes=0000000000000000000000000000000000000000+92d0970eefd7acb6d548878925ce2208cfe2d2ec+refs%2Fheads%2Fbranch4&gl_repository&project=gitlab-org%2Fgitlab-test.git&protocol=ssh&env=%7B%7D&key_id=2&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: 401
+ message: Unauthorized
+ headers:
+ Cache-Control:
+ - max-age=0, private, must-revalidate
+ Content-Length:
+ - '63'
+ Content-Type:
+ - application/json
+ Date:
+ - Wed, 21 Jun 2017 12:24:04 GMT
+ Etag:
+ - W/"76a32010244f80700d5e1ba8a55d094c"
+ Vary:
+ - Origin
+ X-Frame-Options:
+ - SAMEORIGIN
+ X-Request-Id:
+ - c843a5a3-fc08-46eb-aa45-caceae515638
+ X-Runtime:
+ - '7.359835'
+ body:
+ encoding: UTF-8
+ string: '{"status":false,"message":"Git access over SSH is not allowed"}'
+ http_version:
+ recorded_at: Wed, 21 Jun 2017 12:24:04 GMT
+recorded_with: VCR 2.4.0
diff --git a/spec/vcr_cassettes/ssh-push-project-denied.yml b/spec/vcr_cassettes/ssh-push-project-denied.yml
index 5107d15..c16e608 100644
--- a/spec/vcr_cassettes/ssh-push-project-denied.yml
+++ b/spec/vcr_cassettes/ssh-push-project-denied.yml
@@ -5,7 +5,7 @@ http_interactions:
uri: http://localhost:3000/api/v4/internal/allowed
body:
encoding: US-ASCII
- string: action=git-upload-pack&changes=0000000000000000000000000000000000000000+92d0970eefd7acb6d548878925ce2208cfe2d2ec+refs%2Fheads%2Fbranch4&gl_repository&project=gitlab-org%2Fgitlab-test.git&protocol=ssh&env=%7B%7D&key_id=2&secret_token=0a3938d9d95d807e94d937af3a4fbbea%0A
+ string: action=git-receive-pack&changes=0000000000000000000000000000000000000000+92d0970eefd7acb6d548878925ce2208cfe2d2ec+refs%2Fheads%2Fbranch4&gl_repository&project=gitlab-org%2Fgitlab-test.git&protocol=ssh&env=%7B%7D&key_id=2&secret_token=0a3938d9d95d807e94d937af3a4fbbea%0A
headers:
Accept-Encoding:
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
@@ -35,9 +35,9 @@ http_interactions:
X-Frame-Options:
- SAMEORIGIN
X-Request-Id:
- - 8ce54f29-9ed0-46e5-aedb-37edaa3d52da
+ - c843a5a3-fc08-46eb-aa45-caceae515638
X-Runtime:
- - '0.228256'
+ - '7.359835'
body:
encoding: UTF-8
string: '{"status":false,"message":"Git access over SSH is not allowed"}'