Search in sources :

Example 11 with UserInfo

use of org.keycloak.representations.UserInfo in project keycloak by keycloak.

the class UserInfoTest method testSuccess_getMethod_header.

@Test
public void testSuccess_getMethod_header() throws Exception {
    Client client = AdminClientUtil.createResteasyClient();
    try {
        AccessTokenResponse accessTokenResponse = executeGrantAccessTokenRequest(client);
        Response response = UserInfoClientUtil.executeUserInfoRequest_getMethod(client, accessTokenResponse.getToken());
        UserInfo userInfo = testSuccessfulUserInfoResponse(response);
        testRolesAreNotInUserInfoResponse(userInfo);
    } finally {
        client.close();
    }
}
Also used : AccessTokenResponse(org.keycloak.representations.AccessTokenResponse) Response(javax.ws.rs.core.Response) UserInfo(org.keycloak.representations.UserInfo) OAuthClient(org.keycloak.testsuite.util.OAuthClient) Client(javax.ws.rs.client.Client) AccessTokenResponse(org.keycloak.representations.AccessTokenResponse) AbstractKeycloakTest(org.keycloak.testsuite.AbstractKeycloakTest) Test(org.junit.Test)

Example 12 with UserInfo

use of org.keycloak.representations.UserInfo in project keycloak by keycloak.

the class UserInfoTest method testRolesAreAvailable_getMethod_header.

@Test
public void testRolesAreAvailable_getMethod_header() throws Exception {
    switchIncludeRolesInUserInfoEndpoint(true);
    Client client = AdminClientUtil.createResteasyClient();
    try {
        AccessTokenResponse accessTokenResponse = executeGrantAccessTokenRequest(client);
        Response response = UserInfoClientUtil.executeUserInfoRequest_getMethod(client, accessTokenResponse.getToken());
        UserInfo userInfo = testSuccessfulUserInfoResponse(response);
        testRolesInUserInfoResponse(userInfo);
    } finally {
        client.close();
        switchIncludeRolesInUserInfoEndpoint(false);
    }
}
Also used : AccessTokenResponse(org.keycloak.representations.AccessTokenResponse) Response(javax.ws.rs.core.Response) UserInfo(org.keycloak.representations.UserInfo) OAuthClient(org.keycloak.testsuite.util.OAuthClient) Client(javax.ws.rs.client.Client) AccessTokenResponse(org.keycloak.representations.AccessTokenResponse) AbstractKeycloakTest(org.keycloak.testsuite.AbstractKeycloakTest) Test(org.junit.Test)

Aggregations

UserInfo (org.keycloak.representations.UserInfo)12 OAuthClient (org.keycloak.testsuite.util.OAuthClient)11 Test (org.junit.Test)10 AbstractKeycloakTest (org.keycloak.testsuite.AbstractKeycloakTest)8 Client (javax.ws.rs.client.Client)7 Response (javax.ws.rs.core.Response)7 ClientResource (org.keycloak.admin.client.resource.ClientResource)4 AccessTokenResponse (org.keycloak.representations.AccessTokenResponse)4 AccessToken (org.keycloak.representations.AccessToken)3 ClientRepresentation (org.keycloak.representations.idm.ClientRepresentation)3 URI (java.net.URI)2 JWSInput (org.keycloak.jose.jws.JWSInput)2 IDToken (org.keycloak.representations.IDToken)2 EventRepresentation (org.keycloak.representations.idm.EventRepresentation)2 UserRepresentation (org.keycloak.representations.idm.UserRepresentation)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 PublicKey (java.security.PublicKey)1 HashMap (java.util.HashMap)1 HttpResponse (org.apache.http.HttpResponse)1 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)1