Search in sources :

Example 1 with PasswordUpdateParam

use of com.emc.storageos.model.password.PasswordUpdateParam in project coprhd-controller by CoprHD.

the class PasswordServiceTest method testUpdateSamePassword.

@Test(expected = BadRequestException.class)
public void testUpdateSamePassword() {
    PasswordService passwordResource = new PasswordService();
    passwordResource.setPropertiesMetadata(_propertiesMetadata);
    passwordResource.setAuditLogManager(new DummyAuditLogManager());
    PasswordUpdateParam passwordUpdate = getDummyPasswordUpdate("ChangeMe", null);
    LocalPasswordHandler ph = new DummyLocalPasswordHandler();
    ph.setLocalUsers(createLocalUsers());
    passwordResource.setPasswordHandler(ph);
    SecurityContext sc = new DummySecurityContext(LOCAL_ROOT);
    passwordResource.setSecurityContext(sc);
    // The following should fail with exception
    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)

Example 2 with PasswordUpdateParam

use of com.emc.storageos.model.password.PasswordUpdateParam in project coprhd-controller by CoprHD.

the class PasswordServiceTest method testUpdatePasswordEmptyParams.

@Test(expected = BadRequestException.class)
public void testUpdatePasswordEmptyParams() {
    PasswordService passwordResource = new PasswordService();
    passwordResource.setPropertiesMetadata(_propertiesMetadata);
    passwordResource.setAuditLogManager(new DummyAuditLogManager());
    PasswordUpdateParam passwordUpdate = getDummyPasswordUpdate("", "");
    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)

Example 3 with PasswordUpdateParam

use of com.emc.storageos.model.password.PasswordUpdateParam in project coprhd-controller by CoprHD.

the class PasswordServiceTest method testUpdatePasswordNoSecurityContext.

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

Example 4 with PasswordUpdateParam

use of com.emc.storageos.model.password.PasswordUpdateParam 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 5 with PasswordUpdateParam

use of com.emc.storageos.model.password.PasswordUpdateParam 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)

Aggregations

PasswordUpdateParam (com.emc.storageos.model.password.PasswordUpdateParam)9 LocalPasswordHandler (com.emc.storageos.systemservices.impl.util.LocalPasswordHandler)6 Response (javax.ws.rs.core.Response)6 Test (org.junit.Test)6 SecurityContext (javax.ws.rs.core.SecurityContext)5 DummyDbClient (com.emc.storageos.util.DummyDbClient)1