-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomplex-validation.yaml
More file actions
241 lines (234 loc) · 6.5 KB
/
complex-validation.yaml
File metadata and controls
241 lines (234 loc) · 6.5 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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
# Complex validation probe - demonstrates advanced validation patterns
probes:
# Probe 1: Complex nested JSON validation
- name: "Nested JSON Validation"
type: rest
endpoint: "https://httpbin.org/json"
validation:
status: 200
headers:
present:
- "Content-Type"
- "Content-Length"
contains:
Content-Type: "json"
matches:
Content-Length: "^[0-9]+$"
body:
# Nested path validation
present:
- "slideshow"
- "slideshow.author"
- "slideshow.date"
- "slideshow.slides"
- "slideshow.slides[0]"
- "slideshow.slides[0].title"
- "slideshow.slides[0].type"
# Type checking on nested fields
type:
slideshow.author: string
slideshow.date: string
slideshow.slides: array
slideshow.title: string
# Exact value matching
equals:
slideshow.title: "Sample Slide Show"
slideshow.author: "Yours Truly"
slideshow.date: "date of publication"
# Security check - ensure no sensitive data
absent:
- "password"
- "api_key"
- "secret"
# Probe 2: POST with complex body and validation
- name: "Complex POST Validation"
type: rest
endpoint: "https://httpbin.org/post"
method: POST
headers:
Content-Type: "application/json"
X-Request-ID: "test-12345"
body:
user:
name: "John Doe"
email: "john@example.com"
age: 30
active: true
tags: ["premium", "verified"]
metadata:
signup_date: "2024-01-01"
referral_code: "ABC123"
validation:
status: 200
headers:
present:
- "Content-Type"
# Ensure echo header is returned
equals:
Content-Type: "application/json"
body:
# Verify request was echoed correctly
present:
- "json"
- "json.user"
- "json.user.name"
- "json.user.email"
- "json.user.age"
- "json.user.active"
- "json.user.tags"
- "json.user.metadata"
# Type validation
type:
json.user.name: string
json.user.email: string
json.user.age: integer
json.user.active: boolean
json.user.tags: array
json.user.metadata: object
# Value validation
equals:
json.user.name: "John Doe"
json.user.age: 30
json.user.active: true
# Regex pattern validation
matches:
json.user.email: "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$"
json.user.metadata.referral_code: "^[A-Z]{3}[0-9]{3}$"
# Array element validation
contains:
json.user.tags: "premium"
# Range validation
range:
json.user.age: [18, 100]
output:
USER_NAME: "json.user.name"
USER_EMAIL: "json.user.email"
# Probe 3: UUID and pattern matching
- name: "UUID and Pattern Validation"
type: rest
endpoint: "https://httpbin.org/uuid"
validation:
status: 200
body:
present:
- "uuid"
type:
uuid: string
# Strict UUID v4 pattern
matches:
uuid: "^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
# Probe 4: Headers validation with patterns
- name: "Complex Headers Validation"
type: rest
endpoint: "https://httpbin.org/response-headers"
headers:
X-Custom-Header: "test-value"
validation:
status: 200
headers:
present:
- "Content-Type"
- "Content-Length"
# Security headers should be absent
absent:
- "X-Debug-Token"
- "X-Internal-IP"
contains:
Content-Type: "application/json"
# Probe 5: Multiple validations on same response
- name: "Multi-Layer Validation"
type: rest
endpoint: "https://httpbin.org/get"
validation:
status: 200
headers:
present: ["Content-Type"]
contains:
Content-Type: "json"
matches:
Content-Type: "application/json.*"
body:
present:
- "args"
- "headers"
- "origin"
- "url"
type:
args: object
headers: object
origin: string
url: string
# IP address pattern
matches:
origin: "^[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}$"
# URL pattern
matches:
url: "^https://httpbin\\.org/get$"
# Probe 6: Type validation across different types
- name: "Type System Validation"
type: rest
endpoint: "https://httpbin.org/post"
method: POST
headers:
Content-Type: "application/json"
body:
string_field: "text"
integer_field: 42
number_field: 3.14
boolean_field: true
array_field: [1, 2, 3]
object_field:
nested: "value"
null_field: null
validation:
status: 200
body:
type:
json.string_field: string
json.integer_field: integer
json.number_field: number
json.boolean_field: boolean
json.array_field: array
json.object_field: object
json.null_field: "null" # Must be quoted string to represent null type
# Probe 7: Range validation with bounds
- name: "Numeric Range Validation"
type: rest
endpoint: "https://httpbin.org/post"
method: POST
headers:
Content-Type: "application/json"
body:
age: 25
temperature: 72.5
score: 95
count: 1000
validation:
status: 200
body:
range:
json.age: [0, 120] # 0 <= age <= 120
json.temperature: [32, 212] # Fahrenheit range
json.score: [0, 100] # Percentage
json.count: [1, null] # At least 1, no upper limit
# Probe 8: Security validation - ensure sensitive data absent
- name: "Security Validation"
type: rest
endpoint: "https://httpbin.org/get"
validation:
status: 200
headers:
# These headers should never be present
absent:
- "X-API-Key"
- "Authorization"
- "X-Internal-Token"
- "X-Debug-Info"
body:
# These fields should never be in response
absent:
- "password"
- "secret_key"
- "api_token"
- "private_key"
- "session_id"