This is an automated email from the ASF dual-hosted git repository.
juzhiyuan 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 45df5b2 fix: (route_online_debug)Change the appended Content-type
data to overlay to ensure that the Content-type is unique (#1619)
45df5b2 is described below
commit 45df5b26715abc1f02bd69799147a634a20e1b2e
Author: JinChen <[email protected]>
AuthorDate: Sat Mar 20 19:41:42 2021 +0800
fix: (route_online_debug)Change the appended Content-type data to overlay
to ensure that the Content-type is unique (#1619)
Co-authored-by: liuxiran <[email protected]>
---
.../route_online_debug/route_online_debug.go | 6 ++-
.../route_online_debug/route_online_debug_test.go | 63 +++++++++++++++++++++-
.../consumer/create_and_delete_consumer.spec.js | 10 ++--
web/cypress/integration/route/search-route.spec.js | 4 +-
4 files changed, 72 insertions(+), 11 deletions(-)
diff --git a/api/internal/handler/route_online_debug/route_online_debug.go
b/api/internal/handler/route_online_debug/route_online_debug.go
index a419757..e7bbee3 100644
--- a/api/internal/handler/route_online_debug/route_online_debug.go
+++ b/api/internal/handler/route_online_debug/route_online_debug.go
@@ -118,7 +118,11 @@ func (h *HTTPProtocolSupport) RequestForwarding(c
droplet.Context) (interface{},
req.Header.Add("Content-Type", contentType)
for k, v := range tempMap {
for _, v1 := range v {
- req.Header.Add(k, v1)
+ if !strings.EqualFold(k, "Content-Type") {
+ req.Header.Add(k, v1)
+ } else {
+ req.Header.Set(k, v1)
+ }
}
}
diff --git a/api/test/e2enew/route_online_debug/route_online_debug_test.go
b/api/test/e2enew/route_online_debug/route_online_debug_test.go
index fc52c81..cd09aef 100644
--- a/api/test/e2enew/route_online_debug/route_online_debug_test.go
+++ b/api/test/e2enew/route_online_debug/route_online_debug_test.go
@@ -156,6 +156,7 @@ var _ =
ginkgo.Describe("Route_Online_Debug_Route_With_Header_Params", func() {
ginkgo.It("create route with header params", func() {
t := ginkgo.GinkgoT()
var routeBody map[string]interface{} = map[string]interface{}{
+ "name": "route1",
"uri": "/hello",
"methods": []string{"GET"},
"vars": []interface{}{
@@ -193,7 +194,46 @@ var _ =
ginkgo.Describe("Route_Online_Debug_Route_With_Header_Params", func() {
Sleep: base.SleepTime,
})
})
- ginkgo.It("delete the route just created", func() {
+ ginkgo.It("online debug route with header params(add Content-type to
header params to create route)", func() {
+ t := ginkgo.GinkgoT()
+ var routeBody map[string]interface{} = map[string]interface{}{
+ "name": "route2",
+ "status": 1,
+ "uri": "/hello_",
+ "methods": []string{"GET"},
+ "upstream": upstream,
+ }
+ _reqRouteBody, err := json.Marshal(routeBody)
+ assert.Nil(t, err)
+ base.RunTestCase(base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodPost,
+ Path: "/apisix/admin/debug-request-forwarding",
+ Body: string(_reqRouteBody),
+ Headers: map[string]string{
+ "Authorization":
base.GetToken(),
+ "online_debug_url":
base.ManagerAPIHost + `/apisix/admin/routes/r2`,
+ "online_debug_request_protocol": "http",
+ "online_debug_method": http.MethodPut,
+ "Content-Type":
"text/plain;charset=UTF-8",
+ "online_debug_header_params":
`{"Content-type":["application/json"],"Authorization":["` + base.GetToken() +
`"]}`,
+ },
+ ExpectStatus: http.StatusOK,
+ ExpectBody: `{"code":200,"message":"200 OK"`,
+ Sleep: base.SleepTime,
+ })
+ })
+ ginkgo.It("hit the route (r2)", func() {
+ base.RunTestCase(base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/hello_",
+ ExpectStatus: http.StatusOK,
+ ExpectBody: "hello world\n",
+ Sleep: base.SleepTime,
+ })
+ })
+ ginkgo.It("delete the route just created (r1)", func() {
base.RunTestCase(base.HttpTestCase{
Object: base.ManagerApiExpect(),
Method: http.MethodDelete,
@@ -202,7 +242,16 @@ var _ =
ginkgo.Describe("Route_Online_Debug_Route_With_Header_Params", func() {
ExpectStatus: http.StatusOK,
})
})
- ginkgo.It("hit the route just deleted", func() {
+ ginkgo.It("delete the route just created (r2)", func() {
+ base.RunTestCase(base.HttpTestCase{
+ Object: base.ManagerApiExpect(),
+ Method: http.MethodDelete,
+ Path: "/apisix/admin/routes/r2",
+ Headers: map[string]string{"Authorization":
base.GetToken()},
+ ExpectStatus: http.StatusOK,
+ })
+ })
+ ginkgo.It("hit the route just deleted (r1)", func() {
base.RunTestCase(base.HttpTestCase{
Object: base.APISIXExpect(),
Method: http.MethodGet,
@@ -212,6 +261,16 @@ var _ =
ginkgo.Describe("Route_Online_Debug_Route_With_Header_Params", func() {
Sleep: base.SleepTime,
})
})
+ ginkgo.It("hit the route just deleted (r2)", func() {
+ base.RunTestCase(base.HttpTestCase{
+ Object: base.APISIXExpect(),
+ Method: http.MethodGet,
+ Path: "/hello_",
+ ExpectStatus: http.StatusNotFound,
+ ExpectBody: "{\"error_msg\":\"404 Route Not
Found\"}\n",
+ Sleep: base.SleepTime,
+ })
+ })
})
var _ = ginkgo.Describe("Route_Online_Debug_Route_With_Body_Params", func() {
diff --git
a/web/cypress/integration/consumer/create_and_delete_consumer.spec.js
b/web/cypress/integration/consumer/create_and_delete_consumer.spec.js
index 4cd5d51..59a2340 100644
--- a/web/cypress/integration/consumer/create_and_delete_consumer.spec.js
+++ b/web/cypress/integration/consumer/create_and_delete_consumer.spec.js
@@ -36,11 +36,11 @@ context('Create and Delete Consumer', () => {
// plugin config
cy.contains(this.domSelector.pluginCard, 'key-auth').within(() => {
- cy.get('button').click({
- force: true
+ cy.contains('Enable').click({
+ force: true,
});
});
-
+ cy.focused(this.domSelector.drawer).should('exist');
cy.get(this.domSelector.disabledSwitcher).click();
// edit codemirror
cy.get(this.domSelector.codeMirror)
@@ -68,7 +68,7 @@ context('Create and Delete Consumer', () => {
cy.get(this.domSelector.drawer).should('be.visible');
cy.get(this.domSelector.codemirrorScroll).within(() => {
- cy.contains('plugins').should("exist");
+ cy.contains('plugins').should('exist');
cy.contains(this.data.consumerName).should('exist');
});
});
@@ -94,7 +94,7 @@ context('Create and Delete Consumer', () => {
// plugin config
cy.contains(this.domSelector.pluginCard, 'key-auth').within(() => {
cy.get('button').click({
- force: true
+ force: true,
});
});
// edit codeMirror
diff --git a/web/cypress/integration/route/search-route.spec.js
b/web/cypress/integration/route/search-route.spec.js
index 69fb410..f2235b6 100644
--- a/web/cypress/integration/route/search-route.spec.js
+++ b/web/cypress/integration/route/search-route.spec.js
@@ -101,9 +101,7 @@ context('Create and Search Route', () => {
// search one label
cy.contains(data.test0).should('exist');
cy.get(this.domSelector.labelSelect_0).click({ timeout });
- cy.get(this.domSelector.dropdown).should('be.visible').within(() => {
- cy.contains(data.value0).click();
- });
+
cy.get(this.domSelector.dropdown).contains(data.value0).should('be.visible').click();
cy.contains('Search').click();
cy.contains(data.test0).siblings().should('contain', data.label0_value0);
cy.contains(data.test1).should('not.exist');