diff options
author | Stan Hu <stanhu@gmail.com> | 2018-09-07 02:11:51 +0000 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2018-09-07 02:11:51 +0000 |
commit | b0a526354eb012d2a2d874d22515d20c035ea5d6 (patch) | |
tree | 0ab8bc0a082c56e5db667f4dd62ea589ea582b26 | |
parent | 493646938cad8f99f5420ec578689e112515c5d7 (diff) | |
parent | 0601b521ef2fda36b37d745cb4e9b06909bf83a1 (diff) | |
download | gitlab-shell-b0a526354eb012d2a2d874d22515d20c035ea5d6.tar.gz |
Merge branch 'ash.mckenzie/allowed-api-proper-http-status-code-support' into 'master'
Proper HTTP status code support for /api/v4/allowed API endpoint
Closes gitlab-ce#51211
See merge request gitlab-org/gitlab-shell!237
-rw-r--r-- | lib/gitlab_net.rb | 3 | ||||
-rw-r--r-- | lib/http_codes.rb | 5 | ||||
-rw-r--r-- | lib/http_helper.rb | 4 |
3 files changed, 11 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, diff --git a/lib/http_codes.rb b/lib/http_codes.rb new file mode 100644 index 0000000..24b3b5a --- /dev/null +++ b/lib/http_codes.rb @@ -0,0 +1,5 @@ +module HTTPCodes + HTTP_SUCCESS = '200'.freeze + HTTP_UNAUTHORIZED = '401'.freeze + HTTP_NOT_FOUND = '404'.freeze +end diff --git a/lib/http_helper.rb b/lib/http_helper.rb index 62d0c51..1e75833 100644 --- a/lib/http_helper.rb +++ b/lib/http_helper.rb @@ -1,4 +1,8 @@ +require_relative 'http_codes' + module HTTPHelper + include HTTPCodes + READ_TIMEOUT = 300 protected |