Search in sources :

Example 1 with IUserRoleWebService

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

the class UserRoleWebServiceBase method testGetUserRoleSecurityInfo.

@Test
public void testGetUserRoleSecurityInfo() throws Exception {
    IUserRoleWebService service = getUserRoleWebService();
    mockUserAsAdmin(false);
    try {
        service.getUserRoleSecurityInfo();
        Assert.fail();
    } catch (UserRoleException e) {
        // should this be 0001, not admin?
        Assert.assertTrue(e.getMessage().indexOf("ERROR_0001") >= 0);
    }
    mockUserAsAdmin(true);
    UserRoleSecurityInfo info = service.getUserRoleSecurityInfo();
    Assert.assertNotNull(info);
    Assert.assertEquals(2, info.getRoles().size());
    Assert.assertEquals(2, info.getUsers().size());
    Assert.assertEquals(2, info.getAssignments().size());
}
Also used : UserRoleSecurityInfo(org.pentaho.platform.security.userroledao.ws.UserRoleSecurityInfo) IUserRoleWebService(org.pentaho.platform.security.userroledao.ws.IUserRoleWebService) UserRoleException(org.pentaho.platform.security.userroledao.ws.UserRoleException) Test(org.junit.Test)

Example 2 with IUserRoleWebService

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

the class UserRoleWebServiceBase method testSetRoles.

@Test
public void testSetRoles() 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");
    ProxyPentahoRole[] rolesObj = new ProxyPentahoRole[1];
    rolesObj[0] = new ProxyPentahoRole("testRole2");
    try {
        service.setRoles(userObj, rolesObj);
        Assert.fail();
    } catch (UserRoleException e) {
        Assert.assertTrue("ERROR_0001 not found in " + e.getMessage(), e.getMessage().indexOf("ERROR_0001") >= 0);
    }
    mockUserAsAdmin(true);
    userRoleDao.getUserRoles(null, "test1");
    Assert.assertEquals("testRole1", userRoleDao.getUserRoles(null, "test1").get(0).getName());
    service.setRoles(userObj, rolesObj);
    Assert.assertEquals("testRole2", userRoleDao.getUserRoles(null, "test1").get(0).getName());
}
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 3 with IUserRoleWebService

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

the class UserRoleWebServiceBase method testGetUsers.

@Test
public void testGetUsers() throws Exception {
    IUserRoleWebService service = getUserRoleWebService();
    mockUserAsAdmin(false);
    try {
        service.getUsers();
        Assert.fail();
    } catch (UserRoleException e) {
        // should this be 0001, not admin?
        Assert.assertTrue("ERROR_0001 not found in " + e.getMessage(), e.getMessage().indexOf("ERROR_0001") >= 0);
    }
    mockUserAsAdmin(true);
    ProxyPentahoUser[] userObjs = service.getUsers();
    Assert.assertNotNull(userObjs);
    Assert.assertEquals(2, userObjs.length);
}
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 4 with IUserRoleWebService

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

the class UserRoleWebServiceBase method testDeleteRoles.

@Test
public void testDeleteRoles() throws Exception {
    IUserRoleWebService service = getUserRoleWebService();
    mockUserAsAdmin(false);
    ProxyPentahoRole[] rolesObj = new ProxyPentahoRole[1];
    rolesObj[0] = new ProxyPentahoRole("testRole1");
    try {
        service.deleteRoles(rolesObj);
        Assert.fail();
    } catch (UserRoleException e) {
        Assert.assertTrue("ERROR_0001 not found in " + e.getMessage(), e.getMessage().indexOf("ERROR_0001") >= 0);
    }
    mockUserAsAdmin(true);
    service.deleteRoles(rolesObj);
    Assert.assertEquals(1, roles.size());
}
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 5 with IUserRoleWebService

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

the class UserRoleWebServiceBase method testCreateUser.

@Test
public void testCreateUser() throws Exception {
    UserRoleDaoMock userRoleDao = PentahoSystem.get(UserRoleDaoMock.class, USER_ROLE_DAO_TXN, null);
    IUserRoleWebService service = getUserRoleWebService();
    mockUserAsAdmin(false);
    ProxyPentahoUser user = new ProxyPentahoUser();
    user.setName("test");
    user.setEnabled(true);
    user.setPassword("test");
    user.setDescription("testing");
    try {
        service.createUser(user);
        Assert.fail();
    } catch (UserRoleException e) {
        Assert.assertTrue("ERROR_0001 not found in " + e.getMessage(), e.getMessage().indexOf("ERROR_0001") >= 0);
    }
    mockUserAsAdmin(true);
    service.createUser(user);
    // the last role should have the same name and description
    IPentahoUser userVerified = userRoleDao.getUser(null, "test");
    Assert.assertNotNull(userVerified);
    Assert.assertEquals("test", userVerified.getUsername());
    Assert.assertEquals("test", userVerified.getPassword());
    Assert.assertEquals(true, userVerified.isEnabled());
    Assert.assertEquals("testing", userVerified.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) IPentahoUser(org.pentaho.platform.api.engine.security.userroledao.IPentahoUser) 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