use of org.apache.syncope.common.lib.patch.DeassociationPatch in project syncope by apache.
the class AuthenticationITCase method issueSYNCOPE164.
@Test
public void issueSYNCOPE164() throws Exception {
// 1. create user with db resource
UserTO user = UserITCase.getUniqueSampleTO("syncope164@syncope.apache.org");
user.setRealm("/even/two");
user.setPassword("password123");
user.getResources().add(RESOURCE_NAME_TESTDB);
user = createUser(user).getEntity();
assertNotNull(user);
// 2. unlink the resource from the created user
DeassociationPatch deassociationPatch = new DeassociationPatch.Builder().key(user.getKey()).action(ResourceDeassociationAction.UNLINK).resource(RESOURCE_NAME_TESTDB).build();
assertNotNull(userService.deassociate(deassociationPatch).readEntity(BulkActionResult.class));
// 3. change password on Syncope
UserPatch userPatch = new UserPatch();
userPatch.setKey(user.getKey());
userPatch.setPassword(new PasswordPatch.Builder().value("password234").build());
user = updateUser(userPatch).getEntity();
assertNotNull(user);
// 4. check that the db resource has still the initial password value
final JdbcTemplate jdbcTemplate = new JdbcTemplate(testDataSource);
String value = queryForObject(jdbcTemplate, 50, "SELECT PASSWORD FROM test WHERE ID=?", String.class, user.getUsername());
assertEquals(Encryptor.getInstance().encode("password123", CipherAlgorithm.SHA1), value.toUpperCase());
// 5. successfully authenticate with old (on db resource) and new (on internal storage) password values
Pair<Map<String, Set<String>>, UserTO> self = clientFactory.create(user.getUsername(), "password123").self();
assertNotNull(self);
self = clientFactory.create(user.getUsername(), "password234").self();
assertNotNull(self);
}
use of org.apache.syncope.common.lib.patch.DeassociationPatch in project syncope by apache.
the class GroupITCase method unlink.
@Test
public void unlink() {
GroupTO actual = createGroup(getSampleTO("unlink")).getEntity();
assertNotNull(actual);
assertNotNull(resourceService.readConnObject(RESOURCE_NAME_LDAP, AnyTypeKind.GROUP.name(), actual.getKey()));
DeassociationPatch deassociationPatch = new DeassociationPatch.Builder().key(actual.getKey()).action(ResourceDeassociationAction.UNLINK).resource(RESOURCE_NAME_LDAP).build();
assertNotNull(groupService.deassociate(deassociationPatch).readEntity(BulkActionResult.class));
actual = groupService.read(actual.getKey());
assertNotNull(actual);
assertTrue(actual.getResources().isEmpty());
assertNotNull(resourceService.readConnObject(RESOURCE_NAME_LDAP, AnyTypeKind.GROUP.name(), actual.getKey()));
}
use of org.apache.syncope.common.lib.patch.DeassociationPatch in project syncope by apache.
the class UserITCase method deprovisionUnlinked.
@Test
public void deprovisionUnlinked() {
UserTO userTO = getUniqueSampleTO("provision@syncope.apache.org");
userTO.getResources().clear();
userTO.getMemberships().clear();
userTO.getVirAttrs().clear();
userTO.getAuxClasses().add("csv");
UserTO actual = createUser(userTO).getEntity();
assertNotNull(actual);
assertTrue(actual.getResources().isEmpty());
try {
resourceService.readConnObject(RESOURCE_NAME_CSV, AnyTypeKind.USER.name(), actual.getKey());
fail("This should not happen");
} catch (Exception e) {
assertNotNull(e);
}
AssociationPatch associationPatch = new AssociationPatch.Builder().key(actual.getKey()).value("password").action(ResourceAssociationAction.PROVISION).resource(RESOURCE_NAME_CSV).build();
assertNotNull(userService.associate(associationPatch).readEntity(BulkActionResult.class));
actual = userService.read(actual.getKey());
assertNotNull(actual);
assertTrue(actual.getResources().isEmpty());
assertNotNull(resourceService.readConnObject(RESOURCE_NAME_CSV, AnyTypeKind.USER.name(), actual.getKey()));
DeassociationPatch deassociationPatch = new DeassociationPatch.Builder().key(actual.getKey()).action(ResourceDeassociationAction.DEPROVISION).resource(RESOURCE_NAME_CSV).build();
assertNotNull(userService.deassociate(deassociationPatch).readEntity(BulkActionResult.class));
actual = userService.read(actual.getKey());
assertNotNull(actual);
assertTrue(actual.getResources().isEmpty());
try {
resourceService.readConnObject(RESOURCE_NAME_CSV, AnyTypeKind.USER.name(), actual.getKey());
fail("This should not happen");
} catch (Exception e) {
assertNotNull(e);
}
}
use of org.apache.syncope.common.lib.patch.DeassociationPatch in project syncope by apache.
the class UserITCase method unassign.
@Test
public void unassign() {
UserTO userTO = getUniqueSampleTO("unassign@syncope.apache.org");
userTO.getResources().clear();
userTO.getMemberships().clear();
userTO.getVirAttrs().clear();
userTO.getAuxClasses().add("csv");
userTO.getResources().add(RESOURCE_NAME_CSV);
UserTO actual = createUser(userTO).getEntity();
assertNotNull(actual);
assertNotNull(resourceService.readConnObject(RESOURCE_NAME_CSV, AnyTypeKind.USER.name(), actual.getKey()));
DeassociationPatch deassociationPatch = new DeassociationPatch.Builder().key(actual.getKey()).action(ResourceDeassociationAction.UNASSIGN).resource(RESOURCE_NAME_CSV).build();
assertNotNull(userService.deassociate(deassociationPatch).readEntity(BulkActionResult.class));
actual = userService.read(actual.getKey());
assertNotNull(actual);
assertTrue(actual.getResources().isEmpty());
try {
resourceService.readConnObject(RESOURCE_NAME_CSV, AnyTypeKind.USER.name(), actual.getKey());
fail("This should not happen");
} catch (Exception e) {
assertNotNull(e);
}
}
use of org.apache.syncope.common.lib.patch.DeassociationPatch in project syncope by apache.
the class UserITCase method deprovision.
@Test
public void deprovision() {
UserTO userTO = getUniqueSampleTO("deprovision@syncope.apache.org");
userTO.getResources().clear();
userTO.getMemberships().clear();
userTO.getVirAttrs().clear();
userTO.getAuxClasses().add("csv");
userTO.getResources().add(RESOURCE_NAME_CSV);
UserTO actual = createUser(userTO).getEntity();
assertNotNull(actual);
assertNotNull(resourceService.readConnObject(RESOURCE_NAME_CSV, AnyTypeKind.USER.name(), actual.getKey()));
DeassociationPatch deassociationPatch = new DeassociationPatch.Builder().key(actual.getKey()).action(ResourceDeassociationAction.DEPROVISION).resource(RESOURCE_NAME_CSV).build();
assertNotNull(userService.deassociate(deassociationPatch).readEntity(BulkActionResult.class));
actual = userService.read(actual.getKey());
assertNotNull(actual);
assertFalse(actual.getResources().isEmpty());
try {
resourceService.readConnObject(RESOURCE_NAME_CSV, AnyTypeKind.USER.name(), actual.getKey());
fail("This should not happen");
} catch (SyncopeClientException e) {
assertEquals(ClientExceptionType.NotFound, e.getType());
}
}
Aggregations