Skip to content

Commit 5c59e2d

Browse files
committed
Added helm unit tests.
1 parent 9f537ab commit 5c59e2d

File tree

4 files changed

+117
-0
lines changed

4 files changed

+117
-0
lines changed

.github/workflows/cicd.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,19 @@ jobs:
5050
path: |
5151
htmlcov/
5252
coverage.xml
53+
54+
helm-test:
55+
runs-on: ubuntu-latest
56+
57+
steps:
58+
- uses: actions/checkout@v4
59+
- name: Helm install
60+
uses: azure/setup-helm@v4
61+
with:
62+
version: latest
63+
- run: helm lint helm
64+
- name: Helm unit tests
65+
uses: d3adb5/helm-unittest-action@v2
66+
with:
67+
helm-version: latest
68+
charts: helm/

helm/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,20 @@ helm upgrade stac-auth-proxy ./stac-auth-proxy -f custom-values.yaml
7575
helm uninstall stac-auth-proxy
7676
```
7777

78+
## Testing
79+
80+
Run unit tests to validate chart templates:
81+
82+
```bash
83+
helm unittest helm/
84+
```
85+
86+
Requires the [helm-unittest](https://github.com/helm-unittest/helm-unittest) plugin:
87+
88+
```bash
89+
helm plugin install https://github.com/helm-unittest/helm-unittest
90+
```
91+
7892
## Documentation
7993

8094
For more information about STAC Auth Proxy features and configuration:

helm/tests/deployment_test.yaml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
suite: test deployment
2+
templates:
3+
- deployment.yaml
4+
tests:
5+
- it: should create deployment with correct name
6+
set:
7+
env.UPSTREAM_URL: "https://example.com"
8+
env.OIDC_DISCOVERY_URL: "https://example.com/.well-known/openid-configuration"
9+
asserts:
10+
- isKind:
11+
of: Deployment
12+
- matchRegex:
13+
path: metadata.name
14+
pattern: ^RELEASE-NAME-stac-auth-proxy$
15+
16+
- it: should set replica count
17+
set:
18+
replicaCount: 3
19+
env.UPSTREAM_URL: "https://example.com"
20+
env.OIDC_DISCOVERY_URL: "https://example.com/.well-known/openid-configuration"
21+
asserts:
22+
- equal:
23+
path: spec.replicas
24+
value: 3
25+
26+
- it: should set required environment variables
27+
set:
28+
env.UPSTREAM_URL: "https://stac-api.example.com"
29+
env.OIDC_DISCOVERY_URL: "https://auth.example.com/.well-known/openid-configuration"
30+
asserts:
31+
- contains:
32+
path: spec.template.spec.containers[0].env
33+
content:
34+
name: UPSTREAM_URL
35+
value: "https://stac-api.example.com"
36+
- contains:
37+
path: spec.template.spec.containers[0].env
38+
content:
39+
name: OIDC_DISCOVERY_URL
40+
value: "https://auth.example.com/.well-known/openid-configuration"
41+
42+
- it: should use correct image
43+
set:
44+
image.repository: "custom/repo"
45+
image.tag: "v1.2.3"
46+
env.UPSTREAM_URL: "https://example.com"
47+
env.OIDC_DISCOVERY_URL: "https://example.com/.well-known/openid-configuration"
48+
asserts:
49+
- equal:
50+
path: spec.template.spec.containers[0].image
51+
value: "custom/repo:v1.2.3"

helm/tests/service_test.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
suite: test service
2+
templates:
3+
- service.yaml
4+
tests:
5+
- it: should create service with correct name
6+
set:
7+
env.UPSTREAM_URL: "https://example.com"
8+
env.OIDC_DISCOVERY_URL: "https://example.com/.well-known/openid-configuration"
9+
asserts:
10+
- isKind:
11+
of: Service
12+
- matchRegex:
13+
path: metadata.name
14+
pattern: ^RELEASE-NAME-stac-auth-proxy$
15+
16+
- it: should use ClusterIP by default
17+
set:
18+
env.UPSTREAM_URL: "https://example.com"
19+
env.OIDC_DISCOVERY_URL: "https://example.com/.well-known/openid-configuration"
20+
asserts:
21+
- equal:
22+
path: spec.type
23+
value: ClusterIP
24+
25+
- it: should expose correct port
26+
set:
27+
service.port: 8000
28+
env.UPSTREAM_URL: "https://example.com"
29+
env.OIDC_DISCOVERY_URL: "https://example.com/.well-known/openid-configuration"
30+
asserts:
31+
- equal:
32+
path: spec.ports[0].port
33+
value: 8000
34+
- equal:
35+
path: spec.ports[0].targetPort
36+
value: http

0 commit comments

Comments
 (0)