use of org.pentaho.platform.api.engine.security.userroledao.NotFoundException in project pentaho-platform by pentaho.
the class UserRoleDaoEncodeIT method testDeleteUser.
@Test
public void testDeleteUser() throws Exception {
int DEFAULT_TENANT_USER = 1;
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_6, PASSWORD_6, USER_DESCRIPTION_6, null);
pentahoUser = userRoleDaoProxy.getUser(null, USER_6 + DefaultTenantedPrincipleNameResolver.DEFAULT_DELIMETER + mainTenant_1.getRootFolderAbsolutePath());
assertNotNull(pentahoUser);
logout();
login("admin", mainTenant_2, new String[] { adminRoleName, authenticatedRoleName });
try {
userRoleDaoProxy.deleteUser(pentahoUser);
fail("Exception not thrown");
} catch (Throwable th) {
assertNotNull(th);
}
logout();
login("admin", mainTenant_1, new String[] { adminRoleName, authenticatedRoleName });
pentahoUser = userRoleDaoProxy.getUser(null, USER_6 + DefaultTenantedPrincipleNameResolver.DEFAULT_DELIMETER + mainTenant_1.getRootFolderAbsolutePath());
assertNull(pentahoUser);
assertEquals(DEFAULT_TENANT_USER, userRoleDaoProxy.getUsers(mainTenant_1).size());
pentahoUser = userRoleDaoProxy.createUser(null, USER_6 + DefaultTenantedPrincipleNameResolver.DEFAULT_DELIMETER + mainTenant_1.getRootFolderAbsolutePath(), PASSWORD_6, USER_DESCRIPTION_6, null);
pentahoUser = userRoleDaoProxy.getUser(mainTenant_1, USER_6);
assertNotNull(pentahoUser);
userRoleDaoProxy.deleteUser(pentahoUser);
assertNull(userRoleDaoProxy.getUser(null, USER_6 + DefaultTenantedPrincipleNameResolver.DEFAULT_DELIMETER + mainTenant_1.getRootFolderAbsolutePath()));
try {
userRoleDaoProxy.deleteUser(pentahoUser);
fail("Exception not thrown");
} catch (NotFoundException e) {
// Expected exception
}
try {
pentahoUser = new PentahoUser(null, USER_6, PASSWORD_6, USER_DESCRIPTION_6, true);
userRoleDaoProxy.deleteUser(pentahoUser);
fail("Exception not thrown");
} catch (Exception ex) {
// Expected exception
}
try {
pentahoUser = new PentahoUser(mainTenant_1, null, PASSWORD_6, USER_DESCRIPTION_6, true);
userRoleDaoProxy.deleteUser(pentahoUser);
fail("Exception not thrown");
} catch (NotFoundException e) {
// Expected exception
}
try {
pentahoUser = new PentahoUser(mainTenant_1, UNKNOWN_USER, PASSWORD_6, USER_DESCRIPTION_6, true);
userRoleDaoProxy.deleteUser(pentahoUser);
fail("Exception not thrown");
} catch (NotFoundException e) {
// Expected exception
}
}
use of org.pentaho.platform.api.engine.security.userroledao.NotFoundException in project pentaho-platform by pentaho.
the class UserRoleDaoEncodeIT method testDeleteRole.
@Test
public void testDeleteRole() throws Exception {
int DEFAULT_ROLE_COUNT = 3;
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 });
String role_delim = ((DefaultTenantedPrincipleNameResolver) tenantedRoleNameUtils).getDelimeter();
IPentahoRole pentahoRole = userRoleDaoProxy.createRole(mainTenant_1, ROLE_6, ROLE_DESCRIPTION_6, null);
pentahoRole = userRoleDaoProxy.getRole(null, ROLE_6 + role_delim + mainTenant_1.getRootFolderAbsolutePath());
assertNotNull(pentahoRole);
logout();
login("admin", mainTenant_2, new String[] { adminRoleName, authenticatedRoleName });
try {
userRoleDaoProxy.deleteRole(pentahoRole);
fail("Exception not thrown");
} catch (Throwable th) {
assertNotNull(th);
}
logout();
login("admin", mainTenant_1, new String[] { adminRoleName, authenticatedRoleName });
pentahoRole = userRoleDaoProxy.getRole(null, ROLE_6 + role_delim + mainTenant_1.getRootFolderAbsolutePath());
assertNull(pentahoRole);
assertEquals(DEFAULT_ROLE_COUNT, userRoleDaoProxy.getRoles(mainTenant_1).size());
pentahoRole = userRoleDaoProxy.createRole(null, ROLE_6 + role_delim + mainTenant_1.getRootFolderAbsolutePath(), ROLE_DESCRIPTION_6, null);
pentahoRole = userRoleDaoProxy.getRole(mainTenant_1, ROLE_6);
assertNotNull(pentahoRole);
userRoleDaoProxy.deleteRole(pentahoRole);
assertNull(userRoleDaoProxy.getRole(null, ROLE_6 + role_delim + mainTenant_1.getRootFolderAbsolutePath()));
try {
userRoleDaoProxy.deleteRole(pentahoRole);
fail("Exception not thrown");
} catch (NotFoundException e) {
// Expected exception
}
try {
pentahoRole = new PentahoRole(null, ROLE_6, ROLE_DESCRIPTION_6);
userRoleDaoProxy.deleteRole(pentahoRole);
fail("Exception not thrown");
} catch (Exception ex) {
// Expected exception
}
try {
pentahoRole = new PentahoRole(mainTenant_1, null, ROLE_DESCRIPTION_6);
userRoleDaoProxy.deleteRole(pentahoRole);
fail("Exception not thrown");
} catch (NotFoundException e) {
// Expected exception
}
try {
pentahoRole = new PentahoRole(mainTenant_1, UNKNOWN_ROLE, ROLE_DESCRIPTION_6);
userRoleDaoProxy.deleteRole(pentahoRole);
fail("Exception not thrown");
} catch (NotFoundException e) {
// Expected exception
}
}
use of org.pentaho.platform.api.engine.security.userroledao.NotFoundException in project pentaho-platform by pentaho.
the class UserRoleDaoEncodeIT 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();
}
use of org.pentaho.platform.api.engine.security.userroledao.NotFoundException in project pentaho-platform by pentaho.
the class UserRoleDaoIT method testDeleteRole.
@Test
public void testDeleteRole() throws Exception {
int DEFAULT_ROLE_COUNT = 3;
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 });
String role_delim = ((DefaultTenantedPrincipleNameResolver) tenantedRoleNameUtils).getDelimeter();
IPentahoRole pentahoRole = userRoleDaoProxy.createRole(mainTenant_1, ROLE_6, ROLE_DESCRIPTION_6, null);
pentahoRole = userRoleDaoProxy.getRole(null, ROLE_6 + role_delim + mainTenant_1.getRootFolderAbsolutePath());
assertNotNull(pentahoRole);
logout();
login("admin", mainTenant_2, new String[] { adminRoleName, authenticatedRoleName });
try {
userRoleDaoProxy.deleteRole(pentahoRole);
fail("Exception not thrown");
} catch (Throwable th) {
assertNotNull(th);
}
logout();
login("admin", mainTenant_1, new String[] { adminRoleName, authenticatedRoleName });
pentahoRole = userRoleDaoProxy.getRole(null, ROLE_6 + role_delim + mainTenant_1.getRootFolderAbsolutePath());
assertNull(pentahoRole);
assertEquals(DEFAULT_ROLE_COUNT, userRoleDaoProxy.getRoles(mainTenant_1).size());
pentahoRole = userRoleDaoProxy.createRole(null, ROLE_6 + role_delim + mainTenant_1.getRootFolderAbsolutePath(), ROLE_DESCRIPTION_6, null);
pentahoRole = userRoleDaoProxy.getRole(mainTenant_1, ROLE_6);
assertNotNull(pentahoRole);
userRoleDaoProxy.deleteRole(pentahoRole);
assertNull(userRoleDaoProxy.getRole(null, ROLE_6 + role_delim + mainTenant_1.getRootFolderAbsolutePath()));
try {
userRoleDaoProxy.deleteRole(pentahoRole);
fail("Exception not thrown");
} catch (NotFoundException e) {
// Expected exception
}
try {
pentahoRole = new PentahoRole(null, ROLE_6, ROLE_DESCRIPTION_6);
userRoleDaoProxy.deleteRole(pentahoRole);
fail("Exception not thrown");
} catch (Exception ex) {
// Expected exception
}
try {
pentahoRole = new PentahoRole(mainTenant_1, null, ROLE_DESCRIPTION_6);
userRoleDaoProxy.deleteRole(pentahoRole);
fail("Exception not thrown");
} catch (NotFoundException e) {
// Expected exception
}
try {
pentahoRole = new PentahoRole(mainTenant_1, UNKNOWN_ROLE, ROLE_DESCRIPTION_6);
userRoleDaoProxy.deleteRole(pentahoRole);
fail("Exception not thrown");
} catch (NotFoundException e) {
// Expected exception
}
}
use of org.pentaho.platform.api.engine.security.userroledao.NotFoundException in project pentaho-platform by pentaho.
the class UserRoleDaoIT method testDeleteUser.
@Test
public void testDeleteUser() throws Exception {
int DEFAULT_TENANT_USER = 1;
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_6, PASSWORD_6, USER_DESCRIPTION_6, null);
pentahoUser = userRoleDaoProxy.getUser(null, USER_6 + DefaultTenantedPrincipleNameResolver.DEFAULT_DELIMETER + mainTenant_1.getRootFolderAbsolutePath());
assertNotNull(pentahoUser);
logout();
login("admin", mainTenant_2, new String[] { adminRoleName, authenticatedRoleName });
try {
userRoleDaoProxy.deleteUser(pentahoUser);
fail("Exception not thrown");
} catch (Throwable th) {
assertNotNull(th);
}
logout();
login("admin", mainTenant_1, new String[] { adminRoleName, authenticatedRoleName });
pentahoUser = userRoleDaoProxy.getUser(null, USER_6 + DefaultTenantedPrincipleNameResolver.DEFAULT_DELIMETER + mainTenant_1.getRootFolderAbsolutePath());
assertNull(pentahoUser);
assertEquals(DEFAULT_TENANT_USER, userRoleDaoProxy.getUsers(mainTenant_1).size());
pentahoUser = userRoleDaoProxy.createUser(null, USER_6 + DefaultTenantedPrincipleNameResolver.DEFAULT_DELIMETER + mainTenant_1.getRootFolderAbsolutePath(), PASSWORD_6, USER_DESCRIPTION_6, null);
pentahoUser = userRoleDaoProxy.getUser(mainTenant_1, USER_6);
assertNotNull(pentahoUser);
userRoleDaoProxy.deleteUser(pentahoUser);
assertNull(userRoleDaoProxy.getUser(null, USER_6 + DefaultTenantedPrincipleNameResolver.DEFAULT_DELIMETER + mainTenant_1.getRootFolderAbsolutePath()));
try {
userRoleDaoProxy.deleteUser(pentahoUser);
fail("Exception not thrown");
} catch (NotFoundException e) {
// Expected exception
}
try {
pentahoUser = new PentahoUser(null, USER_6, PASSWORD_6, USER_DESCRIPTION_6, true);
userRoleDaoProxy.deleteUser(pentahoUser);
fail("Exception not thrown");
} catch (Exception ex) {
// Expected exception
}
try {
pentahoUser = new PentahoUser(mainTenant_1, null, PASSWORD_6, USER_DESCRIPTION_6, true);
userRoleDaoProxy.deleteUser(pentahoUser);
fail("Exception not thrown");
} catch (NotFoundException e) {
// Expected exception
}
try {
pentahoUser = new PentahoUser(mainTenant_1, UNKNOWN_USER, PASSWORD_6, USER_DESCRIPTION_6, true);
userRoleDaoProxy.deleteUser(pentahoUser);
fail("Exception not thrown");
} catch (NotFoundException e) {
// Expected exception
}
}
Aggregations