use of org.pentaho.platform.api.engine.security.userroledao.IUserRoleDao in project pentaho-platform by pentaho.
the class UserRoleDaoServiceTest method testDeleteUsersUncategorizedUserRoleDaoException.
@Test(expected = UncategorizedUserRoleDaoException.class)
public void testDeleteUsersUncategorizedUserRoleDaoException() {
String users = "admin\tsuzy\t";
setupMockSessionUser(SESSION_USER_NAME, true);
IPentahoUser user = mock(IPentahoUser.class);
IUserRoleDao roleDao = mock(IUserRoleDao.class);
when(roleDao.getUser(any(ITenant.class), anyString())).thenThrow(new UncategorizedUserRoleDaoException("expectedTestException"));
PentahoSystem.registerObject(roleDao);
userRoleService.deleteUsers(users);
}
use of org.pentaho.platform.api.engine.security.userroledao.IUserRoleDao in project pentaho-platform by pentaho.
the class UserRoleDaoServiceTest method testUpdatePassword.
@Test
public void testUpdatePassword() throws Exception {
setupMockSessionUser(SESSION_USER_NAME, true);
IUserRoleDao roleDao = registerMockUserRoleDao();
addMockUserToUserRoleDao(roleDao, SESSION_USER_NAME, SESSION_USER_PASSWORD);
addMockUserToUserRoleDao(roleDao, OTHER_USER_NAME, OTHER_USER_PASSWORD);
userRoleService.updatePassword(new User(OTHER_USER_NAME, A_NEW_PASSWORD));
verify(roleDao, times(1)).setPassword(any(ITenant.class), eq(OTHER_USER_NAME), eq(A_NEW_PASSWORD));
}
use of org.pentaho.platform.api.engine.security.userroledao.IUserRoleDao in project pentaho-platform by pentaho.
the class UserRoleDaoServiceTest method testRemoveRolesFromUserUncategorizedUserRoleDaoException.
@Test(expected = UncategorizedUserRoleDaoException.class)
public void testRemoveRolesFromUserUncategorizedUserRoleDaoException() throws UserRoleListService.UnauthorizedException {
String userName = "testUser";
String roleNames = "Power User\tBusiness User\t";
setupMockSessionUser(SESSION_USER_NAME, true);
// Create session that will generate tenant
IPentahoSession session = mock(IPentahoSession.class);
when(session.getAttribute(IPentahoSession.TENANT_ID_KEY)).thenReturn("testTenantPath");
PentahoSessionHolder.setSession(session);
IUserRoleDao roleDao = mock(IUserRoleDao.class);
when(roleDao.getUserRoles(any(ITenant.class), anyString())).thenThrow(new UncategorizedUserRoleDaoException("expectedTestException"));
PentahoSystem.registerObject(roleDao);
userRoleService.removeRolesFromUser(userName, roleNames);
}
use of org.pentaho.platform.api.engine.security.userroledao.IUserRoleDao in project pentaho-platform by pentaho.
the class UserRoleDaoServiceTest method testRemoveRoleFromUserNotFoundException.
@Test(expected = NotFoundException.class)
public void testRemoveRoleFromUserNotFoundException() {
String userName = "testUser";
String roleNames = "Power User\tBusiness User\t";
setupMockSessionUser(SESSION_USER_NAME, true);
// Create session that will generate tenant
IPentahoSession session = mock(IPentahoSession.class);
when(session.getAttribute(IPentahoSession.TENANT_ID_KEY)).thenReturn("testTenantPath");
PentahoSessionHolder.setSession(session);
IUserRoleDao roleDao = mock(IUserRoleDao.class);
when(roleDao.getUserRoles(any(ITenant.class), anyString())).thenThrow(new NotFoundException("expectedTestException"));
PentahoSystem.registerObject(roleDao);
userRoleService.removeRolesFromUser(userName, roleNames);
}
use of org.pentaho.platform.api.engine.security.userroledao.IUserRoleDao in project pentaho-platform by pentaho.
the class UserRoleDaoServiceTest method testGetRoleMembersSecurityException.
@Test(expected = SecurityException.class)
public void testGetRoleMembersSecurityException() {
setupMockSessionUser(SESSION_USER_NAME, false);
List<IPentahoUser> userList = new ArrayList<>();
IUserRoleDao roleDao = mock(IUserRoleDao.class);
when(roleDao.getRoleMembers(any(ITenant.class), anyString())).thenReturn(userList);
PentahoSystem.registerObject(roleDao);
IPentahoUser user = mock(IPentahoUser.class);
when(user.getUsername()).thenReturn("admin");
userList.add(user);
UserListWrapper wrapUserList = new UserListWrapper(userList);
IPentahoSession session = mock(IPentahoSession.class);
String tenantPath = "testPath";
when(session.getAttribute(IPentahoSession.TENANT_ID_KEY)).thenReturn(tenantPath);
PentahoSessionHolder.setSession(session);
userRoleService.getRoleMembers("Report Author");
}
Aggregations