doTest(contents, Merchant.class);
doTest(contents, ExtendsMerchant.class);
}
void doTest(String contents, Class<? extends Merchant> clazz) {
FlatPack fp = flatpack(contents);
GroupPermissions p = fp.getTypeContext().describe(clazz).getGroupPermissions();
assertNotNull(p);
// Check various type-level permissions
checkMerchantPermissions(p);
// Check property-level permissions, especially type- and global-overrides
Property name = getProperty(fp.getTypeContext(), clazz, "name");
p = name.getGroupPermissions();
assertNotNull(p);
// Just replacing a previous declaration
assertEquals(5, p.getOperations().size());
checkPermissions(p, "*", "crudOperation.read");
// Test the "allow only" construct
Property note = getProperty(fp.getTypeContext(), clazz, "note");
p = note.getGroupPermissions();
assertNotNull(p);
assertEquals(1, p.getOperations().size());
checkPermissions(p, "internalUser", "*.*");
// Verify that unreferenced properties inherit the type's allow
Property other = getProperty(fp.getTypeContext(), clazz, "other");
p = other.getGroupPermissions();
assertNotNull(p);
checkMerchantPermissions(p);
}