use of eu.bcvsolutions.idm.core.api.exception.ResultCodeException in project CzechIdMng by bcvsolutions.
the class DefaultIdmScriptServiceIntegrationTest method tryRedeployMissingScript.
@Test
public void tryRedeployMissingScript() {
IdmScriptDto script = new IdmScriptDto();
script.setCategory(IdmScriptCategory.SYSTEM);
script.setCode("test_" + System.currentTimeMillis());
script.setName("test_" + System.currentTimeMillis());
script = scriptService.save(script);
assertNotNull(script);
assertNotNull(script.getId());
try {
scriptService.redeploy(script);
fail();
} catch (ResultCodeException e) {
ResultCodeException resultCode = (ResultCodeException) e;
assertEquals(resultCode.getError().getError().getStatusEnum(), CoreResultCode.SCRIPT_XML_FILE_NOT_FOUND.name());
}
}
use of eu.bcvsolutions.idm.core.api.exception.ResultCodeException in project CzechIdMng by bcvsolutions.
the class DefaultIdmScriptServiceIntegrationTest method backupMissingFolderNewEntity.
@Test
public void backupMissingFolderNewEntity() {
configurationService.setValue(Recoverable.BACKUP_FOLDER_CONFIG, null);
IdmScriptDto script = new IdmScriptDto();
script.setCategory(IdmScriptCategory.SYSTEM);
script.setCode("test_" + System.currentTimeMillis());
script.setName("test_" + System.currentTimeMillis());
script = scriptService.save(script);
assertNotNull(script);
assertNotNull(script.getId());
try {
scriptService.backup(script);
fail();
} catch (ResultCodeException e) {
ResultCodeException resultCode = (ResultCodeException) e;
assertEquals(resultCode.getError().getError().getStatusEnum(), CoreResultCode.BACKUP_FOLDER_NOT_FOUND.name());
}
}
use of eu.bcvsolutions.idm.core.api.exception.ResultCodeException in project CzechIdMng by bcvsolutions.
the class PasswordPreValidationIntegrationTest method testAdvancedEnabled.
@Test
public void testAdvancedEnabled() {
IdmPasswordPolicyDto policy = new IdmPasswordPolicyDto();
policy.setName(System.currentTimeMillis() + "");
policy.setDefaultPolicy(true);
policy.setMinPasswordLength(10);
policy.setMaxPasswordLength(20);
policy.setPasswordLengthRequired(true);
policy.setMinUpperChar(5);
policy.setUpperCharRequired(true);
policy.setMinLowerChar(4);
policy.setLowerCharRequired(true);
policy.setEnchancedControl(true);
policy.setMinRulesToFulfill(1);
policy.setMinNumber(3);
policy.setNumberRequired(false);
policy.setMinSpecialChar(2);
policy.setSpecialCharRequired(false);
policy.setIdentityAttributeCheck("EMAIL, USERNAME");
PasswordChangeDto passwordChange = new PasswordChangeDto();
passwordChange.setIdm(true);
policy = passwordPolicyService.save(policy);
try {
idmIdentityService.validatePassword(passwordChange);
} catch (ResultCodeException ex) {
Map<String, Object> parametrs = new HashMap<String, Object>();
parametrs.put("minNumber", 3);
parametrs.put("minSpecialChar", 2);
assertEquals(10, ex.getError().getError().getParameters().get("minLength"));
assertEquals(20, ex.getError().getError().getParameters().get("maxLength"));
assertEquals(5, ex.getError().getError().getParameters().get("minUpperChar"));
assertEquals(4, ex.getError().getError().getParameters().get("minLowerChar"));
assertEquals(parametrs.toString(), ex.getError().getError().getParameters().get("minRulesToFulfill").toString());
assertEquals(policy.getName(), ex.getError().getError().getParameters().get("policiesNamesPreValidation"));
// special char base, passwordSimilarUsername, passwordSimilarEmail ->
assertEquals(10, ex.getError().getError().getParameters().size());
policy.setDefaultPolicy(false);
passwordPolicyService.save(policy);
}
}
use of eu.bcvsolutions.idm.core.api.exception.ResultCodeException in project CzechIdMng by bcvsolutions.
the class DefaultIdmNotificationTemplateServiceIntegrationTest method redeployWithoutBackupFolder.
@Test
public void redeployWithoutBackupFolder() {
String backupPath = configurationService.getValue(DefaultIdmNotificationTemplateService.BACKUP_FOLDER_CONFIG);
if (backupPath != null) {
configurationService.setValue(DefaultIdmNotificationTemplateService.BACKUP_FOLDER_CONFIG, null);
}
//
IdmNotificationTemplateDto testTemplate = notificationTemplateService.getByCode(TEST_TEMPLATE);
Assert.assertNotNull(testTemplate);
assertEquals(TEST_TEMPLATE, testTemplate.getCode());
//
try {
notificationTemplateService.redeploy(testTemplate);
fail();
} catch (Exception e) {
assertTrue(e instanceof ResultCodeException);
ResultCodeException resultCode = (ResultCodeException) e;
assertEquals(resultCode.getError().getError().getStatusEnum(), CoreResultCode.BACKUP_FOLDER_NOT_FOUND.name());
}
}
use of eu.bcvsolutions.idm.core.api.exception.ResultCodeException in project CzechIdMng by bcvsolutions.
the class DefaultRecaptchaServiceUnitTest method testNotValid2.
@Test()
public void testNotValid2() {
RecaptchaResponse response = getRecaptchaResponse(TEST_HOSTNAME, false, "a");
when(config.getSecretKey()).thenReturn(new GuardedString(TEST_SECRET_KEY));
when(template.postForEntity(anyString(), any(), eq(RecaptchaResponse.class))).thenReturn(getResponse(response, HttpStatus.OK));
try {
service.checkRecaptcha(getRecaptchaRequest(TEST_REMOTE_IP, TEST_REQUEST));
} catch (ResultCodeException O_o) {
Assert.assertEquals(O_o.getStatus(), CoreResultCode.RECAPTCHA_CHECK_FAILED.getStatus());
}
verify(template).postForEntity(anyString(), any(), eq(RecaptchaResponse.class));
verifyNoMoreInteractions(template);
}
Aggregations