Exemple #1
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();
 }
Exemple #2
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();
 }
 @Before
 public void setUp() {
   agentInstances = mock(AgentInstances.class);
   config = new AgentConfig("uuid", "host", "192.168.1.1");
   when(agentInstances.findAgentAndRefreshStatus("uuid"))
       .thenReturn(AgentInstance.createFromConfig(config, new SystemEnvironment()));
   agentDao = mock(AgentDao.class);
   uuidGenerator = mock(UuidGenerator.class);
   agentService =
       new AgentService(
           mock(AgentConfigService.class),
           new SystemEnvironment(),
           agentInstances,
           mock(EnvironmentConfigService.class),
           mock(GoConfigService.class),
           mock(SecurityService.class),
           agentDao,
           uuidGenerator,
           serverHealthService = mock(ServerHealthService.class));
   logFixture = LogFixture.startListening();
   agentIdentifier = config.getAgentIdentifier();
   when(agentDao.cookieFor(agentIdentifier)).thenReturn("cookie");
 }