use of org.pentaho.platform.api.engine.security.userroledao.NotFoundException in project pentaho-platform by pentaho.
the class MockUserRoleDao method setRoleDescription.
public void setRoleDescription(ITenant tenant, String roleName, String description) throws NotFoundException, UncategorizedUserRoleDaoException {
IPentahoRole role = getRole(tenant, roleName);
if (role == null) {
throw new NotFoundException(roleName);
}
role.setDescription(description);
}
use of org.pentaho.platform.api.engine.security.userroledao.NotFoundException in project pentaho-platform by pentaho.
the class MockUserRoleDao method setUserDescription.
public void setUserDescription(ITenant tenant, String userName, String description) throws NotFoundException, UncategorizedUserRoleDaoException {
IPentahoUser user = getUser(tenant, userName);
if (user == null) {
throw new NotFoundException(userName);
}
user.setDescription(description);
}
use of org.pentaho.platform.api.engine.security.userroledao.NotFoundException in project pentaho-platform by pentaho.
the class MockUserRoleDao method setPassword.
public void setPassword(ITenant tenant, String userName, String password) throws NotFoundException, UncategorizedUserRoleDaoException {
IPentahoUser user = getUser(tenant, userName);
if (user == null) {
throw new NotFoundException(userName);
}
user.setPassword(password);
}
use of org.pentaho.platform.api.engine.security.userroledao.NotFoundException in project pentaho-platform by pentaho.
the class UserRoleDaoEncodeIT method testUpdateUser.
@Test
public void testUpdateUser() throws Exception {
loginAsRepositoryAdmin();
systemTenant = tenantManager.createTenant(null, ServerRepositoryPaths.getPentahoRootFolderName(), adminRoleName, authenticatedRoleName, "Anonymous");
userRoleDaoProxy.createUser(systemTenant, sysAdminUserName, "password", "", new String[] { adminRoleName });
login(sysAdminUserName, systemTenant, new String[] { adminRoleName, authenticatedRoleName });
mainTenant_1 = tenantManager.createTenant(systemTenant, MAIN_TENANT_1, adminRoleName, authenticatedRoleName, "Anonymous");
userRoleDaoProxy.createUser(mainTenant_1, "admin", "password", "", new String[] { adminRoleName });
mainTenant_2 = tenantManager.createTenant(systemTenant, MAIN_TENANT_2, adminRoleName, authenticatedRoleName, "Anonymous");
userRoleDaoProxy.createUser(mainTenant_2, "admin", "password", "", new String[] { adminRoleName });
login("admin", mainTenant_1, new String[] { adminRoleName, authenticatedRoleName });
IPentahoUser pentahoUser = userRoleDaoProxy.createUser(mainTenant_1, USER_5, PASSWORD_5, USER_DESCRIPTION_5, null);
pentahoUser = userRoleDaoProxy.getUser(mainTenant_1, USER_5);
assertEquals(pentahoUser.getDescription(), USER_DESCRIPTION_5);
String changedDescription1 = USER_DESCRIPTION_5 + "change1";
userRoleDaoProxy.setUserDescription(mainTenant_1, USER_5, changedDescription1);
pentahoUser = userRoleDaoProxy.getUser(null, USER_5 + DefaultTenantedPrincipleNameResolver.DEFAULT_DELIMETER + mainTenant_1.getRootFolderAbsolutePath());
assertEquals(changedDescription1, pentahoUser.getDescription());
String changedDescription2 = USER_DESCRIPTION_5 + "change2";
userRoleDaoProxy.setUserDescription(null, USER_5 + DefaultTenantedPrincipleNameResolver.DEFAULT_DELIMETER + mainTenant_1.getRootFolderAbsolutePath(), changedDescription2);
pentahoUser = userRoleDaoProxy.getUser(mainTenant_1, USER_5);
assertEquals(changedDescription2, pentahoUser.getDescription());
userRoleDaoProxy.setUserDescription(null, USER_5 + DefaultTenantedPrincipleNameResolver.DEFAULT_DELIMETER + mainTenant_1.getRootFolderAbsolutePath(), null);
pentahoUser = userRoleDaoProxy.getUser(mainTenant_1, USER_5);
assertNull(pentahoUser.getDescription());
try {
userRoleDaoProxy.setUserDescription(null, null, changedDescription2);
fail("Exception not thrown");
} catch (Exception ex) {
// Expected exception
}
try {
userRoleDaoProxy.setUserDescription(null, USER_5, changedDescription2);
} catch (Exception ex) {
// Expected exception
}
try {
userRoleDaoProxy.setUserDescription(mainTenant_1, UNKNOWN_USER, changedDescription2);
fail("Exception not thrown");
} catch (NotFoundException ex) {
// Expected exception
}
logout();
login("admin", mainTenant_2, new String[] { adminRoleName, authenticatedRoleName });
try {
changedDescription1 = USER_DESCRIPTION_5 + "change1";
userRoleDaoProxy.setUserDescription(mainTenant_1, USER_5, changedDescription1);
fail("Exception not thrown");
} catch (Throwable th) {
assertNotNull(th);
}
logout();
}
use of org.pentaho.platform.api.engine.security.userroledao.NotFoundException in project pentaho-platform by pentaho.
the class UserRoleDaoIT method testUpdateRole.
@Test
public void testUpdateRole() throws Exception {
loginAsRepositoryAdmin();
systemTenant = tenantManager.createTenant(null, ServerRepositoryPaths.getPentahoRootFolderName(), adminRoleName, authenticatedRoleName, "Anonymous");
userRoleDaoProxy.createUser(systemTenant, sysAdminUserName, "password", "", new String[] { adminRoleName });
login(sysAdminUserName, systemTenant, new String[] { adminRoleName, authenticatedRoleName });
mainTenant_1 = tenantManager.createTenant(systemTenant, MAIN_TENANT_1, adminRoleName, authenticatedRoleName, "Anonymous");
userRoleDaoProxy.createUser(mainTenant_1, "admin", "password", "", new String[] { adminRoleName });
mainTenant_2 = tenantManager.createTenant(systemTenant, MAIN_TENANT_2, adminRoleName, authenticatedRoleName, "Anonymous");
userRoleDaoProxy.createUser(mainTenant_2, "admin", "password", "", new String[] { adminRoleName });
login("admin", mainTenant_1, new String[] { adminRoleName, authenticatedRoleName });
IPentahoRole pentahoRole = userRoleDaoProxy.createRole(mainTenant_1, ROLE_5, ROLE_DESCRIPTION_5, null);
pentahoRole = userRoleDaoProxy.getRole(mainTenant_1, ROLE_5);
assertEquals(pentahoRole.getDescription(), ROLE_DESCRIPTION_5);
String changedDescription1 = ROLE_DESCRIPTION_5 + "change1";
userRoleDaoProxy.setRoleDescription(mainTenant_1, ROLE_5, changedDescription1);
String role_delim = ((DefaultTenantedPrincipleNameResolver) tenantedRoleNameUtils).getDelimeter();
pentahoRole = userRoleDaoProxy.getRole(null, ROLE_5 + role_delim + mainTenant_1.getRootFolderAbsolutePath());
assertNotNull(pentahoRole);
assertEquals(changedDescription1, pentahoRole.getDescription());
String changedDescription2 = ROLE_DESCRIPTION_5 + "change2";
userRoleDaoProxy.setRoleDescription(null, ROLE_5 + role_delim + mainTenant_1.getRootFolderAbsolutePath(), changedDescription2);
pentahoRole = userRoleDaoProxy.getRole(mainTenant_1, ROLE_5);
assertEquals(changedDescription2, pentahoRole.getDescription());
userRoleDaoProxy.setRoleDescription(null, ROLE_5 + role_delim + mainTenant_1.getRootFolderAbsolutePath(), null);
pentahoRole = userRoleDaoProxy.getRole(mainTenant_1, ROLE_5);
assertNull(pentahoRole.getDescription());
try {
userRoleDaoProxy.setRoleDescription(null, null, changedDescription2);
fail("Exception not thrown");
} catch (Exception ex) {
// Expected exception
assertNotNull(ex);
}
try {
userRoleDaoProxy.setRoleDescription(mainTenant_1, UNKNOWN_ROLE, changedDescription2);
fail("Exception not thrown");
} catch (NotFoundException ex) {
// Expected exception
assertNotNull(ex);
}
logout();
login("admin", mainTenant_2, new String[] { adminRoleName, authenticatedRoleName });
try {
changedDescription1 = ROLE_DESCRIPTION_5 + "change1";
userRoleDaoProxy.setRoleDescription(mainTenant_1, ROLE_5, changedDescription1);
fail("Exception not thrown");
} catch (Throwable th) {
assertNotNull(th);
}
logout();
}
Aggregations