Search in sources :

Example 11 with Metadata

use of org.keycloak.representations.idm.authorization.AuthorizationRequest.Metadata in project keycloak by keycloak.

the class EntitlementAPITest method testRequestWithoutClaimsFromPublicClient.

@Test
public void testRequestWithoutClaimsFromPublicClient() {
    oauth.realm("authz-test");
    oauth.clientId(PUBLIC_TEST_CLIENT);
    oauth.doLogin("marta", "password");
    // Token request
    String code = oauth.getCurrentQuery().get(OAuth2Constants.CODE);
    OAuthClient.AccessTokenResponse response = oauth.doAccessTokenRequest(code, null);
    AuthorizationRequest request = new AuthorizationRequest();
    request.addPermission("Resource 13");
    assertResponse(new Metadata(), () -> getAuthzClient(AUTHZ_CLIENT_CONFIG).authorization(response.getAccessToken()).authorize(request));
}
Also used : AuthorizationRequest(org.keycloak.representations.idm.authorization.AuthorizationRequest) OAuthClient(org.keycloak.testsuite.util.OAuthClient) Metadata(org.keycloak.representations.idm.authorization.AuthorizationRequest.Metadata) Test(org.junit.Test)

Aggregations

Metadata (org.keycloak.representations.idm.authorization.AuthorizationRequest.Metadata)11 AuthorizationRequest (org.keycloak.representations.idm.authorization.AuthorizationRequest)6 Permission (org.keycloak.representations.idm.authorization.Permission)4 HashMap (java.util.HashMap)3 Test (org.junit.Test)3 AccessToken (org.keycloak.representations.AccessToken)3 LinkedHashMap (java.util.LinkedHashMap)2 AuthorizationProvider (org.keycloak.authorization.AuthorizationProvider)2 KeycloakIdentity (org.keycloak.authorization.common.KeycloakIdentity)2 ResourcePermission (org.keycloak.authorization.permission.ResourcePermission)2 ResourceStore (org.keycloak.authorization.store.ResourceStore)2 StoreFactory (org.keycloak.authorization.store.StoreFactory)2 ClientModel (org.keycloak.models.ClientModel)2 AuthorizationResponse (org.keycloak.representations.idm.authorization.AuthorizationResponse)2 PermissionTicketToken (org.keycloak.representations.idm.authorization.PermissionTicketToken)2 CorsErrorResponseException (org.keycloak.services.CorsErrorResponseException)2 ArrayList (java.util.ArrayList)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 Response (javax.ws.rs.core.Response)1