import pathlib import re import subprocess import unittest ROOT = pathlib.Path(__file__).resolve().parents[1] class NtfyManifestTest(unittest.TestCase): def test_platform_kustomization_owns_internal_ntfy_utility_resources(self): source = (ROOT / 'deploy/k8s/platform/base/kustomization.yaml').read_text() self.assertIn('utility-namespace.yaml', source) self.assertIn('ntfy.yaml', source) def test_ntfy_manifest_is_internal_clusterip_service_with_health_checks(self): source = (ROOT / 'deploy/k8s/platform/base/ntfy.yaml').read_text() self.assertIn('namespace: utility', source) self.assertIn('image: binwiederhier/ntfy:v2.21.0', source) self.assertRegex(source, r'kind: Service[\s\S]*type: ClusterIP') self.assertIn('path: /v1/health', source) self.assertIn('base-url: http://ntfy.utility.svc.cluster.local', source) self.assertNotIn('kind: Ingress', source) def test_overlay_render_contains_cluster_owned_ntfy_without_public_ingress(self): rendered = subprocess.check_output( ['kubectl', 'kustomize', 'deploy/k8s/overlays/hetzner-single-node'], cwd=ROOT, text=True, ) self.assertIn('name: utility', rendered) self.assertIn('name: ntfy', rendered) self.assertIn('image: binwiederhier/ntfy:v2.21.0', rendered) self.assertNotRegex(rendered, re.compile(r'kind: Ingress[\s\S]*name: ntfy')) if __name__ == '__main__': unittest.main()