Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions charts/cf-common-test/tests/external-secrets/error_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: external secrets error handlers
templates:
- templates/external-secrets.yaml
tests:
- it: Test with no external secrets
set:
externalSecrets: []
asserts:
- hasDocuments:
count: 0

- it: Test external secret with no keys or keysFrom
set:
externalSecrets:
- name: test-es
asserts:
- hasDocuments:
count: 1
- equal:
path: spec.data
value: []
- equal:
path: spec.dataFrom
value: []
36 changes: 36 additions & 0 deletions charts/cf-common-test/tests/external-secrets/metadata_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: external secrets metadata
templates:
- templates/external-secrets.yaml
tests:
- it: Test default external secret metadata
set:
externalSecrets:
- name: test-es
keys: []
asserts:
- hasDocuments:
count: 1
- notExists:
path: metadata.labels
- notExists:
path: metadata.annotations

- it: Test custom external secret metadata
set:
externalSecrets:
- name: test-es
labels:
foo: bar
annotations:
alice: bob
keys: []
asserts:
- equal:
path: metadata.labels
value:
foo: bar
- equal:
path: metadata.annotations
value:
alice: bob
174 changes: 174 additions & 0 deletions charts/cf-common-test/tests/external-secrets/spec_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: external secrets spec
templates:
- templates/external-secrets.yaml
tests:
- it: Test default external secret spec
set:
externalSecrets:
- name: test-es
keys:
- name: KEY1
remoteSecretName: my-secret
remoteKey: password
asserts:
- hasDocuments:
count: 1
- isKind:
of: ExternalSecret
- equal:
path: metadata.name
value: test-es
- equal:
path: spec.refreshInterval
value: 1m
- equal:
path: spec.secretStoreRef
value:
name: asm
kind: ClusterSecretStore
- equal:
path: spec.target
value:
name: test-es
creationPolicy: Owner
deletionPolicy: Retain
- equal:
path: spec.data
value:
- secretKey: KEY1
remoteRef:
key: my-secret
property: password
- equal:
path: spec.dataFrom
value: []

- it: Test custom secretStoreRef
set:
externalSecrets:
- name: test-es
secretStoreRef:
name: my-store
kind: SecretStore
keys: []
asserts:
- equal:
path: spec.secretStoreRef
value:
name: my-store
kind: SecretStore

- it: Test custom refreshInterval and target policies
set:
externalSecrets:
- name: test-es
refreshInterval: 5m
creationPolicy: Merge
deletionPolicy: Delete
keys: []
asserts:
- equal:
path: spec.refreshInterval
value: 5m
- equal:
path: spec.target
value:
name: test-es
creationPolicy: Merge
deletionPolicy: Delete

- it: Test keys with remoteKey and decodingStrategy
set:
externalSecrets:
- name: test-es
keys:
- name: KEY1
remoteSecretName: my-secret
remoteKey: password
decodingStrategy: Base64
asserts:
- equal:
path: spec.data
value:
- secretKey: KEY1
remoteRef:
key: my-secret
property: password
decodingStrategy: Base64

- it: Test keysFrom with decodingStrategy
set:
externalSecrets:
- name: test-es
keysFrom:
- remoteSecretName: my-secret
decodingStrategy: Base64
asserts:
- equal:
path: spec.data
value: []
- equal:
path: spec.dataFrom
value:
- extract:
key: my-secret
decodingStrategy: Base64

- it: Test remoteSecretName TPL rendering
set:
global:
stage: staging
externalSecrets:
- name: test-es
keys:
- name: KEY1
remoteSecretName: "{{ .Values.global.stage }}/my-secret"
remoteKey: password
asserts:
- equal:
path: spec.data[0].remoteRef.key
value: staging/my-secret

- it: Test apiVersion override
set:
apiVersionOverrides:
externalSecrets: external-secrets.io/v1beta1
externalSecrets:
- name: test-es
keys: []
asserts:
- isAPIVersion:
of: external-secrets.io/v1beta1

- it: Test with more than one external secret
set:
externalSecrets:
- name: es-one
keys: []
- name: es-two
keys: []
asserts:
- hasDocuments:
count: 2
- equal:
path: metadata.name
value: es-one
documentIndex: 0
- equal:
path: metadata.name
value: es-two
documentIndex: 1

- it: Should fallback to remoteSecretName if keys[].remoteSecretName is not provided
set:
externalSecrets:
- name: test-es
keys:
- name: KEY1
remoteKey: password
remoteSecretName: my-secret
asserts:
- equal:
path: spec.data[0].remoteRef.key
value: my-secret
2 changes: 1 addition & 1 deletion charts/cf-common/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
appVersion: v0.0.0
description: Codefresh library chart
name: cf-common
version: 0.34.0
version: 0.35.0
type: library
keywords:
- codefresh
Expand Down
4 changes: 2 additions & 2 deletions charts/cf-common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Codefresh library chart

![Version: 0.34.0](https://img.shields.io/badge/Version-0.34.0-informational?style=flat-square) ![Type: library](https://img.shields.io/badge/Type-library-informational?style=flat-square) ![AppVersion: v0.0.0](https://img.shields.io/badge/AppVersion-v0.0.0-informational?style=flat-square)
![Version: 0.35.0](https://img.shields.io/badge/Version-0.35.0-informational?style=flat-square) ![Type: library](https://img.shields.io/badge/Type-library-informational?style=flat-square) ![AppVersion: v0.0.0](https://img.shields.io/badge/AppVersion-v0.0.0-informational?style=flat-square)

## Installing the Chart

Expand All @@ -18,7 +18,7 @@ Include this chart as a dependency in your `Chart.yaml` e.g.
# Chart.yaml
dependencies:
- name: cf-common
version: 0.34.0
version: 0.35.0
repository: https://chartmuseum.codefresh.io/cf-common
```

Expand Down
Loading
Loading