Search in sources :

Example 11 with IUserRoleWebService

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

the class UserRoleWebServiceBase method testCreateRole.

@Test
public void testCreateRole() throws Exception {
    UserRoleDaoMock userRoleDao = PentahoSystem.get(UserRoleDaoMock.class, USER_ROLE_DAO_TXN, null);
    IUserRoleWebService service = getUserRoleWebService();
    mockUserAsAdmin(false);
    ProxyPentahoRole role = new ProxyPentahoRole("role");
    role.setDescription("testing");
    try {
        service.createRole(role);
        Assert.fail();
    } catch (UserRoleException e) {
        Assert.assertTrue("ERROR_0001 not found in " + e.getMessage(), e.getMessage().indexOf("ERROR_0001") >= 0);
    }
    mockUserAsAdmin(true);
    service.createRole(role);
    // the last role should have the same name and description
    IPentahoRole roleVerified = userRoleDao.getRole(null, "role");
    Assert.assertNotNull(roleVerified);
    Assert.assertEquals("role", roleVerified.getName());
    Assert.assertEquals("testing", roleVerified.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) IPentahoRole(org.pentaho.platform.api.engine.security.userroledao.IPentahoRole) Test(org.junit.Test)

Example 12 with IUserRoleWebService

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

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

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

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

Aggregations

IUserRoleWebService (org.pentaho.platform.security.userroledao.ws.IUserRoleWebService)16 Test (org.junit.Test)15 UserRoleException (org.pentaho.platform.security.userroledao.ws.UserRoleException)15 ProxyPentahoRole (org.pentaho.platform.security.userroledao.ws.ProxyPentahoRole)9 ProxyPentahoUser (org.pentaho.platform.security.userroledao.ws.ProxyPentahoUser)9 UserRoleSecurityInfo (org.pentaho.platform.security.userroledao.ws.UserRoleSecurityInfo)2 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 QName (javax.xml.namespace.QName)1 Service (javax.xml.ws.Service)1 IPentahoRole (org.pentaho.platform.api.engine.security.userroledao.IPentahoRole)1 IPentahoUser (org.pentaho.platform.api.engine.security.userroledao.IPentahoUser)1 UserRoleWebService (org.pentaho.platform.security.userroledao.ws.UserRoleWebService)1