// 1. set create request not allowed
ConfigurationTO configurationTO = new ConfigurationTO();
configurationTO.setKey("createRequest.allowed");
configurationTO.setValue("false");
Response response = configurationService.create(configurationTO);
assertNotNull(response);
assertEquals(org.apache.http.HttpStatus.SC_CREATED, response.getStatus());
configurationTO = getObject(response, ConfigurationTO.class, configurationService);
assertNotNull(configurationTO);
UserTO userTO = UserTestITCase.getUniqueSampleTO("selfcreate@syncope.apache.org");
// 2. get unauthorized when trying to request user create
try {
createUserRequest(userRequestService, new UserRequestTO(userTO));
fail();
} catch (SyncopeClientCompositeErrorException e) {
assertNotNull(e.getException(SyncopeClientExceptionType.UnauthorizedRole));
}
// 3. set create request allowed
configurationTO.setValue("true");
response = configurationService.create(configurationTO);
assertNotNull(response);
assertEquals(org.apache.http.HttpStatus.SC_CREATED, response.getStatus());
configurationTO = getObject(response, ConfigurationTO.class, configurationService);
assertNotNull(configurationTO);
// 4. as anonymous, request user create works
UserRequestService userRequestService2 = setupCredentials(userRequestService, UserRequestService.class, null, null);