Skip to content

Commit

Permalink
fix(charts): allow helm api test to support 3rd party auth service
Browse files Browse the repository at this point in the history
[CHRON-404](https://blockchaintp.atlassian.net/browse/CHRON-404)

Signed-off-by: Joseph Livesey <[email protected]>
  • Loading branch information
suchapalaver committed Jun 16, 2023
1 parent f4a1a23 commit f38e28c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
2 changes: 1 addition & 1 deletion charts/chronicle/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ keywords:
# This is the chart version. This version number should be incremented each
# time you make changes to the chart and its templates, including the app
# version.
version: 0.1.18
version: 0.1.19

# This is the version number of Chronicle being deployed. This version
# number should be incremented each time you make changes to Chronicle.
Expand Down
2 changes: 1 addition & 1 deletion charts/chronicle/templates/test-token-getter-roles.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if .Values.test.enabled }}
{{- if .Values.test.api.enabled }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
Expand Down
18 changes: 16 additions & 2 deletions charts/chronicle/templates/tests/api-test.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if .Values.test.enabled }}
{{- if .Values.test.api.enabled }}
apiVersion: batch/v1
kind: Job
metadata:
Expand All @@ -16,8 +16,9 @@ spec:
serviceAccountName: {{ include "lib.serviceAccountName" . }}
automountServiceAccountToken: true
{{- if .Values.auth.required }}
{{ if not .Values.test.auth.token }}
{{ if not .Values.devIdProvider.enabled }}
{{ required "If 'auth.required' when using the test suite 'devIdProvider.enabled' must be set to 'true'!" .Values.devIdProvider.enabled }}
{{ required "If 'auth.required' when using the api-test 'test.auth.token' must be provided or 'devIdProvider.enabled' must be set to 'true'!" .Values.devIdProvider.enabled }}
{{ end }}
initContainers:
- name: wait-for-id-provider
Expand Down Expand Up @@ -73,20 +74,33 @@ spec:
volumeMounts:
- name: shared-data
mountPath: /shared-data
{{ end }}
{{- end }}
containers:
- name: test
{{- include "lib.image" (dict "imageRoot" .Values.test.api.image "global" .Values.global ) | nindent 10 }}
command: [ "sh", "-ec" ]
args:
- |
{{ if not .Values.test.auth.token }}
{{ if or .Values.auth.jwks.url .Values.auth.userinfo.url }}
echo "Auth endpoints provided but no token provided."
echo "Please provide 'test.auth.token' in the values.yaml file."
exit 1
{{ end }}
{{ end }}
API={{ include "chronicle.api.service" . }}
export PORT={{ .Values.port }}
echo "Waiting for API to be ready ..."
wait-for-it $API:$PORT --timeout=0
echo "Getting IP address for API ..."
getent hosts $API | cut -f 1 -d \ | head -n 1 > /shared-data/api-ip || exit 1
{{- if .Values.test.auth.token }}
echo "{{ .Values.test.auth.token }}" > /shared-data/jwks-token
{{- end }}
if [ -f "/shared-data/jwks-token" ]; then
echo "Found token."
sleep 5
Expand Down
9 changes: 6 additions & 3 deletions charts/chronicle/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,19 @@ serviceAccount:
test:
## @md | `test.api` | test the chronicle GraphQL server API |
api:
## @md | `api-test-container.image` | the image to use for the api-test container | blockchaintp/chronicle-api-test |
## @md | `test.api.enabled` | true to enable api-test Jobs and Services | true |
enabled: true
## @md | `test.api.image` | the image to use for the api-test container | blockchaintp/chronicle-helm-api-test |
image:
## @md | `test.api.image.pullPolicy` | the image pull policy | IfNotPresent |
pullPolicy: IfNotPresent
## @md | `test.api.image.repository` | the image repository | blockchaintp/chronicle-helm-api-test |
repository: blockchaintp/chronicle-helm-api-test-amd64
## @md | `test.api.image.tag` | the image tag | latest |
tag: BTP2.1.0-0.7.3
## @md | `test.enabled` | true to enable test Jobs and Services | true |
enabled: true
auth:
## @md | `test.auth.token` | provide a token for auth-related testing | nil |
token:

postgres:
# if enabled we allocate a postgres database here
Expand Down

0 comments on commit f38e28c

Please sign in to comment.