use of org.keycloak.partialimport.PartialImportResults in project keycloak by keycloak.
the class PartialImportTest method testAddClientsSkipWithServiceAccountsAndAuthorization.
@EnableFeature(value = UPLOAD_SCRIPTS, skipRestart = true)
@Test
public void testAddClientsSkipWithServiceAccountsAndAuthorization() throws IOException {
addClients(true);
setSkip();
PartialImportResults results = doImport();
assertEquals(NUM_ENTITIES * 2, results.getAdded());
results = doImport();
assertEquals(NUM_ENTITIES * 2, results.getSkipped());
}
use of org.keycloak.partialimport.PartialImportResults in project keycloak by keycloak.
the class PartialImportTest method importEverything.
private void importEverything(boolean withServiceAccounts) throws IOException {
addUsers();
addGroups();
addClients(withServiceAccounts);
addProviders();
addRealmRoles();
addClientRoles();
PartialImportResults results = doImport();
assertNull(results.getErrorMessage());
if (withServiceAccounts) {
assertEquals(NUM_ENTITIES * (NUM_RESOURCE_TYPES + 1), results.getAdded());
} else {
assertEquals(NUM_ENTITIES * NUM_RESOURCE_TYPES, results.getAdded());
}
}
use of org.keycloak.partialimport.PartialImportResults in project keycloak by keycloak.
the class PartialImportTest method testOverwriteExistingInternalClient.
// KEYCLOAK-6058
@Test
public void testOverwriteExistingInternalClient() {
setOverwrite();
ClientRepresentation client = adminClient.realm(MASTER).clients().findByClientId("security-admin-console").get(0);
ClientRepresentation client2 = adminClient.realm(MASTER).clients().findByClientId("master-realm").get(0);
piRep.setClients(Arrays.asList(client, client2));
PartialImportResults result = doImport();
Assert.assertEquals(0, result.getOverwritten());
}
use of org.keycloak.partialimport.PartialImportResults in project keycloak by keycloak.
the class PartialImportTest method testAddClientsWithServiceAccountsAndAuthorization.
@EnableFeature(value = UPLOAD_SCRIPTS, skipRestart = true)
@Test
public void testAddClientsWithServiceAccountsAndAuthorization() throws IOException {
setFail();
addClients(true);
PartialImportResults results = doImport();
assertEquals(NUM_ENTITIES * 2, results.getAdded());
for (PartialImportResult result : results.getResults()) {
if (result.getResourceType().equals(ResourceType.CLIENT)) {
String id = result.getId();
ClientResource clientRsc = testRealmResource().clients().get(id);
ClientRepresentation client = clientRsc.toRepresentation();
assertTrue(client.getName().startsWith(CLIENT_PREFIX));
Assert.assertTrue(client.isServiceAccountsEnabled());
if (ProfileAssume.isFeatureEnabled(AUTHORIZATION)) {
Assert.assertTrue(client.getAuthorizationServicesEnabled());
AuthorizationResource authRsc = clientRsc.authorization();
ResourceServerRepresentation authRep = authRsc.exportSettings();
Assert.assertNotNull(authRep);
Assert.assertEquals(2, authRep.getResources().size());
Assert.assertEquals(3, authRep.getPolicies().size());
} else {
Assert.assertNull(client.getAuthorizationServicesEnabled());
}
} else {
UserResource userRsc = testRealmResource().users().get(result.getId());
Assert.assertTrue(userRsc.toRepresentation().getUsername().startsWith(ServiceAccountConstants.SERVICE_ACCOUNT_USER_PREFIX + CLIENT_PREFIX));
}
}
}
use of org.keycloak.partialimport.PartialImportResults in project keycloak by keycloak.
the class PartialImportTest method testEverythingSkip.
@Test
public void testEverythingSkip() throws IOException {
setSkip();
importEverything(false);
PartialImportResults results = doImport();
assertEquals(NUM_ENTITIES * NUM_RESOURCE_TYPES, results.getSkipped());
}
Aggregations