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/24 07:10:28 UTC

[GitHub] [apisix-dashboard] nic-chen commented on a change in pull request #1110: fix: not allowed to specify `create_time` and `update_time` when create/edit route, service, upstream and consumer

nic-chen commented on a change in pull request #1110:
URL: https://github.com/apache/apisix-dashboard/pull/1110#discussion_r548423974



##########
File path: api/test/e2e/route_with_management_fileds_test.go
##########
@@ -363,3 +363,75 @@ func TestRoute_search_by_label(t *testing.T) {
 		testCaseCheck(tc)
 	}
 }
+
+func TestRoute_With_Create_Time(t *testing.T) {
+	tests := []HttpTestCase{
+		{
+			caseDesc: "create route with create_time",
+			Object:   ManagerApiExpect(t),
+			Path:     "/apisix/admin/routes/r1",
+			Method:   http.MethodPut,
+			Body: `{
+				"uri": "/hello",
+				"create_time": 1,
+				"upstream": {
+					"nodes": {
+						"172.16.238.20:1980": 1
+					},
+					"type": "roundrobin"
+				}
+			}`,
+			Headers:      map[string]string{"Authorization": token},
+			ExpectStatus: http.StatusBadRequest,
+		},
+		{
+			caseDesc: "create route with update_time",
+			Object:   ManagerApiExpect(t),
+			Path:     "/apisix/admin/routes/r1",
+			Method:   http.MethodPut,
+			Body: `{
+				"uri": "/hello",
+				"update_time": 1,

Review comment:
       updated.

##########
File path: api/filter/schema.go
##########
@@ -106,6 +106,18 @@ func parseCert(crt, key string) ([]string, error) {
 }
 
 func handleSpecialField(resource string, reqBody []byte) ([]byte, error) {
+	var bodyMap map[string]interface{}
+	err := json.Unmarshal(reqBody, &bodyMap)
+	if err != nil {
+		return reqBody, fmt.Errorf("read request body failed: %s", err)
+	}
+	if _, ok := bodyMap["create_time"]; ok {
+		return reqBody, fmt.Errorf("not support specifying create_time")

Review comment:
       updated.




----------------------------------------------------------------
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