Skip to content

Commit 36aff6e

Browse files
authored
add test and documentation for multi-value field verification (#310)
1 parent c89c48d commit 36aff6e

File tree

3 files changed

+87
-0
lines changed

3 files changed

+87
-0
lines changed

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,6 +1141,32 @@ proxy-response:
11411141
- [ x-test-trailer-2, { value: two, as: equal } ]
11421142
```
11431143

1144+
To perform multi-value field verification, a specific format must be adhered to.
1145+
This format involves specifying each value within a sequence, ensuring that each
1146+
value is individually verified according to the defined rules.
1147+
1148+
Be aware that field verification is order sensitive. That is, the field values
1149+
will be verified in the order that they are specified in the verification rule.
1150+
1151+
See example below, value `B1` and `B2` are specified in the same order in the
1152+
header fields and verification rule:
1153+
1154+
```YAML
1155+
server-response:
1156+
headers:
1157+
fields:
1158+
- [:status, 200]
1159+
- [Content-Type, text/html]
1160+
- [Content-Length, '11']
1161+
- [Set-Cookie, "B1=abc"]
1162+
- [Set-Cookie, "B2=abc"]
1163+
1164+
proxy-response:
1165+
headers:
1166+
fields:
1167+
- [Set-Cookie, { value: [B1=, B2=] , as: contains }]
1168+
```
1169+
11441170
### URL Verification
11451171

11461172
In a manner similar to field verification described above, a mechanism exists

test/autests/gold_tests/field_verification/field_verification.test.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,3 +159,20 @@
159159

160160
client.ReturnCode = 1
161161
server.ReturnCode = 1
162+
163+
# Test 4: Verify field verification works with multi-value fields
164+
r = Test.AddTestRun("Verify field verification works with multi-value fields")
165+
client = r.AddClientProcess("client4", "replay_files/multi_value.yaml")
166+
server = r.AddServerProcess("server4", "replay_files/multi_value.yaml")
167+
proxy = r.AddProxyProcess(
168+
"proxy4",
169+
listen_port=client.Variables.https_port,
170+
server_port=server.Variables.https_port,
171+
use_ssl=True, use_http2_to_2=True)
172+
173+
client.Streams.stdout += Testers.ContainsExpression(
174+
'Contains Success: Key: "1", Field Name: "set-cookie", Required Values: "B1=" "B2=", Received Values: "B1=abc" "B2=abc"',
175+
"Verification should be happy with the set coookies.")
176+
177+
client.ReturnCode = 0
178+
server.ReturnCode = 0
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
meta:
2+
version: '1.0'
3+
sessions:
4+
- protocol:
5+
- name: http
6+
version: 2
7+
- name: tls
8+
sni: test_sni
9+
- name: tcp
10+
- name: ip
11+
version: 4
12+
transactions:
13+
- client-request:
14+
headers:
15+
fields:
16+
- [:method, POST]
17+
- [:scheme, https]
18+
- [:authority, example.data.com]
19+
- [:path, /a/path]
20+
- [Content-Type, text/html]
21+
- [Content-Length, '11']
22+
- [uuid, 1]
23+
content:
24+
encoding: plain
25+
data: client_test
26+
size: 11
27+
28+
server-response:
29+
headers:
30+
fields:
31+
- [:status, 200]
32+
- [Content-Type, text/html]
33+
- [Content-Length, '11']
34+
- [Set-Cookie, "B1=abc"]
35+
- [Set-Cookie, "B2=abc"]
36+
content:
37+
encoding: plain
38+
data: server_test
39+
size: 11
40+
41+
proxy-response:
42+
headers:
43+
fields:
44+
- [Set-Cookie, { value: [B1=, B2=] , as: contains }]

0 commit comments

Comments
 (0)