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 test_default(self, caplog): # type: (Any) -> None secret = 's3kr3t' check = AgentCheck() message = 'hello, {}'.format(secret) assert check.sanitize(message) == message check.log.error(message) assert secret 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)