Search in sources :

Example 6 with VXPasswordChange

use of org.apache.ranger.view.VXPasswordChange in project ranger by apache.

the class TestUserMgr method test13ChangePasswordAsAdmin.

@Test
public void test13ChangePasswordAsAdmin() {
    setup();
    XXPortalUserDao userDao = Mockito.mock(XXPortalUserDao.class);
    VXPortalUser userProfile = userProfile();
    VXPasswordChange pwdChange = new VXPasswordChange();
    pwdChange.setId(userProfile.getId());
    pwdChange.setLoginId(userProfile.getLoginId());
    pwdChange.setOldPassword(userProfile.getPassword());
    pwdChange.setEmailAddress(userProfile.getEmailAddress());
    pwdChange.setUpdPassword(userProfile.getPassword());
    XXPortalUser user = new XXPortalUser();
    Mockito.when(daoManager.getXXPortalUser()).thenReturn(userDao);
    Mockito.when(userDao.findByLoginId(Mockito.nullable(String.class))).thenReturn(user);
    Mockito.when(stringUtil.equals(Mockito.anyString(), Mockito.nullable(String.class))).thenReturn(true);
    Mockito.when(daoManager.getXXPortalUser()).thenReturn(userDao);
    Mockito.when(stringUtil.validatePassword(Mockito.anyString(), Mockito.any(String[].class))).thenReturn(true);
    VXResponse dbVXResponse = userMgr.changePassword(pwdChange);
    Assert.assertNotNull(dbVXResponse);
    Assert.assertEquals(userProfile.getStatus(), dbVXResponse.getStatusCode());
    Mockito.verify(stringUtil).equals(Mockito.anyString(), Mockito.nullable(String.class));
    Mockito.verify(stringUtil).validatePassword(Mockito.anyString(), Mockito.any(String[].class));
}
Also used : VXResponse(org.apache.ranger.view.VXResponse) XXPortalUser(org.apache.ranger.entity.XXPortalUser) VXPasswordChange(org.apache.ranger.view.VXPasswordChange) XXPortalUserDao(org.apache.ranger.db.XXPortalUserDao) VXPortalUser(org.apache.ranger.view.VXPortalUser) VXString(org.apache.ranger.view.VXString) Test(org.junit.Test)

Aggregations

XXPortalUserDao (org.apache.ranger.db.XXPortalUserDao)6 XXPortalUser (org.apache.ranger.entity.XXPortalUser)6 VXPasswordChange (org.apache.ranger.view.VXPasswordChange)6 VXPortalUser (org.apache.ranger.view.VXPortalUser)6 VXString (org.apache.ranger.view.VXString)6 Test (org.junit.Test)6 ArrayList (java.util.ArrayList)3 Date (java.util.Date)3 XXGroupPermissionDao (org.apache.ranger.db.XXGroupPermissionDao)3 XXModuleDefDao (org.apache.ranger.db.XXModuleDefDao)3 XXPortalUserRoleDao (org.apache.ranger.db.XXPortalUserRoleDao)3 XXUserPermissionDao (org.apache.ranger.db.XXUserPermissionDao)3 XXGroupPermission (org.apache.ranger.entity.XXGroupPermission)3 XXModuleDef (org.apache.ranger.entity.XXModuleDef)3 XXPortalUserRole (org.apache.ranger.entity.XXPortalUserRole)3 XXUserPermission (org.apache.ranger.entity.XXUserPermission)3 VXGroupPermission (org.apache.ranger.view.VXGroupPermission)3 VXResponse (org.apache.ranger.view.VXResponse)3 VXUserPermission (org.apache.ranger.view.VXUserPermission)3