Search in sources :

Example 6 with IUserRoleWebService

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

the class UserRoleWebServiceBase method testGetRolesForUser.

@Test
public void testGetRolesForUser() throws UserRoleException {
    IUserRoleWebService service = getUserRoleWebService();
    mockUserAsAdmin(false);
    ProxyPentahoUser userObj = new ProxyPentahoUser();
    userObj.setName("test1");
    try {
        service.getRolesForUser(userObj);
        Assert.fail();
    } catch (UserRoleException e) {
        Assert.assertTrue("ERROR_0001 not found in " + e.getMessage(), e.getMessage().indexOf("ERROR_0001") >= 0);
    }
    mockUserAsAdmin(true);
    ProxyPentahoRole[] roles = service.getRolesForUser(userObj);
    Assert.assertEquals(1, roles.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 7 with IUserRoleWebService

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

the class UserRoleWebServiceBase method testUpdateRole.

@Test
public void testUpdateRole() 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");
    List<String> usernames = new ArrayList<String>();
    try {
        service.updateRole("testRole1", "testUpdateRoleObject", usernames);
        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.updateRole("testRole1", "testUpdateRoleObject", usernames);
    Assert.assertEquals("testUpdateRoleObject", userRoleDao.getRole(null, "testRole1").getDescription());
}
Also used : ProxyPentahoRole(org.pentaho.platform.security.userroledao.ws.ProxyPentahoRole) ArrayList(java.util.ArrayList) IUserRoleWebService(org.pentaho.platform.security.userroledao.ws.IUserRoleWebService) UserRoleException(org.pentaho.platform.security.userroledao.ws.UserRoleException) Test(org.junit.Test)

Example 8 with IUserRoleWebService

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

the class UserRoleWebServiceBase method testUpdateUser.

@Test
public void testUpdateUser() throws UserRoleException {
    UserRoleDaoMock userRoleDao = PentahoSystem.get(UserRoleDaoMock.class, USER_ROLE_DAO_TXN, null);
    IUserRoleWebService service = getUserRoleWebService();
    mockUserAsAdmin(false);
    ProxyPentahoUser userObj = new ProxyPentahoUser();
    userObj.setName("test1");
    userObj.setDescription("testUpdateUser");
    userObj.setPassword("newpass");
    try {
        service.updateUser(userObj);
        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", userRoleDao.getUser(null, "test1").getDescription());
    service.updateUser(userObj);
    Assert.assertEquals("testUpdateUser", userRoleDao.getUser(null, "test1").getDescription());
}
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 9 with IUserRoleWebService

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

Example 10 with IUserRoleWebService

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

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