my-homelab-configs/tests/jeannie/test_privacy_services_pipel...

67 lines
3.1 KiB
Python

#!/usr/bin/env python3
import pathlib
import unittest
ROOT = pathlib.Path(__file__).resolve().parents[2]
class PrivacyServicesPipelineTests(unittest.TestCase):
def test_privatebin_is_hardened_and_persistent(self):
compose = (ROOT / "infra/privatebin/docker-compose.yml").read_text(encoding="utf-8")
config = (ROOT / "infra/privatebin/conf.php").read_text(encoding="utf-8")
self.assertIn("privatebin/nginx-fpm-alpine:2.1.0-alpine3.24", compose)
self.assertIn("read_only: true", compose)
self.assertIn("./data:/srv/data", compose)
self.assertIn('default = "1week"', config)
self.assertIn("fileupload = false", config)
def test_miniflux_has_private_database_and_healthcheck(self):
compose = (ROOT / "infra/miniflux/docker-compose.yml").read_text(encoding="utf-8")
self.assertIn("miniflux/miniflux:2.3.6", compose)
self.assertIn("postgres:18-alpine", compose)
self.assertIn("./postgres:/var/lib/postgresql", compose)
self.assertIn('"-healthcheck", "auto"', compose)
self.assertNotIn("ports:\n - \"5432", compose)
def test_pipeline_preserves_generated_credentials_and_runs_in_up(self):
pipeline = (ROOT / "lib/jeannie/pipeline.sh").read_text(encoding="utf-8")
self.assertIn("deploy_privatebin()", pipeline)
self.assertIn("deploy_miniflux()", pipeline)
self.assertIn("MINIFLUX_ADMIN_PASSWORD=//p", pipeline)
self.assertIn('"id": "privatebin-deploy"', pipeline)
self.assertIn('"id": "miniflux-deploy"', pipeline)
def test_edge_has_dedicated_routes_and_limits(self):
nginx = (ROOT / "bootstrap/edge/templates/default.conf.tftpl").read_text(encoding="utf-8")
main = (ROOT / "bootstrap/edge/main.tf").read_text(encoding="utf-8")
self.assertIn("server_name ${privatebin_server_name};", nginx)
self.assertIn("zone=privatebin_write", nginx)
self.assertIn("server_name ${miniflux_server_name};", nginx)
self.assertIn("/healthcheck", nginx)
self.assertIn('privatebin_server_name = "paste.${var.server_name}"', main)
self.assertIn('miniflux_server_name', main)
class OpsProofPipelineTests(unittest.TestCase):
def test_opsproof_is_debian_managed_and_version_pinned(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_opsproof()", pipeline)
self.assertIn('require_debian_server "deploy-opsproof"', pipeline)
self.assertIn('go_version="${LAB_OPSPROOF_GO_VERSION:-1.27.4}"', pipeline)
self.assertIn('go${go_version}.linux-amd64.tar.gz', pipeline)
self.assertIn("6dd8bd22b9d335e55b190aa16f3271e73c97cd25", pipeline)
self.assertIn("npm run check", pipeline)
self.assertIn("GOTOOLCHAIN=local go test ./...", pipeline)
self.assertIn("opsproof.service", pipeline)
self.assertIn("deploy-opsproof)", command)
self.assertIn('"deploy-opsproof": true', server)
if __name__ == "__main__":
unittest.main()