-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_codex_reset_page.py
More file actions
64 lines (53 loc) · 2.17 KB
/
Copy pathtest_codex_reset_page.py
File metadata and controls
64 lines (53 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env python3
from __future__ import annotations
import re
import unittest
from pathlib import Path
ROOT = Path(__file__).resolve().parent
HTML = (ROOT / "codex-reset.html").read_text(encoding="utf-8")
class CodexResetPageTests(unittest.TestCase):
def test_page_is_standalone_and_branded(self):
self.assertIn("<!doctype html>", HTML)
self.assertIn("<title>Codex Reset</title>", HTML)
self.assertIn("<h1>Codex Reset</h1>", HTML)
self.assertIn("Reset credit command builder", HTML)
self.assertIn("Official handoff", HTML)
self.assertFalse(re.search(r"[^\x00-\x7F]", HTML))
def test_page_declares_no_network_or_storage_surface(self):
self.assertIn("connect-src 'none'", HTML)
self.assertNotRegex(HTML, r"<script\s+[^>]*src=")
self.assertNotRegex(HTML, r"<link\s+[^>]*href=")
self.assertNotRegex(HTML, r"<form\b")
self.assertNotIn("fetch(", HTML)
self.assertNotIn("XMLHttpRequest", HTML)
self.assertNotIn("WebSocket", HTML)
self.assertNotIn("EventSource", HTML)
self.assertNotIn("sendBeacon", HTML)
self.assertNotIn("localStorage", HTML)
self.assertNotIn("sessionStorage", HTML)
self.assertIn("does not call OpenAI endpoints", HTML)
self.assertIn("does not read `auth.json`", HTML)
def test_page_points_to_codex_reset_repo(self):
self.assertIn(
"https://github.com/aaamosh/codex-reset/raw/main/codex-reset.html",
HTML,
)
self.assertIn(
"https://github.com/aaamosh/codex-reset/blob/main/codex-reset.html",
HTML,
)
self.assertNotIn("codex-invite-helper/raw", HTML)
self.assertNotIn("codex-hud/raw", HTML)
def test_page_generates_expected_command_surfaces(self):
for expected in [
"codex-reset status",
"invite-status",
"--cookie-file",
"consume",
"--dry-run",
"--yes",
"curl -fsSL https://raw.githubusercontent.com/aaamosh/codex-reset/main/codex_reset.py",
]:
self.assertIn(expected, HTML)
if __name__ == "__main__":
unittest.main()