Skip to content

Commit

Permalink
Merge pull request #1077 from SarathChandra24/unit-test-incrementals-…
Browse files Browse the repository at this point in the history
…publisher

chart: incrementals-publisher unit tests for secrets
  • Loading branch information
dduportal authored Feb 22, 2024
2 parents 1208cdc + 6fd4437 commit da46c21
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 24 deletions.
2 changes: 1 addition & 1 deletion charts/incrementals-publisher/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: v1
description: incrementals-publisher
name: incrementals-publisher
version: 0.7.0
version: 0.7.1
12 changes: 6 additions & 6 deletions charts/incrementals-publisher/templates/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ metadata:
{{ include "incrementals-publisher.labels" . | indent 4 }}
type: Opaque
data:
artifactory_key: {{ required "artifactory.key is required" .Values.artifactory.key | toString | b64enc }}
github_token: {{ required "github.token is required" .Values.github.token | toString | b64enc }}
github_app_id: {{ required "github.appId is required" .Values.github.appId | toString | b64enc }}
github_app_private_key: {{ required "github.privateKey is required" .Values.github.privateKey | toString | b64enc }}
jenkins_auth: {{ required "jenkins.auth is required" .Values.jenkins.auth | toString | b64enc }}
preshared_key: {{ required "preshared_key is required" .Values.preshared_key | toString | b64enc }}
artifactory_key: {{ .Values.artifactory.key | toString | b64enc }}
github_token: {{ .Values.github.token | toString | b64enc }}
github_app_id: {{ .Values.github.appId | toString | b64enc }}
github_app_private_key: {{ .Values.github.privateKey | toString | b64enc }}
jenkins_auth: {{ .Values.jenkins.auth | toString | b64enc }}
preshared_key: {{ .Values.preshared_key | toString | b64enc }}
46 changes: 43 additions & 3 deletions charts/incrementals-publisher/tests/custom_values_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@ suite: Custom values
templates:
- deployment.yaml
- secret.yaml # dependency of deployment.yaml
values:
# These values are required by the template "secret.yaml"
- secret-values.yaml
set:
permissions_url: https://somewhere.jenkins.io/github.json
artifactory:
key: testingArtifactoryKey
github:
token: customSuperSecretToken
appId: customSuperSecretAppId
privateKey: customSuperSecretPrivateKey
jenkins:
auth: customSecretJenkinsUser:customSecretJenkinsPassword
preshared_key: customSuperSecretPreSharedKey
tests:
- it: should define a deployment with the provided custom settings
template: deployment.yaml
Expand All @@ -33,3 +39,37 @@ tests:
name: PERMISSIONS_URL
value: https://somewhere.jenkins.io/github.json
any: true
- contains:
path: spec.template.spec.containers[0].env
content:
name: JENKINS_AUTH
valueFrom:
secretKeyRef:
key: jenkins_auth
name: RELEASE-NAME-incrementals-publisher

- it: should create a Secret with the correct value
template: secret.yaml
asserts:
- hasDocuments:
count: 1
- isKind:
of: Secret
- equal:
path: data.artifactory_key
value: dGVzdGluZ0FydGlmYWN0b3J5S2V5
- equal:
path: data.github_token
value: Y3VzdG9tU3VwZXJTZWNyZXRUb2tlbg==
- equal:
path: data.github_app_id
value: Y3VzdG9tU3VwZXJTZWNyZXRBcHBJZA==
- equal:
path: data.github_app_private_key
value: Y3VzdG9tU3VwZXJTZWNyZXRQcml2YXRlS2V5
- equal:
path: data.jenkins_auth
value: Y3VzdG9tU2VjcmV0SmVua2luc1VzZXI6Y3VzdG9tU2VjcmV0SmVua2luc1Bhc3N3b3Jk
- equal:
path: data.preshared_key
value: Y3VzdG9tU3VwZXJTZWNyZXRQcmVTaGFyZWRLZXk=
8 changes: 5 additions & 3 deletions charts/incrementals-publisher/tests/defaults_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ suite: Default values
templates:
- deployment.yaml
- secret.yaml # dependency of deployment.yaml
values:
# These values are required by the template "secret.yaml"
- secret-values.yaml
tests:
- it: should create a secret with default values
template: secret.yaml
asserts:
- hasDocuments:
count: 1
- it: should define a deployment with the default settings
template: deployment.yaml
asserts:
Expand Down
11 changes: 0 additions & 11 deletions charts/incrementals-publisher/tests/secret-values.yaml

This file was deleted.

0 comments on commit da46c21

Please sign in to comment.