tillrohrmann commented on a change in pull request #10532: 
[FLINK-15053][runtime] Escape all dynamical property values for taskmanager
URL: https://github.com/apache/flink/pull/10532#discussion_r362498650
 
 

 ##########
 File path: 
flink-runtime/src/test/java/org/apache/flink/runtime/clusterframework/BootstrapToolsTest.java
 ##########
 @@ -413,17 +413,32 @@ public void 
testActorSystemInstantiationFailureWhenPortOccupied() throws Excepti
        }
 
        @Test
-       public void testGetDynamicProperties() {
-               Configuration baseConfig = new Configuration();
+       public void testGetDynamicPropertiesAsString() {
+               final Configuration baseConfig = new Configuration();
                baseConfig.setString("key.a", "a");
                baseConfig.setString("key.b", "b1");
 
-               Configuration targetConfig = new Configuration();
+               final Configuration targetConfig = new Configuration();
                targetConfig.setString("key.b", "b2");
                targetConfig.setString("key.c", "c");
 
-               String dynamicProperties = 
BootstrapTools.getDynamicProperties(baseConfig, targetConfig);
-               assertEquals("-Dkey.b=b2 -Dkey.c=c", dynamicProperties);
+               final String dynamicProperties = 
BootstrapTools.getDynamicPropertiesAsString(baseConfig, targetConfig);
+               assertEquals("-Dkey.b='b2' -Dkey.c='c'", dynamicProperties);
+       }
+
+       @Test
+       public void testEscapeDynamicPropertyValue() {
+               final String value1 = "#a,b&c^d*e%f(g!h";
+               assertEquals("'" + value1 + "'", 
BootstrapTools.escapeWithSingleQuote(value1));
+
+               final String value2 = "'foobar";
+               assertEquals("''\\''foobar'", 
BootstrapTools.escapeWithSingleQuote(value2));
+
+               final String value3 = "foo''bar";
+               assertEquals("'foo'\\'''\\''bar'", 
BootstrapTools.escapeWithSingleQuote(value3));
+
+               final String value4 = "'foo' 'bar'";
+               assertEquals("''\\''foo'\\'' '\\''bar'\\'''", 
BootstrapTools.escapeWithSingleQuote(value4));
 
 Review comment:
   It is ok to leave it like this but in the future I would suggest to make 
every tested value a separate test case. This allows to give more expressive 
names for what one is testing and if something breaks it is easier to 
understand what's broken.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to