|
| 1 | +suite: frontendIngress |
| 2 | +templates: |
| 3 | +- frontend/sourcegraph-frontend.Ingress.yaml |
| 4 | +tests: |
| 5 | +# Backward-compatible: host + tlsSecret |
| 6 | +- it: should render tls block with secretName when both host and tlsSecret are set |
| 7 | + set: |
| 8 | + frontend.ingress.enabled: true |
| 9 | + frontend.ingress.host: sourcegraph.example.com |
| 10 | + frontend.ingress.tlsSecret: sourcegraph-tls |
| 11 | + asserts: |
| 12 | + - equal: |
| 13 | + path: spec.tls[0].hosts[0] |
| 14 | + value: sourcegraph.example.com |
| 15 | + - equal: |
| 16 | + path: spec.tls[0].secretName |
| 17 | + value: sourcegraph-tls |
| 18 | + - equal: |
| 19 | + path: spec.rules[0].host |
| 20 | + value: sourcegraph.example.com |
| 21 | + |
| 22 | +# Backward-compatible: host only → no tls block (use tls list for TLS without a secret) |
| 23 | +- it: should not render tls block when host is set but tlsSecret is not |
| 24 | + set: |
| 25 | + frontend.ingress.enabled: true |
| 26 | + frontend.ingress.host: sourcegraph.example.com |
| 27 | + asserts: |
| 28 | + - notExists: |
| 29 | + path: spec.tls |
| 30 | + |
| 31 | +# Backward-compatible: no tls when host is not set |
| 32 | +- it: should not render tls block when host is not set |
| 33 | + set: |
| 34 | + frontend.ingress.enabled: true |
| 35 | + asserts: |
| 36 | + - notExists: |
| 37 | + path: spec.tls |
| 38 | + |
| 39 | +# New: hosts list creates one rule per host |
| 40 | +- it: should render rules per host when hosts list is set |
| 41 | + values: |
| 42 | + - frontendIngress_hosts.yaml |
| 43 | + asserts: |
| 44 | + - equal: |
| 45 | + path: spec.rules[0].host |
| 46 | + value: sourcegraph.example.com |
| 47 | + - equal: |
| 48 | + path: spec.rules[1].host |
| 49 | + value: other.example.com |
| 50 | + |
| 51 | +# New: tls list with secretName |
| 52 | +- it: should render tls from tls list |
| 53 | + values: |
| 54 | + - frontendIngress_tls.yaml |
| 55 | + asserts: |
| 56 | + - equal: |
| 57 | + path: spec.tls[0].hosts[0] |
| 58 | + value: sourcegraph.example.com |
| 59 | + - equal: |
| 60 | + path: spec.tls[0].secretName |
| 61 | + value: sourcegraph-tls |
| 62 | + |
| 63 | +# New: tls list without secretName (e.g. Tailscale) |
| 64 | +- it: should render tls block without secretName when tls list omits secretName |
| 65 | + values: |
| 66 | + - frontendIngress_tlsNoSecret.yaml |
| 67 | + asserts: |
| 68 | + - equal: |
| 69 | + path: spec.tls[0].hosts[0] |
| 70 | + value: sourcegraph.example.com |
| 71 | + - notExists: |
| 72 | + path: spec.tls[0].secretName |
| 73 | + |
| 74 | +# Error: hosts and host both set |
| 75 | +- it: should fail when both hosts and host are set |
| 76 | + values: |
| 77 | + - frontendIngress_hosts.yaml |
| 78 | + set: |
| 79 | + frontend.ingress.host: sourcegraph.example.com |
| 80 | + asserts: |
| 81 | + - failedTemplate: |
| 82 | + errorMessage: frontend.ingress.hosts and frontend.ingress.host cannot both be set |
| 83 | + |
| 84 | +# Error: tls and tlsSecret both set |
| 85 | +- it: should fail when both tls and tlsSecret are set |
| 86 | + values: |
| 87 | + - frontendIngress_tls.yaml |
| 88 | + set: |
| 89 | + frontend.ingress.tlsSecret: sourcegraph-tls |
| 90 | + asserts: |
| 91 | + - failedTemplate: |
| 92 | + errorMessage: frontend.ingress.tls and frontend.ingress.tlsSecret cannot both be set |
0 commit comments