05ae530442
Install current verified harness releases inside Docker, preserve persistent accounts and settings, and provide separate interactive and pipeline model defaults with terminal onboarding and fuzzy pickers. Add Docker-aware authoring transport, Pi stage execution, bounded workflow controls, reliable final-result readback and usage settlement, and finite short-lived CLI pipe draining. Keep dated installation evidence and packaged authoring guidance consistent. Verified with a real Docker installation, both harness stages and interactive authors, the built-in plan/implement/review starter, independent host race/vet checks, installer tests, and packaged skill tests. Generated release receipts stay ignored in clean checkouts.
58 lines
2.6 KiB
Python
58 lines
2.6 KiB
Python
import importlib.util
|
|
import os
|
|
from pathlib import Path
|
|
import tempfile
|
|
import unittest
|
|
from unittest.mock import patch
|
|
|
|
spec = importlib.util.spec_from_file_location("configure", Path(__file__).with_name("configure-compose.py"))
|
|
configure = importlib.util.module_from_spec(spec)
|
|
spec.loader.exec_module(configure)
|
|
|
|
|
|
class ConfigureTests(unittest.TestCase):
|
|
def setUp(self):
|
|
# Container runs may have HOME=/home/pipelines, which the mount guard
|
|
# rejects; inject a disposable HOME/USERPROFILE for the fixtures.
|
|
home = tempfile.TemporaryDirectory()
|
|
self.addCleanup(home.cleanup)
|
|
environment = patch.dict(os.environ, {"HOME": home.name, "USERPROFILE": home.name})
|
|
environment.start()
|
|
self.addCleanup(environment.stop)
|
|
|
|
def test_detect_timezone_and_preserve_existing_files(self):
|
|
try:
|
|
configure.host_timezone()
|
|
except ValueError:
|
|
self.skipTest("host timezone is unavailable in this environment")
|
|
with tempfile.TemporaryDirectory() as directory:
|
|
zone = configure.configure(directory, "http://192.168.1.20:8090", "0.0.0.0")
|
|
self.assertTrue(zone)
|
|
settings = Path(directory, ".env")
|
|
original = settings.read_bytes()
|
|
self.assertIn(f"TZ={zone}", settings.read_text())
|
|
self.assertEqual(Path(directory, "secrets/ntfy-token.txt").stat().st_mode & 0o777, 0o600)
|
|
with self.assertRaises(ValueError):
|
|
configure.configure(directory, "http://192.168.1.21:8090", "0.0.0.0")
|
|
self.assertEqual(settings.read_bytes(), original)
|
|
|
|
def test_existing_token_is_not_overwritten(self):
|
|
with tempfile.TemporaryDirectory() as directory:
|
|
secrets = Path(directory, "secrets")
|
|
secrets.mkdir()
|
|
token = secrets / "ntfy-token.txt"
|
|
token.write_text("existing-secret")
|
|
configure.configure(directory, "http://192.168.1.20:8090", "0.0.0.0", "Europe/London")
|
|
self.assertEqual(token.read_text(), "existing-secret")
|
|
|
|
def test_reject_bad_url_and_injected_values(self):
|
|
for url in ["file:///foo", "https://user:pass@example.com", "https://example.com/topic", "https://example.com?token=secret"]:
|
|
with tempfile.TemporaryDirectory() as directory, self.assertRaises(ValueError):
|
|
configure.configure(directory, url, "0.0.0.0", "Europe/London")
|
|
with tempfile.TemporaryDirectory() as directory, self.assertRaises(ValueError):
|
|
configure.configure(directory, "https://example.com", "0.0.0.0\nEVIL=yes", "Europe/London")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|