use of org.apache.ranger.common.UserSessionBase 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.common.UserSessionBase 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.common.UserSessionBase 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.common.UserSessionBase 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.common.UserSessionBase in project ranger by apache.
the class TestRangerBizUtil method testIsAdmin.
@Test
public void testIsAdmin() {
UserSessionBase currentUserSession = ContextUtil.getCurrentUserSession();
currentUserSession.setUserAdmin(true);
boolean isAdminChk = rangerBizUtil.isAdmin();
Assert.assertTrue(isAdminChk);
}
Aggregations