ResourceGroup platformResourceGroup = createTestResourceGroup();
assertNotNull(platformResourceGroup);
// deny destination create (no view of resource group)
try {
BundleDestination dest1 = createDestination(subject, b1, "one", "/test", platformResourceGroup);
fail("Should have thrown IllegalArgumentException");
} catch (EJBException e) {
assert e.getCause() instanceof IllegalArgumentException
&& e.getCause().getMessage().contains("Invalid groupId") : "Should have not had group visibility";
// expected
}
// deny destination create (no deploy perm)
LookupUtil.getRoleManager().addResourceGroupsToRole(overlord, role.getId(),
new int[] { platformResourceGroup.getId() });
try {
BundleDestination dest1 = createDestination(subject, b1, "one", "/test", platformResourceGroup);
fail("Should have thrown PermissionException");
} catch (PermissionException e) {
// expected
}
// allow global
addRolePermissions(role, Permission.DEPLOY_BUNDLES);
BundleDestination dest1 = createDestination(subject, b1, "one", "/test", platformResourceGroup);
assertNotNull(dest1);
Configuration config = new Configuration();
config.put(new PropertySimple("bundletest.property", "bundletest.property value"));
BundleDeployment bd1;
bd1 = createDeployment(subject, "one", bv1, dest1, config);
assertNotNull(bd1);
// allow group
removeRolePermissions(role, Permission.DEPLOY_BUNDLES);
addRolePermissions(role, Permission.DEPLOY_BUNDLES_TO_GROUP);
BundleDestination dest2 = createDestination(subject, b1, "two", "/test2", platformResourceGroup);
assertNotNull(dest2);
Configuration config2 = new Configuration();
config2.put(new PropertySimple("bundletest.property", "bundletest.property value"));
BundleDeployment bd2;
bd2 = createDeployment(subject, "two", bv1, dest2, config2);
assertNotNull(bd1);
// deny delete deployment
removeRolePermissions(role, Permission.DEPLOY_BUNDLES_TO_GROUP);
try {
bundleManager.deleteBundleDeployment(subject, bd2.getId());
fail("Should have thrown PermissionException");
} catch (PermissionException e) {
// expected
}
// allow delete deployment
addRolePermissions(role, Permission.DEPLOY_BUNDLES);
bundleManager.deleteBundleDeployment(subject, bd2.getId());
// deny delete destination
removeRolePermissions(role, Permission.DEPLOY_BUNDLES);
try {
bundleManager.deleteBundleDestination(subject, dest2.getId());
fail("Should have thrown PermissionException");
} catch (PermissionException e) {
// expected
}
// allow delete destination
addRolePermissions(role, Permission.DEPLOY_BUNDLES_TO_GROUP);
bundleManager.deleteBundleDestination(subject, dest2.getId());
}