summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorZeger-Jan van de Weg <git@zjvandeweg.nl>2018-09-05 09:31:25 +0200
committerZeger-Jan van de Weg <git@zjvandeweg.nl>2018-09-05 09:31:25 +0200
commit22c6951d64e8b2c3a9e05306c52cd861c9c23ec7 (patch)
tree0733830d55ff21e37213255cb53f268010b437a4 /spec
parent306b6b5bf0e3dff50af8e37af4a28a36338a0dc6 (diff)
downloadgitlab-shell-22c6951d64e8b2c3a9e05306c52cd861c9c23ec7.tar.gz
Fix handling non 200 response codeszj-fix-non-200-resp-code
After the cleanup in https://gitlab.com/gitlab-org/gitlab-shell/merge_requests/231 gitlab-shell mishandled the non 200 response codes. This commit removes another few lines of codes, which fixes this. Also now we test against this case through mocking. Fixes https://gitlab.com/gitlab-org/gitlab-shell/issues/152
Diffstat (limited to 'spec')
-rw-r--r--spec/gitlab_net_spec.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/spec/gitlab_net_spec.rb b/spec/gitlab_net_spec.rb
index 9f7c462..e14fd83 100644
--- a/spec/gitlab_net_spec.rb
+++ b/spec/gitlab_net_spec.rb
@@ -347,6 +347,15 @@ describe GitlabNet, vcr: true do
end
end
+ it 'handles non 200 status codes' do
+ resp = double(:resp, code: 501)
+
+ allow(gitlab_net).to receive(:post).and_return(resp)
+
+ access = gitlab_net.check_access('git-upload-pack', nil, project, 'user-2', changes, 'ssh')
+ expect(access).not_to be_allowed
+ end
+
it "raises an exception if the connection fails" do
allow_any_instance_of(Net::HTTP).to receive(:request).and_raise(StandardError)
expect {