Skip to content

Commit

Permalink
Avoid using nip.io resolution in RefreshTokenTest#refreshTokenWithDif…
Browse files Browse the repository at this point in the history
…ferentIssuer test

Closes keycloak#25675

Signed-off-by: rmartinc <[email protected]>
  • Loading branch information
rmartinc authored and mposolda committed Nov 6, 2024
1 parent b2930a4 commit d2e19da
Showing 1 changed file with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ public void refreshTokenRequest() throws Exception {

@Test
public void refreshTokenWithDifferentIssuer() throws Exception {
final String proxyHost = "proxy.kc.127.0.0.1.nip.io";
final String proxyHost = "localhost";
final int httpPort = 8666;
final int httpsPort = 8667;

Expand All @@ -330,16 +330,19 @@ public void refreshTokenWithDifferentIssuer() throws Exception {
SimpleUndertowLoadBalancer proxy = new SimpleUndertowLoadBalancer(proxyHost, httpPort, httpsPort, "node1=" + getHttpAuthServerContextRoot() + "/auth");
proxy.start();

oauth.baseUrl(String.format("http://%s:%s", proxyHost, httpPort));

response = oauth.doRefreshTokenRequest(refreshTokenString, "password");

Assert.assertEquals(400, response.getStatusCode());
events.expect(EventType.REFRESH_TOKEN).error(Errors.INVALID_TOKEN).user((String) null).assertEvent();
try {
oauth.baseUrl(String.format("http://%s:%s", proxyHost, httpPort));

proxy.stop();
response = oauth.doRefreshTokenRequest(refreshTokenString, "password");

oauth.baseUrl(AUTH_SERVER_ROOT);
Assert.assertEquals(400, response.getStatusCode());
Assert.assertEquals("invalid_grant", response.getError());
assertThat(response.getErrorDescription(), Matchers.startsWith("Invalid token issuer."));
events.expect(EventType.REFRESH_TOKEN).error(Errors.INVALID_TOKEN).user((String) null).assertEvent();
} finally {
proxy.stop();
oauth.baseUrl(AUTH_SERVER_ROOT);
}
}

@Test
Expand All @@ -352,7 +355,6 @@ public void refreshTokenWithAccessToken() throws Exception {
String accessTokenString = tokenResponse.getAccessToken();

OAuthClient.AccessTokenResponse response = oauth.doRefreshTokenRequest(accessTokenString, "password");

Assert.assertNotEquals(200, response.getStatusCode());
}

Expand Down

0 comments on commit d2e19da

Please sign in to comment.