Search in sources :

Example 6 with PartialImportResults

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

the class PartialImportTest method testAddClientRoles.

@Test
public void testAddClientRoles() {
    setFail();
    addClientRoles();
    PartialImportResults results = doImport();
    assertEquals(NUM_ENTITIES, results.getAdded());
    List<RoleRepresentation> clientRoles = clientRolesClient().roles().list();
    assertEquals(NUM_ENTITIES, clientRoles.size());
    for (RoleRepresentation roleRep : clientRoles) {
        assertTrue(roleRep.getName().startsWith(CLIENT_ROLE_PREFIX));
    }
}
Also used : RoleRepresentation(org.keycloak.representations.idm.RoleRepresentation) PartialImportResults(org.keycloak.partialimport.PartialImportResults) AbstractAuthTest(org.keycloak.testsuite.AbstractAuthTest) Test(org.junit.Test)

Example 7 with PartialImportResults

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

the class PartialImportTest method testEverythingOverwriteWithServiceAccounts.

@EnableFeature(value = UPLOAD_SCRIPTS, skipRestart = true)
@Test
public void testEverythingOverwriteWithServiceAccounts() throws IOException {
    setOverwrite();
    importEverything(true);
    PartialImportResults results = doImport();
    assertEquals(NUM_ENTITIES * (NUM_RESOURCE_TYPES + 1), results.getOverwritten());
}
Also used : PartialImportResults(org.keycloak.partialimport.PartialImportResults) AbstractAuthTest(org.keycloak.testsuite.AbstractAuthTest) Test(org.junit.Test) EnableFeature(org.keycloak.testsuite.arquillian.annotation.EnableFeature)

Example 8 with PartialImportResults

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

the class PartialImportTest method testEverythingFail.

@Test
public void testEverythingFail() throws IOException {
    setFail();
    importEverything(false);
    // second import will fail because not allowed to skip or overwrite
    PartialImportResults results = doImport();
    assertNotNull(results.getErrorMessage());
}
Also used : PartialImportResults(org.keycloak.partialimport.PartialImportResults) AbstractAuthTest(org.keycloak.testsuite.AbstractAuthTest) Test(org.junit.Test)

Example 9 with PartialImportResults

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

the class PartialImportTest method testEverythingSkipWithServiceAccounts.

@EnableFeature(value = UPLOAD_SCRIPTS, skipRestart = true)
@Test
public void testEverythingSkipWithServiceAccounts() throws IOException {
    setSkip();
    importEverything(true);
    PartialImportResults results = doImport();
    assertEquals(NUM_ENTITIES * (NUM_RESOURCE_TYPES + 1), results.getSkipped());
}
Also used : PartialImportResults(org.keycloak.partialimport.PartialImportResults) AbstractAuthTest(org.keycloak.testsuite.AbstractAuthTest) Test(org.junit.Test) EnableFeature(org.keycloak.testsuite.arquillian.annotation.EnableFeature)

Example 10 with PartialImportResults

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

the class PartialImportTest method testAddRealmRoles.

@Test
public void testAddRealmRoles() {
    setFail();
    addRealmRoles();
    PartialImportResults results = doImport();
    assertEquals(NUM_ENTITIES, results.getAdded());
    for (PartialImportResult result : results.getResults()) {
        String name = result.getResourceName();
        RoleResource roleRsc = testRealmResource().roles().get(name);
        RoleRepresentation role = roleRsc.toRepresentation();
        assertTrue(role.getName().startsWith(REALM_ROLE_PREFIX));
    }
}
Also used : RoleRepresentation(org.keycloak.representations.idm.RoleRepresentation) PartialImportResult(org.keycloak.partialimport.PartialImportResult) PartialImportResults(org.keycloak.partialimport.PartialImportResults) RoleResource(org.keycloak.admin.client.resource.RoleResource) AbstractAuthTest(org.keycloak.testsuite.AbstractAuthTest) Test(org.junit.Test)

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