Search in sources :

Example 16 with ProxyPentahoRole

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

the class UserRoleWebServiceBase method testGetUsersForRole.

@Test
public void testGetUsersForRole() throws UserRoleException {
    IUserRoleWebService service = getUserRoleWebService();
    mockUserAsAdmin(false);
    ProxyPentahoRole roleObj = new ProxyPentahoRole("testRole1");
    try {
        service.getUsersForRole(roleObj);
        Assert.fail();
    } catch (UserRoleException e) {
        Assert.assertTrue("ERROR_0001 not found in " + e.getMessage(), e.getMessage().indexOf("ERROR_0001") >= 0);
    }
    mockUserAsAdmin(true);
    ProxyPentahoUser[] userObjs = service.getUsersForRole(roleObj);
    Assert.assertEquals(1, userObjs.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) ProxyPentahoUser(org.pentaho.platform.security.userroledao.ws.ProxyPentahoUser) Test(org.junit.Test)

Example 17 with ProxyPentahoRole

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

the class UserRoleWebServiceBase method testUpdateRoleObject.

@Test
public void testUpdateRoleObject() throws UserRoleException {
    UserRoleDaoMock userRoleDao = PentahoSystem.get(UserRoleDaoMock.class, USER_ROLE_DAO_TXN, null);
    IUserRoleWebService service = getUserRoleWebService();
    mockUserAsAdmin(false);
    ProxyPentahoRole roleObj = new ProxyPentahoRole("testRole1");
    roleObj.setDescription("testUpdateRoleObject");
    try {
        service.updateRoleObject(roleObj);
        Assert.fail();
    } catch (UserRoleException e) {
        Assert.assertTrue("ERROR_0001 not found in " + e.getMessage(), e.getMessage().indexOf("ERROR_0001") >= 0);
    }
    mockUserAsAdmin(true);
    Assert.assertEquals("test role", userRoleDao.getRole(null, "testRole1").getDescription());
    service.updateRoleObject(roleObj);
    Assert.assertEquals("testUpdateRoleObject", userRoleDao.getRole(null, "testRole1").getDescription());
}
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)

Example 18 with ProxyPentahoRole

use of org.pentaho.platform.security.userroledao.ws.ProxyPentahoRole 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 19 with ProxyPentahoRole

use of org.pentaho.platform.security.userroledao.ws.ProxyPentahoRole 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 20 with ProxyPentahoRole

use of org.pentaho.platform.security.userroledao.ws.ProxyPentahoRole 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

ProxyPentahoRole (org.pentaho.platform.security.userroledao.ws.ProxyPentahoRole)21 Test (org.junit.Test)12 UserRoleException (org.pentaho.platform.security.userroledao.ws.UserRoleException)12 IUserRoleWebService (org.pentaho.platform.security.userroledao.ws.IUserRoleWebService)11 IRole (org.pentaho.di.repository.pur.model.IRole)6 ProxyPentahoUser (org.pentaho.platform.security.userroledao.ws.ProxyPentahoUser)4 ArrayList (java.util.ArrayList)3 KettleException (org.pentaho.di.core.exception.KettleException)3 JSONException (org.json.JSONException)2 UserRoleWebService (org.pentaho.platform.security.userroledao.ws.UserRoleWebService)2 UserToRoleAssignment (org.pentaho.platform.security.userroledao.ws.UserToRoleAssignment)2 HashSet (java.util.HashSet)1 EERoleInfo (org.pentaho.di.repository.pur.model.EERoleInfo)1 AlreadyExistsException (org.pentaho.platform.api.engine.security.userroledao.AlreadyExistsException)1 IPentahoRole (org.pentaho.platform.api.engine.security.userroledao.IPentahoRole)1