* This test tries to assign a user in the deployment file to a group that does not exist and asserts that
* deployment file compilation fails.
* @throws IOException
*/
public void testCompileDeploymentAddUserToNonExistentGroup() throws IOException {
TPCCProjectBuilder project = new TPCCProjectBuilder();
project.addDefaultSchema();
project.addDefaultPartitioning();
project.addDefaultProcedures();
project.setSecurityEnabled(true);
GroupInfo groups[] = new GroupInfo[] {
new GroupInfo("foo", false, false, false, false, false, false),
new GroupInfo("blah", false, false, false, false, false, false)
};
project.addGroups(groups);
UserInfo users[] = new UserInfo[] {
new UserInfo("john", "hugg", new String[] {"foo"}),
new UserInfo("ryan", "betts", new String[] {"foo", "bar"}),
new UserInfo("ariel", "weisberg", new String[] {"bar"})
};
project.addUsers(users);
String testDir = BuildDirectoryUtils.getBuildDirectoryPath();
String jarName = "compile-deployment.jar";
String catalogJar = testDir + File.separator + jarName;
assertTrue("Project failed to compile", project.compile(catalogJar));
byte[] bytes = MiscUtils.fileToBytes(new File(catalogJar));
String serializedCatalog = CatalogUtil.getSerializedCatalogStringFromJar(CatalogUtil.loadAndUpgradeCatalogFromJar(bytes).getFirst());
assertNotNull("Error loading catalog from jar", serializedCatalog);
Catalog catalog = new Catalog();
catalog.execute(serializedCatalog);
// this should fail because group "bar" does not exist
assertTrue("Deployment file shouldn't have been able to validate",
CatalogUtil.compileDeployment(catalog, project.getPathToDeployment(), true, true) < 0);
}