unrip/test/ntfy_manifest_test.py
philipp 551050beb3
All checks were successful
deploy / deploy (push) Successful in 46s
Add internal ntfy utility service
Proof: npm test; PYTHONPATH=. python3 test/render_release_manifest_test.py; PYTHONPATH=. python3 test/repo_deployments_test.py; PYTHONPATH=. python3 test/ntfy_manifest_test.py; kubectl kustomize deploy/k8s/base.

Assumptions: ntfy should start as an internal ClusterIP utility so repo-owned services can publish without exposing an unauthenticated public notification endpoint; mobile delivery needs a separate authenticated ingress or external endpoint decision.

Still fake: No public ntfy ingress or operator mobile subscription exists yet; no existing runtime path emits ntfy notifications by default; ntfy cache storage is ephemeral emptyDir.
2026-04-15 21:23:41 +02:00

35 lines
1.6 KiB
Python

import pathlib
import re
import unittest
ROOT = pathlib.Path(__file__).resolve().parents[1]
class NtfyManifestTest(unittest.TestCase):
def test_kustomization_includes_internal_ntfy_utility_resources(self):
source = (ROOT / 'deploy/k8s/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/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_unrip_services_receive_internal_notification_endpoint(self):
source = (ROOT / 'deploy/k8s/base/unrip.yaml').read_text()
self.assertIn('NOTIFICATION_NTFY_BASE_URL: http://ntfy.utility.svc.cluster.local', source)
self.assertIn('NOTIFICATION_NTFY_TOPIC: unrip', source)
def test_workflow_waits_for_ntfy_rollout_without_rewriting_external_image(self):
source = (ROOT / '.forgejo/workflows/deploy.yml').read_text()
self.assertIn('kubectl -n utility rollout status deployment/ntfy --timeout=180s', source)
self.assertNotRegex(source, re.compile(r'set image "deployment/ntfy"'))
if __name__ == '__main__':
unittest.main()