Search in sources :

Example 11 with ProxyPentahoUser

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

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

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

Example 14 with ProxyPentahoUser

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

the class UserRoleHelperTest method convertFromProxyPentahoUser_CopiesDataFromInput.

@Test
public void convertFromProxyPentahoUser_CopiesDataFromInput() throws Exception {
    IRoleSupportSecurityManager manager = mockSecurityManager(false);
    ProxyPentahoUser pentahoUser = pentahoUser("name");
    pentahoUser.setPassword("password");
    pentahoUser.setDescription("desc");
    pentahoUser.setEnabled(true);
    IUser user = convertFromProxyPentahoUser(pentahoUser, Collections.<UserToRoleAssignment>emptyList(), manager);
    assertNotNull(user);
    assertEquals(pentahoUser.getName(), user.getName());
    assertEquals(pentahoUser.getName(), user.getLogin());
    assertEquals(pentahoUser.getPassword(), user.getPassword());
    assertEquals(pentahoUser.getDescription(), user.getDescription());
    assertEquals(pentahoUser.getEnabled(), user.isEnabled());
}
Also used : IRoleSupportSecurityManager(org.pentaho.di.ui.repository.pur.services.IRoleSupportSecurityManager) IUser(org.pentaho.di.repository.IUser) ProxyPentahoUser(org.pentaho.platform.security.userroledao.ws.ProxyPentahoUser) UserRoleHelper.convertFromProxyPentahoUser(org.pentaho.di.repository.pur.UserRoleHelper.convertFromProxyPentahoUser) Test(org.junit.Test)

Example 15 with ProxyPentahoUser

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

the class UserRoleHelperTest method pentahoUser.

private static ProxyPentahoUser pentahoUser(String name) {
    ProxyPentahoUser pentahoUser = new ProxyPentahoUser();
    pentahoUser.setName(name);
    return pentahoUser;
}
Also used : ProxyPentahoUser(org.pentaho.platform.security.userroledao.ws.ProxyPentahoUser) UserRoleHelper.convertFromProxyPentahoUser(org.pentaho.di.repository.pur.UserRoleHelper.convertFromProxyPentahoUser)

Aggregations

ProxyPentahoUser (org.pentaho.platform.security.userroledao.ws.ProxyPentahoUser)24 Test (org.junit.Test)15 UserRoleException (org.pentaho.platform.security.userroledao.ws.UserRoleException)14 IUserRoleWebService (org.pentaho.platform.security.userroledao.ws.IUserRoleWebService)11 IUser (org.pentaho.di.repository.IUser)7 KettleException (org.pentaho.di.core.exception.KettleException)5 JSONException (org.json.JSONException)4 UserRoleHelper.convertFromProxyPentahoUser (org.pentaho.di.repository.pur.UserRoleHelper.convertFromProxyPentahoUser)4 ProxyPentahoRole (org.pentaho.platform.security.userroledao.ws.ProxyPentahoRole)4 IRoleSupportSecurityManager (org.pentaho.di.ui.repository.pur.services.IRoleSupportSecurityManager)3 IEEUser (org.pentaho.di.repository.pur.model.IEEUser)2 UserRoleWebService (org.pentaho.platform.security.userroledao.ws.UserRoleWebService)2 UserToRoleAssignment (org.pentaho.platform.security.userroledao.ws.UserToRoleAssignment)2 ArrayList (java.util.ArrayList)1 UserInfo (org.pentaho.di.repository.UserInfo)1 EEUserInfo (org.pentaho.di.repository.pur.model.EEUserInfo)1 AlreadyExistsException (org.pentaho.platform.api.engine.security.userroledao.AlreadyExistsException)1 IPentahoUser (org.pentaho.platform.api.engine.security.userroledao.IPentahoUser)1