my-homelab-configs/tests/jeannie/test_nextpath_pipeline.py

50 lines
2.3 KiB
Python

import pathlib
import unittest
ROOT = pathlib.Path(__file__).resolve().parents[2]
class NextPathPipelineTests(unittest.TestCase):
def test_deployment_is_debian_hosted_private_and_health_checked(self):
pipeline = (ROOT / "lib/jeannie/pipeline.sh").read_text(encoding="utf-8")
command = (ROOT / "jeannie").read_text(encoding="utf-8")
server = (ROOT / "cmd/jeannie-server/main.go").read_text(encoding="utf-8")
self.assertIn("deploy_nextpath()", pipeline)
self.assertIn('require_debian_server "deploy-nextpath"', pipeline)
self.assertIn("GOTOOLCHAIN=local go test ./cmd/nextpath/...", pipeline)
self.assertIn("NEXTPATH_ACCOUNT_STORE=${install_dir}/data/accounts.json", pipeline)
self.assertIn("ReadWritePaths=${install_dir}/data", pipeline)
self.assertIn("sudo chmod 0700", pipeline)
self.assertIn('curl -fsS --connect-timeout 3 "http://127.0.0.1:${http_port}/healthz"', pipeline)
self.assertIn("nextpath.service", pipeline)
self.assertIn("deploy-nextpath)", command)
self.assertIn('"deploy-nextpath": true', server)
def test_inventory_declares_public_wip(self):
inventory = (ROOT / "homelab.yml").read_text(encoding="utf-8")
self.assertIn("nextpath.lab2025.duckdns.org", inventory)
self.assertIn("install_dir: /data/homelab-nextpath", inventory)
self.assertIn("http_port: 8892", inventory)
def test_edge_routes_public_tls_to_the_private_backend(self):
main = (ROOT / "bootstrap/edge/main.tf").read_text(encoding="utf-8")
variables = (ROOT / "bootstrap/edge/variables.tf").read_text(encoding="utf-8")
nginx = (ROOT / "bootstrap/edge/templates/default.conf.tftpl").read_text(
encoding="utf-8"
)
environment = (ROOT / "lib/jeannie/env.sh").read_text(encoding="utf-8")
self.assertIn('nextpath_server_name = "nextpath.${var.server_name}"', main)
self.assertIn("nextpath_backend_host", variables)
self.assertIn("TF_VAR_nextpath_backend_host", environment)
self.assertIn("server_name ${nextpath_server_name};", nginx)
self.assertIn("proxy_pass http://${nextpath_backend_host}:${nextpath_backend_port}", nginx)
self.assertIn("zone=nextpath_auth", nginx)
self.assertIn("X-Forwarded-Proto https", nginx)
if __name__ == "__main__":
unittest.main()