-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmulti_phase_flow.textproto
More file actions
206 lines (189 loc) · 4.57 KB
/
multi_phase_flow.textproto
File metadata and controls
206 lines (189 loc) · 4.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
# Multi-phase processing test manifest
#
# Tests ExtProc with expectations across multiple phases including:
# - Request headers processing
# - Request body inspection
# - Response headers modification
# - Response body transformation
name: "multi-phase-flow"
description: "Test ExtProc processing across all request/response phases"
test_cases: {
name: "full-request-response-pipeline"
description: "Complete pipeline with expectations in all four main phases"
tags: ["multi-phase", "integration"]
request: {
method: "POST"
path: "/api/v1/process"
scheme: "https"
authority: "api.example.com"
headers: {
key: "content-type"
value: "application/json"
}
headers: {
key: "x-request-id"
value: "req-12345"
}
body: '{"action": "transform", "payload": "test-data"}'
process_request_body: true
process_response_headers: true
process_response_body: true
}
# Phase 1: Request Headers - Add tracking and validation headers
expectations: {
phase: REQUEST_HEADERS
headers_response: {
set_headers: {
key: "x-validated"
value: "true"
}
set_headers: {
key: "x-processing-started"
value: "2025-01-01T00:00:00Z"
}
}
}
# Phase 2: Request Body - Inspect body and add metadata header
expectations: {
phase: REQUEST_BODY
body_response: {
common_response: {
status: CONTINUE
header_mutation: {
set_headers: {
key: "x-body-hash"
value: "sha256:abc123"
}
}
}
}
}
# Phase 3: Response Headers - Add CORS and caching headers
expectations: {
phase: RESPONSE_HEADERS
headers_response: {
set_headers: {
key: "access-control-allow-origin"
value: "*"
}
set_headers: {
key: "cache-control"
value: "no-store"
}
set_headers: {
key: "x-processing-completed"
value: "2025-01-01T00:00:01Z"
}
}
}
# Phase 4: Response Body - Wrap response with metadata
expectations: {
phase: RESPONSE_BODY
body_response: {
body: '{"success": true, "data": {"result": "processed"}, "meta": {"request_id": "req-12345"}}'
common_response: {
status: CONTINUE_AND_REPLACE
}
}
}
}
test_cases: {
name: "request-with-trailers"
description: "Request processing with trailers in multiple phases"
tags: ["multi-phase", "trailers"]
request: {
method: "POST"
path: "/api/v1/stream"
scheme: "https"
authority: "stream.example.com"
headers: {
key: "content-type"
value: "application/octet-stream"
}
headers: {
key: "te"
value: "trailers"
}
body: "chunk1chunk2chunk3"
trailers: {
key: "x-checksum"
value: "abc123"
}
process_request_body: true
process_request_trailers: true
}
# Phase 1: Request Headers - Acknowledge streaming
expectations: {
phase: REQUEST_HEADERS
headers_response: {
set_headers: {
key: "x-streaming"
value: "true"
}
}
}
# Phase 2: Request Body - Continue processing
expectations: {
phase: REQUEST_BODY
body_response: {
common_response: {
status: CONTINUE
header_mutation: {
set_headers: {
key: "x-chunk-count"
value: "3"
}
}
}
}
}
# Phase 3: Request Trailers - Validate checksum
expectations: {
phase: REQUEST_TRAILERS
trailers_response: {
set_trailers: {
key: "x-checksum-validated"
value: "true"
}
}
}
}
test_cases: {
name: "conditional-early-exit"
description: "Multi-phase with conditional immediate response on second phase"
tags: ["multi-phase", "error", "short-circuit"]
request: {
method: "POST"
path: "/api/v1/validate"
scheme: "https"
authority: "api.example.com"
headers: {
key: "content-type"
value: "application/json"
}
body: '{"invalid": true}'
process_request_body: true
}
# Phase 1: Request Headers - Initial processing
expectations: {
phase: REQUEST_HEADERS
headers_response: {
set_headers: {
key: "x-validation-pending"
value: "true"
}
}
}
# Phase 2: Request Body - Validation fails, return immediate response
expectations: {
phase: REQUEST_BODY
immediate_response: {
status_code: 400
headers: {
key: "content-type"
value: "application/json"
}
body: '{"error": "validation_failed", "message": "Request body is invalid", "field": "invalid"}'
}
}
}