Files
cozystack/packages/apps/mongodb/tests/no-certmanager-objects_test.yaml
T
Aleksei Sviridkin 8b6867dc47 fix(mongodb): correct the trust-anchor prose and two e2e assertions
The name-clash note claimed the shared TLS helper documents
<release>-ca-cert as the conventional key-free anchor. It documents the
opposite: the canonical name is <release>.tenant-ca, and it names this
engine as the reason, because MongoDB already claims <release>-ca-cert
with a key-bearing Secret. There is no clash to warn about and the chart
follows the convention rather than deviating from it. The paragraph
above already says <release>-ca-cert holds the CA private key, so drop
the note instead of inverting it.

Guard the ownerReference assertions against an absent list. length() of
null is a type error rather than a failed comparison, and the harness
returns it as an error, which aborts the poll instead of retrying — so
the timeout never applies while the operator is still patching the
reference on.

Restore the two-variable form of the fingerprint comparison. Inlining
both command substitutions into the test swallows a non-zero exit: with
no openssl on PATH both sides are empty, they compare equal, and the
check passes having compared nothing.

Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-09-01 11:20:33 +03:00

91 lines
3.1 KiB
YAML

suite: chart renders no cert-manager objects
# The PSMDB operator owns the entire cert-manager chain — the self-signed
# bootstrap Issuer, the CA Certificate, the CA-backed Issuer and the leaf
# certificates — and controls the CA it embeds in the pods. Anything this chart
# rendered would be orphaned and ignored as a trust anchor while looking like
# it participated. The invariant is stated in both templates/mongodb.yaml and
# the README; this suite is what stops it from silently becoming untrue.
#
# Deliberately NOT scoped with `templates:` — the point is to see every
# document the chart produces, not one file.
#
# `any: true` is REQUIRED on every containsDocument below, and its absence is
# not a style difference. Without it the matcher asserts that EVERY rendered
# document matches, so negating it yields "not every document is a
# Certificate" — true of any template FILE rendering more than one document,
# which is the granularity these are ANDed at, so a forbidden kind rendered
# alongside another document in one file would pass unconditionally. The
# vacuity control is the guard against that: it fails if the negated form ever
# stops discriminating.
release:
name: mg-test
namespace: tenant-test
set:
_cluster:
cluster-domain: cozy.local
tests:
# Positive control for the four negatives that follow. All of them are
# satisfied by a matcher that never matches anything, so they are only worth
# as much as the proof that this one does. Asserting a kind the chart
# certainly DOES render, through the same matcher shape and the same
# `any: true`, supplies it.
#
# Scoped to the one template that renders the CR, unlike the negatives. An
# unscoped assertion is ANDed across template files, so a positive one would
# demand the CR appear in backup-secret.yaml and credentials.yaml too and
# fail for the wrong reason. That same ANDing is what makes the unscoped
# negatives correct: they go red if ANY file renders the forbidden kind.
- it: the containsDocument matcher discriminates
templates:
- templates/mongodb.yaml
asserts:
- containsDocument:
kind: PerconaServerMongoDB
apiVersion: psmdb.percona.com/v1
any: true
- it: renders no cert-manager Certificate
asserts:
- not: true
containsDocument:
kind: Certificate
apiVersion: cert-manager.io/v1
any: true
- it: renders no cert-manager Issuer
asserts:
- not: true
containsDocument:
kind: Issuer
apiVersion: cert-manager.io/v1
any: true
- it: renders no cert-manager objects with external access enabled
set:
external: true
_namespace:
host: example.com
asserts:
- not: true
containsDocument:
kind: Certificate
apiVersion: cert-manager.io/v1
any: true
- not: true
containsDocument:
kind: Issuer
apiVersion: cert-manager.io/v1
any: true
- it: renders no cert-manager ClusterIssuer
asserts:
- not: true
containsDocument:
kind: ClusterIssuer
apiVersion: cert-manager.io/v1
any: true