Files
cozystack/packages/apps/opensearch/tests/dashboard-resourcemap_test.yaml
T
Aleksei Sviridkin f3c28e91c4 test(opensearch): pin the trust anchor, the name guard and the upgrade
Most of what this chart decides about TLS is invisible in a rendered
manifest until a cluster disagrees with it. The upgrade case is the
sharpest: a release that already runs operator-managed HTTP TLS must
keep working when the chart takes the CA over, and nothing about the
rendered output says whether it will.

The negative assertions carry as much as the positive ones. The trust
anchor must stay out of the resource map, since a name grant there
would outlive the platform's verdict on it, and a null tls value must
leave the chart rendering rather than aborting the whole release. Both
are properties that fail silently and only a test states them.

The bats guard covers what helm-unittest cannot see: which Secrets the
opensearch-rd definition exposes, so a key-bearing one cannot be added
to that surface without the guard going red.

Assisted-by: LLM
Signed-off-by: Aleksei Sviridkin <f@lex.la>
2026-09-11 01:23:22 +03:00

85 lines
2.7 KiB
YAML

suite: opensearch tenant RBAC for dashboard resources
# The Role is the direct read grant for tenant subjects, and the credentials Secret is
# the only Secret that needs one. The trust anchor takes the other path: the
# ApplicationDefinition's spec.secrets.include drives the lineage webhook's
# tenantresource label, and the tenant reads the projection through
# core.cozystack.io/tenantsecrets, which the base tenant roles grant. Every converged
# engine delivers it that way and none name-grants it; mongodb's Role says why.
release:
name: os-test
namespace: tenant-test
set:
_cluster:
scheduling: {}
cluster-domain: cozy.local
templates:
- templates/dashboard-resourcemap.yaml
tests:
- it: grants the tenant the credentials Secret and nothing else
documentIndex: 0
asserts:
- isKind:
of: Role
- contains:
path: rules[1].resourceNames
content: os-test-credentials
- equal:
path: rules[1].resources
value:
- secrets
# Every Secret of the TLS chain carries a private key — the cert-manager CA under
# tls.key, and both leaves the same — so granting any of them would hand the tenant
# key material. The count is what makes this exhaustive rather than a list of the
# three names someone happened to think of, the projection included: it reaches the
# tenant through tenantsecrets, so a name grant for it here would be a bypass of the
# webhook's verdict rather than a convenience.
- it: never grants the tenant a Secret beyond the credentials
documentIndex: 0
asserts:
- notContains:
path: rules[1].resourceNames
content: os-test.http-ca
- notContains:
path: rules[1].resourceNames
content: os-test-http-server
- notContains:
path: rules[1].resourceNames
content: os-test-dashboards-server
- notContains:
path: rules[1].resourceNames
content: os-test.tenant-ca
- lengthEqual:
path: rules[1].resourceNames
count: 1
# And the rule count, because the assertion above is exhaustive only within
# rules[1]: a second rule granting secrets at another index satisfies every
# other assertion in this file.
- lengthEqual:
path: rules
count: 3
- it: grants read only, never write
documentIndex: 0
asserts:
- equal:
path: rules[1].verbs
value:
- get
- list
- watch
- it: binds the Role to tenant use subjects
documentIndex: 1
asserts:
- isKind:
of: RoleBinding
- equal:
path: roleRef.name
value: os-test-dashboard-resources