[KEYCLOAK-6321] - Tests
This commit is contained in:
parent
d590600c12
commit
61d5425fdf
1 changed files with 31 additions and 0 deletions
|
@ -20,8 +20,10 @@ package org.keycloak.testsuite.admin.client.authorization;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.keycloak.admin.client.resource.ClientResource;
|
import org.keycloak.admin.client.resource.ClientResource;
|
||||||
|
import org.keycloak.admin.client.resource.RealmResource;
|
||||||
import org.keycloak.representations.adapters.config.PolicyEnforcerConfig;
|
import org.keycloak.representations.adapters.config.PolicyEnforcerConfig;
|
||||||
import org.keycloak.representations.idm.ClientRepresentation;
|
import org.keycloak.representations.idm.ClientRepresentation;
|
||||||
|
import org.keycloak.representations.idm.RealmRepresentation;
|
||||||
import org.keycloak.representations.idm.authorization.PolicyRepresentation;
|
import org.keycloak.representations.idm.authorization.PolicyRepresentation;
|
||||||
import org.keycloak.representations.idm.authorization.ResourceRepresentation;
|
import org.keycloak.representations.idm.authorization.ResourceRepresentation;
|
||||||
import org.keycloak.representations.idm.authorization.ResourceServerRepresentation;
|
import org.keycloak.representations.idm.authorization.ResourceServerRepresentation;
|
||||||
|
@ -29,6 +31,7 @@ import org.keycloak.representations.idm.authorization.ResourceServerRepresentati
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -55,4 +58,32 @@ public class AuthorizationTest extends AbstractAuthorizationTest {
|
||||||
|
|
||||||
assertEquals(2, defaultPolicies.size());
|
assertEquals(2, defaultPolicies.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// KEYCLOAK-6321
|
||||||
|
@Test
|
||||||
|
public void testRemoveDefaultResourceWithAdminEventsEnabled() {
|
||||||
|
RealmResource realmResource = testRealmResource();
|
||||||
|
RealmRepresentation realmRepresentation = realmResource.toRepresentation();
|
||||||
|
|
||||||
|
realmRepresentation.setAdminEventsEnabled(true);
|
||||||
|
|
||||||
|
realmResource.update(realmRepresentation);
|
||||||
|
|
||||||
|
ClientResource clientResource = getClientResource();
|
||||||
|
ClientRepresentation resourceServer = getResourceServer();
|
||||||
|
|
||||||
|
enableAuthorizationServices();
|
||||||
|
|
||||||
|
ResourceServerRepresentation settings = clientResource.authorization().getSettings();
|
||||||
|
|
||||||
|
assertEquals(PolicyEnforcerConfig.EnforcementMode.ENFORCING.name(), settings.getPolicyEnforcementMode().name());
|
||||||
|
assertEquals(resourceServer.getId(), settings.getClientId());
|
||||||
|
List<ResourceRepresentation> defaultResources = clientResource.authorization().resources().resources();
|
||||||
|
|
||||||
|
assertEquals(1, defaultResources.size());
|
||||||
|
|
||||||
|
clientResource.authorization().resources().resource(defaultResources.get(0).getId()).remove();
|
||||||
|
|
||||||
|
assertTrue(clientResource.authorization().resources().resources().isEmpty());
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue