summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Thomas <nick@gitlab.com>2018-09-05 12:12:29 +0000
committerNick Thomas <nick@gitlab.com>2018-09-05 12:12:29 +0000
commitd5306c9535fc5d1a5711a8b0a613904db308bc65 (patch)
tree0733830d55ff21e37213255cb53f268010b437a4
parent306b6b5bf0e3dff50af8e37af4a28a36338a0dc6 (diff)
parent22c6951d64e8b2c3a9e05306c52cd861c9c23ec7 (diff)
downloadgitlab-shell-d5306c9535fc5d1a5711a8b0a613904db308bc65.tar.gz
Merge branch 'zj-fix-non-200-resp-code' into 'master'
Fix handling non 200 response codes Closes #152 See merge request gitlab-org/gitlab-shell!235
-rw-r--r--lib/gitlab_access_status.rb2
-rw-r--r--lib/gitlab_net.rb1
-rw-r--r--spec/gitlab_net_spec.rb9
3 files changed, 10 insertions, 2 deletions
diff --git a/lib/gitlab_access_status.rb b/lib/gitlab_access_status.rb
index 96dd6e8..00ea8de 100644
--- a/lib/gitlab_access_status.rb
+++ b/lib/gitlab_access_status.rb
@@ -1,7 +1,7 @@
require 'json'
class GitAccessStatus
- attr_reader :message, :gl_repository, :gl_id, :gl_username, :repository_path, :gitaly, :git_protocol, :git_config_options
+ attr_reader :message, :gl_repository, :gl_id, :gl_username, :gitaly, :git_protocol, :git_config_options
def initialize(status, message, gl_repository:, gl_id:, gl_username:, gitaly:, git_protocol:, git_config_options:)
@status = status
diff --git a/lib/gitlab_net.rb b/lib/gitlab_net.rb
index 28d1f0d..980897a 100644
--- a/lib/gitlab_net.rb
+++ b/lib/gitlab_net.rb
@@ -44,7 +44,6 @@ class GitlabNet # rubocop:disable Metrics/ClassLength
gl_id: nil,
gl_username: nil,
git_config_options: nil,
- repository_path: nil,
gitaly: nil,
git_protocol: nil)
end
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 {