use of org.pentaho.platform.api.engine.security.userroledao.IPentahoUser in project pentaho-platform by pentaho.
the class MockUserRoleDao method setPassword.
public void setPassword(ITenant tenant, String userName, String password) throws NotFoundException, UncategorizedUserRoleDaoException {
IPentahoUser user = getUser(tenant, userName);
if (user == null) {
throw new NotFoundException(userName);
}
user.setPassword(password);
}
use of org.pentaho.platform.api.engine.security.userroledao.IPentahoUser in project pentaho-platform by pentaho.
the class MockUserRoleDao method getUsers.
public List<IPentahoUser> getUsers(ITenant tenant, boolean includeSubTenants) throws UncategorizedUserRoleDaoException {
ArrayList<IPentahoUser> users = new ArrayList<IPentahoUser>();
users.addAll(getUsers(tenant));
if (includeSubTenants) {
for (ITenant tmpTenant : tenants) {
if (tmpTenant.getRootFolderAbsolutePath().startsWith(tenant.getRootFolderAbsolutePath() + "/", 0)) {
users.addAll(getUsers(tmpTenant));
}
}
}
return users;
}
use of org.pentaho.platform.api.engine.security.userroledao.IPentahoUser in project pentaho-platform by pentaho.
the class UserRoleDaoResource_RolesUpdatedTest method rolesUpdated_WhenAssignAllUsersToRole_WithSessionUser.
@Test
public void rolesUpdated_WhenAssignAllUsersToRole_WithSessionUser() {
ITenant tenant = mock(ITenant.class);
doReturn(tenant).when(resource).getTenant(DEFAULT_STRING);
IPentahoUser sessionUser = new MockPentahoUser(tenant, SESSION_USER_NAME, DEFAULT_STRING, DEFAULT_STRING, true);
doReturn(Collections.singletonList(sessionUser)).when(userRoleDao).getUsers(tenant);
resource.assignAllUsersToRole(DEFAULT_STRING, ROLE_NAME_DEVELOPER);
verify(resource).updateRolesForCurrentSession();
}
use of org.pentaho.platform.api.engine.security.userroledao.IPentahoUser in project pentaho-platform by pentaho.
the class UserRoleDaoResource_RolesUpdatedTest method rolesNotUpdated_WhenAssignAllUsersToRole_WithNoSessionUser.
@Test
public void rolesNotUpdated_WhenAssignAllUsersToRole_WithNoSessionUser() {
ITenant tenant = mock(ITenant.class);
doReturn(tenant).when(resource).getTenant(DEFAULT_STRING);
IPentahoUser nonSessionUser = new MockPentahoUser(tenant, NON_SESSION_USER_NAME, DEFAULT_STRING, DEFAULT_STRING, true);
doReturn(Collections.singletonList(nonSessionUser)).when(userRoleDao).getUsers(tenant);
resource.assignAllUsersToRole(DEFAULT_STRING, ROLE_NAME_DEVELOPER);
verify(resource, never()).updateRolesForCurrentSession();
}
use of org.pentaho.platform.api.engine.security.userroledao.IPentahoUser in project pentaho-platform by pentaho.
the class UserRoleDaoResource_RolesUpdatedTest method rolesUpdated_WhenAssignAllUsersToRole_WithSessionAndNonSessionUser.
@Test
public void rolesUpdated_WhenAssignAllUsersToRole_WithSessionAndNonSessionUser() {
ITenant tenant = mock(ITenant.class);
doReturn(tenant).when(resource).getTenant(DEFAULT_STRING);
final IPentahoUser sessionUser = new MockPentahoUser(tenant, SESSION_USER_NAME, DEFAULT_STRING, DEFAULT_STRING, true);
final IPentahoUser nonSessionUser = new MockPentahoUser(tenant, NON_SESSION_USER_NAME, DEFAULT_STRING, DEFAULT_STRING, true);
List<IPentahoUser> users = Arrays.asList(sessionUser, nonSessionUser);
doReturn(users).when(userRoleDao).getUsers(tenant);
resource.assignAllUsersToRole(DEFAULT_STRING, ROLE_NAME_DEVELOPER);
verify(resource).updateRolesForCurrentSession();
}
Aggregations