diff options
author | Ash McKenzie <amckenzie@gitlab.com> | 2018-09-07 11:01:21 +1000 |
---|---|---|
committer | Ash McKenzie <amckenzie@gitlab.com> | 2018-09-07 11:01:21 +1000 |
commit | 0601b521ef2fda36b37d745cb4e9b06909bf83a1 (patch) | |
tree | 0ab8bc0a082c56e5db667f4dd62ea589ea582b26 | |
parent | 631430b2fd5f581637a66580ee9a56a508cc7ca4 (diff) | |
download | gitlab-shell-0601b521ef2fda36b37d745cb4e9b06909bf83a1.tar.gz |
/api/v4/allowed returns proper HTTP status codes
* Previously, a 200 (OK) was sent when the user was unauthorised or the project was not found (or the user didn't have access)
* We still treat 401 and 404 as 'success' but we need to explicitly handle them
-rw-r--r-- | lib/gitlab_net.rb | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/gitlab_net.rb b/lib/gitlab_net.rb index 980897a..5af2da6 100644 --- a/lib/gitlab_net.rb +++ b/lib/gitlab_net.rb @@ -35,7 +35,8 @@ class GitlabNet # rubocop:disable Metrics/ClassLength url = "#{internal_api_endpoint}/allowed" resp = post(url, params) - if resp.code == '200' + case resp.code.to_s + when HTTP_SUCCESS, HTTP_UNAUTHORIZED, HTTP_NOT_FOUND GitAccessStatus.create_from_json(resp.body) else GitAccessStatus.new(false, |