Skip to content

Fix error handling for http errors everywhere #496

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

px-amaac
Copy link

@px-amaac px-amaac commented Sep 18, 2019

  • This commit adds check for response codes >= 400 on registration request and service configuration request and brings token request to use the same format
  • Creates TYPE_HTTP_ERROR(5) in AuthorizationException
  • Add method to create AuthorizationException of HTTP_ERROR type from http response code and message. Using HttpURLConnection.getErrorStream() to fill out errorDescription.
  • Add tests for each area changed to handle a bad request http error.

This PR follows in line with what was done for #144 following Android documentation and Recommendations from Oracle on handling http error responses. The change in #144 did not address this issue in other places of the library and could potentially throw json exception if error stream does not contain a valid JSON response.

This commit adds check for response codes >= 400 and creates a new type of response for HTTP errors.
Add tests for each area changed to handle a bad request http error.
@codecov-io
Copy link

codecov-io commented Sep 18, 2019

Codecov Report

Merging #496 into master will decrease coverage by 0.41%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #496      +/-   ##
============================================
- Coverage     83.71%   83.29%   -0.42%     
+ Complexity      479      477       -2     
============================================
  Files            42       42              
  Lines          2345     2364      +19     
  Branches        233      234       +1     
============================================
+ Hits           1963     1969       +6     
- Misses          299      314      +15     
+ Partials         83       81       -2
Impacted Files Coverage Δ Complexity Δ
.../java/net/openid/appauth/AuthorizationService.java 69.81% <100%> (-3.17%) 15 <0> (ø)
...nid/appauth/AuthorizationServiceConfiguration.java 87.91% <100%> (+1%) 10 <0> (ø) ⬇️
...ava/net/openid/appauth/AuthorizationException.java 72.97% <100%> (-1.18%) 18 <1> (-1)
...rary/java/net/openid/appauth/internal/UriUtil.java 70.68% <0%> (-1.73%) 16% <0%> (-1%)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f125925...f8b590c. Read the comment docs.

@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (master@f125925). Learn more about missing BASE report.
Report is 91 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##             master     #496   +/-   ##
=========================================
  Coverage          ?   83.29%           
  Complexity        ?      477           
=========================================
  Files             ?       42           
  Lines             ?     2364           
  Branches          ?      234           
=========================================
  Hits              ?     1969           
  Misses            ?      314           
  Partials          ?       81           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants