26 lines
859 B
Python
26 lines
859 B
Python
from protocols._common import extract_code, normalize_status, redact_url_secrets
|
|
|
|
|
|
def test_extract_code():
|
|
assert extract_code("Your code is 123456") == "123456"
|
|
assert extract_code("no code") is None
|
|
|
|
|
|
def test_normalize_smsvn():
|
|
assert normalize_status("smsvn", "STATUS_WAIT_CODE") == "waiting"
|
|
assert normalize_status("smsvn", "STATUS_OK:8888") == "code_received"
|
|
|
|
|
|
def test_normalize_5sim():
|
|
assert normalize_status("5sim", "PENDING") == "waiting"
|
|
assert normalize_status("5sim", "RECEIVED") == "code_received"
|
|
|
|
|
|
def test_redact_url_secrets():
|
|
u = "https://x.test/stubs/handler_api.php?api_key=SECRET123&action=getBalance&token=ABC"
|
|
redacted = redact_url_secrets(u)
|
|
assert "SECRET123" not in redacted
|
|
assert "ABC" not in redacted
|
|
assert "api_key=%2A%2A%2A" in redacted
|
|
assert "token=%2A%2A%2A" in redacted
|