use of org.camunda.bpm.engine.AuthenticationException in project camunda-bpm-platform by camunda.
the class IdentityServiceTest method testSuccessfulLoginAfterFailureWithoutDelay.
@Test
public void testSuccessfulLoginAfterFailureWithoutDelay() {
User user = identityService.newUser("johndoe");
user.setPassword("xxx");
identityService.saveUser(user);
Date now = ClockUtil.getCurrentTime();
assertFalse(identityService.checkPassword("johndoe", "invalid pwd"));
try {
assertFalse(identityService.checkPassword("johndoe", "xxx"));
fail("expected exception");
} catch (AuthenticationException e) {
assertEquals("The user with id 'johndoe' is locked.", e.getMessage());
}
ClockUtil.setCurrentTime(DateUtils.addSeconds(now, 30));
assertTrue(identityService.checkPassword("johndoe", "xxx"));
identityService.deleteUser("johndoe");
}
use of org.camunda.bpm.engine.AuthenticationException in project camunda-bpm-platform by camunda.
the class IdentityServiceTest method testUnsuccessfulLoginAfterFailureWithoutDelay.
@Test
public void testUnsuccessfulLoginAfterFailureWithoutDelay() {
User user = identityService.newUser("johndoe");
user.setPassword("xxx");
identityService.saveUser(user);
Date now = null;
now = ClockUtil.getCurrentTime();
assertFalse(identityService.checkPassword("johndoe", "invalid pwd"));
// try again before exprTime
ClockUtil.setCurrentTime(DateUtils.addSeconds(now, 1));
try {
assertFalse(identityService.checkPassword("johndoe", "invalid pwd"));
fail("expected exception");
} catch (AuthenticationException e) {
assertEquals("The user with id 'johndoe' is locked.", e.getMessage());
}
identityService.deleteUser("johndoe");
}
use of org.camunda.bpm.engine.AuthenticationException in project camunda-bpm-platform by camunda.
the class LoginAttemptsTest method testUsuccessfulAttemptsResultInException.
@Test
public void testUsuccessfulAttemptsResultInException() throws ParseException {
User user = identityService.newUser("johndoe");
user.setPassword("xxx");
identityService.saveUser(user);
Date now = sdf.parse("2000-01-24T13:00:00");
ClockUtil.setCurrentTime(now);
try {
for (int i = 0; i <= 6; i++) {
assertFalse(identityService.checkPassword("johndoe", "invalid pwd"));
now = DateUtils.addSeconds(now, 5);
ClockUtil.setCurrentTime(now);
}
fail("expected exception");
} catch (AuthenticationException e) {
assertTrue(e.getMessage().contains("The user with id 'johndoe' is locked."));
}
identityService.deleteUser(user.getId());
}
Aggregations