...
1from typing import Generator, Tuple, Union
2
3from abstract_tests import HTTP, AmbassadorTest, Node, ServiceType
4from kat.harness import Query
5
6
7class BufferLimitBytesTest(AmbassadorTest):
8 target: ServiceType
9
10 def init(self):
11 self.target = HTTP(name="target")
12
13 # Test generating config with an increased buffer and that the lua body() funciton runs to buffer the request body
14 def config(self) -> Generator[Union[str, Tuple[Node, str]], None, None]:
15 yield self, self.format(
16 """
17---
18apiVersion: getambassador.io/v3alpha1
19kind: Module
20name: ambassador
21config:
22 buffer_limit_bytes: 5242880
23 lua_scripts: |
24 function envoy_on_request(request_handle)
25 request_handle:headers():add("request_body_size", request_handle:body():length())
26 end
27---
28apiVersion: getambassador.io/v3alpha1
29kind: Mapping
30name: {self.target.path.k8s}-foo
31hostname: "*"
32prefix: /foo/
33service: {self.target.path.fqdn}
34"""
35 )
36
37 def queries(self):
38 yield Query(self.url("foo/"))
39 yield Query(self.url("ambassador/v0/diag/"))
40
41 def check(self):
42 assert self.results[0].status == 200
43 assert self.results[1].status == 200
View as plain text