Files
reposilite-charts/unittests/secrets/basicAuth.yaml
Markus Pesch d790cd3ec4 fix(secret): enforce basic auth credentials
This patch remove generation of a random string for the username and password of
the basic auth credentials.

The problem with the random generated basic auth credentials is, that this leads
to a new shasum of the secret. GitOps tools like ArgoCD detects a drift trigger
a rolling update.

To avoid this must now the basic auth credentials be defined to enable
prometheus metrics.
2025-10-22 17:14:53 +02:00

99 lines
2.6 KiB
YAML

chart:
appVersion: 0.1.0
version: 0.1.0
suite: Secret reposilite template
release:
name: reposilite-unittest
namespace: testing
templates:
- templates/secretPrometheusBasicAuth.yaml
tests:
- it: Skip rendering
asserts:
- hasDocuments:
count: 0
- it: Throw error for missing basic auth password
set:
prometheus.metrics.enabled: true
# prometheus.metrics.secret.new.basicAuthPassword: "my-password"
prometheus.metrics.secret.new.basicAuthUsername: "my-username"
asserts:
- failedTemplate:
errorMessage: "Password for basic auth is required!"
- it: Throw error for missing basic auth username
set:
prometheus.metrics.enabled: true
prometheus.metrics.secret.new.basicAuthPassword: "my-password"
# prometheus.metrics.secret.new.basicAuthUsername: "my-username"
asserts:
- failedTemplate:
errorMessage: "Username for basic auth is required!"
- it: Rendering secret with default values.
set:
prometheus.metrics.enabled: true
prometheus.metrics.secret.new.basicAuthPassword: "my-password"
prometheus.metrics.secret.new.basicAuthUsername: "my-username"
asserts:
- hasDocuments:
count: 1
- containsDocument:
apiVersion: v1
kind: Secret
name: reposilite-unittest-basic-auth-credentials
namespace: testing
- notExists:
path: metadata.annotations
- equal:
path: metadata.labels
value:
app.kubernetes.io/instance: reposilite-unittest
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: reposilite
app.kubernetes.io/version: 0.1.0
helm.sh/chart: reposilite-0.1.0
- exists:
path: stringData.password
- exists:
path: stringData.username
- it: Rendering secret with custom values.
set:
prometheus.metrics.enabled: true
prometheus.metrics.secret.new.basicAuthPassword: foo
prometheus.metrics.secret.new.basicAuthUsername: bar
prometheus.metrics.secret.new.annotations:
foo: bar
prometheus.metrics.secret.new.labels:
bar: foo
asserts:
- hasDocuments:
count: 1
- isSubset:
path: metadata.annotations
content:
foo: bar
- isSubset:
path: metadata.labels
content:
bar: foo
- equal:
path: metadata.name
value: reposilite-unittest-basic-auth-credentials
- equal:
path: stringData.password
value: foo
- equal:
path: stringData.username
value: bar
- it: Skip rendering if existing secret is used
set:
prometheus.metrics.enabled: true
prometheus.metrics.secret.existing.enabled: true
asserts:
- hasDocuments:
count: 0