From ab16fe80641689f10be3e8722d943a61044cacfc Mon Sep 17 00:00:00 2001 From: Lawson Jaglom-Kurtz Date: Thu, 20 Jan 2022 11:34:01 -0700 Subject: [PATCH 1/4] Revert 3b02b32276fab70e21a017d62ec9eea67996a906 --- lib/oktakit/response/raise_error.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/oktakit/response/raise_error.rb b/lib/oktakit/response/raise_error.rb index 9175be2..5837a48 100644 --- a/lib/oktakit/response/raise_error.rb +++ b/lib/oktakit/response/raise_error.rb @@ -7,6 +7,8 @@ module Response # This class raises an Oktakit-flavored exception based # HTTP status codes returned by the API class RaiseError < Faraday::Response::Middleware + private + def on_complete(response) if (error = Oktakit::Error.from_response(response)) raise error From 9b9671f3441842bd02164dd3441e055a813471fb Mon Sep 17 00:00:00 2001 From: Lawson Jaglom-Kurtz Date: Thu, 20 Jan 2022 11:34:44 -0700 Subject: [PATCH 2/4] Disable tests around raising custom errors on non 2xx responses The 0.2.0 release did not include this behavior, so we're reverting it. We may choose to add this behavior back in under a configurable flag in the near future. --- spec/oktakit_spec.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/spec/oktakit_spec.rb b/spec/oktakit_spec.rb index 333c7a2..b7a7d97 100644 --- a/spec/oktakit_spec.rb +++ b/spec/oktakit_spec.rb @@ -46,13 +46,13 @@ 504 => Oktakit::ServerError, } - describe 'errors' do - ERRORS.each do |code, error| - it "raises a #{error} on #{code} responses" do - VCR.use_cassette(code) do - expect { client.get('/users/-1') }.to(raise_error(error)) - end - end - end - end + # describe 'errors' do + # ERRORS.each do |code, error| + # it "raises a #{error} on #{code} responses" do + # VCR.use_cassette(code) do + # expect { client.get('/users/-1') }.to(raise_error(error)) + # end + # end + # end + # end end From ff62e91a9e530e371d0e4364de3c53871a40a689 Mon Sep 17 00:00:00 2001 From: Lawson Jaglom-Kurtz Date: Thu, 20 Jan 2022 11:45:40 -0700 Subject: [PATCH 3/4] Bump version to v0.3.1 --- CHANGELOG.md | 3 +++ Gemfile.lock | 2 +- lib/oktakit/version.rb | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 57d556b..d3229d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## [v0.3.1] - 2022-01-20 +- [Reverts a breaking change that caused errors to be raised for non-2xx responses](https://github.com/Shopify/oktakit/pull/54) + ## [v0.3.0] - 2022-01-20 - [Adds support for Ruby 3](https://github.com/Shopify/oktakit/pull/42) - [Adds support for user reactivation endpoint](https://github.com/Shopify/oktakit/pull/47) diff --git a/Gemfile.lock b/Gemfile.lock index 6e85f77..f643d42 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - oktakit (0.3.0) + oktakit (0.3.1) sawyer (~> 0.8.1) GEM diff --git a/lib/oktakit/version.rb b/lib/oktakit/version.rb index 72401bd..e446a49 100644 --- a/lib/oktakit/version.rb +++ b/lib/oktakit/version.rb @@ -1,3 +1,3 @@ module Oktakit - VERSION = '0.3.0'.freeze + VERSION = '0.3.1'.freeze end From ebe892ff4465e285e909e5b2f85f6c8f25ab9bdd Mon Sep 17 00:00:00 2001 From: Lawson Jaglom-Kurtz Date: Thu, 20 Jan 2022 12:09:23 -0700 Subject: [PATCH 4/4] Update error-related specs h/t @ScottifyShopson --- spec/oktakit_spec.rb | 53 ++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/spec/oktakit_spec.rb b/spec/oktakit_spec.rb index b7a7d97..58dc746 100644 --- a/spec/oktakit_spec.rb +++ b/spec/oktakit_spec.rb @@ -28,31 +28,32 @@ end end - ERRORS = { - 400 => Oktakit::BadRequest, - 401 => Oktakit::Unauthorized, - 403 => Oktakit::Forbidden, - 404 => Oktakit::NotFound, - 405 => Oktakit::MethodNotAllowed, - 406 => Oktakit::NotAcceptable, - 409 => Oktakit::Conflict, - 415 => Oktakit::UnsupportedMediaType, - 422 => Oktakit::UnprocessableEntity, - 418 => Oktakit::ClientError, - 500 => Oktakit::InternalServerError, - 501 => Oktakit::NotImplemented, - 502 => Oktakit::BadGateway, - 503 => Oktakit::ServiceUnavailable, - 504 => Oktakit::ServerError, - } + ERROR_STATUSES = [ + 400, + 401, + 403, + 404, + 405, + 406, + 409, + 415, + 422, + 418, + 500, + 501, + 502, + 503, + 504, + ] - # describe 'errors' do - # ERRORS.each do |code, error| - # it "raises a #{error} on #{code} responses" do - # VCR.use_cassette(code) do - # expect { client.get('/users/-1') }.to(raise_error(error)) - # end - # end - # end - # end + describe 'errors' do + ERROR_STATUSES.each do |error_status| + it "returns a #{error_status} status for #{error_status} responses" do + VCR.use_cassette(error_status) do + _, response_status = client.get('/users/-1') + expect(response_status).to eq(error_status) + end + end + end + end end