Github user mattyb149 commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/1774#discussion_r116319214
  
    --- Diff: 
nifi-nar-bundles/nifi-slack-bundle/nifi-slack-processors/src/test/java/org/apache/nifi/processors/slack/PutSlackTest.java
 ---
    @@ -102,6 +106,81 @@ public void testInvalidIconEmoji() {
         }
     
         @Test
    +    public void testInvalidDynamicProperties() {
    +        testRunner.setProperty(PutSlack.WEBHOOK_URL, server.getUrl());
    +        testRunner.setProperty(PutSlack.WEBHOOK_TEXT, WEBHOOK_TEST_TEXT);
    +        PropertyDescriptor dynamicProp = new PropertyDescriptor.Builder()
    +                .dynamic(true)
    +                .name("foo")
    +                .build();
    +        testRunner.setProperty(dynamicProp, "{\"a\": a}");
    +
    +        testRunner.enqueue("{}".getBytes());
    +        testRunner.run(1);
    +        testRunner.assertTransferCount(PutSlack.REL_FAILURE, 1);
    +    }
    +
    +    @Test
    +    public void testValidDynamicProperties() {
    +        testRunner.setProperty(PutSlack.WEBHOOK_URL, server.getUrl());
    +        testRunner.setProperty(PutSlack.WEBHOOK_TEXT, WEBHOOK_TEST_TEXT);
    +        PropertyDescriptor dynamicProp = new PropertyDescriptor.Builder()
    +                .dynamic(true)
    +                .name("foo")
    +                .build();
    +        testRunner.setProperty(dynamicProp, "{\"a\": \"a\"}");
    +
    +        testRunner.enqueue("{}".getBytes());
    +        testRunner.run(1);
    +        testRunner.assertTransferCount(PutSlack.REL_FAILURE, 0);
    +    }
    +
    +    @Test
    +    public void testValidDynamicPropertiesWithExpressionLanguage() {
    +        ProcessSession session = 
testRunner.getProcessSessionFactory().createSession();
    +        FlowFile ff = session.create();
    +        Map<String, String> props = new HashMap<>();
    +        props.put("foo", "\"bar\"");
    +        props.put("ping", "pong");
    +        ff = session.putAllAttributes(ff, props);
    +
    +        testRunner.setProperty(PutSlack.WEBHOOK_URL, server.getUrl());
    +        testRunner.setProperty(PutSlack.WEBHOOK_TEXT, WEBHOOK_TEST_TEXT);
    +        PropertyDescriptor dynamicProp = new PropertyDescriptor.Builder()
    +                .dynamic(true)
    +                .name("foo")
    +                .build();
    +        testRunner.setProperty(dynamicProp, "{\"foo\": ${foo}, 
\"ping\":\"${ping}\"}");
    --- End diff --
    
    Are the payloads always key/value pairs? If so I'm thinking the dynamic 
properties could be the key/value pairs, and the processor could create a JSON 
payload from them?  If the attachment payload is more flexible, then JSON 
should be good. Any chance of injection attacks or anything?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to