def test_sanitize_text(self): # type: () -> None secret = 'p@$$w0rd' check = AgentCheck() check.register_secret(secret) sanitized = check.sanitize('hello, {}'.format(secret)) assert secret not in sanitized
def text_sanitize_logs(self, caplog): # type: (Any) -> None secret = 'p@$$w0rd' check = AgentCheck() check.register_secret(secret) check.log.error('hello, %s', secret) assert secret not in caplog.text
def test_sanitize_service_check_message(self, aggregator, caplog): # type: (Any, Any) -> None secret = 'p@$$w0rd' check = AgentCheck() check.register_secret(secret) sanitized = check.sanitize(secret) check.service_check('test.can_check', status=AgentCheck.CRITICAL, message=secret) aggregator.assert_service_check('test.can_check', status=AgentCheck.CRITICAL, message=sanitized)