Commit d5306c95 authored by Nick Thomas's avatar Nick Thomas

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
parents 306b6b5b 22c6951d
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
......
......@@ -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
......
......@@ -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 {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment