Search in sources :

Example 16 with UserRoleException

use of org.pentaho.platform.security.userroledao.ws.UserRoleException in project pentaho-platform by pentaho.

the class UserRoleWebServiceBase method testSetUsers.

@Test
public void testSetUsers() throws UserRoleException {
    UserRoleDaoMock userRoleDao = PentahoSystem.get(UserRoleDaoMock.class, USER_ROLE_DAO_TXN, null);
    IUserRoleWebService service = getUserRoleWebService();
    mockUserAsAdmin(false);
    ProxyPentahoRole roleObj = new ProxyPentahoRole("testRole1");
    ProxyPentahoUser[] usersObj = new ProxyPentahoUser[1];
    usersObj[0] = new ProxyPentahoUser();
    usersObj[0].setName("test2");
    try {
        service.setUsers(roleObj, usersObj);
        Assert.fail();
    } catch (UserRoleException e) {
        Assert.assertTrue("ERROR_0001 not found in " + e.getMessage(), e.getMessage().indexOf("ERROR_0001") >= 0);
    }
    mockUserAsAdmin(true);
    Assert.assertEquals("test1", userRoleDao.getRoleMembers(null, "testRole1").get(0).getUsername());
    service.setUsers(roleObj, usersObj);
    Assert.assertEquals("test2", userRoleDao.getRoleMembers(null, "testRole1").get(0).getUsername());
}
Also used : ProxyPentahoRole(org.pentaho.platform.security.userroledao.ws.ProxyPentahoRole) IUserRoleWebService(org.pentaho.platform.security.userroledao.ws.IUserRoleWebService) UserRoleException(org.pentaho.platform.security.userroledao.ws.UserRoleException) ProxyPentahoUser(org.pentaho.platform.security.userroledao.ws.ProxyPentahoUser) Test(org.junit.Test)

Example 17 with UserRoleException

use of org.pentaho.platform.security.userroledao.ws.UserRoleException in project pentaho-platform by pentaho.

the class UserRoleWebServiceBase method testDeleteUsers.

@Test
public void testDeleteUsers() throws Exception {
    IUserRoleWebService service = getUserRoleWebService();
    mockUserAsAdmin(false);
    ProxyPentahoUser[] usersObj = new ProxyPentahoUser[1];
    usersObj[0] = new ProxyPentahoUser();
    usersObj[0].setName("test1");
    try {
        service.deleteUsers(usersObj);
        Assert.fail();
    } catch (UserRoleException e) {
        Assert.assertTrue("ERROR_0001 not found in " + e.getMessage(), e.getMessage().indexOf("ERROR_0001") >= 0);
    }
    mockUserAsAdmin(true);
    service.deleteUsers(usersObj);
    Assert.assertEquals(1, users.size());
}
Also used : IUserRoleWebService(org.pentaho.platform.security.userroledao.ws.IUserRoleWebService) UserRoleException(org.pentaho.platform.security.userroledao.ws.UserRoleException) ProxyPentahoUser(org.pentaho.platform.security.userroledao.ws.ProxyPentahoUser) Test(org.junit.Test)

Example 18 with UserRoleException

use of org.pentaho.platform.security.userroledao.ws.UserRoleException in project pentaho-platform by pentaho.

the class UserRoleWebServiceBase method testCreateBlankRole.

@Test
public void testCreateBlankRole() throws UserRoleException {
    UserRoleWebService userRoleWebService = new UserRoleWebService();
    ProxyPentahoRole proxyPentahoRole = new ProxyPentahoRole();
    try {
        userRoleWebService.createRole(proxyPentahoRole);
        Assert.fail();
    } catch (UserRoleException e) {
        Assert.assertEquals(0, e.getStackTrace().length);
    }
}
Also used : ProxyPentahoRole(org.pentaho.platform.security.userroledao.ws.ProxyPentahoRole) UserRoleException(org.pentaho.platform.security.userroledao.ws.UserRoleException) UserRoleWebService(org.pentaho.platform.security.userroledao.ws.UserRoleWebService) IUserRoleWebService(org.pentaho.platform.security.userroledao.ws.IUserRoleWebService) Test(org.junit.Test)

Example 19 with UserRoleException

use of org.pentaho.platform.security.userroledao.ws.UserRoleException in project pentaho-platform by pentaho.

the class UserRoleWebServiceBase method testGetUser.

@Test
public void testGetUser() throws Exception {
    IUserRoleWebService service = getUserRoleWebService();
    mockUserAsAdmin(false);
    try {
        service.getUser(null);
        Assert.fail();
    } catch (UserRoleException e) {
        Assert.assertTrue("ERROR_0001 not found in " + e.getMessage(), e.getMessage().indexOf("ERROR_0001") >= 0);
    }
    mockUserAsAdmin(true);
    ProxyPentahoUser userObj = service.getUser("test1");
    Assert.assertNotNull(userObj);
    Assert.assertEquals("test1", userObj.getName());
}
Also used : IUserRoleWebService(org.pentaho.platform.security.userroledao.ws.IUserRoleWebService) UserRoleException(org.pentaho.platform.security.userroledao.ws.UserRoleException) ProxyPentahoUser(org.pentaho.platform.security.userroledao.ws.ProxyPentahoUser) Test(org.junit.Test)

Example 20 with UserRoleException

use of org.pentaho.platform.security.userroledao.ws.UserRoleException in project pentaho-platform by pentaho.

the class UserRoleWebServiceBase method testGetRoles.

@Test
public void testGetRoles() throws Exception {
    IUserRoleWebService service = getUserRoleWebService();
    mockUserAsAdmin(false);
    try {
        service.getRoles();
        Assert.fail();
    } catch (UserRoleException e) {
        Assert.assertTrue("ERROR_0001 not found in " + e.getMessage(), e.getMessage().indexOf("ERROR_0001") >= 0);
    }
    mockUserAsAdmin(true);
    ProxyPentahoRole[] roleObjs = service.getRoles();
    Assert.assertNotNull(roleObjs);
    Assert.assertEquals(2, roleObjs.length);
}
Also used : ProxyPentahoRole(org.pentaho.platform.security.userroledao.ws.ProxyPentahoRole) IUserRoleWebService(org.pentaho.platform.security.userroledao.ws.IUserRoleWebService) UserRoleException(org.pentaho.platform.security.userroledao.ws.UserRoleException) Test(org.junit.Test)

Aggregations

UserRoleException (org.pentaho.platform.security.userroledao.ws.UserRoleException)21 Test (org.junit.Test)17 IUserRoleWebService (org.pentaho.platform.security.userroledao.ws.IUserRoleWebService)17 ProxyPentahoRole (org.pentaho.platform.security.userroledao.ws.ProxyPentahoRole)11 ProxyPentahoUser (org.pentaho.platform.security.userroledao.ws.ProxyPentahoUser)11 KettleException (org.pentaho.di.core.exception.KettleException)4 JSONException (org.json.JSONException)2 IEEUser (org.pentaho.di.repository.pur.model.IEEUser)2 UserRoleWebService (org.pentaho.platform.security.userroledao.ws.UserRoleWebService)2 ArrayList (java.util.ArrayList)1 IUser (org.pentaho.di.repository.IUser)1 IRole (org.pentaho.di.repository.pur.model.IRole)1 IPentahoRole (org.pentaho.platform.api.engine.security.userroledao.IPentahoRole)1 IPentahoUser (org.pentaho.platform.api.engine.security.userroledao.IPentahoUser)1 UserRoleSecurityInfo (org.pentaho.platform.security.userroledao.ws.UserRoleSecurityInfo)1