Skip to content

Commit

Permalink
Merge pull request #686 from Sathwik-git/main
Browse files Browse the repository at this point in the history
fix(uplink): Ensure string input for b64enc in secret.yaml
  • Loading branch information
dduportal authored Sep 12, 2023
2 parents 25d40b2 + 4094236 commit 5c24e03
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 2 deletions.
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...

0 comments on commit 5c24e03

Please sign in to comment.