use of org.keycloak.partialimport.PartialImportResults in project keycloak by keycloak.
the class PartialImportTest method testAddUsersWithDuplicateEmailsAllowed.
@Test
public void testAddUsersWithDuplicateEmailsAllowed() {
RealmRepresentation realmRep = testRealmResource().toRepresentation();
realmRep.setDuplicateEmailsAllowed(true);
testRealmResource().update(realmRep);
assertAdminEvents.clear();
setFail();
addUsers();
doImport();
UserRepresentation user = createUserRepresentation(USER_PREFIX + 999, USER_PREFIX + 1 + "@foo.com", "foo", "bar", true);
piRep.setUsers(Arrays.asList(user));
PartialImportResults results = doImport();
assertEquals(1, results.getAdded());
}
use of org.keycloak.partialimport.PartialImportResults in project keycloak by keycloak.
the class PartialImportTest method testOverwrite.
private void testOverwrite() {
setOverwrite();
PartialImportResults results = doImport();
assertEquals(NUM_ENTITIES, results.getAdded());
results = doImport();
assertEquals(NUM_ENTITIES, results.getOverwritten());
}
use of org.keycloak.partialimport.PartialImportResults in project keycloak by keycloak.
the class PartialImportTest method testAddUsersWithTermsAndConditions.
@Test
public void testAddUsersWithTermsAndConditions() {
assertAdminEvents.clear();
setFail();
addUsersWithTermsAndConditions();
PartialImportResults results = doImport();
assertEquals(NUM_ENTITIES, results.getAdded());
// Need to do this way as admin events from partial import are unsorted
Set<String> userIds = new HashSet<>();
for (int i = 0; i < NUM_ENTITIES; i++) {
AdminEventRepresentation adminEvent = assertAdminEvents.poll();
Assert.assertEquals(realmId, adminEvent.getRealmId());
Assert.assertEquals(OperationType.CREATE.name(), adminEvent.getOperationType());
Assert.assertTrue(adminEvent.getResourcePath().startsWith("users/"));
String userId = adminEvent.getResourcePath().substring(6);
userIds.add(userId);
}
assertAdminEvents.assertEmpty();
for (PartialImportResult result : results.getResults()) {
String id = result.getId();
UserResource userRsc = testRealmResource().users().get(id);
UserRepresentation user = userRsc.toRepresentation();
assertTrue(user.getUsername().startsWith(USER_PREFIX));
Assert.assertTrue(userIds.contains(id));
}
}
use of org.keycloak.partialimport.PartialImportResults in project keycloak by keycloak.
the class PartialImportTest method testAddUsers.
@Test
public void testAddUsers() {
assertAdminEvents.clear();
setFail();
addUsers();
PartialImportResults results = doImport();
assertEquals(NUM_ENTITIES, results.getAdded());
// Need to do this way as admin events from partial import are unsorted
Set<String> userIds = new HashSet<>();
for (int i = 0; i < NUM_ENTITIES; i++) {
AdminEventRepresentation adminEvent = assertAdminEvents.poll();
Assert.assertEquals(realmId, adminEvent.getRealmId());
Assert.assertEquals(OperationType.CREATE.name(), adminEvent.getOperationType());
Assert.assertTrue(adminEvent.getResourcePath().startsWith("users/"));
String userId = adminEvent.getResourcePath().substring(6);
userIds.add(userId);
}
assertAdminEvents.assertEmpty();
for (PartialImportResult result : results.getResults()) {
String id = result.getId();
UserResource userRsc = testRealmResource().users().get(id);
UserRepresentation user = userRsc.toRepresentation();
Assert.assertThat(user.getUsername(), startsWith(USER_PREFIX));
Assert.assertThat(userIds, hasItem(id));
}
}
use of org.keycloak.partialimport.PartialImportResults in project keycloak by keycloak.
the class PartialImportTest method testAddClients.
@Test
public void testAddClients() throws IOException {
setFail();
addClients(false);
PartialImportResults results = doImport();
assertEquals(NUM_ENTITIES, results.getAdded());
for (PartialImportResult result : results.getResults()) {
String id = result.getId();
ClientResource clientRsc = testRealmResource().clients().get(id);
ClientRepresentation client = clientRsc.toRepresentation();
assertTrue(client.getName().startsWith(CLIENT_PREFIX));
}
}
Aggregations