示例#1
0
 @Test
 @RunIf(
     value = EnhancedOSChecker.class,
     arguments = {DO_NOT_RUN_ON, OSChecker.WINDOWS})
 public void shouldNotLogPasswordsFromStream() {
   LogFixture logFixture = LogFixture.startListening();
   CommandLine line =
       CommandLine.createCommandLine("/bin/echo")
           .withArg("=>")
           .withArg(new PasswordArgument("secret"));
   line.runOrBomb(null);
   System.out.println(ArrayUtil.join(logFixture.getMessages()));
   assertThat(ArrayUtil.join(logFixture.getMessages()), not(containsString("secret")));
   assertThat(ArrayUtil.join(logFixture.getMessages()), containsString("=> ******"));
   logFixture.stopListening();
 }
示例#2
0
 @Test
 public void shouldLogPasswordsOnTheLogAsStars() {
   LogFixture logFixture = LogFixture.startListening();
   LogFixture.enableDebug();
   CommandLine line =
       CommandLine.createCommandLine("notexist").withArg(new PasswordArgument("secret"));
   try {
     line.runOrBomb(null);
   } catch (Exception e) {
     // ignored
   }
   assertThat(ArrayUtil.join(logFixture.getMessages()), containsString("notexist ******"));
   logFixture.stopListening();
 }
示例#3
0
  @Test
  public void shouldAddWebAppContextHandler() throws Exception {
    ArgumentCaptor<ContextHandler> captor = ArgumentCaptor.forClass(ContextHandler.class);
    jetty6Server.configure();

    verify(server, times(4)).addHandler(captor.capture());
    List<ContextHandler> handlers = captor.getAllValues();
    assertThat(handlers.size(), is(4));
    ContextHandler handler = handlers.get(3);
    assertThat(handler instanceof WebAppContext, is(true));
    WebAppContext webAppContext = (WebAppContext) handler;
    List<String> configClasses = ArrayUtil.asList(webAppContext.getConfigurationClasses());
    assertThat(configClasses.contains(WebInfConfiguration.class.getCanonicalName()), is(true));
    assertThat(configClasses.contains(WebXmlConfiguration.class.getCanonicalName()), is(true));
    assertThat(configClasses.contains(JettyWebXmlConfiguration.class.getCanonicalName()), is(true));
    assertThat(webAppContext.getContextPath(), is("context"));
    assertThat(webAppContext.getWar(), is("cruise.war"));
    assertThat(webAppContext.isParentLoaderPriority(), is(false));
    assertThat(
        webAppContext.getDefaultsDescriptor(), is("org/mortbay/jetty/webapp/webdefault.xml"));
  }