feat: e2e test support http body check (#733)

This commit is contained in:
Uncle-Justice
2024-01-12 14:08:46 +08:00
committed by GitHub
parent d35d23e2d5
commit b825f9176f
7 changed files with 693 additions and 28 deletions

View File

@@ -35,7 +35,7 @@ var WasmPluginsTransformer = suite.ConformanceTest{
testcases := []http.Assertion{
{
Meta: http.AssertionMeta{
TestCaseName: "case 1: request transformer",
TestCaseName: "case 1: request header&query transformer",
TargetBackend: "infra-backend-v1",
TargetNamespace: "higress-conformance-infra",
},
@@ -77,7 +77,7 @@ var WasmPluginsTransformer = suite.ConformanceTest{
},
{
Meta: http.AssertionMeta{
TestCaseName: "case 2: response transformer",
TestCaseName: "case 2: response header&query transformer",
TargetBackend: "infra-backend-v1",
TargetNamespace: "higress-conformance-infra",
},
@@ -111,6 +111,85 @@ var WasmPluginsTransformer = suite.ConformanceTest{
},
},
},
{
Meta: http.AssertionMeta{
TestCaseName: "case 4: request body transformer",
TargetBackend: "infra-backend-v1",
TargetNamespace: "higress-conformance-infra",
},
Request: http.AssertionRequest{
ActualRequest: http.Request{
Host: "foo4.com",
Path: "/post",
// TODO(Uncle-Justice) dedupe, replace的body插件逻辑有问题暂跳过测试
Method: "POST",
Body: []byte(`
{
"X-removed":["v1", "v2"],
"X-not-renamed":["v1"]
}
`),
ContentType: http.ContentTypeApplicationJson,
},
ExpectedRequest: &http.ExpectedRequest{
Request: http.Request{
Host: "foo4.com",
Path: "/post",
// TODO(Uncle-Justice) dedupe, replace的body插件逻辑有问题暂跳过测试
Method: "POST",
ContentType: http.ContentTypeApplicationJson,
Body: []byte(`
{
"X-renamed":["v1"],
"X-add-append":["add","append"],
"X-map":["add","append"]
}
`),
},
},
},
Response: http.AssertionResponse{
ExpectedResponse: http.Response{
StatusCode: 200,
},
},
},
{
Meta: http.AssertionMeta{
TestCaseName: "case 5: response json body transformer",
TargetBackend: "infra-backend-echo-body-v1",
TargetNamespace: "higress-conformance-infra",
CompareTarget: http.CompareTargetResponse,
},
Request: http.AssertionRequest{
ActualRequest: http.Request{
Host: "foo5.com",
Path: "/post",
// TODO(Uncle-Justice) dedupe, replace的body插件逻辑有问题暂跳过测试
Method: "POST",
Body: []byte(`
{
"X-removed":["v1", "v2"],
"X-not-renamed":["v1"]
}
`),
ContentType: http.ContentTypeApplicationJson,
},
},
Response: http.AssertionResponse{
ExpectedResponse: http.Response{
StatusCode: 200,
ContentType: http.ContentTypeApplicationJson,
Body: []byte(`
{
"X-renamed":["v1"],
"X-add-append":["add","append"],
"X-map":["add","append"]
}
`),
},
},
},
}
t.Run("WasmPlugin transformer", func(t *testing.T) {
for _, testcase := range testcases {