Files
awoooi/apps/api/tests/test_logging_redaction.py
Your Name 33f85ec8ca
All checks were successful
Code Review / ai-code-review (push) Successful in 17s
CD Pipeline / tests (push) Successful in 1m14s
CD Pipeline / build-and-deploy (push) Successful in 3m19s
CD Pipeline / post-deploy-checks (push) Successful in 1m15s
fix(logging): redact telegram bot urls
2026-05-06 16:54:14 +08:00

24 lines
626 B
Python

from __future__ import annotations
import logging
from src.core.logging import SensitiveURLRedactionFilter
def test_sensitive_url_redaction_filter_redacts_log_record_args() -> None:
record = logging.LogRecord(
name="httpx",
level=logging.INFO,
pathname=__file__,
lineno=1,
msg="HTTP Request: %s",
args=("https://api.telegram.org/bot123456:SECRET/getWebhookInfo",),
exc_info=None,
)
assert SensitiveURLRedactionFilter().filter(record) is True
rendered = record.getMessage()
assert "SECRET" not in rendered
assert "bot<redacted>" in rendered