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);
}
}
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);
}
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());
}
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());
}
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;
}
Aggregations