Debian Codegraph @

mysql-test/suite/x/t/admin_collection_metaschema_official_examples.test

raw
1 ## Test meta-schema validation for various admin collection commands
2 ## for official examples from json-schema.org
3
4 ## Preamble
5 --source include/xplugin_preamble.inc
6 --source include/xplugin_create_user.inc
7
8 ## Test data
9
10 ## Test starts here
11 --write_file $MYSQL_TMP_DIR/metaschema_official_examples.xpl
12 -->import assert_schema.macro
13 -->quiet
14
15 -->title =Command '%COMMAND%'
16
17
18 -->echo 'fstab entry' schema
19 callmacro Assert_schema %COMMAND% xtest fstab_entry {
20 "id": "http://example.com/entry-schema",
21 "$schema": "http://json-schema.org/draft-04/schema#",
22 "description": "JSON Schema for an fstab entry",
23 "type": "object",
24 "required": [ "storage" ],
25 "properties": {
26 "storage": {
27 "type": "object",
28 "oneOf": [
29 { "$ref": "#/definitions/diskDevice" },
30 { "$ref": "#/definitions/diskUUID" },
31 { "$ref": "#/definitions/nfs" },
32 { "$ref": "#/definitions/tmpfs" }
33 ]
34 },
35 "fstype": {
36 "enum": [ "ext3", "ext4", "btrfs" ]
37 },
38 "options": {
39 "type": "array",
40 "minItems": 1,
41 "items": {
42 "type": "string"
43 },
44 "uniqueItems": true
45 },
46 "readonly": {
47 "type": "boolean"
48 }
49 },
50 "definitions": {
51 "diskDevice": {
52 "properties": {
53 "type": {
54 "enum": [ "disk" ]
55 },
56 "device": {
57 "type": "string",
58 "pattern": "^/dev/[^/]+(/[^/]+)*$"
59 }
60 },
61 "required": [ "type", "device" ],
62 "additionalProperties": false
63 },
64 "diskUUID": {
65 "properties": {
66 "type": {
67 "enum": [ "disk" ]
68 },
69 "label": {
70 "type": "string",
71 "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$"
72 }
73 },
74 "required": [ "type", "label" ],
75 "additionalProperties": false
76 },
77 "nfs": {
78 "properties": {
79 "type": { "enum": [ "nfs" ] },
80 "remotePath": {
81 "type": "string",
82 "pattern": "^(/[^/]+)+$"
83 },
84 "server": {
85 "type": "string",
86 "oneOf": [
87 { "format": "hostname" },
88 { "format": "ipv4" },
89 { "format": "ipv6" }
90 ]
91 }
92 },
93 "required": [ "type", "server", "remotePath" ],
94 "additionalProperties": false
95 },
96 "tmpfs": {
97 "properties": {
98 "type": { "enum": [ "tmpfs" ] },
99 "sizeInMB": {
100 "type": "integer",
101 "minimum": 16,
102 "maximum": 512
103 }
104 },
105 "required": [ "type", "sizeInMB" ],
106 "additionalProperties": false
107 }
108 }
109 } ER_SUCCESS;
110
111
112 -->echo 'person' schema
113 callmacro Assert_schema %COMMAND% xtest person {
114 "id": "https://example.com/person.schema.json",
115 "$schema": "http://json-schema.org/draft-04/schema#",
116 "title": "Person",
117 "type": "object",
118 "properties": {
119 "firstName": {
120 "type": "string",
121 "description": "The person's first name."
122 },
123 "lastName": {
124 "type": "string",
125 "description": "The person's last name."
126 },
127 "age": {
128 "description": "Age in years which must be equal to or greater than zero.",
129 "type": "integer",
130 "minimum": 0
131 }
132 }
133 } ER_SUCCESS;
134
135
136 -->echo 'geographical location' schema
137 callmacro Assert_schema %COMMAND% xtest geographical_location {
138 "id": "https://example.com/geographical-location.schema.json",
139 "$schema": "http://json-schema.org/draft-04/schema#",
140 "title": "Longitude and Latitude Values",
141 "description": "A geographical coordinate.",
142 "required": [ "latitude", "longitude" ],
143 "type": "object",
144 "properties": {
145 "latitude": {
146 "type": "number",
147 "minimum": -90,
148 "maximum": 90
149 },
150 "longitude": {
151 "type": "number",
152 "minimum": -180,
153 "maximum": 180
154 }
155 }
156 } ER_SUCCESS;
157
158
159 -->echo 'arrays' schema
160 callmacro Assert_schema %COMMAND% xtest arrays {
161 "id": "https://example.com/arrays.schema.json",
162 "$schema": "http://json-schema.org/draft-04/schema#",
163 "description": "A representation of a person, company, organization, or place",
164 "type": "object",
165 "properties": {
166 "fruits": {
167 "type": "array",
168 "items": {
169 "type": "string"
170 }
171 },
172 "vegetables": {
173 "type": "array",
174 "items": { "$ref": "#/definitions/veggie" }
175 }
176 },
177 "definitions": {
178 "veggie": {
179 "type": "object",
180 "required": [ "veggieName", "veggieLike" ],
181 "properties": {
182 "veggieName": {
183 "type": "string",
184 "description": "The name of the vegetable."
185 },
186 "veggieLike": {
187 "type": "boolean",
188 "description": "Do I like this vegetable?"
189 }
190 }
191 }
192 }
193 } ER_SUCCESS;
194
195
196 -->echo 'address' schema
197 callmacro Assert_schema %COMMAND% xtest address {
198 "id": "https://example.com/address.schema.json",
199 "$schema": "http://json-schema.org/draft-04/schema#",
200 "description": "An address similar to http://microformats.org/wiki/h-card",
201 "type": "object",
202 "properties": {
203 "post-office-box": {
204 "type": "string"
205 },
206 "extended-address": {
207 "type": "string"
208 },
209 "street-address": {
210 "type": "string"
211 },
212 "locality": {
213 "type": "string"
214 },
215 "region": {
216 "type": "string"
217 },
218 "postal-code": {
219 "type": "string"
220 },
221 "country-name": {
222 "type": "string"
223 }
224 },
225 "required": [ "locality", "region", "country-name" ],
226 "dependencies": {
227 "post-office-box": [ "street-address" ],
228 "extended-address": [ "street-address" ]
229 }
230 } ER_SUCCESS;
231
232
233 -->echo 'address' schema
234 callmacro Assert_schema %COMMAND% xtest address {
235 "id": "https://example.com/calendar.schema.json",
236 "$schema": "http://json-schema.org/draft-04/schema#",
237 "description": "A representation of an event",
238 "type": "object",
239 "required": [ "dtstart", "summary" ],
240 "properties": {
241 "dtstart": {
242 "type": "string",
243 "description": "Event starting time"
244 },
245 "dtend": {
246 "type": "string",
247 "description": "Event ending time"
248 },
249 "summary": {
250 "type": "string"
251 },
252 "location": {
253 "type": "string"
254 },
255 "url": {
256 "type": "string"
257 },
258 "duration": {
259 "type": "string",
260 "description": "Event duration"
261 },
262 "rdate": {
263 "type": "string",
264 "description": "Recurrence date"
265 },
266 "rrule": {
267 "type": "string",
268 "description": "Recurrence rule"
269 },
270 "category": {
271 "type": "string"
272 },
273 "description": {
274 "type": "string"
275 },
276 "geo": {
277 "$ref": "http://example.com/geographical-location.schema.json"
278 }
279 }
280 } ER_X_INVALID_VALIDATION_SCHEMA;
281
282
283 -->echo 'card' schema
284 callmacro Assert_schema %COMMAND% xtest card {
285 "$id": "https://example.com/card.schema.json",
286 "$schema": "http://json-schema.org/draft-04/schema#",
287 "description": "A representation of a person, company, organization, or place",
288 "type": "object",
289 "required": [ "familyName", "givenName" ],
290 "properties": {
291 "fn": {
292 "description": "Formatted Name",
293 "type": "string"
294 },
295 "familyName": {
296 "type": "string"
297 },
298 "givenName": {
299 "type": "string"
300 },
301 "additionalName": {
302 "type": "array",
303 "items": {
304 "type": "string"
305 }
306 },
307 "honorificPrefix": {
308 "type": "array",
309 "items": {
310 "type": "string"
311 }
312 },
313 "honorificSuffix": {
314 "type": "array",
315 "items": {
316 "type": "string"
317 }
318 },
319 "nickname": {
320 "type": "string"
321 },
322 "url": {
323 "type": "string"
324 },
325 "email": {
326 "type": "object",
327 "properties": {
328 "type": {
329 "type": "string"
330 },
331 "value": {
332 "type": "string"
333 }
334 }
335 },
336 "tel": {
337 "type": "object",
338 "properties": {
339 "type": {
340 "type": "string"
341 },
342 "value": {
343 "type": "string"
344 }
345 }
346 },
347 "adr": { "$ref": "http://example.com/address.schema.json" },
348 "geo": { "$ref": "http://example.com/geographical-location.schema.json" },
349 "tz": {
350 "type": "string"
351 },
352 "photo": {
353 "type": "string"
354 },
355 "logo": {
356 "type": "string"
357 },
358 "sound": {
359 "type": "string"
360 },
361 "bday": {
362 "type": "string"
363 },
364 "title": {
365 "type": "string"
366 },
367 "role": {
368 "type": "string"
369 },
370 "org": {
371 "type": "object",
372 "properties": {
373 "organizationName": {
374 "type": "string"
375 },
376 "organizationUnit": {
377 "type": "string"
378 }
379 }
380 }
381 }
382 } ER_X_INVALID_VALIDATION_SCHEMA;
383
384
385 EOF
386
387 CREATE SCHEMA xtest DEFAULT CHARSET 'utf8mb4';
388
389 exec $MYSQLXTEST -ux_root --password=''
390 -v%COMMAND%=create_collection
391 --file=$MYSQL_TMP_DIR/metaschema_official_examples.xpl 2>&1;
392
393 exec $MYSQLXTEST -ux_root --password=''
394 -v%COMMAND%=ensure_collection
395 --file=$MYSQL_TMP_DIR/metaschema_official_examples.xpl 2>&1;
396
397 exec $MYSQLXTEST -ux_root --password=''
398 -v%COMMAND%=modify_collection_options
399 --file=$MYSQL_TMP_DIR/metaschema_official_examples.xpl 2>&1;
400
401 ## Cleanup
402 --source ../include/xplugin_cleanup.inc