# 2026-04-20 @ Asia/Taipei from apps.api.src.utils.secret_redactor import redact def test_openrouter_key_redacted(): assert "" in redact("sk-or-v1-abcdef0123456789ABCDEFghijklmnopqrstuv") def test_anthropic_key_redacted(): assert "" in redact("sk-ant-api03-abcDEF_123-xyz") def test_github_token_redacted(): assert "" in redact("ghp_abcdef0123456789ABCDEFghijklmnopqrst") def test_google_key_redacted(): assert "" in redact("AIzaSyABCDEFGHIJKLMNOPQRSTUVWXYZ1234567") def test_telegram_bot_token_redacted(): assert "" in redact("8474499448:AAFqu_i4-PN4zGFOK5ea8o0Ud56qqEtCMeI") def test_aws_key_redacted(): assert "" in redact("key=AKIAIOSFODNN7EXAMPLE") def test_clean_passthrough(): assert redact("normal text here") == "normal text here" def test_nested_dict(): d = {"a": "ghp_abcdef0123456789ABCDEFghijklmnopqrst", "b": {"c": "AIzaSyABCDEFGHIJKLMNOPQRSTUVWXYZ1234567"}} out = redact(d) assert "ghp_abc" not in str(out) assert "AIzaSy" not in str(out)