Search in sources :

Example 1 with SynchronizationResultRepresentation

use of org.keycloak.representations.idm.SynchronizationResultRepresentation in project keycloak by keycloak.

the class LDAPSyncTest method test07SyncRestAPIWrongAction.

// KEYCLOAK-10770 user-storage/{id}/sync should return 400 instead of 404
@Test
public void test07SyncRestAPIWrongAction() {
    ComponentRepresentation ldapRep = testRealm().components().component(ldapModelId).toRepresentation();
    try {
        SynchronizationResultRepresentation syncResultRep = adminClient.realm("test").userStorage().syncUsers(ldapModelId, "wrong action");
        Assert.fail("Should throw 400");
    } catch (Exception e) {
        Assert.assertTrue(e instanceof BadRequestException);
    }
}
Also used : ComponentRepresentation(org.keycloak.representations.idm.ComponentRepresentation) SynchronizationResultRepresentation(org.keycloak.representations.idm.SynchronizationResultRepresentation) BadRequestException(javax.ws.rs.BadRequestException) BadRequestException(javax.ws.rs.BadRequestException) Test(org.junit.Test)

Example 2 with SynchronizationResultRepresentation

use of org.keycloak.representations.idm.SynchronizationResultRepresentation in project keycloak by keycloak.

the class LDAPSyncTest method test06SyncRestAPIMissingAction.

// KEYCLOAK-10770 user-storage/{id}/sync should return 400 instead of 404
@Test
public void test06SyncRestAPIMissingAction() {
    ComponentRepresentation ldapRep = testRealm().components().component(ldapModelId).toRepresentation();
    try {
        SynchronizationResultRepresentation syncResultRep = adminClient.realm("test").userStorage().syncUsers(ldapModelId, null);
        Assert.fail("Should throw 400");
    } catch (Exception e) {
        Assert.assertTrue(e instanceof BadRequestException);
    }
}
Also used : ComponentRepresentation(org.keycloak.representations.idm.ComponentRepresentation) SynchronizationResultRepresentation(org.keycloak.representations.idm.SynchronizationResultRepresentation) BadRequestException(javax.ws.rs.BadRequestException) BadRequestException(javax.ws.rs.BadRequestException) Test(org.junit.Test)

Example 3 with SynchronizationResultRepresentation

use of org.keycloak.representations.idm.SynchronizationResultRepresentation in project keycloak by keycloak.

the class LDAPGroupMapperSyncTest method test05SyncRestAPI.

@Test
public void test05SyncRestAPI() {
    ComponentRepresentation groupMapperRep = findMapperRepByName("groupsMapper");
    try {
        // testing KEYCLOAK-3980 which threw an NPE because I was looking up the factory wrong.
        SynchronizationResultRepresentation syncResultRep = adminClient.realm("test").userStorage().syncMapperData(ldapModelId, groupMapperRep.getId(), "error");
        Assert.fail("Should throw 400");
    } catch (BadRequestException e) {
    }
}
Also used : ComponentRepresentation(org.keycloak.representations.idm.ComponentRepresentation) SynchronizationResultRepresentation(org.keycloak.representations.idm.SynchronizationResultRepresentation) BadRequestException(javax.ws.rs.BadRequestException) Test(org.junit.Test)

Aggregations

BadRequestException (javax.ws.rs.BadRequestException)3 Test (org.junit.Test)3 ComponentRepresentation (org.keycloak.representations.idm.ComponentRepresentation)3 SynchronizationResultRepresentation (org.keycloak.representations.idm.SynchronizationResultRepresentation)3