Search in sources :

Example 6 with UserRoleException

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

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

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

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

the class UserRoleWebServiceBase method testCreateBlankUser.

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

Example 10 with UserRoleException

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

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