1 | {
|
2 | "info": {
|
3 | "_postman_id": "abd64cfd-8645-485e-b9ab-ad81b5a014a9",
|
4 | "name": "store-pet-curd",
|
5 | "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
|
6 | },
|
7 | "item": [
|
8 | {
|
9 | "name": "Create a pet",
|
10 | "event": [
|
11 | {
|
12 | "listen": "test",
|
13 | "script": {
|
14 | "id": "1265e69b-8071-4715-83c7-ba98b27a2c5c",
|
15 | "exec": [
|
16 | "var Ajv = require('ajv');",
|
17 | "var ajv = new Ajv({ logger: console, coerceTypes: true, unknownFormats: [\"int32\"] });",
|
18 | "",
|
19 | "const res = {",
|
20 | " content: pm.response.json(),",
|
21 | " headers: pm.response.headers.reduce((c, k) => ({...c, [k.key]: k.value }), {})",
|
22 | "}",
|
23 | "",
|
24 | "const schema = {\"type\":\"object\",\"required\":[],\"properties\":{\"content\":{\"allOf\":[{\"type\":\"object\",\"required\":[\"name\"],\"properties\":{\"name\":{\"type\":\"string\",\"description\":\"pet's name\"},\"tag\":{\"type\":\"string\",\"enum\":[\"DOG\",\"CAT\"]},\"age\":{\"type\":\"integer\",\"format\":\"int32\"},\"birthAt\":{\"type\":\"string\",\"format\":\"date\"},\"grade\":{\"type\":\"integer\",\"format\":\"int32\"}}},{\"type\":\"object\",\"required\":[\"id\"],\"properties\":{\"id\":{\"type\":\"string\"}}}]}}};",
|
25 | "",
|
26 | "pm.test(\"Status code is 201\", function () {",
|
27 | " pm.response.to.have.status(201);",
|
28 | "});",
|
29 | "",
|
30 | "pm.test(\"Json body schema test\", function(){",
|
31 | " pm.expect(ajv.validate(schema, data)).to.be.true;",
|
32 | "})",
|
33 | "",
|
34 | "pm.test(\"result data test\", function(){",
|
35 | " pm.expect(res.content.name).equal(pm.variables.get(\"name\"));",
|
36 | " pm.expect(res.content.age.toString()).equal(pm.variables.get(\"age\"));",
|
37 | " pm.expect(res.content.tag).equal(pm.variables.get(\"tag\"));",
|
38 | " pm.expect(res.content.owner).equal(pm.variables.get(\"user\"));",
|
39 | "})",
|
40 | "",
|
41 | "// 为后续测试准备数据",
|
42 | "pm.environment.set(\"petId\", res.content.id);"
|
43 | ],
|
44 | "type": "text/javascript"
|
45 | }
|
46 | }
|
47 | ],
|
48 | "_postman_id": "795883c8-2bf0-443d-9fc5-f441e228b9b0",
|
49 | "protocolProfileBehavior": {
|
50 | "disableBodyPruning": true
|
51 | },
|
52 | "request": {
|
53 | "auth": {
|
54 | "type": "bearer",
|
55 | "bearer": [
|
56 | {
|
57 | "key": "token",
|
58 | "value": "{{token}}",
|
59 | "type": "string"
|
60 | }
|
61 | ]
|
62 | },
|
63 | "method": "POST",
|
64 | "header": [
|
65 | {
|
66 | "key": "Accept",
|
67 | "value": "application/json"
|
68 | },
|
69 | {
|
70 | "key": "Content-Type",
|
71 | "value": "application/json"
|
72 | }
|
73 | ],
|
74 | "body": {
|
75 | "mode": "raw",
|
76 | "raw": "{\n \"name\": \"{{name}}\",\n \"tag\": \"{{tag}}\",\n \"age\": {{age}},\n \"birthAt\": \"{{birthAt}}\",\n \"grade\": {{grade}},\n \"owner\": \"{{user}}\"\n}",
|
77 | "options": {
|
78 | "raw": {}
|
79 | }
|
80 | },
|
81 | "url": {
|
82 | "raw": "{{baseUrl}}/pets",
|
83 | "host": [
|
84 | "{{baseUrl}}"
|
85 | ],
|
86 | "path": [
|
87 | "pets"
|
88 | ]
|
89 | }
|
90 | },
|
91 | "response": [
|
92 | {
|
93 | "id": "78861a2c-943b-4069-bd8b-5cde475a2bd0",
|
94 | "name": "Response_201",
|
95 | "originalRequest": {
|
96 | "auth": {
|
97 | "type": "bearer",
|
98 | "bearer": [
|
99 | {
|
100 | "key": "token",
|
101 | "value": "{{token}}",
|
102 | "type": "string"
|
103 | }
|
104 | ]
|
105 | },
|
106 | "method": "POST",
|
107 | "header": [
|
108 | {
|
109 | "key": "Accept",
|
110 | "value": "application/json"
|
111 | },
|
112 | {
|
113 | "key": "Content-Type",
|
114 | "value": "application/json"
|
115 | }
|
116 | ],
|
117 | "body": {
|
118 | "mode": "raw",
|
119 | "raw": "{\n \"name\": \"{{name}}\",\n \"tag\": \"{{tag}}\",\n \"age\": \"{{age}}\",\n \"birthAt\": \"{{birthAt}}\",\n \"grade\": \"{{grade}}\"\n}"
|
120 | },
|
121 | "url": {
|
122 | "raw": "{{baseUrl}}/pets",
|
123 | "host": [
|
124 | "{{baseUrl}}"
|
125 | ],
|
126 | "path": [
|
127 | "pets"
|
128 | ]
|
129 | }
|
130 | },
|
131 | "status": "The Pet created",
|
132 | "code": 201,
|
133 | "_postman_previewlanguage": "Text",
|
134 | "header": [
|
135 | {
|
136 | "key": "Content-type",
|
137 | "value": "application/json"
|
138 | }
|
139 | ],
|
140 | "cookie": [],
|
141 | "responseTime": null,
|
142 | "body": null
|
143 | }
|
144 | ]
|
145 | },
|
146 | {
|
147 | "name": "Find pet by id",
|
148 | "event": [
|
149 | {
|
150 | "listen": "test",
|
151 | "script": {
|
152 | "id": "6481d2e3-fe3a-450e-b955-b4ad30104ae0",
|
153 | "exec": [
|
154 | "var Ajv = require('ajv');",
|
155 | "var ajv = new Ajv({ logger: console, coerceTypes: true, unknownFormats: [\"int32\"] });",
|
156 | "",
|
157 | "pm.test(\"Status code is 200\", function () {",
|
158 | " pm.response.to.have.status(200);",
|
159 | "});",
|
160 | "",
|
161 | "const schema = {\"type\":\"object\",\"required\":[],\"properties\":{\"content\":{\"allOf\":[{\"type\":\"object\",\"required\":[\"name\"],\"properties\":{\"name\":{\"type\":\"string\",\"description\":\"pet's name\"},\"tag\":{\"type\":\"string\",\"enum\":[\"DOG\",\"CAT\"]},\"age\":{\"type\":\"integer\",\"format\":\"int32\"},\"birthAt\":{\"type\":\"string\",\"format\":\"date\"},\"grade\":{\"type\":\"integer\",\"format\":\"int32\"}}},{\"type\":\"object\",\"required\":[\"id\"],\"properties\":{\"id\":{\"type\":\"string\"}}}]}}};",
|
162 | "pm.test(\"Json body schema test\", function(){",
|
163 | " const res = {",
|
164 | " content: pm.response.json(),",
|
165 | " headers: pm.response.headers.reduce((c, k) => ({...c, [k.key]: k.value }), {})",
|
166 | " }",
|
167 | " pm.expect(ajv.validate(schema, data)).to.be.true;",
|
168 | "})",
|
169 | ""
|
170 | ],
|
171 | "type": "text/javascript"
|
172 | }
|
173 | }
|
174 | ],
|
175 | "_postman_id": "f476457f-92d4-465c-8c7b-a526aa6f5be8",
|
176 | "protocolProfileBehavior": {
|
177 | "disableBodyPruning": true
|
178 | },
|
179 | "request": {
|
180 | "auth": {
|
181 | "type": "bearer",
|
182 | "bearer": [
|
183 | {
|
184 | "key": "token",
|
185 | "value": "{{token}}",
|
186 | "type": "string"
|
187 | }
|
188 | ]
|
189 | },
|
190 | "method": "GET",
|
191 | "header": [
|
192 | {
|
193 | "key": "Accept",
|
194 | "value": "application/json"
|
195 | }
|
196 | ],
|
197 | "url": {
|
198 | "raw": "{{baseUrl}}/pets/:petId",
|
199 | "host": [
|
200 | "{{baseUrl}}"
|
201 | ],
|
202 | "path": [
|
203 | "pets",
|
204 | ":petId"
|
205 | ],
|
206 | "variable": [
|
207 | {
|
208 | "key": "petId",
|
209 | "value": "{{petId}}",
|
210 | "type": "string"
|
211 | }
|
212 | ]
|
213 | }
|
214 | },
|
215 | "response": [
|
216 | {
|
217 | "id": "e2963b0b-00ee-4e06-aa76-0937ecc8172c",
|
218 | "name": "Response_200",
|
219 | "originalRequest": {
|
220 | "auth": {
|
221 | "type": "bearer",
|
222 | "bearer": [
|
223 | {
|
224 | "key": "token",
|
225 | "value": "{{token}}",
|
226 | "type": "string"
|
227 | }
|
228 | ]
|
229 | },
|
230 | "method": "GET",
|
231 | "header": [
|
232 | {
|
233 | "key": "Accept",
|
234 | "value": "application/json"
|
235 | }
|
236 | ],
|
237 | "url": {
|
238 | "raw": "{{baseUrl}}/pets/:petId",
|
239 | "host": [
|
240 | "{{baseUrl}}"
|
241 | ],
|
242 | "path": [
|
243 | "pets",
|
244 | ":petId"
|
245 | ],
|
246 | "variable": [
|
247 | {
|
248 | "key": "petId",
|
249 | "value": "petId"
|
250 | }
|
251 | ]
|
252 | }
|
253 | },
|
254 | "status": "Expected response to a valid request",
|
255 | "code": 200,
|
256 | "_postman_previewlanguage": "Text",
|
257 | "header": [
|
258 | {
|
259 | "key": "Content-type",
|
260 | "value": "application/json"
|
261 | }
|
262 | ],
|
263 | "cookie": [],
|
264 | "responseTime": null,
|
265 | "body": null
|
266 | }
|
267 | ]
|
268 | },
|
269 | {
|
270 | "name": "Find pet by wrong id",
|
271 | "event": [
|
272 | {
|
273 | "listen": "test",
|
274 | "script": {
|
275 | "id": "a28c4380-a224-437f-8c18-a7b1026721d0",
|
276 | "exec": [
|
277 | "var Ajv = require('ajv');",
|
278 | "var ajv = new Ajv({ logger: console, coerceTypes: true, unknownFormats: [\"int32\"] });",
|
279 | "",
|
280 | "pm.test(\"Status code is 404\", function () {",
|
281 | " pm.response.to.have.status(404);",
|
282 | "});",
|
283 | "",
|
284 | "const schema = {",
|
285 | " type: \"object\",",
|
286 | " required: [\"name\"],",
|
287 | " properties: {",
|
288 | " name: {",
|
289 | " type: \"string\"",
|
290 | " },",
|
291 | " message: {",
|
292 | " type: \"string\"",
|
293 | " },",
|
294 | " code: {",
|
295 | " type: \"string\"",
|
296 | " },",
|
297 | " path: {",
|
298 | " type: \"string\"",
|
299 | " },",
|
300 | " value: {",
|
301 | " type: \"string\"",
|
302 | " },",
|
303 | " keyword: {",
|
304 | " type: \"string\"",
|
305 | " }",
|
306 | " }",
|
307 | "}",
|
308 | "",
|
309 | "pm.test(\"err schema test\", function(){",
|
310 | " pm.expect(ajv.validate(schema, pm.response.json())).to.be.true;",
|
311 | "})",
|
312 | ""
|
313 | ],
|
314 | "type": "text/javascript"
|
315 | }
|
316 | }
|
317 | ],
|
318 | "_postman_id": "9446f20f-705c-42c5-9916-ec180f09bbc8",
|
319 | "protocolProfileBehavior": {
|
320 | "disableBodyPruning": true
|
321 | },
|
322 | "request": {
|
323 | "auth": {
|
324 | "type": "bearer",
|
325 | "bearer": [
|
326 | {
|
327 | "key": "token",
|
328 | "value": "{{token}}",
|
329 | "type": "string"
|
330 | }
|
331 | ]
|
332 | },
|
333 | "method": "GET",
|
334 | "header": [
|
335 | {
|
336 | "key": "Accept",
|
337 | "value": "application/json"
|
338 | }
|
339 | ],
|
340 | "url": {
|
341 | "raw": "{{baseUrl}}/pets/5ee6d60435d1603c47d0263b",
|
342 | "host": [
|
343 | "{{baseUrl}}"
|
344 | ],
|
345 | "path": [
|
346 | "pets",
|
347 | "5ee6d60435d1603c47d0263b"
|
348 | ]
|
349 | }
|
350 | },
|
351 | "response": [
|
352 | {
|
353 | "id": "4896e9c0-4cf2-4b49-9974-0a823248bbef",
|
354 | "name": "Response_200",
|
355 | "originalRequest": {
|
356 | "auth": {
|
357 | "type": "bearer",
|
358 | "bearer": [
|
359 | {
|
360 | "key": "token",
|
361 | "value": "{{token}}",
|
362 | "type": "string"
|
363 | }
|
364 | ]
|
365 | },
|
366 | "method": "GET",
|
367 | "header": [
|
368 | {
|
369 | "key": "Accept",
|
370 | "value": "application/json"
|
371 | }
|
372 | ],
|
373 | "url": {
|
374 | "raw": "{{baseUrl}}/pets/:petId",
|
375 | "host": [
|
376 | "{{baseUrl}}"
|
377 | ],
|
378 | "path": [
|
379 | "pets",
|
380 | ":petId"
|
381 | ],
|
382 | "variable": [
|
383 | {
|
384 | "key": "petId",
|
385 | "value": "petId"
|
386 | }
|
387 | ]
|
388 | }
|
389 | },
|
390 | "status": "Expected response to a valid request",
|
391 | "code": 200,
|
392 | "_postman_previewlanguage": "Text",
|
393 | "header": [
|
394 | {
|
395 | "key": "Content-type",
|
396 | "value": "application/json"
|
397 | }
|
398 | ],
|
399 | "cookie": [],
|
400 | "responseTime": null,
|
401 | "body": null
|
402 | }
|
403 | ]
|
404 | },
|
405 | {
|
406 | "name": "Update pet",
|
407 | "event": [
|
408 | {
|
409 | "listen": "test",
|
410 | "script": {
|
411 | "id": "95914efd-0005-47f7-a8a2-b863b45c1fab",
|
412 | "exec": [
|
413 | "var Ajv = require('ajv');",
|
414 | "var ajv = new Ajv({ logger: console, coerceTypes: true, unknownFormats: [\"int32\"] });",
|
415 | "",
|
416 | "pm.test(\"Status code is 200\", function () {",
|
417 | " pm.response.to.have.status(200);",
|
418 | "});",
|
419 | "",
|
420 | "const schema = {\"type\":\"object\",\"required\":[],\"properties\":{\"content\":{\"allOf\":[{\"type\":\"object\",\"required\":[\"name\"],\"properties\":{\"name\":{\"type\":\"string\",\"description\":\"pet's name\"},\"tag\":{\"type\":\"string\",\"enum\":[\"DOG\",\"CAT\"]},\"age\":{\"type\":\"integer\",\"format\":\"int32\"},\"birthAt\":{\"type\":\"string\",\"format\":\"date\"},\"grade\":{\"type\":\"integer\",\"format\":\"int32\"}}},{\"type\":\"object\",\"required\":[\"id\"],\"properties\":{\"id\":{\"type\":\"string\"}}}]}}};",
|
421 | "pm.test(\"Json body schema test\", function(){",
|
422 | " const res = {",
|
423 | " content: pm.response.json(),",
|
424 | " headers: pm.response.headers.reduce((c, k) => ({...c, [k.key]: k.value }), {})",
|
425 | " }",
|
426 | " pm.expect(ajv.validate(schema, data)).to.be.true;",
|
427 | "})",
|
428 | ""
|
429 | ],
|
430 | "type": "text/javascript"
|
431 | }
|
432 | }
|
433 | ],
|
434 | "_postman_id": "3bbe3dc7-6e65-4fad-b92e-ddc5767b264a",
|
435 | "protocolProfileBehavior": {
|
436 | "disableBodyPruning": true
|
437 | },
|
438 | "request": {
|
439 | "auth": {
|
440 | "type": "bearer",
|
441 | "bearer": [
|
442 | {
|
443 | "key": "token",
|
444 | "value": "{{token}}",
|
445 | "type": "string"
|
446 | }
|
447 | ]
|
448 | },
|
449 | "method": "PUT",
|
450 | "header": [
|
451 | {
|
452 | "key": "Accept",
|
453 | "value": "application/json"
|
454 | },
|
455 | {
|
456 | "key": "Content-Type",
|
457 | "value": "application/json"
|
458 | }
|
459 | ],
|
460 | "body": {
|
461 | "mode": "raw",
|
462 | "raw": "{\n \"name\": \"{{name}}\",\n \"tag\": \"{{tag}}\",\n \"age\": \"{{age}}\",\n \"birthAt\": \"{{birthAt}}\",\n \"grade\": \"{{grade}}\"\n}",
|
463 | "options": {
|
464 | "raw": {}
|
465 | }
|
466 | },
|
467 | "url": {
|
468 | "raw": "{{baseUrl}}/pets/:petId",
|
469 | "host": [
|
470 | "{{baseUrl}}"
|
471 | ],
|
472 | "path": [
|
473 | "pets",
|
474 | ":petId"
|
475 | ],
|
476 | "variable": [
|
477 | {
|
478 | "key": "petId",
|
479 | "value": "{{petId}}",
|
480 | "type": "string"
|
481 | }
|
482 | ]
|
483 | }
|
484 | },
|
485 | "response": [
|
486 | {
|
487 | "id": "1851c86b-4cba-47b7-93f4-543d0b08c790",
|
488 | "name": "Response_200",
|
489 | "originalRequest": {
|
490 | "auth": {
|
491 | "type": "bearer",
|
492 | "bearer": [
|
493 | {
|
494 | "key": "token",
|
495 | "value": "{{token}}",
|
496 | "type": "string"
|
497 | }
|
498 | ]
|
499 | },
|
500 | "method": "PUT",
|
501 | "header": [
|
502 | {
|
503 | "key": "Accept",
|
504 | "value": "application/json"
|
505 | },
|
506 | {
|
507 | "key": "Content-Type",
|
508 | "value": "application/json"
|
509 | }
|
510 | ],
|
511 | "body": {
|
512 | "mode": "raw",
|
513 | "raw": "{\n \"name\": \"{{name}}\",\n \"tag\": \"{{tag}}\",\n \"age\": \"{{age}}\",\n \"birthAt\": \"{{birthAt}}\",\n \"grade\": \"{{grade}}\"\n}"
|
514 | },
|
515 | "url": {
|
516 | "raw": "{{baseUrl}}/pets/:petId",
|
517 | "host": [
|
518 | "{{baseUrl}}"
|
519 | ],
|
520 | "path": [
|
521 | "pets",
|
522 | ":petId"
|
523 | ],
|
524 | "variable": [
|
525 | {
|
526 | "key": "petId",
|
527 | "value": "petId"
|
528 | }
|
529 | ]
|
530 | }
|
531 | },
|
532 | "status": "The pet",
|
533 | "code": 200,
|
534 | "_postman_previewlanguage": "Text",
|
535 | "header": [
|
536 | {
|
537 | "key": "Content-type",
|
538 | "value": "application/json"
|
539 | }
|
540 | ],
|
541 | "cookie": [],
|
542 | "responseTime": null,
|
543 | "body": null
|
544 | }
|
545 | ]
|
546 | },
|
547 | {
|
548 | "name": "userX can't update pet",
|
549 | "event": [
|
550 | {
|
551 | "listen": "test",
|
552 | "script": {
|
553 | "id": "2febf2d2-a739-4330-a73f-39ffc06dcfc4",
|
554 | "exec": [
|
555 | "pm.test(\"Status code is 403\", function () {",
|
556 | " pm.response.to.have.status(403);",
|
557 | "});"
|
558 | ],
|
559 | "type": "text/javascript"
|
560 | }
|
561 | }
|
562 | ],
|
563 | "_postman_id": "e35015bc-4707-48b3-b6f4-f7e681aeb634",
|
564 | "protocolProfileBehavior": {
|
565 | "disableBodyPruning": true
|
566 | },
|
567 | "request": {
|
568 | "auth": {
|
569 | "type": "bearer",
|
570 | "bearer": [
|
571 | {
|
572 | "key": "token",
|
573 | "value": "{{tokenX}}",
|
574 | "type": "string"
|
575 | }
|
576 | ]
|
577 | },
|
578 | "method": "PUT",
|
579 | "header": [
|
580 | {
|
581 | "key": "Accept",
|
582 | "value": "application/json"
|
583 | },
|
584 | {
|
585 | "key": "Content-Type",
|
586 | "value": "application/json"
|
587 | }
|
588 | ],
|
589 | "body": {
|
590 | "mode": "raw",
|
591 | "raw": "{\n \"name\": \"{{name}}\",\n \"tag\": \"{{tag}}\",\n \"age\": \"{{age}}\",\n \"birthAt\": \"{{birthAt}}\",\n \"grade\": \"{{grade}}\"\n}",
|
592 | "options": {
|
593 | "raw": {}
|
594 | }
|
595 | },
|
596 | "url": {
|
597 | "raw": "{{baseUrl}}/pets/:petId",
|
598 | "host": [
|
599 | "{{baseUrl}}"
|
600 | ],
|
601 | "path": [
|
602 | "pets",
|
603 | ":petId"
|
604 | ],
|
605 | "variable": [
|
606 | {
|
607 | "key": "petId",
|
608 | "value": "{{petId}}",
|
609 | "type": "string"
|
610 | }
|
611 | ]
|
612 | }
|
613 | },
|
614 | "response": [
|
615 | {
|
616 | "id": "c034c6e6-7195-4a2e-b20d-eff085019e01",
|
617 | "name": "Response_200",
|
618 | "originalRequest": {
|
619 | "auth": {
|
620 | "type": "bearer",
|
621 | "bearer": [
|
622 | {
|
623 | "key": "token",
|
624 | "value": "{{token}}",
|
625 | "type": "string"
|
626 | }
|
627 | ]
|
628 | },
|
629 | "method": "PUT",
|
630 | "header": [
|
631 | {
|
632 | "key": "Accept",
|
633 | "value": "application/json"
|
634 | },
|
635 | {
|
636 | "key": "Content-Type",
|
637 | "value": "application/json"
|
638 | }
|
639 | ],
|
640 | "body": {
|
641 | "mode": "raw",
|
642 | "raw": "{\n \"name\": \"{{name}}\",\n \"tag\": \"{{tag}}\",\n \"age\": \"{{age}}\",\n \"birthAt\": \"{{birthAt}}\",\n \"grade\": \"{{grade}}\"\n}"
|
643 | },
|
644 | "url": {
|
645 | "raw": "{{baseUrl}}/pets/:petId",
|
646 | "host": [
|
647 | "{{baseUrl}}"
|
648 | ],
|
649 | "path": [
|
650 | "pets",
|
651 | ":petId"
|
652 | ],
|
653 | "variable": [
|
654 | {
|
655 | "key": "petId",
|
656 | "value": "petId"
|
657 | }
|
658 | ]
|
659 | }
|
660 | },
|
661 | "status": "The pet",
|
662 | "code": 200,
|
663 | "_postman_previewlanguage": "Text",
|
664 | "header": [
|
665 | {
|
666 | "key": "Content-type",
|
667 | "value": "application/json"
|
668 | }
|
669 | ],
|
670 | "cookie": [],
|
671 | "responseTime": null,
|
672 | "body": null
|
673 | }
|
674 | ]
|
675 | },
|
676 | {
|
677 | "name": "Create another pet",
|
678 | "event": [
|
679 | {
|
680 | "listen": "test",
|
681 | "script": {
|
682 | "id": "846bb8bf-0653-46d2-809a-d957577000cd",
|
683 | "exec": [
|
684 | "pm.test(\"Status code is 201\", function () {",
|
685 | " pm.response.to.have.status(201);",
|
686 | "});"
|
687 | ],
|
688 | "type": "text/javascript"
|
689 | }
|
690 | }
|
691 | ],
|
692 | "_postman_id": "b6d0ccdf-f959-4bf5-bfe0-f63b7ab60d76",
|
693 | "protocolProfileBehavior": {
|
694 | "disableBodyPruning": true
|
695 | },
|
696 | "request": {
|
697 | "auth": {
|
698 | "type": "bearer",
|
699 | "bearer": [
|
700 | {
|
701 | "key": "token",
|
702 | "value": "{{token}}",
|
703 | "type": "string"
|
704 | }
|
705 | ]
|
706 | },
|
707 | "method": "POST",
|
708 | "header": [
|
709 | {
|
710 | "key": "Accept",
|
711 | "value": "application/json"
|
712 | },
|
713 | {
|
714 | "key": "Content-Type",
|
715 | "value": "application/json"
|
716 | }
|
717 | ],
|
718 | "body": {
|
719 | "mode": "raw",
|
720 | "raw": "{\n \"name\": \"{{name}}\",\n \"tag\": \"{{tag}}\",\n \"age\": \"{{age}}\",\n \"birthAt\": \"{{birthAt}}\",\n \"grade\": \"{{grade}}\",\n \"owner\": \"{{user}}\"\n}",
|
721 | "options": {
|
722 | "raw": {}
|
723 | }
|
724 | },
|
725 | "url": {
|
726 | "raw": "{{baseUrl}}/pets",
|
727 | "host": [
|
728 | "{{baseUrl}}"
|
729 | ],
|
730 | "path": [
|
731 | "pets"
|
732 | ]
|
733 | }
|
734 | },
|
735 | "response": [
|
736 | {
|
737 | "id": "61eae70a-ccf8-4a39-8ce6-9158a05f00b5",
|
738 | "name": "Response_201",
|
739 | "originalRequest": {
|
740 | "auth": {
|
741 | "type": "bearer",
|
742 | "bearer": [
|
743 | {
|
744 | "key": "token",
|
745 | "value": "{{token}}",
|
746 | "type": "string"
|
747 | }
|
748 | ]
|
749 | },
|
750 | "method": "POST",
|
751 | "header": [
|
752 | {
|
753 | "key": "Accept",
|
754 | "value": "application/json"
|
755 | },
|
756 | {
|
757 | "key": "Content-Type",
|
758 | "value": "application/json"
|
759 | }
|
760 | ],
|
761 | "body": {
|
762 | "mode": "raw",
|
763 | "raw": "{\n \"name\": \"{{name}}\",\n \"tag\": \"{{tag}}\",\n \"age\": \"{{age}}\",\n \"birthAt\": \"{{birthAt}}\",\n \"grade\": \"{{grade}}\"\n}"
|
764 | },
|
765 | "url": {
|
766 | "raw": "{{baseUrl}}/pets",
|
767 | "host": [
|
768 | "{{baseUrl}}"
|
769 | ],
|
770 | "path": [
|
771 | "pets"
|
772 | ]
|
773 | }
|
774 | },
|
775 | "status": "The Pet created",
|
776 | "code": 201,
|
777 | "_postman_previewlanguage": "Text",
|
778 | "header": [
|
779 | {
|
780 | "key": "Content-type",
|
781 | "value": "application/json"
|
782 | }
|
783 | ],
|
784 | "cookie": [],
|
785 | "responseTime": null,
|
786 | "body": null
|
787 | }
|
788 | ]
|
789 | },
|
790 | {
|
791 | "name": "List all pets",
|
792 | "event": [
|
793 | {
|
794 | "listen": "test",
|
795 | "script": {
|
796 | "id": "61c94f53-40ee-43b5-a084-00c4609579c6",
|
797 | "exec": [
|
798 | "var Ajv = require('ajv');",
|
799 | "var ajv = new Ajv({ logger: console, coerceTypes: true, unknownFormats: [\"int32\"] });",
|
800 | "",
|
801 | "var res = {",
|
802 | " content: pm.response.json(),",
|
803 | " headers: pm.response.headers.reduce((c, k) => ({...c, [k.key]: k.value }), {})",
|
804 | "}",
|
805 | "",
|
806 | "const schema = {\"type\":\"object\",\"required\":[],\"properties\":{\"content\":{\"type\":\"array\",\"items\":{\"allOf\":[{\"type\":\"object\",\"required\":[\"name\"],\"properties\":{\"name\":{\"type\":\"string\",\"description\":\"pet's name\"},\"tag\":{\"type\":\"string\",\"enum\":[\"DOG\",\"CAT\"]},\"age\":{\"type\":\"integer\",\"format\":\"int32\"},\"birthAt\":{\"type\":\"string\",\"format\":\"date\"},\"grade\":{\"type\":\"integer\",\"format\":\"int32\"}}},{\"type\":\"object\",\"required\":[\"id\"],\"properties\":{\"id\":{\"type\":\"string\"}}}]}},\"headers\":{\"type\":\"object\",\"required\":[\"X-Total-Count\"],\"properties\":{\"X-Total-Count\":{\"type\":\"integer\"}}}}};",
|
807 | "",
|
808 | "pm.test(\"Status code is 200\", function () {",
|
809 | " pm.response.to.have.status(200);",
|
810 | "});",
|
811 | "",
|
812 | "pm.test(\"result count should right\", function () {",
|
813 | " pm.expect(res.content.length).to.equal(2);",
|
814 | " pm.expect(Number(res.headers[\"X-Total-Count\"])).to.be.above(1);",
|
815 | "})",
|
816 | "",
|
817 | "pm.test(\"Json body schema test\", function(){",
|
818 | " pm.expect(ajv.validate(schema, res)).to.be.true;",
|
819 | "})",
|
820 | ""
|
821 | ],
|
822 | "type": "text/javascript"
|
823 | }
|
824 | }
|
825 | ],
|
826 | "_postman_id": "6087d5be-7c29-4aaf-b5ed-348a093a33d9",
|
827 | "protocolProfileBehavior": {
|
828 | "disableBodyPruning": true
|
829 | },
|
830 | "request": {
|
831 | "auth": {
|
832 | "type": "bearer",
|
833 | "bearer": [
|
834 | {
|
835 | "key": "token",
|
836 | "value": "{{token}}",
|
837 | "type": "string"
|
838 | }
|
839 | ]
|
840 | },
|
841 | "method": "GET",
|
842 | "header": [
|
843 | {
|
844 | "key": "Accept",
|
845 | "value": "application/json"
|
846 | },
|
847 | {
|
848 | "key": "Authorization",
|
849 | "value": "Bearer {{token}}"
|
850 | }
|
851 | ],
|
852 | "url": {
|
853 | "raw": "{{baseUrl}}/pets?_limit=2&tag=CAT",
|
854 | "host": [
|
855 | "{{baseUrl}}"
|
856 | ],
|
857 | "path": [
|
858 | "pets"
|
859 | ],
|
860 | "query": [
|
861 | {
|
862 | "key": "_limit",
|
863 | "value": "2"
|
864 | },
|
865 | {
|
866 | "key": "tag",
|
867 | "value": "CAT"
|
868 | },
|
869 | {
|
870 | "key": "age_gt",
|
871 | "value": "",
|
872 | "disabled": true
|
873 | },
|
874 | {
|
875 | "key": "_select",
|
876 | "value": "",
|
877 | "disabled": true
|
878 | },
|
879 | {
|
880 | "key": "birthAt_gt",
|
881 | "value": "",
|
882 | "disabled": true
|
883 | },
|
884 | {
|
885 | "key": "birthAt_lt",
|
886 | "value": "",
|
887 | "disabled": true
|
888 | },
|
889 | {
|
890 | "key": "grade_gt",
|
891 | "value": "",
|
892 | "disabled": true
|
893 | },
|
894 | {
|
895 | "key": "grade_lt",
|
896 | "value": "",
|
897 | "disabled": true
|
898 | }
|
899 | ]
|
900 | }
|
901 | },
|
902 | "response": [
|
903 | {
|
904 | "id": "cdd12957-89a2-40cc-be9a-66dea787a5ed",
|
905 | "name": "Response_200",
|
906 | "originalRequest": {
|
907 | "auth": {
|
908 | "type": "bearer",
|
909 | "bearer": [
|
910 | {
|
911 | "key": "token",
|
912 | "value": "{{token}}",
|
913 | "type": "string"
|
914 | }
|
915 | ]
|
916 | },
|
917 | "method": "GET",
|
918 | "header": [
|
919 | {
|
920 | "key": "Accept",
|
921 | "value": "application/json"
|
922 | },
|
923 | {
|
924 | "key": "Authorization",
|
925 | "value": "Bearer {{token}}"
|
926 | }
|
927 | ],
|
928 | "body": {
|
929 | "mode": "raw",
|
930 | "raw": ""
|
931 | },
|
932 | "url": {
|
933 | "raw": "{{host}}/pets?_limit=10&tag=&age_gt=&_select=&tag=&age_gt=&birthAt_gt=&birthAt_lt=&grade_gt=&grade_lt=",
|
934 | "host": [
|
935 | "{{host}}"
|
936 | ],
|
937 | "path": [
|
938 | "pets"
|
939 | ],
|
940 | "query": [
|
941 | {
|
942 | "key": "_limit",
|
943 | "value": "10"
|
944 | },
|
945 | {
|
946 | "key": "tag",
|
947 | "value": ""
|
948 | },
|
949 | {
|
950 | "key": "age_gt",
|
951 | "value": ""
|
952 | },
|
953 | {
|
954 | "key": "_select",
|
955 | "value": ""
|
956 | },
|
957 | {
|
958 | "key": "tag",
|
959 | "value": ""
|
960 | },
|
961 | {
|
962 | "key": "age_gt",
|
963 | "value": ""
|
964 | },
|
965 | {
|
966 | "key": "birthAt_gt",
|
967 | "value": ""
|
968 | },
|
969 | {
|
970 | "key": "birthAt_lt",
|
971 | "value": ""
|
972 | },
|
973 | {
|
974 | "key": "grade_gt",
|
975 | "value": ""
|
976 | },
|
977 | {
|
978 | "key": "grade_lt",
|
979 | "value": ""
|
980 | }
|
981 | ]
|
982 | }
|
983 | },
|
984 | "status": "A paged array of pets",
|
985 | "code": 200,
|
986 | "_postman_previewlanguage": "Text",
|
987 | "header": [
|
988 | {
|
989 | "key": "Content-type",
|
990 | "value": "application/json"
|
991 | },
|
992 | {
|
993 | "key": "X-Total-Count",
|
994 | "value": "unset"
|
995 | }
|
996 | ],
|
997 | "cookie": [],
|
998 | "responseTime": null,
|
999 | "body": "[\n {\n \"id\": 1,\n \"name\": \"aa\",\n \"tag\": \"red\",\n \"age\": 3\n },\n {\n \"id\": 2,\n \"name\": \"bb\",\n \"tag\": \"happy\",\n \"age\": 5\n },\n {\n \"id\": 3,\n \"name\": \"cc\",\n \"tag\": \"husky\",\n \"age\": 6\n }\n]\n"
|
1000 | }
|
1001 | ]
|
1002 | },
|
1003 | {
|
1004 | "name": "deletePet",
|
1005 | "event": [
|
1006 | {
|
1007 | "listen": "test",
|
1008 | "script": {
|
1009 | "id": "5d8b8f1c-9d5a-4eca-9824-8d8ca8e212fb",
|
1010 | "exec": [
|
1011 | "var Ajv = require('ajv');",
|
1012 | "var ajv = new Ajv({ logger: console, coerceTypes: true, unknownFormats: [\"int32\"] });",
|
1013 | "",
|
1014 | "pm.test(\"Status code is 204\", function () {",
|
1015 | " pm.response.to.have.status(204);",
|
1016 | "});",
|
1017 | "",
|
1018 | ""
|
1019 | ],
|
1020 | "type": "text/javascript"
|
1021 | }
|
1022 | }
|
1023 | ],
|
1024 | "_postman_id": "c4d46215-843c-42b9-bfe9-75af10e22d74",
|
1025 | "protocolProfileBehavior": {
|
1026 | "disableBodyPruning": true
|
1027 | },
|
1028 | "request": {
|
1029 | "auth": {
|
1030 | "type": "bearer",
|
1031 | "bearer": [
|
1032 | {
|
1033 | "key": "token",
|
1034 | "value": "{{token}}",
|
1035 | "type": "string"
|
1036 | }
|
1037 | ]
|
1038 | },
|
1039 | "method": "DELETE",
|
1040 | "header": [
|
1041 | {
|
1042 | "key": "Accept",
|
1043 | "value": "application/json"
|
1044 | }
|
1045 | ],
|
1046 | "url": {
|
1047 | "raw": "{{baseUrl}}/pets/:petId",
|
1048 | "host": [
|
1049 | "{{baseUrl}}"
|
1050 | ],
|
1051 | "path": [
|
1052 | "pets",
|
1053 | ":petId"
|
1054 | ],
|
1055 | "variable": [
|
1056 | {
|
1057 | "key": "petId",
|
1058 | "value": "{{petId}}",
|
1059 | "type": "string"
|
1060 | }
|
1061 | ]
|
1062 | }
|
1063 | },
|
1064 | "response": [
|
1065 | {
|
1066 | "id": "9ef00b52-93cf-4fe3-a8fa-604a75f2a6a3",
|
1067 | "name": "Response_204",
|
1068 | "originalRequest": {
|
1069 | "auth": {
|
1070 | "type": "bearer",
|
1071 | "bearer": [
|
1072 | {
|
1073 | "key": "token",
|
1074 | "value": "{{token}}",
|
1075 | "type": "string"
|
1076 | }
|
1077 | ]
|
1078 | },
|
1079 | "method": "DELETE",
|
1080 | "header": [
|
1081 | {
|
1082 | "key": "Accept",
|
1083 | "value": "application/json"
|
1084 | }
|
1085 | ],
|
1086 | "url": {
|
1087 | "raw": "{{baseUrl}}/pets/:petId",
|
1088 | "host": [
|
1089 | "{{baseUrl}}"
|
1090 | ],
|
1091 | "path": [
|
1092 | "pets",
|
1093 | ":petId"
|
1094 | ],
|
1095 | "variable": [
|
1096 | {
|
1097 | "key": "petId",
|
1098 | "value": "petId"
|
1099 | }
|
1100 | ]
|
1101 | }
|
1102 | },
|
1103 | "status": "pet deleted",
|
1104 | "code": 204,
|
1105 | "_postman_previewlanguage": "Text",
|
1106 | "header": [],
|
1107 | "cookie": [],
|
1108 | "responseTime": null,
|
1109 | "body": null
|
1110 | }
|
1111 | ]
|
1112 | }
|
1113 | ],
|
1114 | "event": [
|
1115 | {
|
1116 | "listen": "prerequest",
|
1117 | "script": {
|
1118 | "id": "8c6cff73-b837-4f91-bfcf-52ea7d6872bd",
|
1119 | "type": "text/javascript",
|
1120 | "exec": [
|
1121 | ""
|
1122 | ]
|
1123 | }
|
1124 | },
|
1125 | {
|
1126 | "listen": "test",
|
1127 | "script": {
|
1128 | "id": "09de23be-a766-4d39-adb4-05327763f9b4",
|
1129 | "type": "text/javascript",
|
1130 | "exec": [
|
1131 | ""
|
1132 | ]
|
1133 | }
|
1134 | }
|
1135 | ],
|
1136 | "variable": [
|
1137 | {
|
1138 | "id": "a4295301-28d7-44ab-9106-41ea66e0732f",
|
1139 | "key": "age",
|
1140 | "value": "1",
|
1141 | "type": "string"
|
1142 | },
|
1143 | {
|
1144 | "id": "dd3b3cfd-a7a2-4c4f-88ce-f1cf1aab7fb6",
|
1145 | "key": "name",
|
1146 | "value": "tom",
|
1147 | "type": "string"
|
1148 | },
|
1149 | {
|
1150 | "id": "16434abe-f92b-46f0-af83-421f50519cda",
|
1151 | "key": "tag",
|
1152 | "value": "CAT",
|
1153 | "type": "string"
|
1154 | },
|
1155 | {
|
1156 | "id": "38b1bd58-4d15-49ab-8e8a-9484ec797b96",
|
1157 | "key": "birthAt",
|
1158 | "value": "2020-01-01",
|
1159 | "type": "string"
|
1160 | },
|
1161 | {
|
1162 | "id": "56a604bf-c90b-4c2e-be27-c54754090371",
|
1163 | "key": "grade",
|
1164 | "value": "1",
|
1165 | "type": "string"
|
1166 | },
|
1167 | {
|
1168 | "id": "45e1131b-a9b0-4954-a859-76ce95862fdc",
|
1169 | "key": "userX",
|
1170 | "value": "5cb9a4edc48ad400120d28a7",
|
1171 | "type": "string"
|
1172 | },
|
1173 | {
|
1174 | "id": "5ab8da0a-0224-40b0-bcde-6ea7a41b3b7c",
|
1175 | "key": "tokenX",
|
1176 | "value": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjoiNWNiOWE0ZWRjNDhhZDQwMDEyMGQyOGE3IiwiZXhwIjoyNTU3MDM1MjU4LCJucyI6Ii9hZHZlbnR1cmVyIn0.Lzzxd4INuDl-cRLre6fNuaVC8i5ylKki3BvU3ehKmjgORfknuAlsBmLLV0QDrQG49hEmBpPyPRVXH7ksiuf_jyOsq5wRIksQpx58iK7qBIGCC6Fgeka4XUkLZ281r_JO8_07ShYyP3l5QOcyMVVZq0Q038_BZ-TPDt8yYtKFpbU",
|
1177 | "type": "string"
|
1178 | }
|
1179 | ]
|
1180 | }
|