{ "info": { "_postman_id": "04241d74-9eb7-47ff-8226-29dc31099725", "name": "crAPI-AddPosts", "description": "crAPI Training Scripts", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", "_exporter_id": "18686113" }, "item": [ { "name": "Signup", "event": [ { "listen": "test", "script": { "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", "});" ], "type": "text/javascript", "packages": {} } }, { "listen": "prerequest", "script": { "exec": [ "const {Property} = require('postman-collection');", "var xff = Property.replaceSubstitutions('{{$randomIP}}');", "pm.collectionVariables.set(\"X-Forwarded-For\", xff);", "pm.request.headers.remove('X-Forwarded-For');", "pm.request.headers.add({ ", " // These keys appears when you set a header by hand. Just for fun they are here", " disabled: false,", " // Your header, effectively", " key: 'X-Forwarded-For', ", " value: xff", "});", "let name = Property.replaceSubstitutions('{{$randomFirstName}}.{{$randomLastName}}');", "pm.collectionVariables.set(\"name\", name);", "let newName = Property.replaceSubstitutions('{{$randomFirstName}}.{{$randomLastName}}');", "pm.collectionVariables.set(\"new_name\", newName);", "let email = name+\"@example.com\";", "let newEmail = newName+\"@example.com\";", "let pass = Property.replaceSubstitutions(\"{{$randomPassword}}\");", "let phone = Property.replaceSubstitutions(\"{{$randomPhoneNumber}}\").replace(/-/g,'');", "pm.collectionVariables.set(\"email\", email);", "pm.collectionVariables.set(\"new_email\", newEmail);", "pm.collectionVariables.set(\"password\", pass);", "pm.collectionVariables.set(\"name\", name);", "pm.collectionVariables.set(\"phone\", phone);", "console.log(email, newEmail, pass, phone);", "console.log(name );", "console.log(\"no count for old man\")", "console.log(pm.collectionVariables.get(\"count\"))", "const count_idx = pm.collectionVariables.get(\"count\")", "if(count_idx == null || count_idx>10){", " pm.collectionVariables.set(\"count\", 0)", "}", "const count_mecha = pm.collectionVariables.get(\"count_mechanic\")", "pm.collectionVariables.set(\"count_mechanic\", 0)", "pm.collectionVariables.set(\"count_orders\", 0)", "", "" ], "type": "text/javascript", "packages": {} } } ], "request": { "auth": { "type": "noauth" }, "method": "POST", "header": [ { "key": "User-Agent", "value": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36" }, { "key": "Content-Type", "value": "application/json" }, { "key": "Accept", "value": "*/*" } ], "body": { "mode": "raw", "raw": "{\"name\":\"{{name}}\",\"email\":\"{{email}}\",\"number\":\"{{phone}}\",\"password\":\"{{password}}\"}" }, "url": { "raw": "{{url}}/identity/api/auth/signup", "host": [ "{{url}}" ], "path": [ "identity", "api", "auth", "signup" ] } }, "response": [] }, { "name": "Login", "event": [ { "listen": "test", "script": { "exec": [ "", "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", " var jsonData = JSON.parse(responseBody);", " pm.collectionVariables.set(\"token\", jsonData.token);", " var token = pm.collectionVariables.get(\"token\");", " pm.test(\"Token is set\", function () {", " pm.expect(jsonData.token).to.eql(token);", " });", "});", "" ], "type": "text/javascript" } }, { "listen": "prerequest", "script": { "exec": [ "const {Property} = require('postman-collection');\r", "var xff = pm.collectionVariables.get('X-Forwarded-For');\r", "if (!xff){\r", " xff = Property.replaceSubstitutions('{{$randomIP}}');\r", " console.log(\"X-Forwarded-For setting XFF to \"+xff);\r", " \r", "}\r", "console.log(\"X-Forwarded-For setting XFF to \"+xff);\r", "pm.collectionVariables.set(\"X-Forwarded-For\", xff);\r", "pm.request.headers.remove('X-Forwarded-For');\r", "pm.request.headers.add({ \r", " // These keys appears when you set a header by hand. Just for fun they are here\r", " disabled: false,\r", " // Your header, effectively\r", " key: 'X-Forwarded-For', \r", " value: xff\r", "});\r", "" ], "type": "text/javascript" } } ], "request": { "auth": { "type": "noauth" }, "method": "POST", "header": [ { "key": "User-Agent", "value": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36" }, { "key": "Content-Type", "value": "application/json" }, { "key": "Accept", "value": "*/*" } ], "body": { "mode": "raw", "raw": "{\"email\":\"{{email}}\",\"password\":\"{{password}}\"}" }, "url": { "raw": "{{url}}/identity/api/auth/login", "host": [ "{{url}}" ], "path": [ "identity", "api", "auth", "login" ] } }, "response": [] }, { "name": "Verify JWT Token", "event": [ { "listen": "test", "script": { "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", "});" ], "type": "text/javascript" } } ], "request": { "auth": { "type": "noauth" }, "method": "POST", "header": [], "body": { "mode": "raw", "raw": "{\n \"token\": \"{{token}}\"\n}", "options": { "raw": { "language": "json" } } }, "url": { "raw": "{{url}}/identity/api/auth/verify", "host": [ "{{url}}" ], "path": [ "identity", "api", "auth", "verify" ] } }, "response": [] }, { "name": "Create post ", "event": [ { "listen": "test", "script": { "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", " var jsonData = JSON.parse(responseBody);", " var order = jsonData.id;", " pm.collectionVariables.set(\"post_id\", order);", " console.log(order);", "});", "" ], "type": "text/javascript" } }, { "listen": "prerequest", "script": { "exec": [ "const {Property} = require('postman-collection');\r", "var xff = pm.collectionVariables.get('X-Forwarded-For');\r", "if (!xff){\r", " xff = Property.replaceSubstitutions('{{$randomIP}}');\r", " console.log(\"X-Forwarded-For setting XFF to \"+xff);\r", " \r", "}\r", "pm.collectionVariables.set(\"X-Forwarded-For\", xff);\r", "pm.request.headers.remove('X-Forwarded-For');\r", "pm.request.headers.add({ \r", " // These keys appears when you set a header by hand. Just for fun they are here\r", " disabled: false,\r", " // Your header, effectively\r", " key: 'X-Forwarded-For', \r", " value: xff\r", "});" ], "type": "text/javascript" } } ], "request": { "auth": { "type": "bearer", "bearer": [ { "key": "token", "value": "{{token}}", "type": "string" } ] }, "method": "POST", "header": [ { "key": "User-Agent", "value": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36" }, { "key": "Content-Type", "value": "application/json" }, { "key": "Accept", "value": "*/*" } ], "body": { "mode": "raw", "raw": "{\"title\":\"{{$randomLoremSentence}}\",\"content\":\"{{$randomLoremParagraph}}\"}" }, "url": { "raw": "{{url}}/community/api/v2/community/posts", "host": [ "{{url}}" ], "path": [ "community", "api", "v2", "community", "posts" ] } }, "response": [] }, { "name": "Get post", "event": [ { "listen": "test", "script": { "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", " ", "});", "var cidx = pm.collectionVariables.get(\"count\")", "pm.collectionVariables.set(\"count\",cidx+1 )", "if (cidx<10){", " pm.execution.setNextRequest(\"Signup\")", "", "}" ], "type": "text/javascript", "packages": {} } }, { "listen": "prerequest", "script": { "exec": [ "const {Property} = require('postman-collection');\r", "var xff = pm.collectionVariables.get('X-Forwarded-For');\r", "if (!xff){\r", " xff = Property.replaceSubstitutions('{{$randomIP}}');\r", " console.log(\"X-Forwarded-For setting XFF to \"+xff);\r", " \r", "}\r", "pm.collectionVariables.set(\"X-Forwarded-For\", xff);\r", "pm.request.headers.remove('X-Forwarded-For');\r", "pm.request.headers.add({ \r", " // These keys appears when you set a header by hand. Just for fun they are here\r", " disabled: false,\r", " // Your header, effectively\r", " key: 'X-Forwarded-For', \r", " value: xff\r", "});" ], "type": "text/javascript", "packages": {} } } ], "request": { "auth": { "type": "bearer", "bearer": [ { "key": "token", "value": "{{token}}", "type": "string" } ] }, "method": "GET", "header": [ { "key": "User-Agent", "value": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36" }, { "key": "Content-Type", "value": "application/json" }, { "key": "Accept", "value": "*/*" } ], "url": { "raw": "{{url}}/community/api/v2/community/posts/{{post_id}}", "host": [ "{{url}}" ], "path": [ "community", "api", "v2", "community", "posts", "{{post_id}}" ] } }, "response": [] }, { "name": "Get recent posts", "event": [ { "listen": "test", "script": { "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", "});" ], "type": "text/javascript", "packages": {} } }, { "listen": "prerequest", "script": { "exec": [ "const {Property} = require('postman-collection');\r", "var xff = pm.collectionVariables.get('X-Forwarded-For');\r", "if (!xff){\r", " xff = Property.replaceSubstitutions('{{$randomIP}}');\r", " console.log(\"X-Forwarded-For setting XFF to \"+xff);\r", " \r", "}\r", "pm.collectionVariables.set(\"X-Forwarded-For\", xff);\r", "pm.request.headers.remove('X-Forwarded-For');\r", "pm.request.headers.add({ \r", " // These keys appears when you set a header by hand. Just for fun they are here\r", " disabled: false,\r", " // Your header, effectively\r", " key: 'X-Forwarded-For', \r", " value: xff\r", "});" ], "type": "text/javascript", "packages": {} } } ], "request": { "auth": { "type": "bearer", "bearer": [ { "key": "token", "value": "{{token}}", "type": "string" } ] }, "method": "GET", "header": [ { "key": "User-Agent", "value": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36" }, { "key": "Content-Type", "value": "application/json" }, { "key": "Accept", "value": "*/*" } ], "url": { "raw": "{{url}}/community/api/v2/community/posts/recent?limit=300&offset=0", "host": [ "{{url}}" ], "path": [ "community", "api", "v2", "community", "posts", "recent" ], "query": [ { "key": "limit", "value": "300" }, { "key": "offset", "value": "0" } ] } }, "response": [] }, { "name": "SearchMailVehicle Copy", "event": [ { "listen": "test", "script": { "exec": [ "", "function dynamicSort(property) {", " var sortOrder = 1;", " if(property[0] === \"-\") {", " sortOrder = -1;", " property = property.substr(1);", " }", " return function (a,b) {", " /* next line works with strings and numbers, ", " * and you may want to customize it to your needs", " */", " var result = (a[property] < b[property]) ? -1 : (a[property] > b[property]) ? 1 : 0;", " return result * sortOrder;", " }", "}", "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", " var jsonData = JSON.parse(responseBody);", " var mails = jsonData.items;", "", " pm.test(\"Your test name\", function () {", " pm.expect(mails.length).to.be.gt(0);", " console.log(mails[0]);", " //mails.sort(dynamicSort(\"Created\"));", " console.log(mails[0]);", " var mail = mails[0];", " var mbody = mail['Raw']['Data'].replace(/[^a-zA-Z0-9<>:]*\\n/g, \"\");", " var vintext = mbody.match(/VIN(.*)Pincode/i);", " console.log(vintext);", " var VIN = vintext[1].match(/>([A-Za-z0-9]+)([0-9]+)