9292 * @author Ilayaperumal Gopinathan
9393 * @author Janne Valkealahti
9494 * @author Gunnar Hillert
95+ * @author Glenn Renfro
9596 */
9697@ RunWith (SpringRunner .class )
9798@ SpringBootTest (classes = TestDependencies .class )
@@ -214,6 +215,7 @@ public void testFindRelatedAndNestedStreams() throws Exception {
214215 assertEquals (0 , repository .count ());
215216 mockMvc .perform (post ("/streams/definitions/" ).param ("name" , "myStream1" ).param ("definition" , "time | log" )
216217 .accept (MediaType .APPLICATION_JSON )).andDo (print ()).andExpect (status ().isCreated ());
218+
217219 mockMvc .perform (post ("/streams/definitions/" ).param ("name" , "myAnotherStream1" )
218220 .param ("definition" , "time | log" ).accept (MediaType .APPLICATION_JSON )).andDo (print ())
219221 .andExpect (status ().isCreated ());
@@ -234,20 +236,37 @@ public void testFindRelatedAndNestedStreams() throws Exception {
234236 mockMvc .perform (post ("/streams/definitions/" ).param ("name" , "myStream4" )
235237 .param ("definition" , ":myAnotherStream1 > log" ).accept (MediaType .APPLICATION_JSON )).andDo (print ())
236238 .andExpect (status ().isCreated ());
237- assertEquals (8 , repository .count ());
239+
240+ mockMvc .perform (post ("/streams/definitions/" ).param ("name" , "myStream5" ).param ("definition" , "time | log --secret=foo" )
241+ .accept (MediaType .APPLICATION_JSON )).andDo (print ()).andExpect (status ().isCreated ());
242+
243+ mockMvc .perform (post ("/streams/definitions/" ).param ("name" , "myStream6" )
244+ .param ("definition" , ":myStream5.time > log --password=bar" ).accept (MediaType .APPLICATION_JSON )).andDo (print ())
245+ .andExpect (status ().isCreated ());
246+
247+ assertEquals (10 , repository .count ());
238248 String response = mockMvc
239249 .perform (get ("/streams/definitions/myStream1/related?nested=true" ).accept (MediaType .APPLICATION_JSON ))
240250 .andReturn ().getResponse ().getContentAsString ();
241251 assertTrue (response .contains (":myStream1 > log" ));
242252 assertTrue (response .contains (":myStream1.time > log" ));
243253 assertTrue (response .contains ("time | log" ));
244254 assertTrue (response .contains ("\" totalElements\" :6" ));
255+
256+ response = mockMvc
257+ .perform (get ("/streams/definitions/myStream5/related?nested=true" ).accept (MediaType .APPLICATION_JSON ))
258+ .andReturn ().getResponse ().getContentAsString ();
259+ assertTrue (response .contains (":myStream5.time > log --password=******" ));
260+ assertTrue (response .contains ("time | log --secret=******" ));
261+ assertTrue (response .contains ("\" totalElements\" :2" ));
262+
245263 String response2 = mockMvc .perform (
246264 get ("/streams/definitions/myAnotherStream1/related?nested=true" ).accept (MediaType .APPLICATION_JSON ))
247265 .andReturn ().getResponse ().getContentAsString ();
248266 assertTrue (response2 .contains (":myAnotherStream1 > log" ));
249267 assertTrue (response2 .contains ("time | log" ));
250268 assertTrue (response2 .contains ("\" totalElements\" :2" ));
269+
251270 String response3 = mockMvc
252271 .perform (get ("/streams/definitions/myStream2/related?nested=true" ).accept (MediaType .APPLICATION_JSON ))
253272 .andReturn ().getResponse ().getContentAsString ();
@@ -256,6 +275,83 @@ public void testFindRelatedAndNestedStreams() throws Exception {
256275 assertTrue (response3 .contains ("\" totalElements\" :2" ));
257276 }
258277
278+ @ Test
279+ public void testFindAll () throws Exception {
280+ assertEquals (0 , repository .count ());
281+ mockMvc .perform (post ("/streams/definitions/" ).param ("name" , "myStream1" ).param ("definition" , "time --password=foo| log" )
282+ .accept (MediaType .APPLICATION_JSON )).andDo (print ()).andExpect (status ().isCreated ());
283+ mockMvc .perform (post ("/streams/definitions/" ).param ("name" , "myStream1A" ).param ("definition" , "time --foo=bar| log" )
284+ .accept (MediaType .APPLICATION_JSON )).andDo (print ()).andExpect (status ().isCreated ());
285+ mockMvc .perform (post ("/streams/definitions/" ).param ("name" , "myAnotherStream1" )
286+ .param ("definition" , "time | log" ).accept (MediaType .APPLICATION_JSON )).andDo (print ())
287+ .andExpect (status ().isCreated ());
288+ mockMvc .perform (post ("/streams/definitions/" ).param ("name" , "myStream2" ).param ("definition" , ":myStream1 > log" )
289+ .accept (MediaType .APPLICATION_JSON )).andDo (print ()).andExpect (status ().isCreated ());
290+ mockMvc .perform (post ("/streams/definitions/" ).param ("name" , "TapOnmyStream2" )
291+ .param ("definition" , ":myStream2 > log" ).accept (MediaType .APPLICATION_JSON )).andDo (print ())
292+ .andExpect (status ().isCreated ());
293+ mockMvc .perform (post ("/streams/definitions/" ).param ("name" , "myStream3" )
294+ .param ("definition" , ":myStream1.time > log" ).accept (MediaType .APPLICATION_JSON )).andDo (print ())
295+ .andExpect (status ().isCreated ());
296+ mockMvc .perform (post ("/streams/definitions/" ).param ("name" , "TapOnMyStream3" )
297+ .param ("definition" , ":myStream3 > log" ).accept (MediaType .APPLICATION_JSON )).andDo (print ())
298+ .andExpect (status ().isCreated ());
299+ mockMvc .perform (post ("/streams/definitions/" ).param ("name" , "MultipleNestedTaps" )
300+ .param ("definition" , ":TapOnMyStream3 > log" ).accept (MediaType .APPLICATION_JSON )).andDo (print ())
301+ .andExpect (status ().isCreated ());
302+ mockMvc .perform (post ("/streams/definitions/" ).param ("name" , "myStream4" )
303+ .param ("definition" , ":myAnotherStream1 > log" ).accept (MediaType .APPLICATION_JSON )).andDo (print ())
304+ .andExpect (status ().isCreated ());
305+ mockMvc .perform (post ("/streams/definitions" )
306+ .param ("name" , "timelogSingleTick" )
307+ .param ("definition" , "time --format='YYYY MM DD' | log" )
308+ .param ("deploy" , "false" ))
309+ .andExpect (status ().isCreated ());
310+ mockMvc .perform (post ("/streams/definitions" ).param ("name" , "timelogDoubleTick" )
311+ .param ("definition" , "time --format=\" YYYY MM DD\" | log" )
312+ .param ("deploy" , "false" )).andExpect (status ().isCreated ());
313+ mockMvc .perform (post ("/streams/definitions/" ).param ("name" , "twoPassword" )
314+ .param ("definition" , "time --password='foo'| log --password=bar" )
315+ .accept (MediaType .APPLICATION_JSON )).andDo (print ()).andExpect (status ().isCreated ());
316+ mockMvc .perform (post ("/streams/definitions/" ).param ("name" , "nameChannelPassword" )
317+ .param ("definition" , "time --password='foo'> :foobar" )
318+ .accept (MediaType .APPLICATION_JSON )).andDo (print ()).andExpect (status ().isCreated ());
319+ mockMvc .perform (post ("/streams/definitions/" ).param ("name" , "twoParam" ).param ("definition" , "time --password=foo --arg=foo | log" )
320+ .accept (MediaType .APPLICATION_JSON )).andDo (print ()).andExpect (status ().isCreated ());
321+ mockMvc .perform (post ("/streams/definitions/" ).param ("name" , "twoPipeInQuotes" ).param ("definition" , "time --password='fo|o' --arg=bar | log" )
322+ .accept (MediaType .APPLICATION_JSON )).andDo (print ()).andExpect (status ().isCreated ());
323+
324+
325+ assertEquals (15 , repository .count ());
326+ String response = mockMvc
327+ .perform (get ("/streams/definitions/" ).accept (MediaType .APPLICATION_JSON ))
328+ .andReturn ().getResponse ().getContentAsString ();
329+
330+ assertTrue (response .contains ("time --password=****** | log" ));
331+ assertTrue (response .contains ("time --foo=bar| log" ));
332+
333+ assertTrue (response .contains (":myStream1.time > log" ));
334+ assertTrue (response .contains ("time | log" ));
335+ assertTrue (response .contains (":myStream1 > log" ));
336+ assertTrue (response .contains (":myStream1.time > log" ));
337+ assertTrue (response .contains ("time | log" ));
338+ assertTrue (response .contains (":myAnotherStream1 > log" ));
339+ assertTrue (response .contains ("time | log" ));
340+ assertTrue (response .contains (":myStream1 > log" ));
341+ assertTrue (response .contains (":myStream2 > log" ));
342+ assertTrue (response .contains (":myStream3 > log" ));
343+ assertTrue (response .contains ("time --format='YYYY MM DD' | log" ));
344+ assertTrue (response .contains ("time --format=\\ \" YYYY MM DD\\ \" | log" ));
345+ assertTrue (response .contains ("time --password=****** | log --password=******" ));
346+ System .out .println (response );
347+ assertTrue (response .contains ("time --password=****** > :foobar" ));
348+ assertTrue (response .contains ("time --password=****** --arg=foo | log" ));
349+ assertTrue (response .contains ("time --password=****** --arg=bar | log" ));
350+
351+ assertTrue (response .contains ("\" totalElements\" :15" ));
352+
353+ }
354+
259355 @ Test
260356 public void testSaveInvalidAppDefintions () throws Exception {
261357 mockMvc .perform (post ("/streams/definitions/" ).param ("name" , "myStream" ).param ("definition" , "foo | bar" )
@@ -503,6 +599,24 @@ public void testDisplaySingleStream() throws Exception {
503599 .andExpect (content ().json ("{dslText: \" time | log\" }" ));
504600 }
505601
602+ @ Test
603+ public void testDisplaySingleStreamWithRedaction () throws Exception {
604+ StreamDefinition streamDefinition1 = new StreamDefinition ("myStream" , "time --secret=foo | log" );
605+ for (StreamAppDefinition appDefinition : streamDefinition1 .getAppDefinitions ()) {
606+ deploymentIdRepository .save (DeploymentKey .forStreamAppDefinition (appDefinition ),
607+ streamDefinition1 .getName () + "." + appDefinition .getName ());
608+ }
609+ repository .save (streamDefinition1 );
610+ assertEquals (1 , repository .count ());
611+ AppStatus status = mock (AppStatus .class );
612+ when (status .getState ()).thenReturn (DeploymentState .unknown );
613+ when (appDeployer .status ("myStream.time" )).thenReturn (status );
614+ when (appDeployer .status ("myStream.log" )).thenReturn (status );
615+ mockMvc .perform (get ("/streams/definitions/myStream" ).accept (MediaType .APPLICATION_JSON ))
616+ .andExpect (status ().isOk ()).andExpect (content ().json ("{name: \" myStream\" }" ))
617+ .andExpect (content ().json ("{dslText: \" time --secret=****** | log\" }" ));
618+ }
619+
506620 @ Test
507621 public void testDestroyStreamNotFound () throws Exception {
508622 mockMvc .perform (delete ("/streams/definitions/myStream" ).accept (MediaType .APPLICATION_JSON )).andDo (print ())
0 commit comments