use of com.emc.storageos.security.password.rules.ExpireRule in project coprhd-controller by CoprHD.
the class PasswordValidationUnitTest method testExpireRule.
@Test
public void testExpireRule() {
ExpireRule expireRule = new ExpireRule(1);
long current = System.currentTimeMillis();
long twoDaysAgo = current - 2 * 24 * 60 * 60 * 1000;
Password password = new Password("svcuser", "oldpassword", "password");
PasswordHistory passwordHistory = new PasswordHistory();
LongMap map = new LongMap();
map.put("hashedPassword", twoDaysAgo);
passwordHistory.setUserPasswordHash(map);
password.setPasswordHistory(passwordHistory);
logger.info("current=" + current + ", 2daysAgo = " + twoDaysAgo);
try {
expireRule.validate(password);
Assert.fail("password already expired, should fail");
} catch (BadRequestException e) {
logger.info(e.getServiceCode().toString());
logger.info(e.getMessage());
}
}
Aggregations