use of org.apache.ranger.security.context.RangerSecurityContext in project ranger by apache.
the class TestRangerServiceDefServiceBase method setup.
public void setup() {
RangerSecurityContext context = new RangerSecurityContext();
context.setUserSession(new UserSessionBase());
RangerContextHolder.setSecurityContext(context);
UserSessionBase currentUserSession = ContextUtil.getCurrentUserSession();
currentUserSession.setUserAdmin(true);
}
use of org.apache.ranger.security.context.RangerSecurityContext in project ranger by apache.
the class TestRangerServiceService method setup.
public void setup() {
RangerSecurityContext context = new RangerSecurityContext();
context.setUserSession(new UserSessionBase());
RangerContextHolder.setSecurityContext(context);
UserSessionBase currentUserSession = ContextUtil.getCurrentUserSession();
currentUserSession.setUserAdmin(true);
}
use of org.apache.ranger.security.context.RangerSecurityContext in project ranger by apache.
the class TestRangerServiceServiceBase method setup.
public void setup() {
RangerSecurityContext context = new RangerSecurityContext();
context.setUserSession(new UserSessionBase());
RangerContextHolder.setSecurityContext(context);
UserSessionBase currentUserSession = ContextUtil.getCurrentUserSession();
currentUserSession.setUserAdmin(true);
}
use of org.apache.ranger.security.context.RangerSecurityContext in project ranger by apache.
the class TestRangerBizUtil method testGetXUserId_NoUser.
@Test
public void testGetXUserId_NoUser() {
RangerSecurityContext context = new RangerSecurityContext();
context.setUserSession(new UserSessionBase());
RangerContextHolder.setSecurityContext(context);
XXPortalUser xxPortalUser = new XXPortalUser();
xxPortalUser.setId(id);
xxPortalUser.setLoginId("12121");
context.getUserSession().setXXPortalUser(xxPortalUser);
XXUser xxUser = new XXUser();
XXUserDao xxUserDao = Mockito.mock(XXUserDao.class);
XXPortalUserDao xxPortalUserDao = Mockito.mock(XXPortalUserDao.class);
Mockito.when(daoManager.getXXPortalUser()).thenReturn(xxPortalUserDao);
Mockito.when(xxPortalUserDao.getById(Mockito.anyLong())).thenReturn(xxPortalUser);
Mockito.when(daoManager.getXXUser()).thenReturn(xxUserDao);
Mockito.when(xxUserDao.findByUserName(Mockito.anyString())).thenReturn(xxUser);
Long chk = rangerBizUtil.getXUserId();
Mockito.verify(daoManager).getXXPortalUser();
Mockito.verify(xxPortalUserDao).getById(Mockito.anyLong());
Mockito.verify(daoManager).getXXUser();
Mockito.verify(xxUserDao).findByUserName(Mockito.anyString());
Assert.assertNull(chk);
}
use of org.apache.ranger.security.context.RangerSecurityContext in project ranger by apache.
the class TestRangerBizUtil method testGetXUserId.
@Test
public void testGetXUserId() {
XXPortalUser xxPortalUser = new XXPortalUser();
xxPortalUser.setId(id);
xxPortalUser.setLoginId("12121");
XXUser xxUser = new XXUser();
xxUser.setId(id);
XXPortalUserDao xxPortalUserDao = Mockito.mock(XXPortalUserDao.class);
XXUserDao xxUserDao = Mockito.mock(XXUserDao.class);
RangerSecurityContext context = new RangerSecurityContext();
UserSessionBase userSessionBase = new UserSessionBase();
userSessionBase.setUserAdmin(true);
context.setUserSession(userSessionBase);
userSessionBase.setXXPortalUser(xxPortalUser);
RangerContextHolder.setSecurityContext(context);
Mockito.when(daoManager.getXXPortalUser()).thenReturn(xxPortalUserDao);
Mockito.when(xxPortalUserDao.getById(Mockito.anyLong())).thenReturn(xxPortalUser);
Mockito.when(daoManager.getXXUser()).thenReturn(xxUserDao);
Mockito.when(xxUserDao.findByUserName(Mockito.anyString())).thenReturn(xxUser);
Long chk = rangerBizUtil.getXUserId();
Mockito.verify(daoManager).getXXPortalUser();
Mockito.verify(xxPortalUserDao).getById(Mockito.anyLong());
Mockito.verify(daoManager).getXXUser();
Mockito.verify(xxUserDao).findByUserName(Mockito.anyString());
Assert.assertEquals(chk, id);
}
Aggregations