|
| 1 | +suite: opensearch removes the Secrets cert-manager wrote once the release is deleted |
| 2 | + |
| 3 | +release: |
| 4 | + name: opensearch-test |
| 5 | + namespace: tenant-test |
| 6 | + |
| 7 | +set: |
| 8 | + _cluster: |
| 9 | + cluster-domain: cozy.local |
| 10 | + |
| 11 | +tests: |
| 12 | + - it: grants delete on exactly the Secrets its Certificates write |
| 13 | + templates: |
| 14 | + - templates/hooks/cleanup-secrets.yaml |
| 15 | + documentSelector: |
| 16 | + path: kind |
| 17 | + value: Role |
| 18 | + asserts: |
| 19 | + - equal: |
| 20 | + path: rules[0].resourceNames |
| 21 | + value: |
| 22 | + - opensearch-test.http-ca |
| 23 | + - opensearch-test-http-server |
| 24 | + - opensearch-test-dashboards-server |
| 25 | + |
| 26 | + - it: deletes them from a post-delete Job that fails when a delete fails |
| 27 | + templates: |
| 28 | + - templates/hooks/cleanup-secrets.yaml |
| 29 | + documentSelector: |
| 30 | + path: kind |
| 31 | + value: Job |
| 32 | + asserts: |
| 33 | + - equal: |
| 34 | + path: metadata.annotations["helm.sh/hook"] |
| 35 | + value: post-delete |
| 36 | + - equal: |
| 37 | + path: metadata.annotations["helm.sh/hook-delete-policy"] |
| 38 | + value: before-hook-creation,hook-succeeded |
| 39 | + - equal: |
| 40 | + path: spec.template.spec.serviceAccountName |
| 41 | + value: opensearch-test-secrets-cleanup |
| 42 | + - matchRegex: |
| 43 | + path: spec.template.spec.containers[0].command[2] |
| 44 | + pattern: 'kubectl delete secret --namespace tenant-test --ignore-not-found "opensearch-test\.http-ca" "opensearch-test-http-server" "opensearch-test-dashboards-server"; then' |
| 45 | + - matchRegex: |
| 46 | + path: spec.template.spec.containers[0].command[2] |
| 47 | + pattern: 'exit 1' |
| 48 | + - matchRegex: |
| 49 | + path: spec.template.spec.containers[0].image |
| 50 | + pattern: '^docker\.io/clastix/kubectl:v[0-9]+\.[0-9]+(\.[0-9]+)?@sha256:[0-9a-f]{64}$' |
| 51 | + |
| 52 | + - it: still renders when the release no longer issues certificates, since an earlier revision may have |
| 53 | + templates: |
| 54 | + - templates/hooks/cleanup-secrets.yaml |
| 55 | + set: |
| 56 | + tls: |
| 57 | + issuer: operator |
| 58 | + asserts: |
| 59 | + - hasDocuments: |
| 60 | + count: 4 |
| 61 | + |
| 62 | + - it: lists the Secret of Certificate 1 of 3 among those it deletes |
| 63 | + templates: |
| 64 | + - templates/certmanager.yaml |
| 65 | + set: |
| 66 | + tls: |
| 67 | + issuer: cert-manager |
| 68 | + dashboards: |
| 69 | + enabled: true |
| 70 | + documentSelector: |
| 71 | + path: spec.secretName |
| 72 | + value: opensearch-test.http-ca |
| 73 | + asserts: |
| 74 | + - isKind: |
| 75 | + of: Certificate |
| 76 | + |
| 77 | + - it: lists the Secret of Certificate 2 of 3 among those it deletes |
| 78 | + templates: |
| 79 | + - templates/certmanager.yaml |
| 80 | + set: |
| 81 | + tls: |
| 82 | + issuer: cert-manager |
| 83 | + dashboards: |
| 84 | + enabled: true |
| 85 | + documentSelector: |
| 86 | + path: spec.secretName |
| 87 | + value: opensearch-test-http-server |
| 88 | + asserts: |
| 89 | + - isKind: |
| 90 | + of: Certificate |
| 91 | + |
| 92 | + - it: lists the Secret of Certificate 3 of 3 among those it deletes |
| 93 | + templates: |
| 94 | + - templates/certmanager.yaml |
| 95 | + set: |
| 96 | + tls: |
| 97 | + issuer: cert-manager |
| 98 | + dashboards: |
| 99 | + enabled: true |
| 100 | + documentSelector: |
| 101 | + path: spec.secretName |
| 102 | + value: opensearch-test-dashboards-server |
| 103 | + asserts: |
| 104 | + - isKind: |
| 105 | + of: Certificate |
| 106 | + |
| 107 | + - it: issues no Certificate beyond the 3 the cleanup covers |
| 108 | + templates: |
| 109 | + - templates/certmanager.yaml |
| 110 | + set: |
| 111 | + tls: |
| 112 | + issuer: cert-manager |
| 113 | + dashboards: |
| 114 | + enabled: true |
| 115 | + documentSelector: |
| 116 | + path: kind |
| 117 | + value: Certificate |
| 118 | + matchMany: true |
| 119 | + asserts: |
| 120 | + - hasDocuments: |
| 121 | + count: 3 |
| 122 | + filterAware: true |
0 commit comments