use of org.keycloak.broker.provider.util.SimpleHttp in project keycloak by keycloak.
the class AccountRestServiceTest method getUser.
protected UserRepresentation getUser(boolean fetchMetadata) throws IOException {
String accountUrl = getAccountUrl(null) + "?userProfileMetadata=" + fetchMetadata;
SimpleHttp a = SimpleHttp.doGet(accountUrl, httpClient).auth(tokenUtil.getToken());
try {
return a.asJson(UserRepresentation.class);
} catch (IOException e) {
System.err.println("Error during user reading: " + a.asString());
throw e;
}
}
use of org.keycloak.broker.provider.util.SimpleHttp in project keycloak by keycloak.
the class TokenRevocationTest method isAccessTokenDisabled.
private void isAccessTokenDisabled(String accessTokenString, String clientId) throws IOException {
// Test introspection endpoint not possible
String introspectionResponse = oauth.introspectAccessTokenWithClientCredential(clientId, "password", accessTokenString);
TokenMetadataRepresentation rep = JsonSerialization.readValue(introspectionResponse, TokenMetadataRepresentation.class);
assertFalse(rep.isActive());
// Test userInfo endpoint not possible
Response response = UserInfoClientUtil.executeUserInfoRequest_getMethod(userInfoClient, accessTokenString);
assertEquals(Status.UNAUTHORIZED.getStatusCode(), response.getStatus());
// Test account REST not possible
String accountUrl = OAuthClient.AUTH_SERVER_ROOT + "/realms/test/account";
SimpleHttp accountRequest = SimpleHttp.doGet(accountUrl, restHttpClient).auth(accessTokenString).acceptJson();
assertEquals(Status.UNAUTHORIZED.getStatusCode(), accountRequest.asStatus());
// Test admin REST not possible
try (Keycloak adminClient = Keycloak.getInstance(OAuthClient.AUTH_SERVER_ROOT, "test", "test-app", accessTokenString)) {
try {
adminClient.realms().realm("test").toRepresentation();
Assert.fail("Not expected to obtain realm");
} catch (NotAuthorizedException nae) {
// Expected
}
}
}
Aggregations