Search in sources :

Example 6 with ProxyPentahoRole

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

the class UserRoleHelper method convertToPentahoProxyRole.

public static ProxyPentahoRole convertToPentahoProxyRole(IRole roleInfo) {
    ProxyPentahoRole role = new ProxyPentahoRole();
    role.setName(roleInfo.getName());
    role.setDescription(roleInfo.getDescription());
    return role;
}
Also used : ProxyPentahoRole(org.pentaho.platform.security.userroledao.ws.ProxyPentahoRole)

Example 7 with ProxyPentahoRole

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

the class UserRoleHelper method convertToListFromProxyPentahoDefaultRoles.

public static List<IRole> convertToListFromProxyPentahoDefaultRoles(UserRoleSecurityInfo info, IRoleSupportSecurityManager rsm) {
    List<IRole> roleList = new ArrayList<IRole>();
    List<ProxyPentahoRole> roles = info.getDefaultRoles();
    List<UserToRoleAssignment> assignments = info.getAssignments();
    for (ProxyPentahoRole role : roles) {
        roleList.add(convertFromProxyPentahoRole(role, assignments, rsm));
    }
    return roleList;
}
Also used : IRole(org.pentaho.di.repository.pur.model.IRole) UserToRoleAssignment(org.pentaho.platform.security.userroledao.ws.UserToRoleAssignment) ProxyPentahoRole(org.pentaho.platform.security.userroledao.ws.ProxyPentahoRole) ArrayList(java.util.ArrayList)

Example 8 with ProxyPentahoRole

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

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

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

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