Separate one-time bootstrap, historical deployment examples and local validation. Document final hostname and historical status; exclude credentials and runtime data.
33 lines
1.5 KiB
Python
33 lines
1.5 KiB
Python
import importlib.util
|
|
from pathlib import Path
|
|
import unittest
|
|
|
|
spec = importlib.util.spec_from_file_location("exhibition_seed", Path(__file__).with_name("seed.py"))
|
|
seed = importlib.util.module_from_spec(spec)
|
|
spec.loader.exec_module(seed)
|
|
|
|
|
|
class SeedSafetyTests(unittest.TestCase):
|
|
def test_origin_relative_only(self):
|
|
client = seed.Client.__new__(seed.Client)
|
|
for path in ("https://pages.anya.jp/", "//pages.anya.jp/", "relative"):
|
|
with self.assertRaises(ValueError):
|
|
client.request("GET", path)
|
|
|
|
def test_redirects_not_followed(self):
|
|
self.assertIsNone(seed.NoRedirect().redirect_request(None, None, 302, "", {}, "https://example.invalid/"))
|
|
|
|
def test_external_form_controls_and_disabled_fields(self):
|
|
forms = seed.Forms()
|
|
forms.feed('''<form id="campus-update-1"></form>
|
|
<input form="campus-update-1" name="campus_id" value="1">
|
|
<input form="campus-update-1" name="ignore" value="secret" disabled>
|
|
<input form="campus-update-1" name="campus_enabled" type="checkbox" value="1" checked>
|
|
<input form="campus-update-1" name="unchecked" type="checkbox" value="1">
|
|
<select form="campus-update-1" name="mode"><option value="first"></option><option value="standalone" selected></option></select>''')
|
|
self.assertEqual(forms.forms, {"campus-update-1": {"campus_id": "1", "campus_enabled": "1", "mode": "standalone"}})
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|