Skip to content

Commit

Permalink
Merge pull request #59 from auth0/patch-headers
Browse files Browse the repository at this point in the history
Add content-type header to the jwks request
  • Loading branch information
lbalmaceda authored May 2, 2019
2 parents 9deba21 + 9fa6841 commit e6ec173
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/main/java/com/auth0/jwk/UrlJwkProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ private Map<String, Object> getJwks() throws SigningKeyNotFoundException {
if (readTimeout != null) {
c.setReadTimeout(readTimeout);
}
c.setRequestProperty("Accept", "application/json");
final InputStream inputStream = c.getInputStream();
final JsonFactory factory = new JsonFactory();
final JsonParser parser = factory.createParser(inputStream);
Expand Down
6 changes: 5 additions & 1 deletion src/test/java/com/auth0/jwk/UrlJwkProviderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ protected URLConnection openConnection(URL url) throws IOException {
}

@Test
public void shouldConfigureURLConnectionTimeouts() throws Exception {
public void shouldConfigureURLConnection() throws Exception {
URLConnection urlConnection = mock(URLConnection.class);

// Although somewhat of a hack, this approach gets the job done - this method can
Expand All @@ -213,12 +213,16 @@ public void shouldConfigureURLConnectionTimeouts() throws Exception {
Jwk jwk = urlJwkProvider.get("NkJCQzIyQzRBMEU4NjhGNUU4MzU4RkY0M0ZDQzkwOUQ0Q0VGNUMwQg");
assertNotNull(jwk);

//Request Timeout assertions
ArgumentCaptor<Integer> connectTimeoutCaptor = ArgumentCaptor.forClass(Integer.class);
verify(urlConnection).setConnectTimeout(connectTimeoutCaptor.capture());
assertThat(connectTimeoutCaptor.getValue(), is(connectTimeout));

ArgumentCaptor<Integer> readTimeoutCaptor = ArgumentCaptor.forClass(Integer.class);
verify(urlConnection).setReadTimeout(readTimeoutCaptor.capture());
assertThat(readTimeoutCaptor.getValue(), is(readTimeout));

//Request Headers assertions
verify(urlConnection).setRequestProperty("Accept", "application/json");
}
}

0 comments on commit e6ec173

Please sign in to comment.