from mars_bot.redact import mask_secrets


def test_masks_tgstat_query_token():
    text = ("HTTPSConnectionPool: url "
            "https://api.tgstat.ru/channels/mentions?token=abc123SECRET&channelId=@x")
    out = mask_secrets(text)
    assert "abc123SECRET" not in out
    assert "token=***" in out
    assert "channelId=@x" in out  # остальные параметры не тронуты


def test_masks_telegram_bot_path_token():
    text = ("Max retries exceeded with url: "
            "https://api.telegram.org/bot123456789:AAExampleTokenValue_-/sendMessage")
    out = mask_secrets(text)
    assert "AAExampleTokenValue" not in out
    assert "123456789" not in out
    assert "/bot***/sendMessage" in out


def test_noop_when_no_secret():
    text = "plain connection error, no tokens here"
    assert mask_secrets(text) == text
