· 5 years ago · Jan 05, 2021, 07:58 AM
1{
2 "info": {
3 "_postman_id": "74a1833f-bc4e-4e85-a525-72d268ab9999",
4 "name": "Flask-JWT-Extended",
5 "description": "This collection contains requests associated witht the Flask-JWT-Extended section of the REST API course.",
6 "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
7 },
8 "item": [
9 {
10 "name": "users",
11 "description": "",
12 "item": [
13 {
14 "name": "register a new user",
15 "request": {
16 "method": "POST",
17 "header": [
18 {
19 "key": "Content-Type",
20 "value": "application/json"
21 }
22 ],
23 "body": {
24 "mode": "raw",
25 "raw": "{\n\t\"username\": \"jose\",\n\t\"password\": \"1234\"\n}"
26 },
27 "url": {
28 "raw": "{{server_address}}/register",
29 "host": [
30 "{{server_address}}"
31 ],
32 "path": [
33 "register"
34 ]
35 }
36 },
37 "response": []
38 },
39 {
40 "name": "get user by id",
41 "request": {
42 "method": "GET",
43 "header": [],
44 "body": {
45 "mode": "raw",
46 "raw": "{\n\t\"username\": \"jose\",\n\t\"password\": \"1234\"\n}"
47 },
48 "url": {
49 "raw": "{{server_address}}/user/1",
50 "host": [
51 "{{server_address}}"
52 ],
53 "path": [
54 "user",
55 "1"
56 ]
57 }
58 },
59 "response": []
60 },
61 {
62 "name": "delete user by id",
63 "request": {
64 "method": "DELETE",
65 "header": [],
66 "body": {
67 "mode": "raw",
68 "raw": "{\n\t\"username\": \"jose\",\n\t\"password\": \"1234\"\n}"
69 },
70 "url": {
71 "raw": "{{server_address}}/user/2",
72 "host": [
73 "{{server_address}}"
74 ],
75 "path": [
76 "user",
77 "2"
78 ]
79 }
80 },
81 "response": []
82 },
83 {
84 "name": "login",
85 "event": [
86 {
87 "listen": "test",
88 "script": {
89 "id": "8c0c0ed6-c206-4c88-9349-429e024e312b",
90 "type": "text/javascript",
91 "exec": [
92 "var jsonData = pm.response.json();",
93 "pm.test(\"access_token not empty\", function () {",
94 " pm.expect(jsonData.access_token).not.eql(undefined);",
95 "});",
96 "",
97 "pm.test(\"refresh token not empty\", function () {",
98 " pm.expect(jsonData.refresh_token).not.eql(undefined);",
99 "});",
100 "// set access token as environement variable",
101 "if (jsonData.access_token !== undefined) {",
102 " postman.setEnvironmentVariable(\"access_token\", jsonData.access_token);",
103 "} else {",
104 " postman.setEnvironmentVariable(\"access_token\", null);",
105 "}",
106 "// set refresh token as environement variable",
107 "if (jsonData.refresh_token !== undefined) {",
108 " postman.setEnvironmentVariable(\"refresh_token\", jsonData.refresh_token);",
109 "} else {",
110 " postman.setEnvironmentVariable(\"refresh_token\", null);",
111 "}"
112 ]
113 }
114 }
115 ],
116 "request": {
117 "method": "POST",
118 "header": [
119 {
120 "key": "Content-Type",
121 "value": "application/json"
122 }
123 ],
124 "body": {
125 "mode": "raw",
126 "raw": "{\n \"username\" : \"jose\",\n \"password\" : \"1234\"\n}"
127 },
128 "url": {
129 "raw": "{{server_address}}/login",
130 "host": [
131 "{{server_address}}"
132 ],
133 "path": [
134 "login"
135 ]
136 }
137 },
138 "response": []
139 },
140 {
141 "name": "logout",
142 "event": [
143 {
144 "listen": "test",
145 "script": {
146 "id": "dc763e9b-e6c7-4ff3-9766-637976a5c64b",
147 "type": "text/javascript",
148 "exec": [
149 ""
150 ]
151 }
152 }
153 ],
154 "request": {
155 "method": "POST",
156 "header": [
157 {
158 "key": "Authorization",
159 "value": "Bearer {{access_token}}"
160 }
161 ],
162 "body": {
163 "mode": "raw",
164 "raw": ""
165 },
166 "url": {
167 "raw": "{{server_address}}/logout",
168 "host": [
169 "{{server_address}}"
170 ],
171 "path": [
172 "logout"
173 ]
174 }
175 },
176 "response": []
177 },
178 {
179 "name": "refresh token",
180 "event": [
181 {
182 "listen": "test",
183 "script": {
184 "id": "ad818ea6-8f79-436e-b756-ad878666ae9e",
185 "type": "text/javascript",
186 "exec": [
187 "var jsonData = pm.response.json();",
188 "pm.test(\"access_token not empty\", function () {",
189 " pm.expect(jsonData.access_token).not.eql(undefined);",
190 "});",
191 "// set access token as environement variable",
192 "if (jsonData.access_token !== undefined) {",
193 " postman.setEnvironmentVariable(\"access_token\", jsonData.access_token);",
194 "} else {",
195 " postman.setEnvironmentVariable(\"access_token\", null);",
196 "}"
197 ]
198 }
199 }
200 ],
201 "request": {
202 "method": "POST",
203 "header": [
204 {
205 "key": "Content-Type",
206 "value": "application/json"
207 },
208 {
209 "key": "Authorization",
210 "value": "Bearer {{refresh_token}}"
211 }
212 ],
213 "body": {
214 "mode": "raw",
215 "raw": ""
216 },
217 "url": {
218 "raw": "{{local_flask}}/refresh",
219 "host": [
220 "{{local_flask}}"
221 ],
222 "path": [
223 "refresh"
224 ]
225 }
226 },
227 "response": []
228 }
229 ]
230 },
231 {
232 "name": "items",
233 "description": "",
234 "item": [
235 {
236 "name": "get item/name",
237 "request": {
238 "method": "GET",
239 "header": [
240 {
241 "key": "Authorization",
242 "value": "Bearer {{access_token}}"
243 }
244 ],
245 "body": {},
246 "url": {
247 "raw": "{{local_flask}}/item/chair",
248 "host": [
249 "{{local_flask}}"
250 ],
251 "path": [
252 "item",
253 "chair"
254 ]
255 }
256 },
257 "response": []
258 },
259 {
260 "name": "post item/name",
261 "request": {
262 "method": "POST",
263 "header": [
264 {
265 "key": "Authorization",
266 "value": "Bearer {{access_token}}"
267 },
268 {
269 "key": "Content-Type",
270 "value": "application/json"
271 }
272 ],
273 "body": {
274 "mode": "raw",
275 "raw": "{\n \"price\": 12.99,\n \"store_id\": 1\n}"
276 },
277 "url": {
278 "raw": "{{local_flask}}/item/chair",
279 "host": [
280 "{{local_flask}}"
281 ],
282 "path": [
283 "item",
284 "chair"
285 ]
286 }
287 },
288 "response": []
289 },
290 {
291 "name": "put item/name",
292 "request": {
293 "method": "PUT",
294 "header": [
295 {
296 "key": "Authorization",
297 "value": "Bearer {{access_token}}"
298 },
299 {
300 "key": "Content-Type",
301 "value": "application/json"
302 }
303 ],
304 "body": {
305 "mode": "raw",
306 "raw": "{\n \"price\": 12.99,\n \"store_id\": 1\n}"
307 },
308 "url": {
309 "raw": "{{local_flask}}/item/chair",
310 "host": [
311 "{{local_flask}}"
312 ],
313 "path": [
314 "item",
315 "chair"
316 ]
317 }
318 },
319 "response": []
320 },
321 {
322 "name": "delete item by name",
323 "request": {
324 "method": "DELETE",
325 "header": [
326 {
327 "key": "Authorization",
328 "value": "Bearer {{access_token}}"
329 },
330 {
331 "key": "Content-Type",
332 "value": "application/json"
333 }
334 ],
335 "body": {
336 "mode": "raw",
337 "raw": ""
338 },
339 "url": {
340 "raw": "{{local_flask}}/item/chair",
341 "host": [
342 "{{local_flask}}"
343 ],
344 "path": [
345 "item",
346 "chair"
347 ]
348 }
349 },
350 "response": []
351 },
352 {
353 "name": "get all items",
354 "request": {
355 "method": "GET",
356 "header": [
357 {
358 "key": "Authorization",
359 "value": "Bearer {{access_token}}"
360 }
361 ],
362 "body": {
363 "mode": "raw",
364 "raw": "{\n \"username\" : \"cristiano\",\n \"password\" : \"12345678\"\n}"
365 },
366 "url": {
367 "raw": "{{local_flask}}/items",
368 "host": [
369 "{{local_flask}}"
370 ],
371 "path": [
372 "items"
373 ]
374 }
375 },
376 "response": []
377 },
378 {
379 "name": "get all items without JWT",
380 "request": {
381 "method": "GET",
382 "header": [],
383 "body": {
384 "mode": "raw",
385 "raw": "{\n \"username\" : \"cristiano\",\n \"password\" : \"12345678\"\n}"
386 },
387 "url": {
388 "raw": "{{local_flask}}/items",
389 "host": [
390 "{{local_flask}}"
391 ],
392 "path": [
393 "items"
394 ]
395 }
396 },
397 "response": []
398 }
399 ]
400 },
401 {
402 "name": "stores",
403 "description": "",
404 "item": [
405 {
406 "name": "create a new store",
407 "request": {
408 "method": "POST",
409 "header": [],
410 "body": {},
411 "url": {
412 "raw": "{{server_address}}/store/My Wonderful Store",
413 "host": [
414 "{{server_address}}"
415 ],
416 "path": [
417 "store",
418 "My Wonderful Store"
419 ]
420 }
421 },
422 "response": []
423 },
424 {
425 "name": "get store by name",
426 "request": {
427 "method": "GET",
428 "header": [],
429 "body": {},
430 "url": {
431 "raw": "{{server_address}}/store/My Wonderful Store",
432 "host": [
433 "{{server_address}}"
434 ],
435 "path": [
436 "store",
437 "My Wonderful Store"
438 ]
439 }
440 },
441 "response": []
442 },
443 {
444 "name": "delete a new store by name",
445 "request": {
446 "method": "DELETE",
447 "header": [],
448 "body": {},
449 "url": {
450 "raw": "{{server_address}}/store/My Wonderful Store",
451 "host": [
452 "{{server_address}}"
453 ],
454 "path": [
455 "store",
456 "My Wonderful Store"
457 ]
458 }
459 },
460 "response": []
461 },
462 {
463 "name": "get all stores",
464 "request": {
465 "method": "GET",
466 "header": [],
467 "body": {},
468 "url": {
469 "raw": "{{server_address}}/stores",
470 "host": [
471 "{{server_address}}"
472 ],
473 "path": [
474 "stores"
475 ]
476 }
477 },
478 "response": []
479 }
480 ]
481 }
482 ]
483}