Files
cozystack/packages/apps/postgres/tests/host_guard_test.yaml
IvanHunters 2fa51bf587 test(charts): isolate guard coverage for every guarded template
Add per-template guard suites so each guarded hostname site is exercised
on its own: harbor harbor.yaml and httproute.yaml, bootbox machines.yaml,
seaweedfs cosi-deployment.yaml, bucket deployment.yaml and httproute.yaml,
monitoring alerta.yaml, grafana httproute.yaml and the grafanaHost helper
via oidc-keycloak.yaml. Each suite renders only its target template, so
removing that file's guard reddens it. Also add a postgres positive case
that renders the Certificate with an apex set (external=true).

Signed-off-by: IvanHunters <xorokhotnikov@gmail.com>
2026-09-28 18:32:49 +03:00

64 lines
1.7 KiB
YAML

suite: postgres external cert fails on an empty apex, but only when external
templates:
- templates/db.yaml
release:
name: pg-test
namespace: tenant-test
# db.yaml appends the external SAN <release>.<_namespace.host> only under
# `if and $tlsEnabled .Values.external`. cozy-lib.ns-host-required guards that
# line, so an empty apex fails the render when TLS and external are on, and is a
# non-issue when external is off.
tests:
- it: fails when tls and external are on and the apex is empty
set:
external: true
tls:
enabled: true
_namespace:
host: ""
_cluster:
scheduling: {}
cluster-domain: cozy.local
asserts:
- failedTemplate:
errorMessage: "the tenant apex (_namespace.host) is empty and this app sets no host override, so its ingress hostname would be malformed. Set tenant.spec.host on this tenant, inherit it from a parent that has host set, or set this app's host value."
- it: still renders when external is off even though the apex is empty
set:
external: false
tls:
enabled: true
_namespace:
host: ""
_cluster:
scheduling: {}
cluster-domain: cozy.local
documentSelector:
path: kind
value: Cluster
asserts:
- isNull:
path: spec.certificates
- it: renders the external cert SAN from the apex when it is set
set:
external: true
tls:
enabled: true
_namespace:
host: example.org
_cluster:
scheduling: {}
cluster-domain: cozy.local
documentSelector:
path: kind
value: Cluster
asserts:
- equal:
path: spec.certificates.serverAltDNSNames[0]
value: pg-test.example.org