Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(uplink): Ensure string input for b64enc in secret.yaml #686

Merged
merged 14 commits into from
Sep 12, 2023
2 changes: 1 addition & 1 deletion charts/uplink/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ apiVersion: v1
appVersion: "1.0"
description: A Helm chart for uplink.jenkins.io
name: uplink
version: 0.1.2
version: 0.1.3
maintainers:
- name: olblak
2 changes: 1 addition & 1 deletion charts/uplink/templates/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metadata:
labels:
{{ include "uplink.labels" . | indent 4 }}
data:
postgresql.url: {{ .Values.postgresql.url | b64enc }}
postgresql.url: {{ .Values.postgresql.url | toString | b64enc }}
client.id: {{ .Values.client.id | b64enc }}
client.secret: {{ .Values.client.secret | b64enc }}
sentry.dsn: {{ .Values.sentry.dsn | b64enc }}
41 changes: 41 additions & 0 deletions charts/uplink/templates/tests/custom_values_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
suite: test secret.yaml
templates:
- secret.yaml
tests:
- it: should ensure the secret has correct metadata
set:
postgresql.url: "example-url"
client.id: "example-id"
client.secret: "example-secret"
sentry.dsn: "example-dsn"
asserts:
- isKind:
of: Secret
- matchRegex:
path: metadata.name
pattern: "^uplink.*" # General check to ensure name starts with "uplink"
- equal:
path: metadata.name
value: "RELEASE-NAME-uplink." # Specific check for the exact name

- it: should check data fields in secret
set:
postgresql.url: "example-url"
client.id: "example-id"
client.secret: "example-secret"
sentry.dsn: "example-dsn"
asserts:
- equal:
path: data.postgresql.url
value: "ZXhhbXBsZS11cmw=" # Base64 encoded value of "example-url"
- equal:
path: data.client.id
value: "ZXhhbXBsZS1pZA==" # Base64 encoded value of "example-id"
- equal:
path: data.client.secret
value: "ZXhhbXBsZS1zZWNyZXQ=" # Base64 encoded value of "example-secret"
- equal:
path: data.sentry.dsn
value: "ZXhhbXBsZS1kc24=" # Base64 encoded value of "example-dsn"

# Add more tests as required...
25 changes: 25 additions & 0 deletions charts/uplink/templates/tests/defaults_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
suite: test default behavior of secret.yaml with default values
templates:
- secret.yaml
tests:
- it: should render with default values without error
asserts:
- isKind:
of: Secret
- matchRegex:
path: metadata.name
pattern: "^uplink.*" # Assuming the default behavior still starts with "uplink"
- notMatchRegex:
path: data.postgresql.url
pattern: "." # Assuming no default value provided
- notMatchRegex:
path: data.client.id
pattern: "." # Assuming no default value provided
- notMatchRegex:
path: data.client.secret
pattern: "." # Assuming no default value provided
- notMatchRegex:
path: data.sentry.dsn
pattern: "." # Assuming no default value provided

# Add more tests as required to check default behavior...