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

@@ -86,6 +86,76 @@ var WasmPluginsRequestBlock = suite.ConformanceTest{
},
},
},
{
// post blocked body
Meta: http.AssertionMeta{
TargetBackend: "infra-backend-v1",
TargetNamespace: "higress-conformance-infra",
},
Request: http.AssertionRequest{
ActualRequest: http.Request{
Host: "foo.com",
Path: "/foo",
Method: "POST",
ContentType: http.ContentTypeTextPlain,
Body: []byte(`hello world`),
UnfollowRedirect: true,
},
},
Response: http.AssertionResponse{
ExpectedResponse: http.Response{
StatusCode: 403,
},
},
},
{
// check body echoed back in expected request(same as ActualRequest if not set)
Meta: http.AssertionMeta{
TargetBackend: "infra-backend-v1",
TargetNamespace: "higress-conformance-infra",
CompareTarget: http.CompareTargetRequest,
},
Request: http.AssertionRequest{
ActualRequest: http.Request{
Host: "foo.com",
Path: "/foo",
Method: "POST",
ContentType: http.ContentTypeTextPlain,
Body: []byte(`hello higress`),
UnfollowRedirect: true,
},
},
Response: http.AssertionResponse{
ExpectedResponse: http.Response{
StatusCode: 200,
},
},
},
{
// check body echoed back in expected response
Meta: http.AssertionMeta{
TargetBackend: "infra-backend-echo-body-v1",
TargetNamespace: "higress-conformance-infra",
CompareTarget: http.CompareTargetResponse,
},
Request: http.AssertionRequest{
ActualRequest: http.Request{
Host: "foo2.com",
Path: "/foo",
Method: "POST",
ContentType: http.ContentTypeTextPlain,
Body: []byte(`hello higress`),
UnfollowRedirect: true,
},
},
Response: http.AssertionResponse{
ExpectedResponse: http.Response{
StatusCode: 200,
ContentType: http.ContentTypeTextPlain,
Body: []byte(`hello higress`),
},
},
},
}
t.Run("WasmPlugins request-block", func(t *testing.T) {
for _, testcase := range testcases {