81d43666c7
Phase 1 (Assist Core + Guardrail) complete. 8 slices, 4 waves, 24 tasks. 12 REQs covered (3 ASSIST + 3 NFR + 6 IDEATE). 92 new tests (409 total). G-049 + G-067 MUSTs resolved. Verify: APPROVE_WITH_NOTES, 5 P1+ flagged. Live Assist voice loop: shift-bounded sessions, context-binding, 3-layer guardrail (prompt + regex filter + audit log), tap-to-talk client control, warm WebRTC, reconnect logic, incremental audit write, PII policy, consent disclosure, mode-conflict enforcement. ---ci--- project: praxis phase: 1 milestone: v0.5 status: complete requirements: covered: [REQ-ASSIST-01, REQ-ASSIST-02, REQ-ASSIST-03, REQ-NFR-ASSIST-02, REQ-NFR-ASSIST-03, REQ-NFR-ASSIST-04, REQ-IDEATE-01, REQ-IDEATE-02, REQ-IDEATE-03, REQ-IDEATE-05, REQ-IDEATE-08, REQ-IDEATE-09] partial: [] ---/ci---
61 lines
2.0 KiB
Python
61 lines
2.0 KiB
Python
"""Unit tests for the customer-speech PII policy (TASK-04-04, REQ-IDEATE-05)."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from server.assist.pii_policy import (
|
|
CUSTOMER_SPEECH_POLICY,
|
|
RETENTION_DAYS,
|
|
get_pii_policy,
|
|
redact_pii,
|
|
)
|
|
|
|
|
|
def test_redact_phone_number():
|
|
assert redact_pii("Call me at 416-555-1234") == "Call me at [PHONE]"
|
|
assert redact_pii("Call me at 416.555.1234") == "Call me at [PHONE]"
|
|
assert redact_pii("Call me at 4165551234") == "Call me at [PHONE]"
|
|
|
|
|
|
def test_redact_email():
|
|
assert redact_pii("Email me at john@example.com") == "Email me at [EMAIL]"
|
|
assert redact_pii("Send to john.doe+test@sub.example.co.uk") == "Send to [EMAIL]"
|
|
|
|
|
|
def test_redact_card_number():
|
|
assert redact_pii("My card is 4111-1111-1111-1111") == "My card is [CARD]"
|
|
assert redact_pii("My card is 4111 1111 1111 1111") == "My card is [CARD]"
|
|
|
|
|
|
def test_redact_sin_like_number():
|
|
assert redact_pii("My SIN is 123-456-789") == "My SIN is [SIN]"
|
|
|
|
|
|
def test_no_false_redactions():
|
|
"""Numbers that aren't PII patterns are not redacted."""
|
|
assert redact_pii("I have 3 kids") == "I have 3 kids"
|
|
assert redact_pii("Order #12345") == "Order #12345"
|
|
assert redact_pii("That's 25% off") == "That's 25% off"
|
|
|
|
|
|
def test_redact_empty_string():
|
|
assert redact_pii("") == ""
|
|
|
|
|
|
def test_redact_multiple_patterns():
|
|
text = "Call 416-555-1234 or email john@example.com, card 4111-1111-1111-1111"
|
|
redacted = redact_pii(text)
|
|
assert "[PHONE]" in redacted
|
|
assert "[EMAIL]" in redacted
|
|
assert "[CARD]" in redacted
|
|
|
|
|
|
def test_get_pii_policy_returns_dict():
|
|
policy = get_pii_policy()
|
|
assert policy["policy"] == CUSTOMER_SPEECH_POLICY
|
|
assert policy["retention_days"] == RETENTION_DAYS
|
|
assert RETENTION_DAYS == 30
|
|
assert "phone" in policy["redaction_patterns"]
|
|
assert "email" in policy["redaction_patterns"]
|
|
assert "card" in policy["redaction_patterns"]
|
|
assert "sin-like" in policy["redaction_patterns"]
|
|
assert "pending" in policy["legal_review"].lower() |