@@ -10,102 +10,6 @@ import (
1010 "github.com/kong/kubernetes-ingress-controller/v3/internal/dataplane/deckgen"
1111)
1212
13- func TestGetFCertificateFromKongCert (t * testing.T ) {
14- testCases := []struct {
15- name string
16- inmemory bool
17- cert kong.Certificate
18- want file.FCertificate
19- }{
20- {
21- name : "empty certificate" ,
22- inmemory : false ,
23- cert : kong.Certificate {},
24- want : file.FCertificate {
25- SNIs : []kong.SNI {},
26- },
27- },
28- {
29- name : "all fields set, inmemory=true, SNIs have no certificate ref" ,
30- inmemory : true ,
31- cert : kong.Certificate {
32- ID : kong .String ("cert-id" ),
33- Key : kong .String ("cert-key" ),
34- Cert : kong .String ("cert-pem" ),
35- SNIs : []* string {kong .String ("example.com" ), kong .String ("other.com" )},
36- },
37- want : file.FCertificate {
38- ID : kong .String ("cert-id" ),
39- Key : kong .String ("cert-key" ),
40- Cert : kong .String ("cert-pem" ),
41- SNIs : []kong.SNI {
42- {Name : kong .String ("example.com" )},
43- {Name : kong .String ("other.com" )},
44- },
45- },
46- },
47- {
48- name : "all fields set, inmemory=false, SNIs have certificate ref" ,
49- inmemory : false ,
50- cert : kong.Certificate {
51- ID : kong .String ("cert-id" ),
52- Key : kong .String ("cert-key" ),
53- Cert : kong .String ("cert-pem" ),
54- SNIs : []* string {kong .String ("example.com" )},
55- },
56- want : file.FCertificate {
57- ID : kong .String ("cert-id" ),
58- Key : kong .String ("cert-key" ),
59- Cert : kong .String ("cert-pem" ),
60- SNIs : []kong.SNI {
61- {
62- Name : kong .String ("example.com" ),
63- Certificate : & kong.Certificate {ID : kong .String ("cert-id" )},
64- },
65- },
66- },
67- },
68- {
69- name : "nil ID, inmemory=false, SNIs have no certificate ref" ,
70- inmemory : false ,
71- cert : kong.Certificate {
72- Key : kong .String ("cert-key" ),
73- Cert : kong .String ("cert-pem" ),
74- SNIs : []* string {kong .String ("example.com" )},
75- },
76- want : file.FCertificate {
77- Key : kong .String ("cert-key" ),
78- Cert : kong .String ("cert-pem" ),
79- SNIs : []kong.SNI {
80- {Name : kong .String ("example.com" )},
81- },
82- },
83- },
84- {
85- name : "no SNIs" ,
86- inmemory : false ,
87- cert : kong.Certificate {
88- ID : kong .String ("cert-id" ),
89- Key : kong .String ("cert-key" ),
90- Cert : kong .String ("cert-pem" ),
91- },
92- want : file.FCertificate {
93- ID : kong .String ("cert-id" ),
94- Key : kong .String ("cert-key" ),
95- Cert : kong .String ("cert-pem" ),
96- SNIs : []kong.SNI {},
97- },
98- },
99- }
100-
101- for _ , tc := range testCases {
102- t .Run (tc .name , func (t * testing.T ) {
103- got := deckgen .GetFCertificateFromKongCert (tc .inmemory , tc .cert )
104- require .Equal (t , tc .want , got )
105- })
106- }
107- }
108-
10913func TestIsContentEmpty (t * testing.T ) {
11014 testCases := []struct {
11115 name string
0 commit comments