Search in sources :

Example 1 with ExpireRule

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());
    }
}
Also used : LongMap(com.emc.storageos.db.client.model.LongMap) BadRequestException(com.emc.storageos.svcs.errorhandling.resources.BadRequestException) ExpireRule(com.emc.storageos.security.password.rules.ExpireRule) PasswordHistory(com.emc.storageos.db.client.model.PasswordHistory) Password(com.emc.storageos.security.password.Password) Test(org.junit.Test)

Aggregations

LongMap (com.emc.storageos.db.client.model.LongMap)1 PasswordHistory (com.emc.storageos.db.client.model.PasswordHistory)1 Password (com.emc.storageos.security.password.Password)1 ExpireRule (com.emc.storageos.security.password.rules.ExpireRule)1 BadRequestException (com.emc.storageos.svcs.errorhandling.resources.BadRequestException)1 Test (org.junit.Test)1