Search in sources :

Example 6 with UncategorizedUserRoleDaoException

use of org.pentaho.platform.api.engine.security.userroledao.UncategorizedUserRoleDaoException in project pentaho-platform by pentaho.

the class UserRoleDaoResourceTest method testDeleteUserUncategorizedUserRoleDaoException.

@Test
public void testDeleteUserUncategorizedUserRoleDaoException() {
    String users = "user1\tuser2\tuser3\t";
    doThrow(new UncategorizedUserRoleDaoException("expectedTestException")).when(userRoleService).deleteUsers(anyString());
    try {
        Response response = userRoleResource.deleteUsers(users);
    } catch (WebApplicationException e) {
        assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), e.getResponse().getStatus());
    }
}
Also used : Response(javax.ws.rs.core.Response) WebApplicationException(javax.ws.rs.WebApplicationException) UncategorizedUserRoleDaoException(org.pentaho.platform.api.engine.security.userroledao.UncategorizedUserRoleDaoException) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 7 with UncategorizedUserRoleDaoException

use of org.pentaho.platform.api.engine.security.userroledao.UncategorizedUserRoleDaoException in project pentaho-platform by pentaho.

the class UserRoleDaoResourceTest method testDeleteRoleUncategorizedUserRoleDaoException.

@Test
public void testDeleteRoleUncategorizedUserRoleDaoException() {
    String roles = "role1\trole2";
    doThrow(new UncategorizedUserRoleDaoException("expectedTestException")).when(userRoleService).deleteRoles(anyString());
    try {
        userRoleResource.deleteRoles(roles);
    } catch (WebApplicationException e) {
        assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), e.getResponse().getStatus());
    }
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) UncategorizedUserRoleDaoException(org.pentaho.platform.api.engine.security.userroledao.UncategorizedUserRoleDaoException) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 8 with UncategorizedUserRoleDaoException

use of org.pentaho.platform.api.engine.security.userroledao.UncategorizedUserRoleDaoException in project pentaho-platform by pentaho.

the class UserRoleDaoResourceTest method testRemoveRolesFromUserUncategorizedUserRoleDaoException.

@Test
public void testRemoveRolesFromUserUncategorizedUserRoleDaoException() {
    String user = "testUser1";
    String roles = "testRole1";
    doThrow(new UncategorizedUserRoleDaoException("expectedTestException")).when(userRoleService).removeRolesFromUser(anyString(), anyString());
    try {
        userRoleResource.removeRolesFromUser(user, roles);
    } catch (WebApplicationException e) {
        assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), e.getResponse().getStatus());
        assertNotNull(e.getResponse().getEntity());
    }
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) UncategorizedUserRoleDaoException(org.pentaho.platform.api.engine.security.userroledao.UncategorizedUserRoleDaoException) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 9 with UncategorizedUserRoleDaoException

use of org.pentaho.platform.api.engine.security.userroledao.UncategorizedUserRoleDaoException in project pentaho-platform by pentaho.

the class UserRoleDaoResourceTest method testAssignRoleToUserUncategorizedUserRoleDaoException.

@Test
public void testAssignRoleToUserUncategorizedUserRoleDaoException() {
    String user = "testUser1";
    String roles = "testRole1";
    doThrow(new UncategorizedUserRoleDaoException("expectedTestException")).when(userRoleService).assignRolesToUser(anyString(), anyString());
    try {
        userRoleResource.assignRolesToUser(user, roles);
    } catch (WebApplicationException e) {
        assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), e.getResponse().getStatus());
    }
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) UncategorizedUserRoleDaoException(org.pentaho.platform.api.engine.security.userroledao.UncategorizedUserRoleDaoException) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 10 with UncategorizedUserRoleDaoException

use of org.pentaho.platform.api.engine.security.userroledao.UncategorizedUserRoleDaoException 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);
}
Also used : ITenant(org.pentaho.platform.api.mt.ITenant) UncategorizedUserRoleDaoException(org.pentaho.platform.api.engine.security.userroledao.UncategorizedUserRoleDaoException) Matchers.anyString(org.mockito.Matchers.anyString) IUserRoleDao(org.pentaho.platform.api.engine.security.userroledao.IUserRoleDao) IPentahoUser(org.pentaho.platform.api.engine.security.userroledao.IPentahoUser) Test(org.junit.Test)

Aggregations

UncategorizedUserRoleDaoException (org.pentaho.platform.api.engine.security.userroledao.UncategorizedUserRoleDaoException)13 Test (org.junit.Test)11 Matchers.anyString (org.mockito.Matchers.anyString)10 WebApplicationException (javax.ws.rs.WebApplicationException)8 IUserRoleDao (org.pentaho.platform.api.engine.security.userroledao.IUserRoleDao)5 ITenant (org.pentaho.platform.api.mt.ITenant)5 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)3 IPentahoRole (org.pentaho.platform.api.engine.security.userroledao.IPentahoRole)2 IPentahoUser (org.pentaho.platform.api.engine.security.userroledao.IPentahoUser)2 ArrayList (java.util.ArrayList)1 Consumes (javax.ws.rs.Consumes)1 PUT (javax.ws.rs.PUT)1 Path (javax.ws.rs.Path)1 Response (javax.ws.rs.core.Response)1 StatusCodes (org.codehaus.enunciate.jaxrs.StatusCodes)1 GrantedAuthority (org.springframework.security.core.GrantedAuthority)1 SimpleGrantedAuthority (org.springframework.security.core.authority.SimpleGrantedAuthority)1 User (org.springframework.security.core.userdetails.User)1 UsernameNotFoundException (org.springframework.security.core.userdetails.UsernameNotFoundException)1