From fcdde6e2c1ddc22b4f7b4756c423082cf61a6f1c Mon Sep 17 00:00:00 2001 From: demo-bot Date: Sun, 9 Aug 2026 16:03:54 +0000 Subject: [PATCH] decomposer: generate deliverable files for Define the service contract and project architecture for the FastAPI endpoint monitoring service.; Implement the typed monitor CRUD API and concurrency-safe in-memory state according to the service design.; Implement secure on-demand endpoint checks with status updates, latency measurement, robust error handling, and redacted structured logs.; Add operational API endpoints and environment-driven runtime configuration to the monitoring service.; Create automated tests for the monitoring service.; Package the service with Docker and developer documentation.; Validate the complete project. --- tests/test_logging.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 tests/test_logging.py diff --git a/tests/test_logging.py b/tests/test_logging.py new file mode 100644 index 0000000..0360a57 --- /dev/null +++ b/tests/test_logging.py @@ -0,0 +1,19 @@ +import json +import logging + +from app.logging_config import JsonFormatter, redact_url + + +def test_redact_url_removes_credentials_query_and_fragment(): + assert redact_url("https://user:pass@example.com:8443/a?token=secret#x") == "https://example.com:8443/a" + + +def test_json_formatter_never_emits_url_secrets(): + record = logging.LogRecord("test", logging.INFO, "", 0, "event", (), None) + record.url = "https://user:pass@example.com/a?token=secret#fragment" + record.monitor_id = "123" + output = JsonFormatter().format(record) + parsed = json.loads(output) + assert parsed["url"] == "https://example.com/a" + assert "secret" not in output + assert "pass" not in output