Files
kkallas e5a33a1c34 Technician tool v0.1
Imported from the Google Drive folder 004-technician_tool/v0.1.
2026-09-26 16:11:07 +02:00

34 lines
1.3 KiB
Python

from kota_tech.core.redact import MASK, redact
INFLUX_TOKEN = "Zq3v9nX2kLmP0aBcD4eFgH7iJ8kLmN1oPqRsT5uVwXyZ0aB-cD_eFgHiJkLmNoPqRsTuVwXyZ0123456789abcd=="
def test_ota_token_lines():
assert redact("I (1) OTA_CLIENT: OTA token loaded from NVS: abc123def") == (
f"I (1) OTA_CLIENT: OTA token loaded from NVS: {MASK}"
)
out = redact("I (2) OTA_CLIENT: Device registered successfully, received token: tok_9f8e7d")
assert "tok_9f8e7d" not in out and out.endswith(MASK)
def test_env_and_header_secrets():
assert INFLUX_TOKEN not in redact(f"INFLUX_TOKEN={INFLUX_TOKEN}")
assert "hunter2" not in redact("PASSWORD=hunter2")
assert INFLUX_TOKEN not in redact(f"Authorization: Token {INFLUX_TOKEN}")
def test_bare_long_blob():
assert redact(f"x {INFLUX_TOKEN} y") == f"x {MASK} y"
def test_non_secrets_untouched():
for s in [
"I (13664) INFLUX_BUFFER: Read INFLUX_URL from .env file: "
"https://influx.kota-app.com/api/v2/write?bucket=sensorbox&org=kota",
"as7341_adc,device=14C19F57720C f1=3,f2=8 1789655366000000000",
"E (30917) OTA_CLIENT: Error ESP_ERR_HTTP_CONNECT at ./main/ota_client.cpp:223",
"I (24792) OTA_CLIENT: HTTP client handle: 0x3fcf1560",
"I (2300) wifi:mode : sta (a4:cb:8f:c9:47:3c)",
]:
assert redact(s) == s