Search in sources :

Example 66 with VXPortalUser

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

the class TestUserREST method test8CreateDefaultAccountUser.

@Test
public void test8CreateDefaultAccountUser() {
    VXPortalUser vxPUserExp = CreateVXPortalUser();
    Mockito.when(userManager.createDefaultAccountUser(vxPUserExp)).thenReturn(vxPUserExp);
    Mockito.doNothing().when(xUserMgr).assignPermissionToUser(vxPUserExp, true);
    VXPortalUser VXPUserAct = userREST.createDefaultAccountUser(vxPUserExp, request);
    Assert.assertNotNull(VXPUserAct);
    Assert.assertEquals(vxPUserExp, VXPUserAct);
    Assert.assertEquals(vxPUserExp.getLoginId(), VXPUserAct.getLoginId());
    Assert.assertEquals(vxPUserExp.getFirstName(), VXPUserAct.getFirstName());
    Assert.assertEquals(vxPUserExp.getLastName(), VXPUserAct.getLastName());
    Assert.assertEquals(vxPUserExp.getEmailAddress(), VXPUserAct.getEmailAddress());
    Mockito.verify(userManager).createDefaultAccountUser(vxPUserExp);
    Mockito.verify(xUserMgr).assignPermissionToUser(vxPUserExp, true);
}
Also used : VXPortalUser(org.apache.ranger.view.VXPortalUser) Test(org.junit.Test)

Example 67 with VXPortalUser

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

the class TestUserREST method test7CreateDefaultAccountUser.

@Test
public void test7CreateDefaultAccountUser() {
    VXPortalUser vxPUserExp = new VXPortalUser();
    vxPUserExp = null;
    Mockito.when(userManager.createDefaultAccountUser(vxPUserExp)).thenReturn(vxPUserExp);
    VXPortalUser VXPUserAct = userREST.createDefaultAccountUser(vxPUserExp, request);
    Assert.assertNull(VXPUserAct);
    Mockito.verify(userManager).createDefaultAccountUser(vxPUserExp);
}
Also used : VXPortalUser(org.apache.ranger.view.VXPortalUser) Test(org.junit.Test)

Example 68 with VXPortalUser

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

the class TestUserREST method test9Update.

@Test
public void test9Update() {
    VXPortalUser vxPUserExp = new VXPortalUser();
    XXPortalUser xxPUserExp = new XXPortalUser();
    xxPUserExp = null;
    XXPortalUserDao xxPortalUserDao = Mockito.mock(XXPortalUserDao.class);
    Mockito.when(daoManager.getXXPortalUser()).thenReturn(xxPortalUserDao);
    Mockito.doNothing().when(userManager).checkAccess(xxPUserExp);
    Mockito.when(restErrorUtil.createRESTException(Mockito.anyString(), (MessageEnums) Mockito.any(), Mockito.nullable(Long.class), Mockito.nullable(String.class), Mockito.anyString())).thenReturn(new WebApplicationException());
    thrown.expect(WebApplicationException.class);
    userREST.update(vxPUserExp, request);
    Mockito.verify(daoManager).getXXPortalUser();
    Mockito.verify(xxPortalUserDao).getById(Mockito.anyLong());
    Mockito.verify(userManager).checkAccess(xxPUserExp);
    Mockito.verify(restErrorUtil).createRESTException(Mockito.anyString(), (MessageEnums) Mockito.any(), Mockito.anyLong(), Mockito.anyString(), Mockito.anyString());
}
Also used : XXPortalUser(org.apache.ranger.entity.XXPortalUser) WebApplicationException(javax.ws.rs.WebApplicationException) VXPortalUser(org.apache.ranger.view.VXPortalUser) XXPortalUserDao(org.apache.ranger.db.XXPortalUserDao) Test(org.junit.Test)

Example 69 with VXPortalUser

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

the class TestUserREST method test8Update.

@Test
public void test8Update() {
    VXPortalUser vxPUserExp = CreateVXPortalUser();
    vxPUserExp.setLoginId(loginId);
    XXPortalUser xxPUserExp = new XXPortalUser();
    xxPUserExp.setLoginId(loginId);
    XXPortalUserDao xxPortalUserDao = Mockito.mock(XXPortalUserDao.class);
    Mockito.when(daoManager.getXXPortalUser()).thenReturn(xxPortalUserDao);
    Mockito.when(xxPortalUserDao.getById(Mockito.anyLong())).thenReturn(xxPUserExp);
    Mockito.doNothing().when(userManager).checkAccess(xxPUserExp);
    Mockito.doNothing().when(msRestUtil).validateVUserProfileForUpdate(xxPUserExp, vxPUserExp);
    Mockito.when(userManager.updateUser(vxPUserExp)).thenReturn(xxPUserExp);
    Mockito.when(userManager.mapXXPortalUserVXPortalUser(xxPUserExp)).thenReturn(vxPUserExp);
    VXPortalUser vxPUserAct = userREST.update(vxPUserExp, request);
    Assert.assertNotNull(vxPUserAct);
    Assert.assertEquals(xxPUserExp.getLoginId(), vxPUserAct.getLoginId());
    Assert.assertEquals(vxPUserExp.getId(), vxPUserAct.getId());
    Assert.assertEquals(vxPUserExp.getFirstName(), vxPUserAct.getFirstName());
    Mockito.verify(daoManager).getXXPortalUser();
    Mockito.verify(xxPortalUserDao).getById(Mockito.anyLong());
    Mockito.verify(userManager).checkAccess(xxPUserExp);
    Mockito.verify(msRestUtil).validateVUserProfileForUpdate(xxPUserExp, vxPUserExp);
    Mockito.verify(userManager).updateUser(vxPUserExp);
    Mockito.verify(userManager).mapXXPortalUserVXPortalUser(xxPUserExp);
}
Also used : XXPortalUser(org.apache.ranger.entity.XXPortalUser) VXPortalUser(org.apache.ranger.view.VXPortalUser) XXPortalUserDao(org.apache.ranger.db.XXPortalUserDao) Test(org.junit.Test)

Example 70 with VXPortalUser

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

the class TestUserREST method CreateVXPortalUser.

private VXPortalUser CreateVXPortalUser() {
    VXPortalUser vxPUserExp = new VXPortalUser();
    vxPUserExp.setId(userId);
    vxPUserExp.setFirstName(firstName);
    vxPUserExp.setLastName(lastName);
    vxPUserExp.setEmailAddress(emailId);
    vxPUserExp.setLoginId(loginId);
    return vxPUserExp;
}
Also used : VXPortalUser(org.apache.ranger.view.VXPortalUser)

Aggregations

VXPortalUser (org.apache.ranger.view.VXPortalUser)129 Test (org.junit.Test)110 XXPortalUser (org.apache.ranger.entity.XXPortalUser)86 VXString (org.apache.ranger.view.VXString)80 ArrayList (java.util.ArrayList)74 XXPortalUserDao (org.apache.ranger.db.XXPortalUserDao)61 XXPortalUserRole (org.apache.ranger.entity.XXPortalUserRole)49 XXPortalUserRoleDao (org.apache.ranger.db.XXPortalUserRoleDao)47 XXUserPermission (org.apache.ranger.entity.XXUserPermission)47 VXUser (org.apache.ranger.view.VXUser)33 Date (java.util.Date)29 WebApplicationException (javax.ws.rs.WebApplicationException)29 XXUserPermissionDao (org.apache.ranger.db.XXUserPermissionDao)29 XXModuleDef (org.apache.ranger.entity.XXModuleDef)28 XXModuleDefDao (org.apache.ranger.db.XXModuleDefDao)26 XXGroupPermission (org.apache.ranger.entity.XXGroupPermission)26 VXUserPermission (org.apache.ranger.view.VXUserPermission)24 VXGroupPermission (org.apache.ranger.view.VXGroupPermission)21 XXUserDao (org.apache.ranger.db.XXUserDao)20 XXUser (org.apache.ranger.entity.XXUser)19