From 7adac14ee4928d76092ed721270c318b53a89917 Mon Sep 17 00:00:00 2001 From: Stavros kois Date: Fri, 8 Dec 2023 02:31:02 +0200 Subject: [PATCH] fix and test clusterCertificate --- .../common-test/tests/ingress/tls_test.yaml | 56 +++++++++++++++++-- library/common/templates/class/_ingress.tpl | 4 +- 2 files changed, 53 insertions(+), 7 deletions(-) diff --git a/library/common-test/tests/ingress/tls_test.yaml b/library/common-test/tests/ingress/tls_test.yaml index 089ef69f..afeba8e4 100644 --- a/library/common-test/tests/ingress/tls_test.yaml +++ b/library/common-test/tests/ingress/tls_test.yaml @@ -148,7 +148,7 @@ tests: - some-other-test-host secretName: test-release-name-common-test-scale-tls-1 - - it: should pass with ingress created with tls with certificateIssuer + - it: should pass with ingress created with clusterCertificate set: operator: *operator service: *service @@ -167,10 +167,10 @@ tests: - hosts: - test-host - other-test-host - certificateIssuer: some-issuer + clusterCertificate: some-cert - hosts: - some-other-test-host - certificateIssuer: some-other-issuer + clusterCertificate: some-other-cert integrations: &integrations traefik: enabled: false @@ -189,7 +189,53 @@ tests: - hosts: - test-host - other-test-host - secretName: test-release-name-common-test-tls-0 + secretName: certificate-issuer-some-cert - hosts: - some-other-test-host - secretName: test-release-name-common-test-tls-1 + secretName: certificate-issuer-some-other-cert + + # - it: should pass with ingress created with tls with certificateIssuer + # set: + # operator: *operator + # service: *service + # ingress: + # my-ingress: + # enabled: true + # primary: true + # hosts: + # - host: test-host + # paths: + # - path: /test-path + # - host: other-test-host + # paths: + # - path: /other-test-path + # tls: + # - hosts: + # - test-host + # - other-test-host + # certificateIssuer: some-issuer + # - hosts: + # - some-other-test-host + # certificateIssuer: some-other-issuer + # integrations: &integrations + # traefik: + # enabled: false + # asserts: + # - documentIndex: &ingressDoc 1 + # isKind: + # of: Ingress + # - documentIndex: *ingressDoc + # equal: + # path: metadata.name + # value: test-release-name-common-test + # - documentIndex: *ingressDoc + # equal: + # path: spec.tls + # value: + # - hosts: + # - test-host + # - other-test-host + # secretName: test-release-name-common-test-tls-0 + # - hosts: + # - some-other-test-host + # secretName: test-release-name-common-test-tls-1 diff --git a/library/common/templates/class/_ingress.tpl b/library/common/templates/class/_ingress.tpl index 6e925721..08bcbea4 100644 --- a/library/common/templates/class/_ingress.tpl +++ b/library/common/templates/class/_ingress.tpl @@ -78,10 +78,10 @@ spec: {{- $secretName = tpl $t.secretName $rootCtx -}} {{- else if $t.scaleCert -}} {{- $secretName = printf "%s-scale-tls-%d" $objectData.name ($idx | int) -}} - {{- else if $t.certificateIssuer -}} + {{- else if $t.certificateIssuer -}} {{/* TODO: UT */}} {{- $secretName = printf "%s-tls-%d" $objectData.name ($idx | int) -}} {{- else if $t.clusterCertificate -}} - {{/* TODO: Needs the refactor of Certificate object */}} + {{- $secretName = printf "certificate-issuer-%s" (tpl $t.clusterCertificate $rootCtx) -}} {{- end }} - secretName: {{ $secretName }} hosts: