Search in sources :

Example 6 with PlainSchemaTO

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);
}
Also used : PlainSchemaTO(org.apache.syncope.common.lib.to.PlainSchemaTO) Test(org.junit.jupiter.api.Test)

Example 7 with PlainSchemaTO

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());
    }
}
Also used : PlainSchemaTO(org.apache.syncope.common.lib.to.PlainSchemaTO) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) Test(org.junit.jupiter.api.Test)

Example 8 with PlainSchemaTO

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());
    }
}
Also used : PlainSchemaTO(org.apache.syncope.common.lib.to.PlainSchemaTO) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) Test(org.junit.jupiter.api.Test)

Example 9 with PlainSchemaTO

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));
}
Also used : PlainSchemaTO(org.apache.syncope.common.lib.to.PlainSchemaTO) AnyTypeClassTO(org.apache.syncope.common.lib.to.AnyTypeClassTO) GroupPatch(org.apache.syncope.common.lib.patch.GroupPatch) AttrPatch(org.apache.syncope.common.lib.patch.AttrPatch) GroupTO(org.apache.syncope.common.lib.to.GroupTO) Test(org.junit.jupiter.api.Test)

Example 10 with PlainSchemaTO

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;
}
Also used : EntityTO(org.apache.syncope.common.lib.to.EntityTO) PlainSchemaTO(org.apache.syncope.common.lib.to.PlainSchemaTO) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) ArrayList(java.util.ArrayList) AnyTypeTO(org.apache.syncope.common.lib.to.AnyTypeTO) DerSchemaTO(org.apache.syncope.common.lib.to.DerSchemaTO) VirSchemaTO(org.apache.syncope.common.lib.to.VirSchemaTO)

Aggregations

PlainSchemaTO (org.apache.syncope.common.lib.to.PlainSchemaTO)39 Test (org.junit.jupiter.api.Test)26 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)19 AnyTypeClassTO (org.apache.syncope.common.lib.to.AnyTypeClassTO)11 UserTO (org.apache.syncope.common.lib.to.UserTO)9 AttrTO (org.apache.syncope.common.lib.to.AttrTO)6 Response (javax.ws.rs.core.Response)5 IOException (java.io.IOException)4 Set (java.util.Set)4 StandardCharsets (java.nio.charset.StandardCharsets)3 AnyTypeTO (org.apache.syncope.common.lib.to.AnyTypeTO)3 DerSchemaTO (org.apache.syncope.common.lib.to.DerSchemaTO)3 GroupTO (org.apache.syncope.common.lib.to.GroupTO)3 MembershipTO (org.apache.syncope.common.lib.to.MembershipTO)3 SchemaService (org.apache.syncope.common.rest.api.service.SchemaService)3 ParseException (java.text.ParseException)2 ArrayList (java.util.ArrayList)2 ListIterator (java.util.ListIterator)2 Map (java.util.Map)2 Collectors (java.util.stream.Collectors)2