31 lines
1.1 KiB
Python
31 lines
1.1 KiB
Python
from hermes_cli import web_server
|
|
|
|
|
|
def test_deidentify_session_search_result_masks_emails_and_phone():
|
|
item = {
|
|
"snippet": "聯絡 john.doe@bremen.com.tw 或 0912-345-678",
|
|
"title": "由 john.doe@bremen.com.tw 提交",
|
|
"preview": "電話 0912345678",
|
|
}
|
|
out = web_server._deidentify_session_search_result(item)
|
|
assert "john.doe@bremen.com.tw" not in out["snippet"]
|
|
assert "0912-345-678" not in out["snippet"]
|
|
assert "0912345678" not in out["preview"]
|
|
assert "[已隱碼Email]" in out["snippet"]
|
|
assert "[已隱碼電話]" in out["snippet"]
|
|
|
|
|
|
def test_deidentify_export_payload_masks_nested_content():
|
|
payload = {
|
|
"session": {"title": "聯絡 john.doe@bremen.com.tw"},
|
|
"messages": [
|
|
{"content": "手機 0912-345-678"},
|
|
{"reasoning_content": "email john.doe@bremen.com.tw"},
|
|
{"content": [{"text": "call me 0912345678"}]},
|
|
],
|
|
}
|
|
out = web_server._deidentify_export_payload(payload)
|
|
assert "john.doe@bremen.com.tw" not in str(out)
|
|
assert "0912-345-678" not in str(out)
|
|
assert "0912345678" not in str(out)
|