/** * */ @Plugin(type = "udt") @Name("len") public class StringLengthUDT implements UDT { @Override public int apply(String str) { return str.length(); } }
@AuthEnforce(entities = "namespaceId", enforceOn = NamespaceId.class, actions = {Action.ADMIN, Action.READ}) public void testWrongEntityName(@Name("wrongId") NamespaceId namespaceId) throws Exception { // no-op } }
@AuthEnforce(entities = "", enforceOn = NamespaceId.class, actions = {Action.ADMIN, Action.READ}) public void testBlankEntityName(@Name("") NamespaceId namespaceId) throws Exception { // no-op } }
@AuthEnforce(entities = "namespaceId", enforceOn = NamespaceId.class, actions = Action.ADMIN) public void testMethodWithoutException(@Name("namespaceId") NamespaceId namespaceId) { // no-op // After class rewrite we make a call to AuthorizationEnforcer.enforce which can throw UnauthorizedException. // This tests that a method which does not specify throws Exception in its signature will be able to throw // exception during enforcement }
@AuthEnforce(entities = {"schedule"}, enforceOn = ScheduleId.class, actions = Action.READ) public void testInvalidEnforceOn(@Name("schedule") ScheduleId scheduleId) throws Exception { // no-op } }
@AuthEnforce(entities = "namespace", enforceOn = NamespaceId.class, actions = Action.ADMIN) public void testMultipleAnnotationsPref(@Name("namespace") @PathParam("namespaceId") NamespaceId namespaceId) throws Exception { // the above annotation will call enforce after class rewrite which should throw an exception. // If the line below is reached it means that enforce was not called as it supposed to be throw new EnforceNotCalledException(); }
@AuthEnforce(entities = "namespaceId", enforceOn = NamespaceId.class, actions = Action.ADMIN) public void testNameAnnotationPref(@Name("namespaceId") NamespaceId namespaceId, @PathParam("namespaceId") String ns) throws Exception { // the above annotation will call enforce after class rewrite which should throw an exception. // If the line below is reached it means that enforce was not called as it supposed to be throw new EnforceNotCalledException(); } }
@VisibleForTesting // NOTE : tests that the presence of other annotations does not affect class rewrite @AuthEnforce(entities = "namespaceId", enforceOn = NamespaceId.class, actions = {Action.ADMIN, Action.READ}) public void testMultipleAction(@Name("namespaceId") NamespaceId namespaceId) throws Exception { // the above annotation will call enforce after class rewrite which should throw an exception. // If the line below is reached it means that enforce was not called as it supposed to be throw new EnforceNotCalledException(); }
/** * plugin should fail deploy. */ @Plugin(type = "invalid") @Name("invalidParamType") @Description("This is a Plugin with invalid params for method") public class InvalidPluginMethodParamType { @Path("ping") public String callMe(String input, Long timestamp) { return "hello"; } }
/** * plugin doesn't actually do anything, just for tests */ @Plugin(type = "invalid") @Name("invalidParams") @Description("This is a Plugin with invalid params for method") public class InvalidPluginMethodParams { @Path("ping") public String callMe(String input, EndpointPluginContext context, Long timestamp) { return "hello"; } }
@Plugin(type = PLUGIN_TYPE) @Name(PLUGIN_NAME) @Description(PLUGIN_DESCRIPTION) public static class AppPlugin { private PConfig pluginConf; public double doSomething() { return pluginConf.y; } } }
@AuthEnforce(entities = "someEntity", enforceOn = InstanceId.class, actions = Action.ADMIN) public void testParaPreference(@Name("someEntity") InstanceId instanceId) throws Exception { // the above annotation will call enforce after class rewrite which should throw an exception. // If the line below is reached it means that enforce was not called as it supposed to be throw new EnforceNotCalledException(); }
@AuthEnforce(entities = "namespaceId", enforceOn = NamespaceId.class, actions = Action.ADMIN) public void testSomeOtherAction(@Name("namespaceId") NamespaceId namespaceId) throws Exception { // the above annotation will call enforce after class rewrite which should throw an exception. // If the line below is reached it means that enforce was not called as it supposed to be throw new EnforceNotCalledException(); } }
@Plugin(type = PLUGIN_TYPE) @Name("SingleRequirementPlugin") @Description(PLUGIN_DESCRIPTION) @Requirements(datasetTypes = Table.TYPE) public static class SingleRequirementPlugin { private PConfig pluginConf; public double doSomething() { return pluginConf.y; } }
@Plugin(type = PLUGIN_TYPE) @Name("DuplicateRequirementsPlugin") @Description(PLUGIN_DESCRIPTION) @Requirements(datasetTypes = {Table.TYPE, " DupliCate ", " duplicate "}) public static class DuplicateRequirementsPlugin { private PConfig pluginConf; public double doSomething() { return pluginConf.y; } }
@Plugin(type = PLUGIN_TYPE) @Name("NonTransactionalPlugin") @Description(PLUGIN_DESCRIPTION) @Requirements(datasetTypes = {"req1", "req2"}) public static class NonTransactionalPlugin { private PConfig pluginConf; public double doSomething() { return pluginConf.y; } } }