3737 protocol: HTTP
3838 port: 80
3939`
40+ var defautlGatewayHTTPS = `
41+ apiVersion: gateway.networking.k8s.io/v1
42+ kind: Gateway
43+ metadata:
44+ name: api7ee
45+ spec:
46+ gatewayClassName: %s
47+ listeners:
48+ - name: http1
49+ protocol: HTTPS
50+ port: 443
51+ hostname: api6.com
52+ tls:
53+ certificateRefs:
54+ - kind: Secret
55+ group: ""
56+ name: test-apisix-tls
57+ `
4058
4159 var ResourceApplied = func (resourType , resourceName , resourceRaw string , observedGeneration int ) {
4260 Expect (s .CreateResourceFromString (resourceRaw )).
5674 )
5775 time .Sleep (1 * time .Second )
5876 }
59- var beforeEach = func () {
77+ var beforeEachHTTP = func () {
6078 By ("create GatewayClass" )
6179 gatewayClassName := fmt .Sprintf ("api7-%d" , time .Now ().Unix ())
6280 err := s .CreateResourceFromStringWithNamespace (fmt .Sprintf (defautlGatewayClass , gatewayClassName , s .GetControllerName ()), "" )
8199 Expect (gwyaml ).To (ContainSubstring ("message: the gateway has been accepted by the api7-ingress-controller" ), "checking Gateway condition message" )
82100 }
83101
102+ var beforeEachHTTPS = func () {
103+ secretName := "test-apisix-tls"
104+ createSecret (s , secretName )
105+ By ("create GatewayClass" )
106+ gatewayClassName := fmt .Sprintf ("api7-%d" , time .Now ().Unix ())
107+ err := s .CreateResourceFromStringWithNamespace (fmt .Sprintf (defautlGatewayClass , gatewayClassName , s .GetControllerName ()), "" )
108+ Expect (err ).NotTo (HaveOccurred (), "creating GatewayClass" )
109+ time .Sleep (5 * time .Second )
110+
111+ By ("check GatewayClass condition" )
112+ gcyaml , err := s .GetResourceYaml ("GatewayClass" , gatewayClassName )
113+ Expect (err ).NotTo (HaveOccurred (), "getting GatewayClass yaml" )
114+ Expect (gcyaml ).To (ContainSubstring (`status: "True"` ), "checking GatewayClass condition status" )
115+ Expect (gcyaml ).To (ContainSubstring ("message: the gatewayclass has been accepted by the api7-ingress-controller" ), "checking GatewayClass condition message" )
116+
117+ By ("create Gateway" )
118+ err = s .CreateResourceFromString (fmt .Sprintf (defautlGatewayHTTPS , gatewayClassName ))
119+ Expect (err ).NotTo (HaveOccurred (), "creating Gateway" )
120+ time .Sleep (5 * time .Second )
121+
122+ By ("check Gateway condition" )
123+ gwyaml , err := s .GetResourceYaml ("Gateway" , "api7ee" )
124+ Expect (err ).NotTo (HaveOccurred (), "getting Gateway yaml" )
125+ Expect (gwyaml ).To (ContainSubstring (`status: "True"` ), "checking Gateway condition status" )
126+ Expect (gwyaml ).To (ContainSubstring ("message: the gateway has been accepted by the api7-ingress-controller" ), "checking Gateway condition message" )
127+ }
128+ FContext ("HTTPRoute with HTTPS Gateway" , func () {
129+ var exactRouteByGet = `
130+ apiVersion: gateway.networking.k8s.io/v1
131+ kind: HTTPRoute
132+ metadata:
133+ name: httpbin
134+ spec:
135+ parentRefs:
136+ - name: api7ee
137+ hostnames:
138+ - api6.com
139+ rules:
140+ - matches:
141+ - path:
142+ type: Exact
143+ value: /get
144+ backendRefs:
145+ - name: httpbin-service-e2e-test
146+ port: 80
147+ `
148+
149+ BeforeEach (beforeEachHTTPS )
150+
151+ It ("Create/Updtea/Delete HTTPRoute" , func () {
152+ By ("create HTTPRoute" )
153+ ResourceApplied ("HTTPRoute" , "httpbin" , exactRouteByGet , 1 )
154+
155+ By ("access dataplane to check the HTTPRoute" )
156+ s .NewAPISIXClientWithHTTPS ().
157+ GET ("/get" ).
158+ WithHost ("api6.com" ).
159+ Expect ().
160+ Status (200 )
161+ time .Sleep (1000 * time .Second )
162+ // By("delete HTTPRoute")
163+ // err := s.DeleteResourceFromString(exactRouteByGet)
164+ // Expect(err).NotTo(HaveOccurred(), "deleting HTTPRoute")
165+ // time.Sleep(5 * time.Second)
166+
167+ // s.NewAPISIXClientWithHTTPS().
168+ // GET("/get").
169+ // WithHost("api6.com").
170+ // Expect().
171+ // Status(404)
172+ })
173+ })
174+
84175 Context ("HTTPRoute Base" , func () {
85176
86177 var exactRouteByGet = `
@@ -103,7 +194,7 @@ spec:
103194 port: 80
104195`
105196
106- BeforeEach (beforeEach )
197+ BeforeEach (beforeEachHTTP )
107198
108199 It ("Create/Updtea/Delete HTTPRoute" , func () {
109200 By ("create HTTPRoute" )
@@ -198,7 +289,7 @@ spec:
198289 - name: httpbin-service-e2e-test
199290 port: 80
200291`
201- BeforeEach (beforeEach )
292+ BeforeEach (beforeEachHTTP )
202293
203294 It ("HTTPRoute Exact Match" , func () {
204295 By ("create HTTPRoute" )
@@ -368,7 +459,7 @@ spec:
368459 statusCode: 301
369460`
370461
371- BeforeEach (beforeEach )
462+ BeforeEach (beforeEachHTTP )
372463
373464 It ("HTTPRoute RequestHeaderModifier" , func () {
374465 By ("create HTTPRoute" )
@@ -565,7 +656,7 @@ spec:
565656 `
566657
567658 BeforeEach (func () {
568- beforeEach ()
659+ beforeEachHTTP ()
569660 s .DeployNginx (framework.NginxOptions {
570661 Namespace : s .Namespace (),
571662 })
0 commit comments