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 2022/10/09 03:01:14 UTC

[GitHub] [apisix-java-plugin-runner] tzssangglass commented on a diff in pull request #200: feat: support for getting upstream response body

tzssangglass commented on code in PR #200:
URL: https://github.com/apache/apisix-java-plugin-runner/pull/200#discussion_r990723967


##########
tests/e2e/plugins/plugins_post_with_vars_test.go:
##########
@@ -0,0 +1,75 @@
+/*
+ * 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 plugins_test
+
+import (
+	"github.com/gavv/httpexpect/v2"
+	"github.com/onsi/ginkgo"
+	"github.com/onsi/ginkgo/extensions/table"
+	"net/http"
+
+	"github.com/apache/apisix-java-plugin-runner/tests/e2e/tools"
+)
+
+var _ = ginkgo.Describe("Post", func() {
+	table.DescribeTable("test route create and update",
+		func(tc tools.HttpTestCase) {
+			tools.RunTestCase(tc)
+		},
+		table.Entry("create java runner post plugin route success", tools.HttpTestCase{
+			Object: tools.PutA6Conf(),
+			Method: http.MethodPut,
+			Path:   "/apisix/admin/routes/1",
+			Body: `{
+				"uri":"/test/java/runner/postvars",
+				"plugins":{
+					"ext-plugin-pre-req":{
+						"conf":[
+							{
+								"name":"PostReqWithVarsFilter",
+								"value":"{\"rewrite_path\":\"/get\"}"
+							}
+						]
+					},
+					"ext-plugin-post-resp":{
+						"conf":[
+							{
+								"name":"PostReqWithVarsFilter",
+								"value":"{\"rewrite_path\":\"/get\"}"
+							}
+						]
+					}
+				},
+				"upstream":{
+					"nodes":{
+						"web:8888":1
+					},
+					"type":"roundrobin"
+				}
+			}`,
+			Headers:           map[string]string{"X-API-KEY": tools.GetAdminToken()},
+			ExpectStatusRange: httpexpect.Status2xx,
+		}),
+		table.Entry("test java runner post plugin route success", tools.HttpTestCase{
+			Object:       tools.GetA6Expect(),
+			Method:       http.MethodGet,
+			Path:         "/test/java/runner/postvars",
+			ExpectStatus: http.StatusOK,
+		}),
+	)
+})

Review Comment:
   1. `PostReqWithVarsFilter` change the request path from `/test/java/runner/postvars` to `/get` in `filter` by `ext-plugin-pre-req`;
   
   2. `PostReqWithVarsFilter` **get the upstream response body(from the httpbin)** and check the `url` in the body, the `url` should be `/get`
   
   3. the response body also one of `vars` 



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

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org