Search in sources :

Example 1 with PasswordResetParam

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

the class PasswordServiceTest method testUpdateUserPasswordNoSecurtyContext.

@Test(expected = ForbiddenException.class)
public void testUpdateUserPasswordNoSecurtyContext() {
    PasswordService passwordResource = new PasswordService();
    passwordResource.setPropertiesMetadata(_propertiesMetadata);
    passwordResource.setAuditLogManager(new DummyAuditLogManager());
    PasswordResetParam passwordUpdate = getDummyPasswordReset("user123", "!changeme", "");
    Response res = passwordResource.updateUserPassword(passwordUpdate, false);
    Assert.assertTrue("Should throw exception, but returned " + res.getStatus(), false);
}
Also used : Response(javax.ws.rs.core.Response) PasswordResetParam(com.emc.storageos.model.password.PasswordResetParam) Test(org.junit.Test)

Example 2 with PasswordResetParam

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

the class PasswordServiceTest method getDummyPasswordReset.

public PasswordResetParam getDummyPasswordReset(String username, String password, String encpassword) {
    PasswordResetParam passwordUpdate = new PasswordResetParam();
    passwordUpdate.setUsername(username);
    passwordUpdate.setPassword(password);
    passwordUpdate.setEncPassword(encpassword);
    return passwordUpdate;
}
Also used : PasswordResetParam(com.emc.storageos.model.password.PasswordResetParam)

Example 3 with PasswordResetParam

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

the class PasswordServiceTest method testUpdateUserPasswordTooManyParams.

@Test(expected = BadRequestException.class)
public void testUpdateUserPasswordTooManyParams() {
    PasswordService passwordResource = new PasswordService();
    passwordResource.setPropertiesMetadata(_propertiesMetadata);
    passwordResource.setAuditLogManager(new DummyAuditLogManager());
    PasswordResetParam passwordUpdate = getDummyPasswordReset(LOCAL_ROOT, "clearTextPwd", "HashedPassword");
    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 4 with PasswordResetParam

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

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

the class PasswordServiceTest method testUpdateUserPasswordNoPrincipal.

@Test(expected = ForbiddenException.class)
public void testUpdateUserPasswordNoPrincipal() {
    PasswordService passwordResource = new PasswordService();
    passwordResource.setPropertiesMetadata(_propertiesMetadata);
    passwordResource.setAuditLogManager(new DummyAuditLogManager());
    PasswordResetParam passwordUpdate = getDummyPasswordReset("user123", "!changeme", "");
    SecurityContext sc = new DummySecurityContext("noprincipal");
    passwordResource.setSecurityContext(sc);
    Response res = passwordResource.updateUserPassword(passwordUpdate, false);
    Assert.assertTrue("Should throw exception, but returned " + res.getStatus(), false);
}
Also used : Response(javax.ws.rs.core.Response) PasswordResetParam(com.emc.storageos.model.password.PasswordResetParam) SecurityContext(javax.ws.rs.core.SecurityContext) Test(org.junit.Test)

Aggregations

PasswordResetParam (com.emc.storageos.model.password.PasswordResetParam)10 Response (javax.ws.rs.core.Response)6 Test (org.junit.Test)6 SecurityContext (javax.ws.rs.core.SecurityContext)5 LocalPasswordHandler (com.emc.storageos.systemservices.impl.util.LocalPasswordHandler)4 ClientResponse (com.sun.jersey.api.client.ClientResponse)1