Search in sources :

Example 6 with LocalPasswordHandler

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

the class LocalPasswordHandlerTestBase method getPasswordHandler.

public LocalPasswordHandler getPasswordHandler() {
    PasswordUtils.setDefaultProperties(new Properties());
    PasswordUtils utils = new PasswordUtils();
    utils.setCoordinator(new StubCoordinatorClientImpl(URI.create("urn:coordinator")));
    utils.setDbClient(new DummyDbClient());
    LocalPasswordHandler ph = new LocalPasswordHandler();
    ph.setConfigService(_cfg);
    ph.setPasswordUtils(utils);
    return ph;
}
Also used : DummyDbClient(com.emc.storageos.util.DummyDbClient) StubCoordinatorClientImpl(com.emc.storageos.db.server.util.StubCoordinatorClientImpl) PasswordUtils(com.emc.storageos.security.password.PasswordUtils) Properties(java.util.Properties) LocalPasswordHandler(com.emc.storageos.systemservices.impl.util.LocalPasswordHandler)

Example 7 with LocalPasswordHandler

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

the class PasswordServiceTest method testUpdatePassword.

@Test
public void testUpdatePassword() {
    PasswordService passwordResource = new PasswordService();
    passwordResource.setPropertiesMetadata(_propertiesMetadata);
    passwordResource.setAuditLogManager(new DummyAuditLogManager());
    PasswordUpdateParam passwordUpdate = getDummyPasswordUpdate("!changeMe3", null);
    passwordUpdate.setOldPassword("changeMe");
    LocalPasswordHandler ph = getDummyLocalPasswordHandler();
    ph.setLocalUsers(createLocalUsers());
    ph.setDbClient(new DummyDbClient());
    ph.setEncryptionProvider(provider);
    passwordResource.setPasswordHandler(ph);
    SecurityContext sc = new DummySecurityContext(LOCAL_ROOT);
    passwordResource.setSecurityContext(sc);
    Response res = passwordResource.updatePassword(null, null, 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);
    res = passwordResource.updatePassword(null, null, 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) DummyDbClient(com.emc.storageos.util.DummyDbClient) SecurityContext(javax.ws.rs.core.SecurityContext) PasswordUpdateParam(com.emc.storageos.model.password.PasswordUpdateParam) LocalPasswordHandler(com.emc.storageos.systemservices.impl.util.LocalPasswordHandler) Test(org.junit.Test)

Example 8 with LocalPasswordHandler

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

the class PasswordServiceTest method testUpdateUserPasswordNonExistingUser.

@Test(expected = BadRequestException.class)
public void testUpdateUserPasswordNonExistingUser() {
    PasswordService passwordResource = new PasswordService();
    passwordResource.setPropertiesMetadata(_propertiesMetadata);
    passwordResource.setAuditLogManager(new DummyAuditLogManager());
    PasswordResetParam passwordUpdate = getDummyPasswordReset("user123", "!changeme", "");
    LocalPasswordHandler ph = getDummyLocalPasswordHandler();
    ph.setLocalUsers(createLocalUsers());
    passwordResource.setPasswordHandler(ph);
    SecurityContext sc = new DummySecurityContext("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 9 with LocalPasswordHandler

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

the class PasswordServiceTest method testUpdatePasswordNoPrincipal.

@Test(expected = ForbiddenException.class)
public void testUpdatePasswordNoPrincipal() {
    PasswordService passwordResource = new PasswordService();
    passwordResource.setPropertiesMetadata(_propertiesMetadata);
    passwordResource.setAuditLogManager(new DummyAuditLogManager());
    PasswordUpdateParam passwordUpdate = getDummyPasswordUpdate("!changeme", null);
    LocalPasswordHandler ph = getPasswordHandler();
    passwordResource.setPasswordHandler(ph);
    SecurityContext sc = new DummySecurityContext("noprincipal");
    passwordResource.setSecurityContext(sc);
    Response res = passwordResource.updatePassword(null, null, passwordUpdate, false);
    res.getStatus();
}
Also used : Response(javax.ws.rs.core.Response) SecurityContext(javax.ws.rs.core.SecurityContext) PasswordUpdateParam(com.emc.storageos.model.password.PasswordUpdateParam) LocalPasswordHandler(com.emc.storageos.systemservices.impl.util.LocalPasswordHandler) Test(org.junit.Test)

Example 10 with LocalPasswordHandler

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

the class PasswordServiceTest method testUpdatePasswordTooManyParams.

@Test(expected = BadRequestException.class)
public void testUpdatePasswordTooManyParams() {
    PasswordService passwordResource = new PasswordService();
    passwordResource.setPropertiesMetadata(_propertiesMetadata);
    passwordResource.setAuditLogManager(new DummyAuditLogManager());
    PasswordUpdateParam passwordUpdate = getDummyPasswordUpdate("clearTextPwd", "HashedPassword");
    LocalPasswordHandler ph = getPasswordHandler();
    ph.setLocalUsers(createLocalUsers());
    passwordResource.setPasswordHandler(ph);
    SecurityContext sc = new DummySecurityContext(LOCAL_ROOT);
    passwordResource.setSecurityContext(sc);
    Response res = passwordResource.updatePassword(null, null, passwordUpdate, false);
}
Also used : Response(javax.ws.rs.core.Response) SecurityContext(javax.ws.rs.core.SecurityContext) PasswordUpdateParam(com.emc.storageos.model.password.PasswordUpdateParam) 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