solidprivacy-nl commited on
Commit
a0a49e0
·
1 Parent(s): ce070aa

Add WP39 clean DOCX export policy tests

Browse files
tests/test_clean_docx_export_policy.py ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from pathlib import Path
4
+
5
+
6
+ REPO_ROOT = Path(__file__).resolve().parents[1]
7
+ POLICY_DOC = REPO_ROOT / "CLEAN_DOCX_EXPORT_POLICY.md"
8
+
9
+
10
+ def _policy_text() -> str:
11
+ return POLICY_DOC.read_text(encoding="utf-8")
12
+
13
+
14
+ def test_policy_forbids_clean_docx_claim_for_current_exports():
15
+ text = _policy_text()
16
+ lowered = text.lower()
17
+
18
+ assert "current docx output must not be described as a clean docx export" in lowered
19
+ assert "not allowed yet" in lowered
20
+ assert "clean docx" in lowered
21
+ assert "fully cleaned docx" in lowered
22
+ assert "metadata-free docx" in lowered
23
+ assert "comments removed" in lowered
24
+ assert "tracked changes removed" in lowered
25
+
26
+
27
+ def test_policy_preserves_current_export_semantics_and_no_blocking():
28
+ text = _policy_text()
29
+ lowered = text.lower()
30
+
31
+ assert "current export behavior remains unchanged" in lowered
32
+ assert "no export is blocked by wp39" in lowered
33
+ assert "no content is removed by wp39" in lowered
34
+ assert "no export file bytes are changed by wp39" in lowered
35
+ assert "blocking must not be silently added" in lowered
36
+ assert "without a separate workpackage" in lowered
37
+
38
+
39
+ def test_policy_defines_warning_report_rules_for_docx_hygiene_findings():
40
+ text = _policy_text()
41
+ lowered = text.lower()
42
+
43
+ assert "no supported hidden-content findings were detected" in lowered
44
+ assert "not a clean-docx guarantee" in lowered
45
+ assert "headers or footers" in lowered
46
+ assert "comments or margin notes" in lowered
47
+ assert "tracked changes can preserve" in lowered
48
+ assert "docx hygiene risk could not be fully assessed" in lowered
49
+ assert "high-risk warning + audit finding" in lowered
50
+
51
+
52
+ def test_policy_sets_minimum_requirements_before_clean_export_claim():
53
+ text = _policy_text()
54
+ lowered = text.lower()
55
+
56
+ assert "minimum requirements before a clean-docx claim" in lowered
57
+ assert "explicit clean-export mode" in lowered
58
+ assert "comments, tracked changes, headers and footers" in lowered
59
+ assert "metadata" in lowered
60
+ assert "footnotes" in lowered
61
+ assert "endnotes" in lowered
62
+ assert "custom xml" in lowered
63
+ assert "residual placeholders" in lowered
64
+ assert "no hidden recovery" in lowered
65
+ assert "must not claim a docx export is clean" in lowered
66
+
67
+
68
+ def test_policy_explicitly_does_not_implement_cleaner_or_ui_behavior():
69
+ text = _policy_text()
70
+ lowered = text.lower()
71
+
72
+ for required in [
73
+ "does not:",
74
+ "implement a docx cleaner",
75
+ "remove comments",
76
+ "accept or remove tracked changes",
77
+ "remove metadata",
78
+ "block export",
79
+ "change export semantics",
80
+ "change docx reinsert behavior",
81
+ "change streamlit ui",
82
+ "change scrub key schema",
83
+ "add dependencies",
84
+ "add real data",
85
+ "add cloud processing",
86
+ ]:
87
+ assert required in lowered
88
+
89
+
90
+ def test_policy_uses_no_real_personal_data_examples():
91
+ text = _policy_text()
92
+
93
+ assert "Jan Jansen" not in text
94
+ assert "Piet de Vries" not in text
95
+ assert "123456782" not in text
96
+ assert "BSN 123" not in text