use of org.keycloak.representations.idm.OAuth2ErrorRepresentation in project keycloak by keycloak.
the class UncaughtErrorPageTest method uncaughtErrorClientRegistration.
@Test
@UncaughtServerErrorExpected
public void uncaughtErrorClientRegistration() throws IOException {
try (CloseableHttpClient client = HttpClientBuilder.create().build()) {
HttpPost post = new HttpPost(suiteContext.getAuthServerInfo().getUriBuilder().path("/auth/realms/master/clients-registrations/openid-connect").build());
post.setEntity(new StringEntity("{ invalid : invalid }"));
post.setHeader("Content-Type", "application/json");
CloseableHttpResponse response = client.execute(post);
assertEquals(400, response.getStatusLine().getStatusCode());
OAuth2ErrorRepresentation error = JsonSerialization.readValue(response.getEntity().getContent(), OAuth2ErrorRepresentation.class);
assertEquals("unknown_error", error.getError());
assertNull(error.getErrorDescription());
}
}
use of org.keycloak.representations.idm.OAuth2ErrorRepresentation in project keycloak by keycloak.
the class UncaughtErrorPageTest method uncaughtErrorAdmin.
@Test
@UncaughtServerErrorExpected
public void uncaughtErrorAdmin() throws IOException {
try (CloseableHttpClient client = HttpClientBuilder.create().build()) {
String accessToken = adminClient.tokenManager().getAccessTokenString();
HttpPost post = new HttpPost(suiteContext.getAuthServerInfo().getUriBuilder().path("/auth/admin/realms").build());
post.setEntity(new StringEntity("{ invalid : invalid }"));
post.setHeader("Authorization", "bearer " + accessToken);
post.setHeader("Content-Type", "application/json");
CloseableHttpResponse response = client.execute(post);
assertEquals(400, response.getStatusLine().getStatusCode());
OAuth2ErrorRepresentation error = JsonSerialization.readValue(response.getEntity().getContent(), OAuth2ErrorRepresentation.class);
assertEquals("unknown_error", error.getError());
assertNull(error.getErrorDescription());
}
}
Aggregations