Proof: python3 test/ntfy_manifest_test.py; kubectl kustomize deploy/k8s/overlays/hetzner-single-node. Assumptions: ntfy starts as an internal ClusterIP platform utility at http://ntfy.utility.svc.cluster.local; public or Tailscale exposure requires a later authenticated ingress decision. Still fake: No public ntfy URL, auth policy, iOS subscription, webhook ingress, or durable ntfy cache volume is configured yet.
37 lines
1.5 KiB
Python
37 lines
1.5 KiB
Python
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()
|