Skip to content

Conversation

mattnworb
Copy link
Member

I noticed that the test assertJwtEndpointWithNoKeyThrows() was taking
10 seconds to run so I took a look into why that was.

The test method has @Test(expected=Exception.class) but the exception
that is thrown is different than the one that the test is expected - the
test was throwing a SocketTimeoutException after 10 seconds (which is
the OkHttpClient's default read timeout setting) because there was no
mock requests enqueued in the mock web server.

I refactored these tests to use assertThrows instead to assert against
the details of the thrown Exceptions, and also fixed what seems like a
bug in the getAuthorizationHeader method - if the client has an
accessToken, it will be used as the header, even if the request path is
one that needs a private-key-signed JWT token.

I noticed that the test `assertJwtEndpointWithNoKeyThrows()` was taking
10 seconds to run so I took a look into why that was.

The test method has `@Test(expected=Exception.class)` but the exception
that is thrown is different than the one that the test is expected - the
test was throwing a SocketTimeoutException after 10 seconds (which is
the OkHttpClient's default read timeout setting) because there was no
mock requests enqueued in the mock web server.

I refactored these tests to use `assertThrows` instead to assert against
the details of the thrown Exceptions, and also fixed what seems like a
bug in the `getAuthorizationHeader` method - if the client has an
accessToken, it will be used as the header, even if the request path is
one that needs a private-key-signed JWT token.
@codecov
Copy link

codecov bot commented Oct 29, 2020

Codecov Report

Merging #45 into master will increase coverage by 2.14%.
The diff coverage is 72.41%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master      #45      +/-   ##
============================================
+ Coverage     65.80%   67.94%   +2.14%     
- Complexity      176      191      +15     
============================================
  Files            30       32       +2     
  Lines           731      758      +27     
  Branches         29       31       +2     
============================================
+ Hits            481      515      +34     
+ Misses          229      222       -7     
  Partials         21       21              
Impacted Files Coverage Δ Complexity Δ
...va/com/spotify/github/v3/prs/ReviewParameters.java 100.00% <ø> (+100.00%) 1.00 <0.00> (+1.00)
...m/spotify/github/v3/clients/PullRequestClient.java 26.41% <63.63%> (+26.41%) 5.00 <2.00> (+5.00)
...va/com/spotify/github/v3/clients/GitHubClient.java 72.55% <75.00%> (+3.40%) 48.00 <10.00> (+7.00)
...spotify/github/v3/prs/RequestReviewParameters.java 100.00% <100.00%> (ø) 1.00 <1.00> (?)
.../java/com/spotify/github/v3/prs/ReviewComment.java 100.00% <100.00%> (ø) 1.00 <1.00> (?)

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 d00da14...666d6f8. Read the comment docs.

Copy link
Contributor

@henriquetruta henriquetruta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Thanks for the fix!

@henriquetruta henriquetruta merged commit 32b0bf5 into spotify:master Oct 29, 2020
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.

2 participants