Search in sources :

Example 11 with LocalPasswordHandler

use of com.emc.storageos.systemservices.impl.util.LocalPasswordHandler in project coprhd-controller by CoprHD.

the class PasswordServiceTest method testUpdateUserPasswordEmptyParams.

@Test(expected = BadRequestException.class)
public void testUpdateUserPasswordEmptyParams() {
    PasswordService passwordResource = new PasswordService();
    passwordResource.setPropertiesMetadata(_propertiesMetadata);
    passwordResource.setAuditLogManager(new DummyAuditLogManager());
    PasswordResetParam passwordUpdate = getDummyPasswordReset(LOCAL_ROOT, "", "");
    LocalPasswordHandler ph = getPasswordHandler();
    ph.setLocalUsers(createLocalUsers());
    passwordResource.setPasswordHandler(ph);
    SecurityContext sc = new DummySecurityContext(LOCAL_ROOT);
    passwordResource.setSecurityContext(sc);
    Response res = passwordResource.updateUserPassword(passwordUpdate, false);
}
Also used : Response(javax.ws.rs.core.Response) PasswordResetParam(com.emc.storageos.model.password.PasswordResetParam) SecurityContext(javax.ws.rs.core.SecurityContext) LocalPasswordHandler(com.emc.storageos.systemservices.impl.util.LocalPasswordHandler) Test(org.junit.Test)

Example 12 with LocalPasswordHandler

use of com.emc.storageos.systemservices.impl.util.LocalPasswordHandler in project coprhd-controller by CoprHD.

the class PasswordServiceTest method testUpdateUserPassword.

@Test
public void testUpdateUserPassword() {
    PasswordService passwordResource = new PasswordService();
    passwordResource.setPropertiesMetadata(_propertiesMetadata);
    passwordResource.setAuditLogManager(new DummyAuditLogManager());
    PasswordResetParam passwordUpdate = getDummyPasswordReset(LOCAL_ROOT, "!changeMe3", "");
    LocalPasswordHandler ph = getDummyLocalPasswordHandler();
    ph.setLocalUsers(createLocalUsers());
    passwordResource.setPasswordHandler(ph);
    SecurityContext sc = new DummySecurityContext(LOCAL_ROOT);
    passwordResource.setSecurityContext(sc);
    Response res = passwordResource.updateUserPassword(passwordUpdate, false);
    int statusCode = res.getStatus();
    Assert.assertTrue("updatePassword failed with code " + statusCode + ": " + res.getEntity().toString(), statusCode == Status.OK.getStatusCode());
    sc = new DummySecurityContext(LOCAL_PROXYUSER);
    passwordResource.setSecurityContext(sc);
    passwordUpdate.setUsername(LOCAL_PROXYUSER);
    res = passwordResource.updateUserPassword(passwordUpdate, false);
    statusCode = res.getStatus();
    Assert.assertTrue("updatePassword failed with code " + statusCode + ": " + res.getEntity().toString(), statusCode == Status.OK.getStatusCode());
}
Also used : Response(javax.ws.rs.core.Response) PasswordResetParam(com.emc.storageos.model.password.PasswordResetParam) SecurityContext(javax.ws.rs.core.SecurityContext) LocalPasswordHandler(com.emc.storageos.systemservices.impl.util.LocalPasswordHandler) Test(org.junit.Test)

Example 13 with LocalPasswordHandler

use of com.emc.storageos.systemservices.impl.util.LocalPasswordHandler in project coprhd-controller by CoprHD.

the class PasswordServiceTest method getPasswordHandler.

public LocalPasswordHandler getPasswordHandler() {
    LocalPasswordHandler ph = new LocalPasswordHandler();
    initPasswordHandler(ph);
    return ph;
}
Also used : LocalPasswordHandler(com.emc.storageos.systemservices.impl.util.LocalPasswordHandler)

Example 14 with LocalPasswordHandler

use of com.emc.storageos.systemservices.impl.util.LocalPasswordHandler in project coprhd-controller by CoprHD.

the class LocalPasswordHandlerTest method testSetAndVerifyUserPassword.

@Test
public void testSetAndVerifyUserPassword() throws Exception {
    // NOSONAR ("squid:S2068 Suppressing sonar violation of hard-coded password")
    String newPassword = "newPassword123";
    LocalPasswordHandler ph = getPasswordHandler();
    changeAndVerifyUserPassword(LOCAL_ROOT, newPassword, "hashed", ph);
    changeAndVerifyUserPassword(LOCAL_SYSMON, newPassword, "hashed", ph);
    changeAndVerifyUserPassword(LOCAL_PROXYUSER, newPassword, "encrypted", ph);
}
Also used : LocalPasswordHandler(com.emc.storageos.systemservices.impl.util.LocalPasswordHandler) Test(org.junit.Test)

Example 15 with LocalPasswordHandler

use of com.emc.storageos.systemservices.impl.util.LocalPasswordHandler in project coprhd-controller by CoprHD.

the class LocalPasswordHandlerTest method testCheckUserExists.

@Test
public void testCheckUserExists() {
    LocalPasswordHandler ph = getPasswordHandler();
    ph.setLocalUsers(createLocalUsers());
    Assert.assertTrue(ph.checkUserExists(LOCAL_ROOT));
    Assert.assertTrue(ph.checkUserExists(LOCAL_SYSMON));
    Assert.assertTrue(ph.checkUserExists(LOCAL_PROXYUSER));
    Assert.assertFalse(ph.checkUserExists("fakeuser"));
}
Also used : LocalPasswordHandler(com.emc.storageos.systemservices.impl.util.LocalPasswordHandler) Test(org.junit.Test)

Aggregations

LocalPasswordHandler (com.emc.storageos.systemservices.impl.util.LocalPasswordHandler)15 Test (org.junit.Test)13 Response (javax.ws.rs.core.Response)10 SecurityContext (javax.ws.rs.core.SecurityContext)9 PasswordUpdateParam (com.emc.storageos.model.password.PasswordUpdateParam)6 PasswordResetParam (com.emc.storageos.model.password.PasswordResetParam)4 DummyDbClient (com.emc.storageos.util.DummyDbClient)2 StubCoordinatorClientImpl (com.emc.storageos.db.server.util.StubCoordinatorClientImpl)1 PasswordUtils (com.emc.storageos.security.password.PasswordUtils)1 Properties (java.util.Properties)1