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());
}
}
Aggregations