{ "info": { "_postman_id": "70c72275-e112-4542-a5f3-4ba2976cfc44", "name": "crAPI Accepted", "description": "crAPI Training Scripts", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", "_exporter_id": "18686113" }, "item": [ { "name": "Signup example.com", "event": [ { "listen": "test", "script": { "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", "});" ], "type": "text/javascript" } }, { "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 );" ], "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": "{\"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": "Forgot Password", "event": [ { "listen": "test", "script": { "exec": [ "", "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", " var jsonData = JSON.parse(responseBody);", " pm.test(\"Body matches string\", function () {", " pm.expect(pm.response.text()).to.include(\"OTP Sent\");", " });", "});", "" ], "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": "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}}\"}" }, "url": { "raw": "{{url}}/identity/api/auth/forget-password", "host": [ "{{url}}" ], "path": [ "identity", "api", "auth", "forget-password" ] } }, "response": [] }, { "name": "SearchMailOTP", "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(\"Get OTP\", function () {", " pm.expect(mails.length).to.be.gt(0);", " var mail = mails[0];", " console.log(mail);", " //mails.sort(dynamicSort(\"Created\"));", " var mail = mails[0];", " var mbody = mail['Raw']['Data'].replace(/[^a-zA-Z0-9<>:]*\\n/g, \"\");", " console.log(mail);", " var otpmatch = mbody.match(/generated otp is: ([0-9]+)/);", " console.log(otpmatch);", " var otp = otpmatch[1]", " console.log(\"OTP: \"+ otp);", " pm.collectionVariables.set(\"OTP\", otp);", " });", " ", "});", "" ], "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": { "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_mail}}/api/v2/search?kind=to&query={{email}}&limit=10", "host": [ "{{url_mail}}" ], "path": [ "api", "v2", "search" ], "query": [ { "key": "kind", "value": "to" }, { "key": "query", "value": "{{email}}" }, { "key": "limit", "value": "10" } ] } }, "response": [] }, { "name": "Check OTP V2", "event": [ { "listen": "test", "script": { "exec": [ "", "" ], "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": "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": "{\n \"email\": \"{{email}}\",\n \"otp\": \"{{OTP}}\",\n \"password\": \"{{password}}\"\n}" }, "url": { "raw": "{{url}}/identity/api/auth/v2/check-otp", "host": [ "{{url}}" ], "path": [ "identity", "api", "auth", "v2", "check-otp" ] } }, "response": [] }, { "name": "Check OTP", "event": [ { "listen": "test", "script": { "exec": [ "" ], "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": "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": "{\n \"email\": \"{{email}}\",\n \"otp\": \"{{OTP}}\",\n \"password\": \"{{password}}\"\n}" }, "url": { "raw": "{{url}}/identity/api/auth/v3/check-otp", "host": [ "{{url}}" ], "path": [ "identity", "api", "auth", "v3", "check-otp" ] } }, "response": [] }, { "name": "Resend vehicle email", "event": [ { "listen": "test", "script": { "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", "});" ], "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": "*/*" } ], "url": { "raw": "{{url}}/identity/api/v2/vehicle/resend_email", "host": [ "{{url}}" ], "path": [ "identity", "api", "v2", "vehicle", "resend_email" ] } }, "response": [] }, { "name": "SearchMailVehicle", "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]+) 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(\"Get Token\", function () {", " pm.expect(mails.length).to.be.gt(0);", " //mails.sort(dynamicSort(\"Created\"));", " var mail = mails[0];", " var mbody = mail['Raw']['Data'].replace(/[^a-zA-Z0-9<>:]*\\n/g, \"\");", " console.log(mbody);", " var tokentext = mbody.match(/token:\\s*[^\\s]+/i);", " console.log(tokentext);", " var email_token = tokentext[0].match(/>([A-Za-z0-9]+) 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(\"Get Token\", function () {", " pm.expect(mails.length).to.be.gt(0);", " //mails.sort(dynamicSort(\"Created\"));", " var mail = mails[0];", " var mbody = mail['Raw']['Data'].replace(/[^a-zA-Z0-9<>:]*\\n/g, \"\");", " console.log(mbody);", " var tokentext = mbody.match(/token:\\s*[^\\s]+/i);", " console.log(tokentext);", " var email_token = tokentext[0].match(/>([A-Za-z0-9]+)