Search in sources :

Example 11 with IPentahoUser

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);
}
Also used : NotFoundException(org.pentaho.platform.api.engine.security.userroledao.NotFoundException) IPentahoUser(org.pentaho.platform.api.engine.security.userroledao.IPentahoUser)

Example 12 with IPentahoUser

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;
}
Also used : ITenant(org.pentaho.platform.api.mt.ITenant) ArrayList(java.util.ArrayList) IPentahoUser(org.pentaho.platform.api.engine.security.userroledao.IPentahoUser)

Example 13 with IPentahoUser

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();
}
Also used : MockPentahoUser(org.pentaho.test.mock.MockPentahoUser) ITenant(org.pentaho.platform.api.mt.ITenant) IPentahoUser(org.pentaho.platform.api.engine.security.userroledao.IPentahoUser) Test(org.junit.Test)

Example 14 with IPentahoUser

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();
}
Also used : MockPentahoUser(org.pentaho.test.mock.MockPentahoUser) ITenant(org.pentaho.platform.api.mt.ITenant) IPentahoUser(org.pentaho.platform.api.engine.security.userroledao.IPentahoUser) Test(org.junit.Test)

Example 15 with IPentahoUser

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();
}
Also used : MockPentahoUser(org.pentaho.test.mock.MockPentahoUser) ITenant(org.pentaho.platform.api.mt.ITenant) IPentahoUser(org.pentaho.platform.api.engine.security.userroledao.IPentahoUser) Test(org.junit.Test)

Aggregations

IPentahoUser (org.pentaho.platform.api.engine.security.userroledao.IPentahoUser)60 Test (org.junit.Test)23 ArrayList (java.util.ArrayList)16 ITenant (org.pentaho.platform.api.mt.ITenant)15 IUserRoleDao (org.pentaho.platform.api.engine.security.userroledao.IUserRoleDao)13 IPentahoRole (org.pentaho.platform.api.engine.security.userroledao.IPentahoRole)12 NotFoundException (org.pentaho.platform.api.engine.security.userroledao.NotFoundException)11 RepositoryException (javax.jcr.RepositoryException)8 PentahoUser (org.pentaho.platform.security.userroledao.PentahoUser)8 AlreadyExistsException (org.pentaho.platform.api.engine.security.userroledao.AlreadyExistsException)7 HashSet (java.util.HashSet)6 Matchers.anyString (org.mockito.Matchers.anyString)5 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)5 IOException (java.io.IOException)4 AccessControlException (javax.jcr.security.AccessControlException)4 Group (org.apache.jackrabbit.api.security.user.Group)4 BeansException (org.springframework.beans.BeansException)4 User (org.apache.jackrabbit.api.security.user.User)3 UncategorizedUserRoleDaoException (org.pentaho.platform.api.engine.security.userroledao.UncategorizedUserRoleDaoException)3 UserListWrapper (org.pentaho.platform.web.http.api.resources.UserListWrapper)3