use of org.apache.syncope.common.lib.to.PlainSchemaTO in project syncope by apache.
the class PlainSchemaITCase method createEncrypted.
@Test
public void createEncrypted() {
PlainSchemaTO schemaTO = new PlainSchemaTO();
schemaTO.setKey("encrypted");
schemaTO.setType(AttrSchemaType.Encrypted);
schemaTO.setCipherAlgorithm(CipherAlgorithm.AES);
schemaTO.setSecretKey("huhadfhsjfsfsdkj!####");
createSchema(SchemaType.PLAIN, schemaTO);
}
use of org.apache.syncope.common.lib.to.PlainSchemaTO in project syncope by apache.
the class PlainSchemaITCase method update.
@Test
public void update() {
PlainSchemaTO schemaTO = schemaService.read(SchemaType.PLAIN, "icon");
assertNotNull(schemaTO);
schemaService.update(SchemaType.PLAIN, schemaTO);
PlainSchemaTO updatedTO = schemaService.read(SchemaType.PLAIN, "icon");
assertEquals(schemaTO, updatedTO);
updatedTO.setType(AttrSchemaType.Date);
try {
schemaService.update(SchemaType.PLAIN, updatedTO);
fail("This should not be reacheable");
} catch (SyncopeClientException e) {
assertEquals(ClientExceptionType.InvalidPlainSchema, e.getType());
}
}
use of org.apache.syncope.common.lib.to.PlainSchemaTO in project syncope by apache.
the class PlainSchemaITCase method issueSYNCOPE323.
@Test
public void issueSYNCOPE323() {
PlainSchemaTO actual = schemaService.read(SchemaType.PLAIN, "icon");
assertNotNull(actual);
try {
createSchema(SchemaType.PLAIN, actual);
fail("This should not happen");
} catch (SyncopeClientException e) {
assertEquals(Response.Status.CONFLICT, e.getType().getResponseStatus());
assertEquals(ClientExceptionType.EntityExists, e.getType());
}
actual.setKey(null);
try {
createSchema(SchemaType.PLAIN, actual);
fail("This should not happen");
} catch (SyncopeClientException e) {
assertEquals(Response.Status.BAD_REQUEST, e.getType().getResponseStatus());
assertEquals(ClientExceptionType.RequiredValuesMissing, e.getType());
}
}
use of org.apache.syncope.common.lib.to.PlainSchemaTO in project syncope by apache.
the class GroupITCase method issueSYNCOPE717.
@Test
public void issueSYNCOPE717() {
String doubleSchemaName = "double" + getUUIDString();
// 1. create double schema without conversion pattern
PlainSchemaTO schema = new PlainSchemaTO();
schema.setKey(doubleSchemaName);
schema.setType(AttrSchemaType.Double);
schema = createSchema(SchemaType.PLAIN, schema);
assertNotNull(schema);
assertNull(schema.getConversionPattern());
AnyTypeClassTO minimalGroup = anyTypeClassService.read("minimal group");
assertNotNull(minimalGroup);
minimalGroup.getPlainSchemas().add(doubleSchemaName);
anyTypeClassService.update(minimalGroup);
// 2. create group, provide valid input value
GroupTO groupTO = GroupITCase.getBasicSampleTO("syncope717");
groupTO.getPlainAttrs().add(attrTO(doubleSchemaName, "11.23"));
groupTO = createGroup(groupTO).getEntity();
assertNotNull(groupTO);
assertEquals("11.23", groupTO.getPlainAttr(doubleSchemaName).get().getValues().get(0));
// 3. update schema, set conversion pattern
schema = schemaService.read(SchemaType.PLAIN, schema.getKey());
schema.setConversionPattern("0.000");
schemaService.update(SchemaType.PLAIN, schema);
// 4. re-read group, verify that pattern was applied
groupTO = groupService.read(groupTO.getKey());
assertNotNull(groupTO);
assertEquals("11.230", groupTO.getPlainAttr(doubleSchemaName).get().getValues().get(0));
// 5. modify group with new double value
GroupPatch patch = new GroupPatch();
patch.setKey(groupTO.getKey());
patch.getPlainAttrs().add(new AttrPatch.Builder().attrTO(attrTO(doubleSchemaName, "11.257")).build());
groupTO = updateGroup(patch).getEntity();
assertNotNull(groupTO);
assertEquals("11.257", groupTO.getPlainAttr(doubleSchemaName).get().getValues().get(0));
// 6. update schema, unset conversion pattern
schema.setConversionPattern(null);
schemaService.update(SchemaType.PLAIN, schema);
// 7. modify group with new double value, verify that no pattern is applied
patch = new GroupPatch();
patch.setKey(groupTO.getKey());
patch.getPlainAttrs().add(new AttrPatch.Builder().attrTO(attrTO(doubleSchemaName, "11.23")).build());
groupTO = updateGroup(patch).getEntity();
assertNotNull(groupTO);
assertEquals("11.23", groupTO.getPlainAttr(doubleSchemaName).get().getValues().get(0));
}
use of org.apache.syncope.common.lib.to.PlainSchemaTO in project syncope by apache.
the class NotificationWizardBuilder method getSchemas.
private List<String> getSchemas() {
AnyTypeTO type = null;
try {
type = anyTypeRestClient.read(AnyTypeKind.USER.name());
} catch (SyncopeClientException e) {
LOG.error("While reading all any types", e);
}
String[] anyTypeClasses = type == null ? new String[0] : type.getClasses().toArray(new String[] {});
List<String> result = new ArrayList<>();
result.add("username");
result.addAll(schemaRestClient.<PlainSchemaTO>getSchemas(SchemaType.PLAIN, null, anyTypeClasses).stream().map(EntityTO::getKey).collect(Collectors.toList()));
result.addAll(schemaRestClient.<DerSchemaTO>getSchemas(SchemaType.DERIVED, null, anyTypeClasses).stream().map(EntityTO::getKey).collect(Collectors.toList()));
result.addAll(schemaRestClient.<VirSchemaTO>getSchemas(SchemaType.VIRTUAL, null, anyTypeClasses).stream().map(EntityTO::getKey).collect(Collectors.toList()));
Collections.sort(result);
return result;
}
Aggregations