This is an automated email from the ASF dual-hosted git repository.

chenjunxu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-dashboard.git


The following commit(s) were added to refs/heads/master by this push:
     new 478cbeb  test: add route with uri or uris ( E2E ) (#888)
478cbeb is described below

commit 478cbebd82cd7912f8cdac5f85a6086ceea191c2
Author: idbeta <[email protected]>
AuthorDate: Sun Nov 29 08:04:21 2020 +0800

    test: add route with uri or uris ( E2E ) (#888)
    
    * WIP: add route with invalid uri or uris
    
    * test: 1.add route with invalid uri or uris, 2.add route with valid uri or 
uris,
    
    * fix: update English
    
    * test: remove useless case
    
    * chore: update the caseDesc
---
 api/test/e2e/route_with_uri_uris_test.go | 116 +++++++++++++++++++++++++++++++
 1 file changed, 116 insertions(+)

diff --git a/api/test/e2e/route_with_uri_uris_test.go 
b/api/test/e2e/route_with_uri_uris_test.go
new file mode 100644
index 0000000..b9ab043
--- /dev/null
+++ b/api/test/e2e/route_with_uri_uris_test.go
@@ -0,0 +1,116 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package e2e
+
+import (
+       "net/http"
+       "testing"
+)
+
+func TestRoute_with_valid_uri_uris(t *testing.T) {
+       tests := []HttpTestCase{
+               {
+                       caseDesc: "add route with valid uri",
+                       Object:   MangerApiExpect(t),
+                       Method:   http.MethodPut,
+                       Path:     "/apisix/admin/routes/r1",
+                       Body: `{
+                                       "uri": "/hello",
+                                       "upstream": {
+                                               "type": "roundrobin",
+                                               "nodes": [{
+                                                       "host": "172.16.238.20",
+                                                       "port": 1980,
+                                                       "weight": 1
+                                               }]
+                                       }
+                               }`,
+                       Headers:      map[string]string{"Authorization": token},
+                       ExpectStatus: http.StatusOK,
+               },
+               {
+                       caseDesc:     "hit the route (r1)",
+                       Object:       APISIXExpect(t),
+                       Method:       http.MethodGet,
+                       Path:         "/hello",
+                       Headers:      map[string]string{"Authorization": token},
+                       ExpectStatus: http.StatusOK,
+                       ExpectBody:   "hello world",
+                       Sleep:        sleepTime,
+               },
+               {
+                       caseDesc:     "delete the route (r1)",
+                       Object:       MangerApiExpect(t),
+                       Method:       http.MethodDelete,
+                       Path:         "/apisix/admin/routes/r1",
+                       Headers:      map[string]string{"Authorization": token},
+                       ExpectStatus: http.StatusOK,
+                       Sleep:        sleepTime,
+               },
+               {
+                       caseDesc: "add route with valid uris",
+                       Object:   MangerApiExpect(t),
+                       Method:   http.MethodPut,
+                       Path:     "/apisix/admin/routes/r1",
+                       Body: `{
+                                       "uris": ["/hello","/status"],
+                                       "upstream": {
+                                               "type": "roundrobin",
+                                               "nodes": [{
+                                                       "host": "172.16.238.20",
+                                                       "port": 1980,
+                                                       "weight": 1
+                                               }]
+                                       }
+                               }`,
+                       Headers:      map[string]string{"Authorization": token},
+                       ExpectStatus: http.StatusOK,
+               },
+               {
+                       caseDesc:     "hit the route (/hello)",
+                       Object:       APISIXExpect(t),
+                       Method:       http.MethodGet,
+                       Path:         "/hello",
+                       Headers:      map[string]string{"Authorization": token},
+                       ExpectStatus: http.StatusOK,
+                       ExpectBody:   "hello world",
+                       Sleep:        sleepTime,
+               },
+               {
+                       caseDesc:     "hit the route (/status)",
+                       Object:       APISIXExpect(t),
+                       Method:       http.MethodGet,
+                       Path:         "/status",
+                       Headers:      map[string]string{"Authorization": token},
+                       ExpectStatus: http.StatusOK,
+                       ExpectBody:   "ok",
+                       Sleep:        sleepTime,
+               },
+               {
+                       caseDesc:     "delete the route (r1)",
+                       Object:       MangerApiExpect(t),
+                       Method:       http.MethodDelete,
+                       Path:         "/apisix/admin/routes/r1",
+                       Headers:      map[string]string{"Authorization": token},
+                       ExpectStatus: http.StatusOK,
+               },
+       }
+
+       for _, tc := range tests {
+               testCaseCheck(tc)
+       }
+}

Reply via email to