Search in sources :

Example 1 with MockPentahoUser

use of org.pentaho.test.mock.MockPentahoUser 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 2 with MockPentahoUser

use of org.pentaho.test.mock.MockPentahoUser 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 3 with MockPentahoUser

use of org.pentaho.test.mock.MockPentahoUser 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

Test (org.junit.Test)3 IPentahoUser (org.pentaho.platform.api.engine.security.userroledao.IPentahoUser)3 ITenant (org.pentaho.platform.api.mt.ITenant)3 MockPentahoUser (org.pentaho.test.mock.MockPentahoUser)3