Search in sources :

Example 21 with PartialImportResults

use of org.keycloak.partialimport.PartialImportResults in project keycloak by keycloak.

the class PartialImportTest method testAddClientsOverwriteServiceAccountsWithNoServiceAccounts.

@EnableFeature(value = UPLOAD_SCRIPTS, skipRestart = true)
@Test
public void testAddClientsOverwriteServiceAccountsWithNoServiceAccounts() throws IOException {
    addClients(true);
    setOverwrite();
    PartialImportResults results = doImport();
    assertEquals(NUM_ENTITIES * 2, results.getAdded());
    // check the service accounts are there
    for (int i = 0; i < NUM_ENTITIES; i++) {
        List<UserRepresentation> l = testRealmResource().users().search(ServiceAccountConstants.SERVICE_ACCOUNT_USER_PREFIX + CLIENT_PREFIX + i);
        Assert.assertEquals(1, l.size());
    }
    // re-import without service accounts enabled
    piRep = new PartialImportRepresentation();
    addClients(false);
    setOverwrite();
    results = doImport();
    assertEquals(NUM_ENTITIES, results.getOverwritten());
    // check the service accounts have been removed
    for (int i = 0; i < NUM_ENTITIES; i++) {
        List<UserRepresentation> l = testRealmResource().users().search(ServiceAccountConstants.SERVICE_ACCOUNT_USER_PREFIX + CLIENT_PREFIX + i);
        Assert.assertEquals(0, l.size());
    }
}
Also used : PartialImportRepresentation(org.keycloak.representations.idm.PartialImportRepresentation) PartialImportResults(org.keycloak.partialimport.PartialImportResults) UserRepresentation(org.keycloak.representations.idm.UserRepresentation) AbstractAuthTest(org.keycloak.testsuite.AbstractAuthTest) Test(org.junit.Test) EnableFeature(org.keycloak.testsuite.arquillian.annotation.EnableFeature)

Aggregations

PartialImportResults (org.keycloak.partialimport.PartialImportResults)21 Test (org.junit.Test)17 AbstractAuthTest (org.keycloak.testsuite.AbstractAuthTest)17 PartialImportResult (org.keycloak.partialimport.PartialImportResult)6 EnableFeature (org.keycloak.testsuite.arquillian.annotation.EnableFeature)6 UserRepresentation (org.keycloak.representations.idm.UserRepresentation)4 UserResource (org.keycloak.admin.client.resource.UserResource)3 ClientRepresentation (org.keycloak.representations.idm.ClientRepresentation)3 HashSet (java.util.HashSet)2 ClientResource (org.keycloak.admin.client.resource.ClientResource)2 AdminEventRepresentation (org.keycloak.representations.idm.AdminEventRepresentation)2 RoleRepresentation (org.keycloak.representations.idm.RoleRepresentation)2 AuthorizationResource (org.keycloak.admin.client.resource.AuthorizationResource)1 IdentityProviderResource (org.keycloak.admin.client.resource.IdentityProviderResource)1 RoleResource (org.keycloak.admin.client.resource.RoleResource)1 IdentityProviderRepresentation (org.keycloak.representations.idm.IdentityProviderRepresentation)1 PartialImportRepresentation (org.keycloak.representations.idm.PartialImportRepresentation)1 RealmRepresentation (org.keycloak.representations.idm.RealmRepresentation)1 ResourceServerRepresentation (org.keycloak.representations.idm.authorization.ResourceServerRepresentation)1