use of org.apache.syncope.common.lib.to.PlainSchemaTO in project syncope by apache.
the class AuthenticationITCase method userSchemaAuthorization.
@Test
public void userSchemaAuthorization() {
String schemaName = "authTestSchema" + getUUIDString();
// 1. create a schema (as admin)
PlainSchemaTO schemaTO = new PlainSchemaTO();
schemaTO.setKey(schemaName);
schemaTO.setMandatoryCondition("false");
schemaTO.setType(AttrSchemaType.String);
PlainSchemaTO newPlainSchemaTO = createSchema(SchemaType.PLAIN, schemaTO);
assertEquals(schemaTO, newPlainSchemaTO);
// 2. create an user with the role created above (as admin)
UserTO userTO = UserITCase.getUniqueSampleTO("auth@test.org");
userTO = createUser(userTO).getEntity();
assertNotNull(userTO);
// 3. read the schema created above (as admin) - success
schemaTO = schemaService.read(SchemaType.PLAIN, schemaName);
assertNotNull(schemaTO);
// 4. read the schema created above (as user) - success
SchemaService schemaService2 = clientFactory.create(userTO.getUsername(), "password123").getService(SchemaService.class);
schemaTO = schemaService2.read(SchemaType.PLAIN, schemaName);
assertNotNull(schemaTO);
// 5. update the schema create above (as user) - failure
try {
schemaService2.update(SchemaType.PLAIN, schemaTO);
fail("Schema update as user should not work");
} catch (ForbiddenException e) {
assertNotNull(e);
}
assertEquals(0, getFailedLogins(userService, userTO.getKey()));
}
use of org.apache.syncope.common.lib.to.PlainSchemaTO in project syncope by apache.
the class ConfigurationITCase method create.
@Test
public void create() {
PlainSchemaTO testKey = new PlainSchemaTO();
testKey.setKey("testKey" + getUUIDString());
testKey.setType(AttrSchemaType.String);
createSchema(SchemaType.PLAIN, testKey);
AttrTO conf = new AttrTO.Builder().schema(testKey.getKey()).value("testValue").build();
configurationService.set(conf);
AttrTO actual = configurationService.get(conf.getSchema());
actual.setSchemaInfo(null);
assertEquals(actual, conf);
}
use of org.apache.syncope.common.lib.to.PlainSchemaTO in project syncope by apache.
the class ConfigurationITCase method issueSYNCOPE418.
@Test
public void issueSYNCOPE418() {
PlainSchemaTO failing = new PlainSchemaTO();
failing.setKey("http://schemas.examples.org/security/authorization/organizationUnit");
failing.setType(AttrSchemaType.String);
try {
createSchema(SchemaType.PLAIN, failing);
fail("This should not happen");
} catch (SyncopeClientException e) {
assertEquals(ClientExceptionType.InvalidPlainSchema, e.getType());
assertNotNull(e.getElements());
assertEquals(1, e.getElements().size());
assertTrue(e.getElements().iterator().next().contains(EntityViolationType.InvalidKey.name()));
}
}
use of org.apache.syncope.common.lib.to.PlainSchemaTO in project syncope by apache.
the class PlainSchemaITCase method createWithNotPermittedName.
@Test
public void createWithNotPermittedName() {
PlainSchemaTO schemaTO = new PlainSchemaTO();
schemaTO.setKey("failedLogins");
schemaTO.setType(AttrSchemaType.String);
try {
createSchema(SchemaType.PLAIN, schemaTO);
fail("This should not be reacheable");
} catch (SyncopeClientException e) {
assertEquals(ClientExceptionType.InvalidPlainSchema, e.getType());
boolean entityViolationTypeCheck = false;
for (String element : e.getElements()) {
if (!entityViolationTypeCheck) {
entityViolationTypeCheck = element.contains(EntityViolationType.InvalidKey.name());
}
}
assertTrue(entityViolationTypeCheck);
}
}
use of org.apache.syncope.common.lib.to.PlainSchemaTO in project syncope by apache.
the class PlainSchemaITCase method delete.
@Test
public void delete() {
PlainSchemaTO schemaTO = buildPlainSchemaTO("todelete", AttrSchemaType.String);
schemaTO.setMandatoryCondition("false");
createSchema(SchemaType.PLAIN, schemaTO);
schemaService.delete(SchemaType.PLAIN, schemaTO.getKey());
PlainSchemaTO firstname = null;
try {
firstname = schemaService.read(SchemaType.PLAIN, schemaTO.getKey());
} catch (SyncopeClientException e) {
assertEquals(Response.Status.NOT_FOUND, e.getType().getResponseStatus());
}
assertNull(firstname);
}
Aggregations