mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-21 20:23:39 +09:00
These cases picked a document by position and then asserted only that something is absent from it. When a template gains or reorders a document, the index lands on a different object that lacks the field just as well, and the case stays green while the property it names is no longer checked. Selecting by kind or metadata.name keeps each case on the object it names, and fails with "document not found" when that object stops rendering. Assisted-by: LLM Signed-off-by: Aleksei Sviridkin <f@lex.la>
235 lines
5.9 KiB
YAML
235 lines
5.9 KiB
YAML
suite: security secrets tests
|
|
|
|
templates:
|
|
- templates/security.yaml
|
|
|
|
tests:
|
|
###################
|
|
# Basic rendering #
|
|
###################
|
|
|
|
- it: renders three secrets (admin-credentials, security-config, credentials)
|
|
release:
|
|
name: test-os
|
|
namespace: tenant-test
|
|
set:
|
|
_cluster:
|
|
cluster-domain: cozy.local
|
|
asserts:
|
|
- hasDocuments:
|
|
count: 3
|
|
|
|
###########################
|
|
# Admin credentials #
|
|
###########################
|
|
|
|
- it: sets admin-credentials secret name
|
|
release:
|
|
name: test-os
|
|
namespace: tenant-test
|
|
set:
|
|
_cluster:
|
|
cluster-domain: cozy.local
|
|
asserts:
|
|
- equal:
|
|
path: metadata.name
|
|
value: test-os-admin-credentials
|
|
documentIndex: 0
|
|
|
|
- it: sets admin username
|
|
release:
|
|
name: test-os
|
|
namespace: tenant-test
|
|
set:
|
|
_cluster:
|
|
cluster-domain: cozy.local
|
|
asserts:
|
|
- equal:
|
|
path: stringData.username
|
|
value: admin
|
|
documentIndex: 0
|
|
|
|
- it: generates a 32-char alphanumeric password
|
|
release:
|
|
name: test-os
|
|
namespace: tenant-test
|
|
set:
|
|
_cluster:
|
|
cluster-domain: cozy.local
|
|
asserts:
|
|
- matchRegex:
|
|
path: stringData.password
|
|
pattern: "^[a-zA-Z0-9]{32}$"
|
|
documentIndex: 0
|
|
|
|
###########################
|
|
# Security config #
|
|
###########################
|
|
|
|
- it: sets security-config secret name
|
|
release:
|
|
name: test-os
|
|
namespace: tenant-test
|
|
set:
|
|
_cluster:
|
|
cluster-domain: cozy.local
|
|
asserts:
|
|
- equal:
|
|
path: metadata.name
|
|
value: test-os-security-config
|
|
documentIndex: 1
|
|
|
|
- it: includes config.yml with basic auth
|
|
release:
|
|
name: test-os
|
|
namespace: tenant-test
|
|
set:
|
|
_cluster:
|
|
cluster-domain: cozy.local
|
|
asserts:
|
|
- exists:
|
|
path: stringData["config.yml"]
|
|
documentIndex: 1
|
|
|
|
- it: includes internal_users.yml with bcrypt hash
|
|
release:
|
|
name: test-os
|
|
namespace: tenant-test
|
|
set:
|
|
_cluster:
|
|
cluster-domain: cozy.local
|
|
asserts:
|
|
- matchRegex:
|
|
path: stringData["internal_users.yml"]
|
|
pattern: "hash:.*\\$2a\\$"
|
|
documentIndex: 1
|
|
|
|
- it: includes roles_mapping.yml
|
|
release:
|
|
name: test-os
|
|
namespace: tenant-test
|
|
set:
|
|
_cluster:
|
|
cluster-domain: cozy.local
|
|
asserts:
|
|
- exists:
|
|
path: stringData["roles_mapping.yml"]
|
|
documentIndex: 1
|
|
|
|
###########################
|
|
# User-facing credentials #
|
|
###########################
|
|
|
|
- it: sets credentials secret name
|
|
release:
|
|
name: test-os
|
|
namespace: tenant-test
|
|
set:
|
|
_cluster:
|
|
cluster-domain: cozy.local
|
|
asserts:
|
|
- equal:
|
|
path: metadata.name
|
|
value: test-os-credentials
|
|
documentIndex: 2
|
|
|
|
- it: sets correct host and port
|
|
release:
|
|
name: test-os
|
|
namespace: tenant-test
|
|
set:
|
|
_cluster:
|
|
cluster-domain: cozy.local
|
|
asserts:
|
|
- equal:
|
|
path: stringData.host
|
|
value: test-os.tenant-test.svc.cozy.local
|
|
documentIndex: 2
|
|
- equal:
|
|
path: stringData.port
|
|
value: "9200"
|
|
documentIndex: 2
|
|
|
|
- it: sets https URI with credentials
|
|
release:
|
|
name: test-os
|
|
namespace: tenant-test
|
|
set:
|
|
_cluster:
|
|
cluster-domain: cozy.local
|
|
asserts:
|
|
- matchRegex:
|
|
path: stringData.uri
|
|
pattern: "^https://admin:[a-zA-Z0-9]{32}@test-os\\.tenant-test\\.svc\\.cozy\\.local:9200$"
|
|
documentIndex: 2
|
|
|
|
- it: does not include dashboards fields when dashboards disabled
|
|
release:
|
|
name: test-os
|
|
namespace: tenant-test
|
|
set:
|
|
_cluster:
|
|
cluster-domain: cozy.local
|
|
dashboards:
|
|
enabled: false
|
|
replicas: 1
|
|
resourcesPreset: "medium"
|
|
resources: {}
|
|
asserts:
|
|
- notExists:
|
|
path: stringData.dashboards-host
|
|
documentSelector:
|
|
path: metadata.name
|
|
value: test-os-credentials
|
|
|
|
- it: includes dashboards fields when dashboards enabled
|
|
release:
|
|
name: test-os
|
|
namespace: tenant-test
|
|
set:
|
|
_cluster:
|
|
cluster-domain: cozy.local
|
|
dashboards:
|
|
enabled: true
|
|
replicas: 1
|
|
resourcesPreset: "medium"
|
|
resources: {}
|
|
asserts:
|
|
- equal:
|
|
path: stringData.dashboards-host
|
|
value: test-os-dashboards.tenant-test.svc.cozy.local
|
|
documentIndex: 2
|
|
- equal:
|
|
path: stringData.dashboards-port
|
|
value: "5601"
|
|
documentIndex: 2
|
|
- matchRegex:
|
|
path: stringData.dashboards-uri
|
|
pattern: "^https://admin:[a-zA-Z0-9]{32}@test-os-dashboards\\.tenant-test\\.svc\\.cozy\\.local:5601$"
|
|
documentIndex: 2
|
|
|
|
###########################################
|
|
# Rendering without the platform's _cluster #
|
|
###########################################
|
|
|
|
# Every case above injects _cluster, which is what the platform does, so none of
|
|
# them exercises the read itself. `index` on an absent map is a hard render error
|
|
# rather than a miss returning nil, so it takes the whole template down and the
|
|
# `| default` that follows never runs. certmanager.yaml has the same read and its
|
|
# own suite for this in tls_test.yaml; this is the other half.
|
|
#
|
|
# No _cluster in `set` on purpose: injecting it is the one thing this case must
|
|
# not do. The host assertion is what makes it more than a render check — it says
|
|
# the fallback value actually reached the output.
|
|
- it: falls back to the default cluster domain when _cluster is absent
|
|
release:
|
|
name: test-os
|
|
namespace: tenant-test
|
|
asserts:
|
|
- hasDocuments:
|
|
count: 3
|
|
- equal:
|
|
path: stringData.host
|
|
value: test-os.tenant-test.svc.cozy.local
|
|
documentIndex: 2
|