nic-chen commented on a change in pull request #1112:
URL: https://github.com/apache/apisix-dashboard/pull/1112#discussion_r548417852
##########
File path: api/test/e2e/route_test.go
##########
@@ -392,3 +392,135 @@ func TestRoute_Patch(t *testing.T) {
testCaseCheck(tc)
}
}
+
+//uris methods remote_addrs
+func TestRoute_With_Empty_Array(t *testing.T) {
+ tests := []HttpTestCase{
+ {
+ caseDesc: "create route with empty hosts and host",
+ Object: ManagerApiExpect(t),
+ Path: "/apisix/admin/routes/r1",
+ Method: http.MethodPut,
+ Body: `{
+ "uri": "/hello",
+ "hosts": [],
+ "host": "test.com",
+ "upstream": {
+ "nodes": {
+ "172.16.238.20:1980": 1
+ },
+ "type": "roundrobin"
+ }
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusBadRequest,
+ ExpectBody: `{"code":10000,"message":"schema validate
failed: (root): Must validate one and only one schema (oneOf)\n(root): Must
validate all the schemas (allOf)\nhosts: Array must have at least 1 items"}`,
+ },
+ {
+ caseDesc: "make sure the route not created",
+ Object: APISIXExpect(t),
+ Method: http.MethodGet,
+ Path: "/hello",
+ Headers: map[string]string{"Host": "test.com"},
+ ExpectStatus: http.StatusNotFound,
+ ExpectBody: `{"error_msg":"404 Route Not Found"}`,
+ },
+ {
+ caseDesc: "create route with empty hosts",
+ Object: ManagerApiExpect(t),
+ Path: "/apisix/admin/routes/r1",
+ Method: http.MethodPut,
+ Body: `{
+ "uri": "/hello",
+ "hosts": [],
+ "upstream": {
+ "nodes": {
+ "172.16.238.20:1980": 1
+ },
+ "type": "roundrobin"
+ }
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusBadRequest,
+ ExpectBody: `{"code":10000,"message":"schema validate
failed: hosts: Array must have at least 1 items"}`,
+ },
+ {
+ caseDesc: "make sure the route not created",
+ Object: APISIXExpect(t),
+ Method: http.MethodGet,
+ Path: "/hello",
+ ExpectStatus: http.StatusNotFound,
+ ExpectBody: `{"error_msg":"404 Route Not Found"}`,
+ },
+ {
+ caseDesc: "create route with empty uris and uri",
+ Object: ManagerApiExpect(t),
+ Path: "/apisix/admin/routes/r1",
+ Method: http.MethodPut,
+ Body: `{
+ "uri": "/hello",
+ "uris": [],
+ "upstream": {
+ "nodes": {
+ "172.16.238.20:1980": 1
+ },
+ "type": "roundrobin"
+ }
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusBadRequest,
+ ExpectBody: `{"code":10000,"message":"schema validate
failed: (root): Must validate one and only one schema (oneOf)\n(root): Must
validate all the schemas (allOf)\nuris: Array must have at least 1 items"}`,
+ },
+ {
+ caseDesc: "create route with empty remote_addrs and
remote_addr",
+ Object: ManagerApiExpect(t),
+ Path: "/apisix/admin/routes/r1",
+ Method: http.MethodPut,
+ Body: `{
+ "uri": "/hello",
+ "remote_addrs": [],
+ "remote_addr": "0.0.0.0",
+ "upstream": {
+ "nodes": {
+ "172.16.238.20:1980": 1
+ },
+ "type": "roundrobin"
+ }
+ }`,
+ Headers: map[string]string{"Authorization": token},
+ ExpectStatus: http.StatusBadRequest,
+ ExpectBody: `{"code":10000,"message":"schema validate
failed: (root): Must validate one and only one schema (oneOf)\n(root): Must
validate all the schemas (allOf)\nremote_addrs: Array must have at least 1
items"}`,
+ },
+ //{
Review comment:
removed. @tokers
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]