You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2020/12/23 15:52:12 UTC

[GitHub] [apisix-dashboard] nic-chen opened a new pull request #1112: feat: add test cases for rejecting request data if it contains an empty array

nic-chen opened a new pull request #1112:
URL: https://github.com/apache/apisix-dashboard/pull/1112


   Please answer these questions before submitting a pull request
   
   - Why submit this pull request?
   - [ ] Bugfix
   - [ ] New feature provided
   - [ ] Improve performance
   - [x] Test case
   
   issue has resolved by https://github.com/apache/apisix/pull/3008
   just add e2e test cases for it
   
   - Related issues
   close #984
   
   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [apisix-dashboard] nic-chen merged pull request #1112: feat: add test cases for rejecting request data if it contains an empty array

Posted by GitBox <gi...@apache.org>.
nic-chen merged pull request #1112:
URL: https://github.com/apache/apisix-dashboard/pull/1112


   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [apisix-dashboard] nic-chen commented on a change in pull request #1112: feat: add test cases for rejecting request data if it contains an empty array

Posted by GitBox <gi...@apache.org>.
nic-chen commented on a change in pull request #1112:
URL: https://github.com/apache/apisix-dashboard/pull/1112#discussion_r548369168



##########
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",

Review comment:
       they are two different fields.




----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [apisix-dashboard] nic-chen commented on a change in pull request #1112: feat: add test cases for rejecting request data if it contains an empty array

Posted by GitBox <gi...@apache.org>.
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:
users@infra.apache.org



[GitHub] [apisix-dashboard] tokers commented on a change in pull request #1112: feat: add test cases for rejecting request data if it contains an empty array

Posted by GitBox <gi...@apache.org>.
tokers commented on a change in pull request #1112:
URL: https://github.com/apache/apisix-dashboard/pull/1112#discussion_r548339515



##########
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:
       Remove these commented lines if we don't need them.

##########
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",

Review comment:
       typo: with empty hosts and hosts?




----------------------------------------------------------------
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:
users@infra.apache.org