...
1from typing import Generator, Tuple, Union
2
3from abstract_tests import HTTP, AmbassadorTest, Node, ServiceType
4from kat.harness import Query
5
6
7class MaxRequestHeaderKBTest(AmbassadorTest):
8 target: ServiceType
9
10 def init(self):
11 self.target = HTTP()
12
13 def config(self) -> Generator[Union[str, Tuple[Node, str]], None, None]:
14 yield self, self.format(
15 """
16---
17apiVersion: getambassador.io/v3alpha1
18kind: Module
19name: ambassador
20ambassador_id: [{self.ambassador_id}]
21config:
22 max_request_headers_kb: 30
23"""
24 )
25 yield self, self.format(
26 """
27---
28apiVersion: getambassador.io/v3alpha1
29kind: Mapping
30name: {self.name}
31hostname: "*"
32prefix: /target/
33service: http://{self.target.path.fqdn}
34"""
35 )
36
37 def queries(self):
38 h1 = "i" * (31 * 1024)
39 yield Query(self.url("target/"), expected=431, headers={"big": h1})
40 h2 = "i" * (29 * 1024)
41 yield Query(self.url("target/"), expected=200, headers={"small": h2})
42
43 def check(self):
44 # We're just testing the status codes above, so nothing to check here
45 assert True
46
47
48class MaxRequestHeaderKBMaxTest(AmbassadorTest):
49 target: ServiceType
50
51 def init(self):
52 self.target = HTTP()
53
54 def config(self) -> Generator[Union[str, Tuple[Node, str]], None, None]:
55 yield self, self.format(
56 """
57---
58apiVersion: getambassador.io/v3alpha1
59kind: Module
60name: ambassador
61ambassador_id: [{self.ambassador_id}]
62config:
63 max_request_headers_kb: 96
64"""
65 )
66 yield self, self.format(
67 """
68---
69apiVersion: getambassador.io/v3alpha1
70kind: Mapping
71name: {self.name}
72hostname: "*"
73prefix: /target/
74service: http://{self.target.path.fqdn}
75"""
76 )
77
78 def queries(self):
79 # without the override the response headers will cause envoy to respond with a 503
80 h1 = "i" * (97 * 1024)
81 yield Query(
82 self.url("target/?override_extauth_header=1"), expected=431, headers={"big": h1}
83 )
84 h2 = "i" * (95 * 1024)
85 yield Query(
86 self.url("target/?override_extauth_header=1"), expected=200, headers={"small": h2}
87 )
88
89 def check(self):
90 # We're just testing the status codes above, so nothing to check here
91 assert True
View as plain text