diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4d7a41c1..0c4fddbc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -177,7 +177,7 @@ jobs: - name: Install Node uses: actions/setup-node@v3 with: - node-version: 14 + node-version: 16 - name: Install newman run: npm install -g newman diff --git a/deploy/docker/docker-compose.yml b/deploy/docker/docker-compose.yml index 5589ef6e..577f93d8 100755 --- a/deploy/docker/docker-compose.yml +++ b/deploy/docker/docker-compose.yml @@ -245,7 +245,7 @@ services: #ports: # - "${LISTEN_IP:-127.0.0.1}:8443:443" # https healthcheck: - test: echo -n "GET / HTTP/1.1\n\n" > /dev/tcp/api.mypremiumdealership.com/443 + test: echo -n "GET / HTTP/1.1\n\n" > /dev/tcp/127.0.0.1/443 interval: 15s timeout: 15s retries: 15 diff --git a/deploy/helm/Chart.yaml b/deploy/helm/Chart.yaml index bd2c14e3..2729c248 100644 --- a/deploy/helm/Chart.yaml +++ b/deploy/helm/Chart.yaml @@ -15,7 +15,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.1.1 +version: 0.1.4 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/deploy/helm/templates/identity/config.yaml b/deploy/helm/templates/identity/config.yaml index 8bd427f4..06dc2cb5 100644 --- a/deploy/helm/templates/identity/config.yaml +++ b/deploy/helm/templates/identity/config.yaml @@ -27,7 +27,7 @@ data: SMTP_PASS: {{ .Values.identity.config.smtpPass }} SMTP_FROM: {{ .Values.identity.config.smtpFrom }} SMTP_AUTH: {{ .Values.identity.config.smtpAuth | quote }} - JWT_EXPIRATION: {{ .Values.identity.config.jwtExpiration | quote }} + JWT_EXPIRATION: {{ .Values.jwtExpiration | quote }} SMTP_STARTTLS: {{ .Values.identity.config.smtpStartTLS | quote }} SERVER_PORT: {{ .Values.identity.port | quote }} API_GATEWAY_URL: {{ if .Values.apiGatewayServiceInstall }}"https://{{ .Values.apiGatewayService.service.name }}"{{ else }}{{ .Values.apiGatewayServiceUrl }}{{ end }} diff --git a/deploy/helm/values.yaml b/deploy/helm/values.yaml index 41259177..6735da7c 100644 --- a/deploy/helm/values.yaml +++ b/deploy/helm/values.yaml @@ -10,6 +10,7 @@ apiGatewayServiceUrl: https://api.mypremiumdealership.com apiGatewayServiceInstall: true apiGatewayPassword: tlsEnabled: false +jwtExpiration: 604800000 waitForK8sResources: image: groundnuty/k8s-wait-for:v1.3 @@ -73,7 +74,6 @@ identity: smtpFrom: "no-reply@example.com" smtpAuth: true smtpStartTLS: true - jwtExpiration: 604800000 keyStoreType: PKCS12 keyStore: classpath:certs/server.p12 keyStorePassword: passw0rd diff --git a/openapi-spec/openapi-spec.json b/openapi-spec/openapi-spec.json index 96f71227..cb774075 100644 --- a/openapi-spec/openapi-spec.json +++ b/openapi-spec/openapi-spec.json @@ -28,19 +28,19 @@ "properties" : { "email" : { "type" : "string", - "example": "Cristobal.Weissnat@example.com" + "example" : "Cristobal.Weissnat@example.com" }, "name" : { "type" : "string", - "example": "Cristobal.Weissnat" + "example" : "Cristobal.Weissnat" }, "number" : { "type" : "string", - "example": "6915656974" + "example" : "6915656974" }, "password" : { "type" : "string", - "example": "5hmb0gvyC__hVQg" + "example" : "5hmb0gvyC__hVQg" } } } @@ -97,11 +97,11 @@ "properties" : { "email" : { "type" : "string", - "example": "test@example.com" + "example" : "test@example.com" }, "password" : { "type" : "string", - "example": "Test!123" + "example" : "Test!123" } } } @@ -149,7 +149,7 @@ "properties" : { "email" : { "type" : "string", - "example": "adam007@example.com" + "example" : "adam007@example.com" } } } @@ -412,11 +412,11 @@ "properties" : { "new_email" : { "type" : "string", - "example": "Sofia.Predovic@example.com" + "example" : "Sofia.Predovic@example.com" }, "old_email" : { "type" : "string", - "example": "Cristobal.Weissnat@example.com" + "example" : "Cristobal.Weissnat@example.com" } } } @@ -460,11 +460,11 @@ }, "new_email" : { "type" : "string", - "example": "Danielle.Ankunding@example.com" + "example" : "Danielle.Ankunding@example.com" }, "token" : { "type" : "string", - "example": "T9O2s6i3C7o2E8l7X5Y4" + "example" : "T9O2s6i3C7o2E8l7X5Y4" } } } @@ -526,6 +526,18 @@ "video_name" : { }, "video_url" : { }, "picture_url" : { } + }, + "example" : { + "id" : 35, + "name" : "Jasen.Hamill", + "email" : "Jasen.Hamill@example.com", + "number" : "7005397357", + "picture_url" : null, + "video_url" : null, + "video_name" : null, + "available_credit" : 155, + "video_id" : 0, + "role" : "ROLE_USER" } } } @@ -677,7 +689,8 @@ "schema" : { "type" : "integer", "format" : "int64" - } + }, + "example" : 1 } ], "responses" : { "200" : { @@ -717,7 +730,8 @@ "schema" : { "type" : "integer", "format" : "int64" - } + }, + "example" : 10 } ], "requestBody" : { "content" : { @@ -767,7 +781,8 @@ "schema" : { "type" : "integer", "format" : "int64" - } + }, + "example" : 1 } ], "responses" : { "200" : { @@ -819,7 +834,8 @@ "schema" : { "type" : "integer", "format" : "int64" - } + }, + "example" : 1 } ], "responses" : { "200" : { @@ -851,7 +867,8 @@ "schema" : { "type" : "integer", "format" : "int64" - } + }, + "example" : 12345 } ], "responses" : { "200" : { @@ -1009,11 +1026,11 @@ "properties" : { "pincode" : { "type" : "string", - "example": "9896" + "example" : "9896" }, "vin" : { "type" : "string", - "example": "0IOJO38SMVL663989" + "example" : "0IOJO38SMVL663989" } } } @@ -1108,7 +1125,7 @@ "schema" : { "type" : "string", "format" : "uuid", - "example": "0be319f0-f0dd-44aa-af0b-af927f3a383f" + "example" : "0be319f0-f0dd-44aa-af0b-af927f3a383f" } } ] }, @@ -1174,7 +1191,7 @@ "required" : true, "schema" : { "type" : "string", - "example": "tiSTSUzh4BwtvYSLWPsqu9" + "example" : "tiSTSUzh4BwtvYSLWPsqu9" } } ] }, @@ -1195,11 +1212,11 @@ "properties" : { "content" : { "type" : "string", - "example": "Est maiores voluptas velit. Necessitatibus vero veniam quos nobis." + "example" : "Est maiores voluptas velit. Necessitatibus vero veniam quos nobis." }, "title" : { "type" : "string", - "example": "Velit quia minima." + "example" : "Velit quia minima." } } } @@ -1282,7 +1299,7 @@ "properties" : { "content" : { "type" : "string", - "example": "Porro aut ratione et." + "example" : "Porro aut ratione et." } } } @@ -1388,7 +1405,7 @@ "required" : true, "schema" : { "type" : "string", - "example": "tiSTSUzh4BwtvYSLWPsqu9" + "example" : "tiSTSUzh4BwtvYSLWPsqu9" } } ] }, @@ -1401,6 +1418,23 @@ "security" : [ { "bearerAuth" : [ ] } ], + "parameters" : [ { + "in" : "query", + "name" : "limit", + "required" : false, + "schema" : { + "type" : "integer", + "example" : "30" + } + }, { + "in" : "query", + "name" : "offset", + "required" : false, + "schema" : { + "type" : "integer", + "example" : "0" + } + } ], "responses" : { "200" : { "description" : "OK", @@ -1522,11 +1556,10 @@ "content" : { "application/json" : { "schema" : { - "$ref" : "#/components/schemas/Coupon" + "$ref" : "#/components/schemas/AddCouponRequest" } } - }, - "required" : true + } }, "responses" : { "200" : { @@ -1534,7 +1567,7 @@ "content" : { "application/json" : { "schema" : { - "type" : "string" + "$ref" : "#/components/schemas/AddCouponResponse" } } } @@ -1565,49 +1598,53 @@ "/community/api/v2/coupon/validate-coupon" : { "post" : { "operationId" : "validate_coupon", - "summary" : "Validate Coupon - Version 2", + "summary" : "Validate Coupon", "description" : "Used to validate the provided discount coupon code", "tags" : [ "Community / Coupon" ], "security" : [ { "bearerAuth" : [ ] } ], "requestBody" : { + "description" : "Coupon", "content" : { "application/json" : { "schema" : { - "type" : "object", - "required" : [ "coupon_code" ], - "properties" : { - "coupon_code" : { - "type" : "string", - "example": "TRAC075" - } - } + "$ref" : "#/components/schemas/ValidateCouponRequest" } } - } + }, + "required" : true }, "responses" : { "200" : { + "description" : "Validate coupon response", "content" : { "application/json" : { "schema" : { - "$ref" : "#/components/schemas/Coupon" + "$ref" : "#/components/schemas/ValidateCouponResponse" } } - }, - "description" : "" + } + }, + "400" : { + "description" : "Bad Request", + "content" : { + "application/json" : { + "schema" : { + "type" : "string" + } + } + } }, "500" : { + "description" : "Internal Server Error", "content" : { "application/json" : { "schema" : { - "type" : "object", - "properties" : { } + "type" : "string" } } - }, - "description" : "" + } } } } @@ -1634,7 +1671,7 @@ "type" : "number" }, "products" : { - "$ref" : "#/components/schemas/Product" + "$ref" : "#/components/schemas/Products" } } } @@ -1724,6 +1761,11 @@ "type" : "number", "format" : "float" } + }, + "example" : { + "id" : 30, + "message" : "Order sent successfully.", + "credit" : 155 } } } @@ -1767,7 +1809,8 @@ "schema" : { "type" : "integer" }, - "required" : true + "required" : true, + "example" : 1 } ], "requestBody" : { "content" : { @@ -1850,7 +1893,8 @@ "schema" : { "type" : "integer" }, - "required" : true + "required" : true, + "example" : 1 } ], "responses" : { "200" : { @@ -1983,7 +2027,7 @@ "name" : "order_id", "schema" : { "type" : "integer", - "example": 33 + "example" : 33 }, "required" : true } ], @@ -2065,18 +2109,7 @@ "content" : { "application/json" : { "schema" : { - "type" : "object", - "required" : [ "amount", "coupon_code" ], - "properties" : { - "amount" : { - "type" : "number", - "example": 75 - }, - "coupon_code" : { - "type" : "string", - "example": "TRAC075" - } - } + "$ref" : "#/components/schemas/ApplyCouponRequest" } } } @@ -2086,16 +2119,7 @@ "content" : { "application/json" : { "schema" : { - "type" : "object", - "required" : [ "credit", "message" ], - "properties" : { - "credit" : { - "type" : "number" - }, - "message" : { - "type" : "string" - } - } + "$ref" : "#/components/schemas/ApplyCouponResponse" } } }, @@ -2154,6 +2178,101 @@ } } }, + "/workshop/api/management/users/all" : { + "get" : { + "operationId" : "get_workshop_users_all", + "summary" : "Get Workshop Users Detail", + "description" : "Used to get all the users in the workshop database.", + "tags" : [ "Workshop / Shop" ], + "security" : [ { + "bearerAuth" : [ ] + } ], + "parameters" : [ { + "in" : "query", + "name" : "limit", + "required" : false, + "schema" : { + "type" : "integer", + "example" : "30" + } + }, { + "in" : "query", + "name" : "offset", + "required" : false, + "schema" : { + "type" : "integer", + "example" : "0" + } + } ], + "responses" : { + "200" : { + "description" : "OK", + "headers" : { + "Transfer-Encoding" : { + "content" : { + "text/plain" : { + "schema" : { + "type" : "string" + }, + "example" : "chunked" + } + } + } + }, + "content" : { + "application/json" : { + "schema" : { + "type" : "object", + "required" : [ "users" ], + "properties" : { + "users" : { + "type" : "array", + "items" : { + "type" : "object", + "required" : [ "user", "available_credit" ], + "properties" : { + "available_credit" : { + "type" : "integer", + "format" : "float" + }, + "user" : { + "type" : "object", + "required" : [ "email", "number" ], + "properties" : { + "email" : { + "type" : "string" + }, + "number" : { + "type" : "string" + } + } + } + } + } + } + } + }, + "example" : { + "users" : [ { + "user" : { + "email" : "adam007@example.com", + "number" : "9876895423" + }, + "available_credit" : 100 + }, { + "user" : { + "email" : "pogba006@example.com", + "number" : "9876570006" + }, + "available_credit" : 100 + } ] + } + } + } + } + } + } + }, "/workshop/api/mechanic/" : { "get" : { "operationId" : "get_mechanics", @@ -2626,6 +2745,25 @@ "security" : [ { "bearerAuth" : [ ] } ], + "parameters" : [ { + "name" : "limit", + "in" : "query", + "required" : true, + "schema" : { + "type" : "integer", + "format" : "int32", + "example" : 30 + } + }, { + "name" : "offset", + "in" : "query", + "required" : true, + "schema" : { + "type" : "integer", + "format" : "int32", + "example" : 0 + } + } ], "responses" : { "200" : { "description" : "OK", @@ -2658,7 +2796,13 @@ "content" : { "application/json" : { "schema" : { - "$ref" : "#/components/schemas/ServiceRequests" + "type" : "object", + "properties" : { + "message" : { + "type" : "string" + } + }, + "required" : [ "message" ] } } } @@ -2802,7 +2946,18 @@ "format" : "url" } }, - "required" : [ "image_url", "name", "price" ] + "required" : [ "image_url", "name", "price" ], + "example" : { + "name" : "WheelBase", + "image_url" : "http://example.com/wheelbase.png", + "price" : "10.12" + } + }, + "Products" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/Product" + } }, "Product" : { "type" : "object", @@ -2824,7 +2979,13 @@ "format" : "url" } }, - "required" : [ "id", "image_url", "name", "price" ] + "required" : [ "id", "image_url", "name", "price" ], + "example" : { + "id" : 1, + "name" : "Seat", + "price" : "10.00", + "image_url" : "images/seat.svg" + } }, "OrderStatusEnum" : { "enum" : [ "delivered", "return pending", "returned" ], @@ -2835,11 +2996,11 @@ "properties" : { "product_id" : { "type" : "integer", - "example": 1 + "example" : 1 }, "quantity" : { "type" : "integer", - "example": 1 + "example" : 1 } }, "required" : [ "product_id", "quantity" ] @@ -2959,19 +3120,19 @@ "maxLength" : 4, "minLength" : 3, "type" : "string", - "example": "9969" + "example" : "9969" }, "password" : { "maxLength" : 30, "minLength" : 5, "type" : "string", - "example": "5hmb0gvyC__hVQg" + "example" : "5hmb0gvyC__hVQg" }, "email" : { "maxLength" : 30, "minLength" : 5, "type" : "string", - "example": "Cristobal.Weissnat@example.com" + "example" : "Cristobal.Weissnat@example.com" } } }, @@ -3028,9 +3189,95 @@ "user" : { "$ref" : "#/components/schemas/User" } + }, + "example" : { + "id" : 1, + "video_name" : "abc.mp4", + "conversion_params" : "-v codec h264", + "profileVideo" : "data:image/jpeg;base64,aGFrZmhhcw==" + } + }, + "ApplyCouponRequest" : { + "type" : "object", + "properties" : { + "amount" : { + "type" : "integer" + }, + "coupon_code" : { + "type" : "string" + } + }, + "required" : [ "amount", "coupon_code" ], + "example" : { + "coupon_code" : "TRAC075", + "amount" : 75 } }, - "Coupon" : { + "ApplyCouponResponse" : { + "type" : "object", + "properties" : { + "credit" : { + "type" : "integer" + }, + "message" : { + "type" : "string" + } + }, + "required" : [ "credit", "message" ], + "example" : { + "credit" : 165, + "message" : "Coupon successfully applied!" + } + }, + "AddCouponRequest" : { + "type" : "object", + "properties" : { + "coupon_code" : { + "type" : "string" + }, + "amount" : { + "type" : "integer" + } + }, + "required" : [ "coupon_code", "amount" ], + "example" : { + "coupon_code" : "TRAC075", + "amount" : 75 + } + }, + "AddCouponResponse" : { + "type" : "object", + "properties" : { + "amount" : { + "type" : "string" + }, + "coupon_code" : { + "type" : "string" + }, + "createdAt" : { + "type" : "string" + } + }, + "required" : [ "amount", "coupon_code", "CreatedAt" ], + "example" : { + "coupon_code" : "TRAC075", + "amount" : "75", + "CreatedAt" : "2023-12-07T14:22:29.832Z" + } + }, + "ValidateCouponRequest" : { + "type" : "object", + "properties" : { + "coupon_code" : { + "type" : "string" + } + }, + "required" : [ "coupon_code" ], + "example" : { + "coupon_code" : "TRAC075" + } + }, + "ValidateCouponResponse" : { "type" : "object", "properties" : { "amount" : { @@ -3043,7 +3290,12 @@ "type" : "string" } }, - "required" : [ "amount", "coupon_code" ] + "required" : [ "amount", "coupon_code", "CreatedAt" ], + "example" : { + "coupon_code" : "TRAC075", + "amount" : "75", + "CreatedAt" : "2023-12-07T14:22:29.832Z" + } }, "ServiceRequests" : { "title" : "Service Requests", @@ -3137,4 +3389,4 @@ } } } -} +} \ No newline at end of file diff --git a/postman_collections/crAPI.postman_collection.json b/postman_collections/crAPI.postman_collection.json index ecf42d98..707898b5 100644 --- a/postman_collections/crAPI.postman_collection.json +++ b/postman_collections/crAPI.postman_collection.json @@ -5,71 +5,19 @@ "name": "crAPI Accepted", "description": "crAPI Training Scripts", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", - "updatedAt": "2023-02-15T20:57:41.000Z" + "updatedAt": "2024-01-09T18:25:19.000Z", + "uid": "11111111-1111-1111-1111-111111111111", + "createdAt": null, + "lastUpdatedBy": null }, "item": [ - { - "name": "Reset Test Users", - "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": [ - "" - ], - "type": "text/javascript" - } - } - ], - "request": { - "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/auth/reset-test-users", - "host": [ - "{{url}}" - ], - "path": [ - "identity", - "api", - "auth", - "reset-test-users" - ] - } - }, - "response": [] - }, { "name": "Signup example.com", "event": [ { "listen": "test", "script": { - "id": "e857cde3-4585-4826-b7f4-c70ebb0eec03", + "id": "212edd4c-4269-4ec5-84f7-bcddae94fbf2", "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", @@ -81,7 +29,7 @@ { "listen": "prerequest", "script": { - "id": "4d9cddf8-786f-459f-9328-4e4d868532a7", + "id": "d91fc02a-4d94-4f60-a834-1508ba0d69a7", "exec": [ "const {Property} = require('postman-collection');", "var xff = Property.replaceSubstitutions('{{$randomIP}}');", @@ -114,7 +62,7 @@ } } ], - "id": "95011fcb-1cf0-482d-95f8-6d6a64458924", + "id": "73c92330-9c81-4526-a720-242a647bd1fa", "protocolProfileBehavior": { "disableBodyPruning": true }, @@ -154,7 +102,8 @@ ] } }, - "response": [] + "response": [], + "uid": "13872198-73c92330-9c81-4526-a720-242a647bd1fa" }, { "name": "Login", @@ -162,7 +111,6 @@ { "listen": "test", "script": { - "id": "b3dabfb0-9e1e-4bb1-9036-db271ea9be42", "exec": [ "", "pm.test(\"Status code is 200\", function () {", @@ -176,13 +124,13 @@ "});", "" ], - "type": "text/javascript" + "type": "text/javascript", + "id": "fc0cb347-ad16-46de-9985-207c5146d7c5" } }, { "listen": "prerequest", "script": { - "id": "dd734d51-fae8-4593-99ac-53b33a210333", "exec": [ "const {Property} = require('postman-collection');\r", "var xff = pm.collectionVariables.get('X-Forwarded-For');\r", @@ -203,11 +151,12 @@ "});\r", "" ], - "type": "text/javascript" + "type": "text/javascript", + "id": "c0a43741-3b36-48c0-be1a-9e5595f57c11" } } ], - "id": "6b3b62af-9854-40b8-a774-a0aad25723b9", + "id": "5f9c7b75-681c-43aa-9d80-448f7907669c", "protocolProfileBehavior": { "disableBodyPruning": true }, @@ -247,7 +196,8 @@ ] } }, - "response": [] + "response": [], + "uid": "13872198-5f9c7b75-681c-43aa-9d80-448f7907669c" }, { "name": "Verify JWT Token", @@ -261,11 +211,11 @@ "});" ], "type": "text/javascript", - "id": "e15ce32f-489c-4dd7-856f-302e4a0ddaca" + "id": "ed5c1a2a-44dd-4cd7-8adc-d094cd7fdae8" } } ], - "id": "227248d7-751c-4139-81d6-7e6bf00050ec", + "id": "c4ffff4d-e81c-405d-a8c0-caf9299b8020", "protocolProfileBehavior": { "disableBodyPruning": true }, @@ -297,7 +247,8 @@ ] } }, - "response": [] + "response": [], + "uid": "13872198-c4ffff4d-e81c-405d-a8c0-caf9299b8020" }, { "name": "Forgot Password", @@ -305,7 +256,6 @@ { "listen": "test", "script": { - "id": "77220831-6b67-48f2-abce-62229adddb7a", "exec": [ "", "pm.test(\"Status code is 200\", function () {", @@ -317,13 +267,13 @@ "});", "" ], - "type": "text/javascript" + "type": "text/javascript", + "id": "01bbbbc5-87cd-4337-af44-5a9433e4bf1c" } }, { "listen": "prerequest", "script": { - "id": "11239e51-1e5d-4433-a87a-f8a01f62e963", "exec": [ "const {Property} = require('postman-collection');\r", "var xff = pm.collectionVariables.get('X-Forwarded-For');\r", @@ -342,11 +292,12 @@ " value: xff\r", "});" ], - "type": "text/javascript" + "type": "text/javascript", + "id": "902385be-d824-4990-8e17-022fe8a0313f" } } ], - "id": "4561e464-0591-4acb-94cd-8e6868bb4d93", + "id": "fff7f353-9fbc-457f-97c1-42b7fa4b1024", "protocolProfileBehavior": { "disableBodyPruning": true }, @@ -386,7 +337,8 @@ ] } }, - "response": [] + "response": [], + "uid": "13872198-fff7f353-9fbc-457f-97c1-42b7fa4b1024" }, { "name": "SearchMailOTP", @@ -394,7 +346,6 @@ { "listen": "test", "script": { - "id": "bb7b2f05-7128-4f51-88bd-1f90de8c5da1", "exec": [ "", "", @@ -429,19 +380,19 @@ " console.log(otpmatch);", " var otp = otpmatch[1]", " console.log(\"OTP: \"+ otp);", - " pm.globals.set(\"OTP\", otp);", + " pm.collectionVariables.set(\"OTP\", otp);", " });", " ", "});", "" ], - "type": "text/javascript" + "type": "text/javascript", + "id": "eed6b360-55c8-43f2-ad6a-4f8e1e8a1da3" } }, { "listen": "prerequest", "script": { - "id": "1b1e2d29-0161-4461-b2af-d6ce6aa4bf3d", "exec": [ "const {Property} = require('postman-collection');\r", "var xff = pm.collectionVariables.get('X-Forwarded-For');\r", @@ -460,11 +411,12 @@ " value: xff\r", "});" ], - "type": "text/javascript" + "type": "text/javascript", + "id": "42443fb8-3a72-4d37-ab36-597308aff3d2" } } ], - "id": "38501ca0-531b-42ed-a3df-6a6a869a0eaf", + "id": "437e1354-581b-4a26-94a8-1ff508ac8420", "protocolProfileBehavior": { "disableBodyPruning": true }, @@ -514,7 +466,8 @@ ] } }, - "response": [] + "response": [], + "uid": "13872198-437e1354-581b-4a26-94a8-1ff508ac8420" }, { "name": "Check OTP", @@ -522,7 +475,6 @@ { "listen": "test", "script": { - "id": "03dc20b1-db94-425f-8cd6-8cef62437579", "exec": [ "", "pm.test(\"Status code is 200\", function () {", @@ -530,13 +482,13 @@ "});", "" ], - "type": "text/javascript" + "type": "text/javascript", + "id": "a8af689c-e601-43b1-bb64-0b8224908bce" } }, { "listen": "prerequest", "script": { - "id": "5c7e05d5-f2ee-4f56-82e9-b380b3c21781", "exec": [ "const {Property} = require('postman-collection');\r", "var xff = pm.collectionVariables.get('X-Forwarded-For');\r", @@ -555,11 +507,12 @@ " value: xff\r", "});" ], - "type": "text/javascript" + "type": "text/javascript", + "id": "ba8abbec-945d-48f3-9f9a-d407cfbc2571" } } ], - "id": "e93361b7-2a6a-42bb-9e9c-66c12c2cdcb6", + "id": "a45abeb7-f6c3-405d-bd01-3c79786d321b", "protocolProfileBehavior": { "disableBodyPruning": true }, @@ -600,7 +553,8 @@ ] } }, - "response": [] + "response": [], + "uid": "13872198-a45abeb7-f6c3-405d-bd01-3c79786d321b" }, { "name": "Resend vehicle email", @@ -608,7 +562,7 @@ { "listen": "test", "script": { - "id": "0e8904cd-5bf5-452d-9f76-c0942e0e1ddd", + "id": "9c1dc5cd-e1d6-4c3b-8bfd-52ae448c4595", "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", @@ -620,7 +574,7 @@ { "listen": "prerequest", "script": { - "id": "2edb89b6-a1f8-452d-a3d8-44c480bd1194", + "id": "3eebacdf-ed5a-43f7-9ed5-fce2bd2447ce", "exec": [ "const {Property} = require('postman-collection');\r", "var xff = pm.collectionVariables.get('X-Forwarded-For');\r", @@ -643,11 +597,21 @@ } } ], - "id": "b33396c1-6f43-405a-9d0f-2379cb1341d8", + "id": "598598c0-9905-4291-beef-3199c4a80ef7", "protocolProfileBehavior": { "disableBodyPruning": true }, "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{token}}", + "type": "string" + } + ] + }, "method": "POST", "header": [ { @@ -677,7 +641,8 @@ ] } }, - "response": [] + "response": [], + "uid": "13872198-598598c0-9905-4291-beef-3199c4a80ef7" }, { "name": "SearchMailVehicle", @@ -685,7 +650,6 @@ { "listen": "test", "script": { - "id": "04f79757-0b2e-4572-a378-9ed71916f2cf", "exec": [ "", "function dynamicSort(property) {", @@ -729,13 +693,13 @@ "});", "" ], - "type": "text/javascript" + "type": "text/javascript", + "id": "e4b022af-785b-4fe5-b6ef-65ec4ea8d7a1" } }, { "listen": "prerequest", "script": { - "id": "44894299-8190-41f3-b38d-02637870a0ce", "exec": [ "const {Property} = require('postman-collection');\r", "var xff = pm.collectionVariables.get('X-Forwarded-For');\r", @@ -754,11 +718,12 @@ " value: xff\r", "});" ], - "type": "text/javascript" + "type": "text/javascript", + "id": "70271721-08c8-41f9-a5a4-f3b83093dad4" } } ], - "id": "50487bec-79e0-470f-97cc-60229e96aa22", + "id": "c0ef62ef-8ca0-4eaf-a3d8-44c1aa41a407", "protocolProfileBehavior": { "disableBodyPruning": true }, @@ -808,7 +773,8 @@ ] } }, - "response": [] + "response": [], + "uid": "13872198-c0ef62ef-8ca0-4eaf-a3d8-44c1aa41a407" }, { "name": "Add Vehicle from Mail", @@ -816,7 +782,7 @@ { "listen": "test", "script": { - "id": "fdaef0e3-04c3-4de2-902b-f511a77d34de", + "id": "aeb0161e-8372-4da8-b151-1ab732099cf8", "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", @@ -828,7 +794,7 @@ { "listen": "prerequest", "script": { - "id": "c2209f89-7827-4f88-aa0a-55222576d643", + "id": "aa6ed8be-83b9-4071-9c2e-ad35c08050f7", "exec": [ "const {Property} = require('postman-collection');\r", "var xff = pm.collectionVariables.get('X-Forwarded-For');\r", @@ -851,11 +817,21 @@ } } ], - "id": "75ca2936-1a83-41ed-b9a6-361ec77b0158", + "id": "557cbaea-7709-4da6-8f18-36d05a49f3c5", "protocolProfileBehavior": { "disableBodyPruning": true }, "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{token}}", + "type": "string" + } + ] + }, "method": "POST", "header": [ { @@ -889,7 +865,96 @@ ] } }, - "response": [] + "response": [], + "uid": "13872198-557cbaea-7709-4da6-8f18-36d05a49f3c5" + }, + { + "name": "Get Dashboard", + "event": [ + { + "listen": "test", + "script": { + "id": "94c6588b-1056-4828-8c7f-309bdd80a557", + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "id": "15ed7adb-1256-4039-9d7a-2c81d5b9a764", + "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" + } + } + ], + "id": "51aeab4f-44d3-44f4-a68f-8ca534c76eb2", + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "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}}/identity/api/v2/user/dashboard", + "host": [ + "{{url}}" + ], + "path": [ + "identity", + "api", + "v2", + "user", + "dashboard" + ] + } + }, + "response": [], + "uid": "13872198-51aeab4f-44d3-44f4-a68f-8ca534c76eb2" }, { "name": "Get vehicles", @@ -897,7 +962,7 @@ { "listen": "test", "script": { - "id": "93cf51a1-5bf4-4147-b0b2-30e87faf8dd9", + "id": "94c6588b-1056-4828-8c7f-309bdd80a557", "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", @@ -911,7 +976,7 @@ { "listen": "prerequest", "script": { - "id": "d2d0e181-fe2a-4988-b879-6d59101d25bc", + "id": "15ed7adb-1256-4039-9d7a-2c81d5b9a764", "exec": [ "const {Property} = require('postman-collection');\r", "var xff = pm.collectionVariables.get('X-Forwarded-For');\r", @@ -934,11 +999,21 @@ } } ], - "id": "e5ceaf9c-4baa-45b5-b18e-83e8eebcf68e", + "id": "071e3d09-178d-4119-a4d2-cad20b48bbb5", "protocolProfileBehavior": { "disableBodyPruning": true }, "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{token}}", + "type": "string" + } + ] + }, "method": "GET", "header": [ { @@ -968,7 +1043,8 @@ ] } }, - "response": [] + "response": [], + "uid": "13872198-071e3d09-178d-4119-a4d2-cad20b48bbb5" }, { "name": "Get recent posts", @@ -976,7 +1052,7 @@ { "listen": "test", "script": { - "id": "7cf01ed9-84bb-4848-b26c-28ca4fb3a1f2", + "id": "38fb751f-d2f2-4868-9c73-fc603acfe23f", "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", @@ -988,7 +1064,7 @@ { "listen": "prerequest", "script": { - "id": "05b8694a-1c5e-472a-a360-b6b5c089c8fd", + "id": "9b6b4be9-5cf3-460a-a34a-e92899854e58", "exec": [ "const {Property} = require('postman-collection');\r", "var xff = pm.collectionVariables.get('X-Forwarded-For');\r", @@ -1011,11 +1087,21 @@ } } ], - "id": "eff155f5-d633-4b52-a3a9-493a6753068b", + "id": "3672b547-3a8f-4d57-aad2-3e180d7fa47c", "protocolProfileBehavior": { "disableBodyPruning": true }, "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{token}}", + "type": "string" + } + ] + }, "method": "GET", "header": [ { @@ -1032,7 +1118,7 @@ } ], "url": { - "raw": "{{url}}/community/api/v2/community/posts/recent", + "raw": "{{url}}/community/api/v2/community/posts/recent?limit=30&offset=0", "host": [ "{{url}}" ], @@ -1043,10 +1129,21 @@ "community", "posts", "recent" + ], + "query": [ + { + "key": "limit", + "value": "30" + }, + { + "key": "offset", + "value": "0" + } ] } }, - "response": [] + "response": [], + "uid": "13872198-3672b547-3a8f-4d57-aad2-3e180d7fa47c" }, { "name": "Create post ", @@ -1054,13 +1151,13 @@ { "listen": "test", "script": { - "id": "9f9b1e4d-c951-42eb-8858-1041141838b3", + "id": "b5458d72-88ae-423b-8ae2-46a26842fe38", "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", " var jsonData = JSON.parse(responseBody);", " var order = jsonData.id;", - " pm.globals.set(\"post_id\", order);", + " pm.collectionVariables.set(\"post_id\", order);", " console.log(order);", "});", "" @@ -1071,7 +1168,7 @@ { "listen": "prerequest", "script": { - "id": "0e710fbf-7bf4-4756-a98d-306ff290f5bd", + "id": "f2aa7cd1-923a-4608-81fd-131c19e5c42b", "exec": [ "const {Property} = require('postman-collection');\r", "var xff = pm.collectionVariables.get('X-Forwarded-For');\r", @@ -1094,11 +1191,21 @@ } } ], - "id": "239d5ac0-6a05-43a8-bd58-4645860c30a3", + "id": "36850ebe-8a64-42b2-aeff-d5a36d0005d9", "protocolProfileBehavior": { "disableBodyPruning": true }, "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{token}}", + "type": "string" + } + ] + }, "method": "POST", "header": [ { @@ -1132,7 +1239,8 @@ ] } }, - "response": [] + "response": [], + "uid": "13872198-36850ebe-8a64-42b2-aeff-d5a36d0005d9" }, { "name": "Get post", @@ -1140,7 +1248,7 @@ { "listen": "test", "script": { - "id": "6c112c0a-5544-425b-a268-edf153569c81", + "id": "49844a45-d740-4e48-b00b-bc89ffc12556", "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", @@ -1153,7 +1261,7 @@ { "listen": "prerequest", "script": { - "id": "83e07b19-d6a7-47df-a8d6-30e82973b52d", + "id": "2656982e-1f5a-4812-ba13-84539e8d5cd4", "exec": [ "const {Property} = require('postman-collection');\r", "var xff = pm.collectionVariables.get('X-Forwarded-For');\r", @@ -1176,11 +1284,21 @@ } } ], - "id": "4f2474b3-f0a1-4941-bded-afc46afec0d9", + "id": "6a434301-adbb-41ed-a2d9-b1599aac7dcc", "protocolProfileBehavior": { "disableBodyPruning": true }, "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{token}}", + "type": "string" + } + ] + }, "method": "GET", "header": [ { @@ -1211,7 +1329,8 @@ ] } }, - "response": [] + "response": [], + "uid": "13872198-6a434301-adbb-41ed-a2d9-b1599aac7dcc" }, { "name": "Post comment", @@ -1219,7 +1338,7 @@ { "listen": "test", "script": { - "id": "206f5f46-8078-4387-b33a-61fa50d53c4d", + "id": "4ed7e169-9c0a-4b2f-9900-931fde9cc253", "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", @@ -1231,7 +1350,7 @@ { "listen": "prerequest", "script": { - "id": "ec75a9d0-08d0-4296-bf9c-039b436472ef", + "id": "7f7a041c-4686-497f-af7c-69d182486153", "exec": [ "const {Property} = require('postman-collection');\r", "var xff = pm.collectionVariables.get('X-Forwarded-For');\r", @@ -1254,11 +1373,21 @@ } } ], - "id": "4f62b2d3-9645-4062-a675-b477d8cd45f4", + "id": "f4da30f3-5f68-457e-9f52-57e744d638a0", "protocolProfileBehavior": { "disableBodyPruning": true }, "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{token}}", + "type": "string" + } + ] + }, "method": "POST", "header": [ { @@ -1295,7 +1424,8 @@ }, "description": "Post comment" }, - "response": [] + "response": [], + "uid": "13872198-f4da30f3-5f68-457e-9f52-57e744d638a0" }, { "name": "Get vehicle location", @@ -1303,7 +1433,7 @@ { "listen": "test", "script": { - "id": "073fa9a9-f836-41b9-bde5-3db6e8d75790", + "id": "1d1f1d9e-34e2-462a-8469-f3a48bfce052", "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", @@ -1315,7 +1445,7 @@ { "listen": "prerequest", "script": { - "id": "336eec10-68c0-4ae2-9504-d68d97d65212", + "id": "f13d8ca4-39d1-4003-bf2e-8d31f3b4a178", "exec": [ "const {Property} = require('postman-collection');\r", "var xff = pm.collectionVariables.get('X-Forwarded-For');\r", @@ -1338,11 +1468,21 @@ } } ], - "id": "d9b2f169-5409-4cb4-88bb-56c9e28d575e", + "id": "7fe2e5da-ca18-46c5-b802-eb777841d76c", "protocolProfileBehavior": { "disableBodyPruning": true }, "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{token}}", + "type": "string" + } + ] + }, "method": "GET", "header": [ { @@ -1373,20 +1513,19 @@ ] } }, - "response": [] + "response": [], + "uid": "13872198-7fe2e5da-ca18-46c5-b802-eb777841d76c" }, { - "name": "Contact mechanic", + "name": "Get All Mechanics", "event": [ { "listen": "test", "script": { - "id": "ae15ee18-59d9-4171-b6f1-8d2c7fd1579a", + "id": "1d1f1d9e-34e2-462a-8469-f3a48bfce052", "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", - " var jsonData = pm.response.json();", - " pm.collectionVariables.set(\"report_id\", jsonData.response_from_mechanic_api.id);", "});" ], "type": "text/javascript" @@ -1395,7 +1534,7 @@ { "listen": "prerequest", "script": { - "id": "6b16a4ec-32b1-4c09-b052-ca2ab017f41b", + "id": "f13d8ca4-39d1-4003-bf2e-8d31f3b4a178", "exec": [ "const {Property} = require('postman-collection');\r", "var xff = pm.collectionVariables.get('X-Forwarded-For');\r", @@ -1418,20 +1557,26 @@ } } ], - "id": "76b2378b-1d7f-4519-a642-c45fb209e0d4", + "id": "76ff951b-e220-4784-a97b-8bf29a63b58f", "protocolProfileBehavior": { "disableBodyPruning": true }, "request": { - "method": "POST", + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{token}}", + "type": "string" + } + ] + }, + "method": "GET", "header": [ - { - "key": "Authorization", - "value": "Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJtb25zdGVyQGRhcmt3ZWIuY29tIiwiaWF0IjoxNjA4NTQzODI0LCJleHAiOjE2MDg2MzAyMjR9.AAIvhrtstlloPf7-NNCcmhEZm-XkO1aO3x3CLns1em7ft9U77B88LpK9jIrF8C-IH32JPWVazRFo0gBIBZ9FpA" - }, { "key": "User-Agent", - "value": "Mozilla/5.0 (Macintosh; Intel Mac OS X 11_1_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36" + "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", @@ -1442,32 +1587,212 @@ "value": "*/*" } ], - "body": { - "mode": "raw", - "raw": "{\"mechanic_code\":\"TRAC_JHN\",\"problem_details\":\"Hi Jhon\",\"vin\":\"{{VIN}}\",\"mechanic_api\":\"{{url}}/workshop/api/mechanic/receive_report\",\"repeat_request_if_failed\":false,\"number_of_repeats\":1}" - }, "url": { - "raw": "{{url}}/workshop/api/merchant/contact_mechanic", + "raw": "{{url}}/workshop/api/mechanic", "host": [ "{{url}}" ], "path": [ "workshop", "api", - "merchant", + "mechanic" + ] + } + }, + "response": [], + "uid": "13872198-76ff951b-e220-4784-a97b-8bf29a63b58f" + }, + { + "name": "Contact mechanic", + "event": [ + { + "listen": "test", + "script": { + "id": "f0f39752-0671-4381-8df8-9cbe570e6925", + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + " var jsonData = pm.response.json();", + " pm.collectionVariables.set(\"report_id\", jsonData.response_from_mechanic_api.id);", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "id": "d470cb7e-2d7a-45e8-b610-da6a0d820882", + "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" + } + } + ], + "id": "66c46dc2-2386-44cf-890a-63d917d2ca23", + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{token}}", + "type": "string" + } + ] + }, + "method": "POST", + "header": [ + { + "key": "Authorization", + "value": "Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJtb25zdGVyQGRhcmt3ZWIuY29tIiwiaWF0IjoxNjA4NTQzODI0LCJleHAiOjE2MDg2MzAyMjR9.AAIvhrtstlloPf7-NNCcmhEZm-XkO1aO3x3CLns1em7ft9U77B88LpK9jIrF8C-IH32JPWVazRFo0gBIBZ9FpA" + }, + { + "key": "User-Agent", + "value": "Mozilla/5.0 (Macintosh; Intel Mac OS X 11_1_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36" + }, + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Accept", + "value": "*/*" + } + ], + "body": { + "mode": "raw", + "raw": "{\r\n \"mechanic_code\": \"TRAC_JHN\",\r\n \"problem_details\": \"Hi Jhon\",\r\n \"vin\": \"{{VIN}}\",\r\n \"mechanic_api\": \"{{url}}/workshop/api/mechanic/receive_report\",\r\n \"repeat_request_if_failed\": false,\r\n \"number_of_repeats\": 1\r\n}" + }, + "url": { + "raw": "{{url}}/workshop/api/merchant/contact_mechanic", + "host": [ + "{{url}}" + ], + "path": [ + "workshop", + "api", + "merchant", "contact_mechanic" ] } }, - "response": [] + "response": [], + "uid": "13872198-66c46dc2-2386-44cf-890a-63d917d2ca23" }, { - "name": "GetReport", + "name": "Mechanic Login", + "event": [ + { + "listen": "test", + "script": { + "id": "ecefadd8-d1fb-4415-a0b2-cfcae8216ac6", + "exec": [ + "", + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + " var jsonData = JSON.parse(responseBody);", + " pm.collectionVariables.set(\"mechanicToken\", jsonData.token);", + " var token = pm.collectionVariables.get(\"mechanicToken\");", + " pm.test(\"Token is set\", function () {", + " pm.expect(jsonData.token).to.eql(token);", + " });", + "});", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "id": "96148952-7c1a-4316-8577-b7b0cc59fdb4", + "exec": [ + "const {Property} = require('postman-collection');\r", + "var xff = Property.replaceSubstitutions('{{$randomIP}}');\r", + "pm.collectionVariables.set(\"X-Forwarded-For-Admin\", 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" + } + } + ], + "id": "0eeb2452-e86b-48f3-bf4f-082703f39884", + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "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\":\"jhon@example.com\",\"password\":\"Admin1@#\"}" + }, + "url": { + "raw": "{{url}}/identity/api/auth/login", + "host": [ + "{{url}}" + ], + "path": [ + "identity", + "api", + "auth", + "login" + ] + } + }, + "response": [], + "uid": "13872198-0eeb2452-e86b-48f3-bf4f-082703f39884" + }, + { + "name": "Service Requests", "event": [ { "listen": "test", "script": { - "id": "ae15ee18-59d9-4171-b6f1-8d2c7fd1579a", + "id": "f0f39752-0671-4381-8df8-9cbe570e6925", "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", @@ -1479,7 +1804,7 @@ { "listen": "prerequest", "script": { - "id": "6b16a4ec-32b1-4c09-b052-ca2ab017f41b", + "id": "d470cb7e-2d7a-45e8-b610-da6a0d820882", "exec": [ "const {Property} = require('postman-collection');\r", "var xff = pm.collectionVariables.get('X-Forwarded-For');\r", @@ -1502,11 +1827,21 @@ } } ], - "id": "78b2749d-ecad-435f-b257-7d185f178682", + "id": "dc6c5d9a-9cd1-493e-9226-41cb0d50b3a1", "protocolProfileBehavior": { "disableBodyPruning": true }, "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{mechanicToken}}", + "type": "string" + } + ] + }, "method": "GET", "header": [ { @@ -1528,7 +1863,108 @@ ], "body": { "mode": "raw", - "raw": "{\"mechanic_code\":\"TRAC_JHN\",\"problem_details\":\"Hi Jhon\",\"vin\":\"{{VIN}}\",\"mechanic_api\":\"{{url}}/workshop/api/mechanic/receive_report\",\"repeat_request_if_failed\":false,\"number_of_repeats\":1}" + "raw": "" + }, + "url": { + "raw": "{{url}}/workshop/api/mechanic/service_requests?limit=30&offset=0", + "host": [ + "{{url}}" + ], + "path": [ + "workshop", + "api", + "mechanic", + "service_requests" + ], + "query": [ + { + "key": "limit", + "value": "30" + }, + { + "key": "offset", + "value": "0" + } + ] + } + }, + "response": [], + "uid": "13872198-dc6c5d9a-9cd1-493e-9226-41cb0d50b3a1" + }, + { + "name": "GetReport", + "event": [ + { + "listen": "test", + "script": { + "id": "4f6d9666-0933-4e5c-a4a1-efdd2e2c49aa", + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "id": "b30d69f4-b8cc-4e58-9acc-fe49d38a8a89", + "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" + } + } + ], + "id": "a992c051-2e26-42f6-8aba-52005b766363", + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{token}}", + "type": "string" + } + ] + }, + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJtb25zdGVyQGRhcmt3ZWIuY29tIiwiaWF0IjoxNjA4NTQzODI0LCJleHAiOjE2MDg2MzAyMjR9.AAIvhrtstlloPf7-NNCcmhEZm-XkO1aO3x3CLns1em7ft9U77B88LpK9jIrF8C-IH32JPWVazRFo0gBIBZ9FpA" + }, + { + "key": "User-Agent", + "value": "Mozilla/5.0 (Macintosh; Intel Mac OS X 11_1_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36" + }, + { + "key": "Accept", + "value": "*/*" + } + ], + "body": { + "mode": "raw", + "raw": "" }, "url": { "raw": "{{url}}/workshop/api/mechanic/mechanic_report?report_id={{report_id}}", @@ -1549,7 +1985,8 @@ ] } }, - "response": [] + "response": [], + "uid": "13872198-a992c051-2e26-42f6-8aba-52005b766363" }, { "name": "Get products", @@ -1557,7 +1994,7 @@ { "listen": "test", "script": { - "id": "943760c1-3ffe-4236-903a-50b40d20d1d6", + "id": "f58f20f7-878b-4ffa-b17a-835c779b561a", "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", @@ -1573,7 +2010,7 @@ { "listen": "prerequest", "script": { - "id": "8c7773ce-bfbf-4c89-90cb-1e8917fa3d78", + "id": "200fbc66-8abc-4d88-8d38-787ee390c27a", "exec": [ "const {Property} = require('postman-collection');\r", "var xff = pm.collectionVariables.get('X-Forwarded-For');\r", @@ -1596,11 +2033,21 @@ } } ], - "id": "c18a307b-b21b-4839-8403-3645e7d5b9c5", + "id": "f76df6ed-a560-4517-ae32-9bf7d7518896", "protocolProfileBehavior": { "disableBodyPruning": true }, "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{token}}", + "type": "string" + } + ] + }, "method": "GET", "header": [ { @@ -1629,7 +2076,8 @@ ] } }, - "response": [] + "response": [], + "uid": "13872198-f76df6ed-a560-4517-ae32-9bf7d7518896" }, { "name": "Validate coupon", @@ -1637,7 +2085,7 @@ { "listen": "test", "script": { - "id": "1dabfe9e-bb80-4eb3-a436-7c322af4ad14", + "id": "6c7102fd-abfd-44a1-bd70-aaf2d46ee7f1", "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", @@ -1649,7 +2097,7 @@ { "listen": "prerequest", "script": { - "id": "d43ae7a4-bf74-49e1-9099-ac44ef6a8cb3", + "id": "785896e4-8b48-4cec-957d-4b27ea74d5c3", "exec": [ "const {Property} = require('postman-collection');\r", "var xff = pm.collectionVariables.get('X-Forwarded-For');\r", @@ -1672,11 +2120,21 @@ } } ], - "id": "59d4b28e-3469-4791-b5e8-b72ab988b173", + "id": "443e66e0-34b9-4804-b761-bd62e7cc4288", "protocolProfileBehavior": { "disableBodyPruning": true }, "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{token}}", + "type": "string" + } + ] + }, "method": "POST", "header": [ { @@ -1714,7 +2172,8 @@ ] } }, - "response": [] + "response": [], + "uid": "13872198-443e66e0-34b9-4804-b761-bd62e7cc4288" }, { "name": "Apply coupon", @@ -1722,7 +2181,7 @@ { "listen": "prerequest", "script": { - "id": "f81179f1-dede-49ec-9e87-fe68a7436dc7", + "id": "51f8310b-533a-4f39-b7bc-c1da9906ae6f", "exec": [ "const {Property} = require('postman-collection');\r", "var xff = pm.collectionVariables.get('X-Forwarded-For');\r", @@ -1745,11 +2204,21 @@ } } ], - "id": "693df9e3-9e63-4cc6-be0c-c0caeafa1eea", + "id": "b3bd0f55-5f8c-4ea6-bca3-94993a1d1804", "protocolProfileBehavior": { "disableBodyPruning": true }, "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{token}}", + "type": "string" + } + ] + }, "method": "POST", "header": [ { @@ -1782,7 +2251,8 @@ ] } }, - "response": [] + "response": [], + "uid": "13872198-b3bd0f55-5f8c-4ea6-bca3-94993a1d1804" }, { "name": "Create Order", @@ -1790,7 +2260,7 @@ { "listen": "test", "script": { - "id": "494bc4be-eb14-4d81-8d3d-e3a796024a50", + "id": "6a143464-3847-43eb-bed4-89cec5a83a72", "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", @@ -1806,7 +2276,7 @@ { "listen": "prerequest", "script": { - "id": "da7db3f5-09b9-4d88-8234-10253cd014a2", + "id": "71cce0c9-d934-4353-be0f-47a19817003e", "exec": [ "const {Property} = require('postman-collection');\r", "var xff = pm.collectionVariables.get('X-Forwarded-For');\r", @@ -1829,11 +2299,21 @@ } } ], - "id": "b87d7feb-f128-4206-a8b7-d7f40815a1b0", + "id": "776bef3d-b912-4847-a268-2e452f9b238b", "protocolProfileBehavior": { "disableBodyPruning": true }, "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{token}}", + "type": "string" + } + ] + }, "method": "POST", "header": [ { @@ -1866,7 +2346,8 @@ ] } }, - "response": [] + "response": [], + "uid": "13872198-776bef3d-b912-4847-a268-2e452f9b238b" }, { "name": "Get orders", @@ -1874,7 +2355,7 @@ { "listen": "test", "script": { - "id": "ec7ea74a-8799-4142-bdb7-ca74183b5455", + "id": "67a60d41-74e2-4d55-90bb-9434ed930515", "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", @@ -1886,7 +2367,7 @@ { "listen": "prerequest", "script": { - "id": "332c5a36-476b-4dfc-8e3c-c3da667914a3", + "id": "8737b250-4b38-4cd9-8da4-549bc83fcd8e", "exec": [ "const {Property} = require('postman-collection');\r", "var xff = pm.collectionVariables.get('X-Forwarded-For');\r", @@ -1909,11 +2390,21 @@ } } ], - "id": "9094e2a9-d3b7-4ecb-a66d-2a87ec9ee421", + "id": "d8b2a762-c4ab-460d-91a9-c1f666897cb0", "protocolProfileBehavior": { "disableBodyPruning": true }, "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{token}}", + "type": "string" + } + ] + }, "method": "GET", "header": [ { @@ -1943,7 +2434,8 @@ ] } }, - "response": [] + "response": [], + "uid": "13872198-d8b2a762-c4ab-460d-91a9-c1f666897cb0" }, { "name": "Get Order", @@ -1951,7 +2443,7 @@ { "listen": "test", "script": { - "id": "fe055072-70ae-4dcf-9eeb-d762d914f5d5", + "id": "63c33dcb-8e01-49e8-b76f-dc552707b126", "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", @@ -1963,7 +2455,7 @@ { "listen": "prerequest", "script": { - "id": "272887d9-2467-4bbd-8b6c-c9ab22d847bb", + "id": "ee8efbbf-d317-4a0a-b6c2-9af346d11dfd", "exec": [ "const {Property} = require('postman-collection');\r", "var xff = pm.collectionVariables.get('X-Forwarded-For');\r", @@ -1986,11 +2478,21 @@ } } ], - "id": "3d8817d4-0952-4ac1-84c1-3db35e28655c", + "id": "a42bff0b-3401-410e-855b-6fcff08178e1", "protocolProfileBehavior": { "disableBodyPruning": true }, "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{token}}", + "type": "string" + } + ] + }, "method": "GET", "header": [ { @@ -2020,7 +2522,8 @@ ] } }, - "response": [] + "response": [], + "uid": "13872198-a42bff0b-3401-410e-855b-6fcff08178e1" }, { "name": "Return order", @@ -2028,7 +2531,7 @@ { "listen": "test", "script": { - "id": "b23313b6-db41-4f4c-8444-f50a9ab45ce9", + "id": "95bf82ce-48af-4157-a4aa-8e11dcb386ef", "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", @@ -2040,7 +2543,7 @@ { "listen": "prerequest", "script": { - "id": "e56a6acb-682a-43e8-a6f5-c2a0a727d4fb", + "id": "e2c85c92-3844-459d-8355-4e182b9786ba", "exec": [ "const {Property} = require('postman-collection');\r", "var xff = pm.collectionVariables.get('X-Forwarded-For');\r", @@ -2063,11 +2566,21 @@ } } ], - "id": "5dc85a94-3f8e-463c-9b40-66bbf9fa3f8f", + "id": "9bb458ba-48cf-4dab-b9f3-4b9789095b72", "protocolProfileBehavior": { "disableBodyPruning": true }, "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{token}}", + "type": "string" + } + ] + }, "method": "POST", "header": [ { @@ -2103,7 +2616,8 @@ ] } }, - "response": [] + "response": [], + "uid": "13872198-9bb458ba-48cf-4dab-b9f3-4b9789095b72" }, { "name": "Add video", @@ -2111,7 +2625,7 @@ { "listen": "test", "script": { - "id": "5895f73f-db45-415e-b872-f48d57468fb2", + "id": "f25025f1-7dd9-4ff2-b1df-90c34e74915f", "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", @@ -2128,7 +2642,7 @@ { "listen": "prerequest", "script": { - "id": "276fb107-06e0-444c-abdf-fe45a03e9c9a", + "id": "ca302a6a-c9b1-44c1-9ecc-66744ee10ba7", "exec": [ "const {Property} = require('postman-collection');\r", "var xff = pm.collectionVariables.get('X-Forwarded-For');\r", @@ -2151,14 +2665,24 @@ } } ], - "id": "5fd1f6c8-6615-430a-9649-d6b069a2b9e2", + "id": "7bba9029-97f6-458e-9b7a-65edcd364ef8", "protocolProfileBehavior": { - "disableBodyPruning": true, "disabledSystemHeaders": { "content-type": true - } + }, + "disableBodyPruning": true }, "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{token}}", + "type": "string" + } + ] + }, "method": "POST", "header": [ { @@ -2197,7 +2721,8 @@ ] } }, - "response": [] + "response": [], + "uid": "13872198-7bba9029-97f6-458e-9b7a-65edcd364ef8" }, { "name": "Get Video", @@ -2205,7 +2730,7 @@ { "listen": "test", "script": { - "id": "68aef3b9-bb21-4a31-ad68-9aadd266e719", + "id": "9610a1b1-fd62-4e42-9779-8c1cecb8b100", "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", @@ -2217,7 +2742,7 @@ { "listen": "prerequest", "script": { - "id": "db6cd700-8067-48d4-8059-3a7a7c71b2f0", + "id": "bc84846a-b858-49e9-b081-77b7c810596e", "exec": [ "const {Property} = require('postman-collection');\r", "var xff = pm.collectionVariables.get('X-Forwarded-For');\r", @@ -2240,11 +2765,21 @@ } } ], - "id": "76c10078-a6df-4c94-b1f5-e255f58c97dd", + "id": "e5d8f95f-404d-45f5-8df0-b524a2d9dece", "protocolProfileBehavior": { "disableBodyPruning": true }, "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{token}}", + "type": "string" + } + ] + }, "method": "GET", "header": [ { @@ -2275,7 +2810,8 @@ ] } }, - "response": [] + "response": [], + "uid": "13872198-e5d8f95f-404d-45f5-8df0-b524a2d9dece" }, { "name": "Change Video Name", @@ -2283,7 +2819,7 @@ { "listen": "test", "script": { - "id": "460d5f47-867d-4c03-b5fa-48d6af29d8bb", + "id": "529e0248-a28e-49bc-aafc-d31d0701aa90", "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", @@ -2295,7 +2831,7 @@ { "listen": "prerequest", "script": { - "id": "ae043c78-80b8-40b0-8374-34cca47a7317", + "id": "7b194f02-d120-4d6a-b38e-1faf7606e8c0", "exec": [ "const {Property} = require('postman-collection');\r", "var xff = pm.collectionVariables.get('X-Forwarded-For');\r", @@ -2318,11 +2854,21 @@ } } ], - "id": "1e741c34-e320-4a6d-9249-013b6f0eacdb", + "id": "66ef9d3e-6d22-4a6f-b2f2-73aec8c5f4cc", "protocolProfileBehavior": { "disableBodyPruning": true }, "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{token}}", + "type": "string" + } + ] + }, "method": "PUT", "header": [ { @@ -2357,7 +2903,8 @@ ] } }, - "response": [] + "response": [], + "uid": "13872198-66ef9d3e-6d22-4a6f-b2f2-73aec8c5f4cc" }, { "name": "Share video", @@ -2365,7 +2912,7 @@ { "listen": "test", "script": { - "id": "cd8a41fb-9621-431b-8520-bbaf7644ca54", + "id": "6d7b66b9-ee50-4b0b-b529-742a494211eb", "exec": [ "pm.test(\"Status code is 403\", function () {", " pm.response.to.have.status(403);", @@ -2379,7 +2926,7 @@ { "listen": "prerequest", "script": { - "id": "1567ead8-846c-446b-b788-3b0594cfcdb2", + "id": "b91969ad-e768-40fd-b3e4-8bb525f5061f", "exec": [ "const {Property} = require('postman-collection');\r", "var xff = pm.collectionVariables.get('X-Forwarded-For');\r", @@ -2402,11 +2949,21 @@ } } ], - "id": "d465a93a-0fa5-4327-a683-9756f2e5fe32", + "id": "d74fc742-a4aa-4a80-b52a-f528d72164cb", "protocolProfileBehavior": { "disableBodyPruning": true }, "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{token}}", + "type": "string" + } + ] + }, "method": "GET", "header": [ { @@ -2443,7 +3000,8 @@ ] } }, - "response": [] + "response": [], + "uid": "13872198-d74fc742-a4aa-4a80-b52a-f528d72164cb" }, { "name": "Get user dashboard", @@ -2451,10 +3009,195 @@ { "listen": "test", "script": { - "id": "16d7908d-3cca-4e2f-9446-a9654d902984", + "id": "01630281-abcf-4238-b4a2-e38d2fec16c8", + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "id": "c7d793e8-e008-4199-ba9a-6e47ac54746c", + "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" + } + } + ], + "id": "1482944a-48e9-4cb0-8bb8-35914843b76f", + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "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}}/identity/api/v2/user/dashboard", + "host": [ + "{{url}}" + ], + "path": [ + "identity", + "api", + "v2", + "user", + "dashboard" + ] + } + }, + "response": [], + "uid": "13872198-1482944a-48e9-4cb0-8bb8-35914843b76f" + }, + { + "name": "Add new video", + "event": [ + { + "listen": "test", + "script": { + "id": "f25d8fc0-edb3-48f3-9721-0ac92825c681", + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + " var jsonData = JSON.parse(responseBody);", + " var video_id = jsonData.id;", + " pm.collectionVariables.set(\"video_id\", video_id);", + " console.log(video_id);", + "});", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "prerequest", + "script": { + "id": "3510de26-4ffe-4a20-b77c-55b8c441a185", + "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" + } + } + ], + "id": "e19ac072-9f09-4564-b23e-94729143cf78", + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "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": "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW" + }, + { + "key": "Accept", + "value": "*/*" + } + ], + "body": { + "mode": "raw", + "raw": "\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"file\"; filename=\"abc.mp4\"\r\nContent-Type: video/mp4\r\n\r\nhakfhas\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--" + }, + "url": { + "raw": "{{url}}/identity/api/v2/user/videos", + "host": [ + "{{url}}" + ], + "path": [ + "identity", + "api", + "v2", + "user", + "videos" + ] + } + }, + "response": [], + "uid": "13872198-e19ac072-9f09-4564-b23e-94729143cf78" + }, + { + "name": "Delete video", + "event": [ + { + "listen": "test", + "script": { + "id": "4569b343-c5be-4b72-9a94-f409dd6ce7bb", "exec": [ - "pm.test(\"Status code is 200\", function () {", - " pm.response.to.have.status(200);", + "pm.test(\"Status code is 403\", function () {", + " pm.response.to.have.status(404);", "});" ], "type": "text/javascript" @@ -2463,7 +3206,7 @@ { "listen": "prerequest", "script": { - "id": "9d59315a-e25d-4eb7-81db-684b043a074e", + "id": "4670b368-098a-4935-b67a-ab518d0e78ce", "exec": [ "const {Property} = require('postman-collection');\r", "var xff = pm.collectionVariables.get('X-Forwarded-For');\r", @@ -2486,12 +3229,22 @@ } } ], - "id": "eff513a9-38e7-4d22-bf56-967c360f1d1b", + "id": "68c9d559-1009-4a99-bdf8-7376ae05f0f2", "protocolProfileBehavior": { "disableBodyPruning": true }, "request": { - "method": "GET", + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{token}}", + "type": "string" + } + ] + }, + "method": "DELETE", "header": [ { "key": "User-Agent", @@ -2507,7 +3260,7 @@ } ], "url": { - "raw": "{{url}}/identity/api/v2/user/dashboard", + "raw": "{{url}}/identity/api/v2/user/videos/{{video_id}}", "host": [ "{{url}}" ], @@ -2516,45 +3269,44 @@ "api", "v2", "user", - "dashboard" + "videos", + "{{video_id}}" ] } }, - "response": [] + "response": [], + "uid": "13872198-68c9d559-1009-4a99-bdf8-7376ae05f0f2" }, { - "name": "Add new video", + "name": "Admin Login", "event": [ { "listen": "test", "script": { - "id": "5895f73f-db45-415e-b872-f48d57468fb2", "exec": [ + "", "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", " var jsonData = JSON.parse(responseBody);", - " var video_id = jsonData.id;", - " pm.collectionVariables.set(\"video_id\", video_id);", - " console.log(video_id);", + " pm.collectionVariables.set(\"adminToken\", jsonData.token);", + " var token = pm.collectionVariables.get(\"adminToken\");", + " pm.test(\"Token is set\", function () {", + " pm.expect(jsonData.token).to.eql(token);", + " });", "});", "" ], - "type": "text/javascript" + "type": "text/javascript", + "id": "ecefadd8-d1fb-4415-a0b2-cfcae8216ac6" } }, { "listen": "prerequest", "script": { - "id": "276fb107-06e0-444c-abdf-fe45a03e9c9a", "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", + "var xff = Property.replaceSubstitutions('{{$randomIP}}');\r", + "pm.collectionVariables.set(\"X-Forwarded-For-Admin\", 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", @@ -2564,15 +3316,19 @@ " value: xff\r", "});" ], - "type": "text/javascript" + "type": "text/javascript", + "id": "96148952-7c1a-4316-8577-b7b0cc59fdb4" } } ], - "id": "aad230d3-1318-44ca-acd7-c5a2de4d80f6", + "id": "29cdda38-7bdf-471c-9a17-9217e4749ce2", "protocolProfileBehavior": { "disableBodyPruning": true }, "request": { + "auth": { + "type": "noauth" + }, "method": "POST", "header": [ { @@ -2581,7 +3337,7 @@ }, { "key": "Content-Type", - "value": "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW" + "value": "application/json" }, { "key": "Accept", @@ -2590,34 +3346,38 @@ ], "body": { "mode": "raw", - "raw": "\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"file\"; filename=\"abc.mp4\"\r\nContent-Type: video/mp4\r\n\r\nhakfhas\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--" + "raw": "{\"email\":\"admin@example.com\",\"password\":\"Admin!123\"}" }, "url": { - "raw": "{{url}}/identity/api/v2/user/videos", + "raw": "{{url}}/identity/api/auth/login", "host": [ "{{url}}" ], "path": [ "identity", "api", - "v2", - "user", - "videos" + "auth", + "login" ] } }, - "response": [] + "response": [], + "uid": "13872198-29cdda38-7bdf-471c-9a17-9217e4749ce2" }, { - "name": "Delete video", + "name": "Add Product", "event": [ { "listen": "test", "script": { - "id": "68aef3b9-bb21-4a31-ad68-9aadd266e719", + "id": "f58f20f7-878b-4ffa-b17a-835c779b561a", "exec": [ - "pm.test(\"Status code is 403\", function () {", - " pm.response.to.have.status(404);", + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + " var jsonData = pm.response.json();", + " var productId = jsonData.id;", + " pm.collectionVariables.set(\"product_id\", productId);", + " console.log(\"Product ID \", productId);", "});" ], "type": "text/javascript" @@ -2626,7 +3386,7 @@ { "listen": "prerequest", "script": { - "id": "f80b27fb-14f8-4b29-b3f1-3e7eb6407d28", + "id": "200fbc66-8abc-4d88-8d38-787ee390c27a", "exec": [ "const {Property} = require('postman-collection');\r", "var xff = pm.collectionVariables.get('X-Forwarded-For');\r", @@ -2649,12 +3409,22 @@ } } ], - "id": "339ba02c-b183-48f8-a2e9-f5c401de4167", + "id": "c9414a2a-aac8-4db6-be4d-b501931922d7", "protocolProfileBehavior": { "disableBodyPruning": true }, "request": { - "method": "DELETE", + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{adminToken}}", + "type": "string" + } + ] + }, + "method": "POST", "header": [ { "key": "User-Agent", @@ -2669,53 +3439,52 @@ "value": "*/*" } ], + "body": { + "mode": "raw", + "raw": "{\n \"name\": \"NewSeat\",\n \"price\": 100,\n \"image_url\": \"images/seat.svg\"\n}" + }, "url": { - "raw": "{{url}}/identity/api/v2/user/videos/{{video_id}}", + "raw": "{{url}}/workshop/api/shop/products", "host": [ "{{url}}" ], "path": [ - "identity", + "workshop", "api", - "v2", - "user", - "videos", - "{{video_id}}" + "shop", + "products" ] } }, - "response": [] + "response": [], + "uid": "13872198-c9414a2a-aac8-4db6-be4d-b501931922d7" }, { - "name": "Admin Login", + "name": "Delete video by admin", "event": [ { "listen": "test", "script": { - "id": "9f78ac74-9343-43a2-93b9-08ac1e0e3495", "exec": [ - "", "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", - " var jsonData = JSON.parse(responseBody);", - " pm.collectionVariables.set(\"adminToken\", jsonData.token);", - " var token = pm.collectionVariables.get(\"adminToken\");", - " pm.test(\"Token is set\", function () {", - " pm.expect(jsonData.token).to.eql(token);", - " });", - "});", - "" + "});" ], - "type": "text/javascript" + "type": "text/javascript", + "id": "7ec00694-305a-425c-a234-38349add316d" } }, { "listen": "prerequest", "script": { - "id": "08e257a1-3205-45e4-a75f-0c8f6cfe0113", "exec": [ "const {Property} = require('postman-collection');\r", - "var xff = Property.replaceSubstitutions('{{$randomIP}}');\r", + "var xff = pm.collectionVariables.get('X-Forwarded-For-Admin');\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-Admin\", xff);\r", "pm.request.headers.remove('X-Forwarded-For');\r", "pm.request.headers.add({ \r", @@ -2726,19 +3495,27 @@ " value: xff\r", "});" ], - "type": "text/javascript" + "type": "text/javascript", + "id": "20b3646f-e7ed-47c8-9aa0-d0ac7428f675" } } ], - "id": "7035a54a-536c-4dc7-ab8c-2b5d50af06a7", + "id": "62277a20-07b8-4954-8188-e41729cf4f39", "protocolProfileBehavior": { "disableBodyPruning": true }, "request": { "auth": { - "type": "noauth" + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{adminToken}}", + "type": "string" + } + ] }, - "method": "POST", + "method": "DELETE", "header": [ { "key": "User-Agent", @@ -2753,36 +3530,40 @@ "value": "*/*" } ], - "body": { - "mode": "raw", - "raw": "{\"email\":\"admin@example.com\",\"password\":\"Admin!123\"}" - }, "url": { - "raw": "{{url}}/identity/api/auth/login", + "raw": "{{url}}/identity/api/v2/admin/videos/{{video_id}}", "host": [ "{{url}}" ], "path": [ "identity", "api", - "auth", - "login" + "v2", + "admin", + "videos", + "{{video_id}}" ] } }, - "response": [] + "response": [], + "uid": "13872198-62277a20-07b8-4954-8188-e41729cf4f39" }, { - "name": "Delete video by admin", + "name": "ReAdd new video", "event": [ { "listen": "test", "script": { - "id": "68aef3b9-bb21-4a31-ad68-9aadd266e719", + "id": "77752d0e-50d9-4a7f-bf6c-80dabacd5563", "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", - "});" + " var jsonData = JSON.parse(responseBody);", + " var video_id = jsonData.id;", + " pm.collectionVariables.set(\"video_id\", video_id);", + " console.log(video_id);", + "});", + "" ], "type": "text/javascript" } @@ -2790,16 +3571,16 @@ { "listen": "prerequest", "script": { - "id": "b064fb58-e796-44da-8d55-460fac7f5213", + "id": "7e0b3d53-0e0e-4d88-829c-541c5ecdae2b", "exec": [ "const {Property} = require('postman-collection');\r", - "var xff = pm.collectionVariables.get('X-Forwarded-For-Admin');\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-Admin\", 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", @@ -2813,7 +3594,7 @@ } } ], - "id": "b1895b03-74bc-4366-b974-88456ffc60c0", + "id": "0eaef3a1-e5b8-4756-bbe7-1eaefa4173d8", "protocolProfileBehavior": { "disableBodyPruning": true }, @@ -2823,12 +3604,12 @@ "bearer": [ { "key": "token", - "value": "{{adminToken}}", + "value": "{{token}}", "type": "string" } ] }, - "method": "DELETE", + "method": "POST", "header": [ { "key": "User-Agent", @@ -2836,15 +3617,19 @@ }, { "key": "Content-Type", - "value": "application/json" + "value": "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW" }, { "key": "Accept", "value": "*/*" } ], + "body": { + "mode": "raw", + "raw": "\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"file\"; filename=\"abc.mp4\"\r\nContent-Type: video/mp4\r\n\r\nhakfhas\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--" + }, "url": { - "raw": "{{url}}/identity/api/v2/admin/videos/{{video_id}}", + "raw": "{{url}}/identity/api/v2/user/videos", "host": [ "{{url}}" ], @@ -2852,21 +3637,21 @@ "identity", "api", "v2", - "admin", - "videos", - "{{video_id}}" + "user", + "videos" ] } }, - "response": [] + "response": [], + "uid": "13872198-0eaef3a1-e5b8-4756-bbe7-1eaefa4173d8" }, { - "name": "ReAdd new video", + "name": "Get Workshop User Details", "event": [ { "listen": "test", "script": { - "id": "5895f73f-db45-415e-b872-f48d57468fb2", + "id": "77752d0e-50d9-4a7f-bf6c-80dabacd5563", "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", @@ -2883,7 +3668,7 @@ { "listen": "prerequest", "script": { - "id": "276fb107-06e0-444c-abdf-fe45a03e9c9a", + "id": "7e0b3d53-0e0e-4d88-829c-541c5ecdae2b", "exec": [ "const {Property} = require('postman-collection');\r", "var xff = pm.collectionVariables.get('X-Forwarded-For');\r", @@ -2906,12 +3691,22 @@ } } ], - "id": "c65d9d61-0670-488f-9de5-4c31174d2bd2", + "id": "b5d507ef-ece1-4b81-b3ab-67d14f15e56c", "protocolProfileBehavior": { "disableBodyPruning": true }, "request": { - "method": "POST", + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{adminToken}}", + "type": "string" + } + ] + }, + "method": "GET", "header": [ { "key": "User-Agent", @@ -2931,20 +3726,31 @@ "raw": "\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"file\"; filename=\"abc.mp4\"\r\nContent-Type: video/mp4\r\n\r\nhakfhas\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--" }, "url": { - "raw": "{{url}}/identity/api/v2/user/videos", + "raw": "{{url}}/workshop/api/management/users/all?limit=30&offset=0", "host": [ "{{url}}" ], "path": [ - "identity", + "workshop", "api", - "v2", - "user", - "videos" + "management", + "users", + "all" + ], + "query": [ + { + "key": "limit", + "value": "30" + }, + { + "key": "offset", + "value": "0" + } ] } }, - "response": [] + "response": [], + "uid": "13872198-b5d507ef-ece1-4b81-b3ab-67d14f15e56c" }, { "name": "Change email", @@ -2952,7 +3758,7 @@ { "listen": "test", "script": { - "id": "2f5e6a1e-61b9-4f70-9358-77bb62890c36", + "id": "38a418ce-9e8e-4ceb-9ad5-ee89ee0af464", "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", @@ -2964,7 +3770,7 @@ { "listen": "prerequest", "script": { - "id": "596bd2dd-bbf9-40a8-a761-cdcfe43d85ec", + "id": "21130742-f16a-44cd-ac8b-190d25fcdf54", "exec": [ "const {Property} = require('postman-collection');\r", "var xff = pm.collectionVariables.get('X-Forwarded-For');\r", @@ -2987,11 +3793,21 @@ } } ], - "id": "c4a08b50-4d6d-4e89-9c3a-f39920170032", + "id": "14fa4db8-ea42-40ff-ae75-cb9b1c6f5f78", "protocolProfileBehavior": { "disableBodyPruning": true }, "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{token}}", + "type": "string" + } + ] + }, "method": "POST", "header": [ { @@ -3025,7 +3841,8 @@ ] } }, - "response": [] + "response": [], + "uid": "13872198-14fa4db8-ea42-40ff-ae75-cb9b1c6f5f78" }, { "name": "SearchMailVerificationToken", @@ -3033,7 +3850,6 @@ { "listen": "test", "script": { - "id": "fe2c7752-b716-4787-89c8-95587a2ad57e", "exec": [ "", "", @@ -3071,13 +3887,13 @@ "});", "" ], - "type": "text/javascript" + "type": "text/javascript", + "id": "e7a12935-7dcc-4524-a0ca-47500df1041d" } }, { "listen": "prerequest", "script": { - "id": "6c4ddaff-ff87-43fa-8acf-219a455dc3c3", "exec": [ "const {Property} = require('postman-collection');\r", "var xff = pm.collectionVariables.get('X-Forwarded-For');\r", @@ -3096,11 +3912,12 @@ " value: xff\r", "});" ], - "type": "text/javascript" + "type": "text/javascript", + "id": "8104da9e-1e65-4741-957c-1b60715198d3" } } ], - "id": "eae8cd29-3263-45e2-8c0d-9778a2cdc2db", + "id": "9bdb45a6-0cbc-416b-813b-c63513a9fb78", "protocolProfileBehavior": { "disableBodyPruning": true }, @@ -3150,7 +3967,8 @@ ] } }, - "response": [] + "response": [], + "uid": "13872198-9bdb45a6-0cbc-416b-813b-c63513a9fb78" }, { "name": "Verify email token", @@ -3158,7 +3976,7 @@ { "listen": "test", "script": { - "id": "1e128817-13c7-4d26-9094-bc5c5c8bc846", + "id": "9bd693bc-3f61-4b0e-a1de-fbb852f1bc1b", "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", @@ -3170,7 +3988,7 @@ { "listen": "prerequest", "script": { - "id": "32c4af06-26c1-4843-b928-242193ce338f", + "id": "20995566-89c9-424f-a135-8035330f6f22", "exec": [ "const {Property} = require('postman-collection');\r", "var xff = pm.collectionVariables.get('X-Forwarded-For');\r", @@ -3193,11 +4011,21 @@ } } ], - "id": "07386f04-f0e8-4ffd-9312-0789534eb826", + "id": "a2543f67-c10e-450e-8f43-1ce3bff4a5e4", "protocolProfileBehavior": { "disableBodyPruning": true }, "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{token}}", + "type": "string" + } + ] + }, "method": "POST", "header": [ { @@ -3231,7 +4059,8 @@ ] } }, - "response": [] + "response": [], + "uid": "13872198-a2543f67-c10e-450e-8f43-1ce3bff4a5e4" }, { "name": "Login Back", @@ -3239,7 +4068,6 @@ { "listen": "test", "script": { - "id": "efbd6318-e2ca-4a1c-9c7d-5f76124c039a", "exec": [ "", "pm.test(\"Status code is 200\", function () {", @@ -3253,13 +4081,13 @@ "});", "" ], - "type": "text/javascript" + "type": "text/javascript", + "id": "f63d459c-2004-4718-9d85-cfabe679c33f" } }, { "listen": "prerequest", "script": { - "id": "2c56ed4f-eb1c-4daa-ac6b-0e08ca6e3f28", "exec": [ "const {Property} = require('postman-collection');\r", "var xff = pm.collectionVariables.get('X-Forwarded-For');\r", @@ -3278,11 +4106,12 @@ " value: xff\r", "});" ], - "type": "text/javascript" + "type": "text/javascript", + "id": "113f6e16-a21c-4cfb-9c8e-da3dff482826" } } ], - "id": "5d58c4ba-58e5-4bb8-b811-d269bea71f8f", + "id": "1db55c21-1d59-4477-98d9-fe5640fff62c", "protocolProfileBehavior": { "disableBodyPruning": true }, @@ -3322,7 +4151,8 @@ ] } }, - "response": [] + "response": [], + "uid": "13872198-1db55c21-1d59-4477-98d9-fe5640fff62c" }, { "name": "Change email Back", @@ -3330,7 +4160,7 @@ { "listen": "test", "script": { - "id": "70415a06-9323-4c41-a7e6-f969182bf66d", + "id": "c848598b-7d28-4806-8ad5-0d7e20a9d950", "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", @@ -3342,7 +4172,7 @@ { "listen": "prerequest", "script": { - "id": "11b8f9ff-9c82-4f2f-9680-feb981b2d7f7", + "id": "3ff5d22f-d710-4ed7-afa4-d115e85ea824", "exec": [ "const {Property} = require('postman-collection');\r", "var xff = pm.collectionVariables.get('X-Forwarded-For');\r", @@ -3365,11 +4195,21 @@ } } ], - "id": "13149265-d58c-439f-be95-9919e3246bf0", + "id": "e09f649c-7215-4aca-9b50-1b1acb8c7f95", "protocolProfileBehavior": { "disableBodyPruning": true }, "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{token}}", + "type": "string" + } + ] + }, "method": "POST", "header": [ { @@ -3403,7 +4243,8 @@ ] } }, - "response": [] + "response": [], + "uid": "13872198-e09f649c-7215-4aca-9b50-1b1acb8c7f95" }, { "name": "SearchMailVerificationToken Back", @@ -3411,7 +4252,7 @@ { "listen": "test", "script": { - "id": "c15e8800-1d01-401e-8931-03b5d8952041", + "id": "77bac1af-c8c4-4989-b04c-1e351c8fd482", "exec": [ "", "function dynamicSort(property) {", @@ -3454,7 +4295,7 @@ { "listen": "prerequest", "script": { - "id": "4500a35d-a34a-419b-a641-a63deb9a35a1", + "id": "b2332f48-9202-415b-baa4-43e43d9ecd55", "exec": [ "const {Property} = require('postman-collection');\r", "var xff = pm.collectionVariables.get('X-Forwarded-For');\r", @@ -3477,11 +4318,14 @@ } } ], - "id": "52e03cf6-c401-4ce3-8e74-bc1da604af14", + "id": "d4e9595d-f33f-4548-bae5-b852749ad857", "protocolProfileBehavior": { "disableBodyPruning": true }, "request": { + "auth": { + "type": "noauth" + }, "method": "GET", "header": [ { @@ -3523,7 +4367,8 @@ ] } }, - "response": [] + "response": [], + "uid": "13872198-d4e9595d-f33f-4548-bae5-b852749ad857" }, { "name": "Verify email token Back", @@ -3531,7 +4376,7 @@ { "listen": "test", "script": { - "id": "8ce19507-6497-462d-b850-32b4bae603b6", + "id": "71747391-89fb-4364-bd0b-aea2c2d8a71e", "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", @@ -3543,7 +4388,7 @@ { "listen": "prerequest", "script": { - "id": "913f1dfe-9f4a-4a67-a191-fd505def4101", + "id": "3f45fffa-8639-49d8-be61-203d91dd3e6b", "exec": [ "const {Property} = require('postman-collection');\r", "var xff = pm.collectionVariables.get('X-Forwarded-For');\r", @@ -3566,11 +4411,21 @@ } } ], - "id": "5c96d385-7d37-46ab-93f5-bb96bb14a7a9", + "id": "4c8b0ba7-01f8-4070-9f0c-11c187878ca7", "protocolProfileBehavior": { "disableBodyPruning": true }, "request": { + "auth": { + "type": "bearer", + "bearer": [ + { + "key": "token", + "value": "{{token}}", + "type": "string" + } + ] + }, "method": "POST", "header": [ { @@ -3604,7 +4459,8 @@ ] } }, - "response": [] + "response": [], + "uid": "13872198-4c8b0ba7-01f8-4070-9f0c-11c187878ca7" }, { "name": "Login", @@ -3612,7 +4468,6 @@ { "listen": "test", "script": { - "id": "9f78ac74-9343-43a2-93b9-08ac1e0e3495", "exec": [ "", "pm.test(\"Status code is 200\", function () {", @@ -3626,13 +4481,13 @@ "});", "" ], - "type": "text/javascript" + "type": "text/javascript", + "id": "d00789ea-c0b8-4df0-bb89-dd64aa184034" } }, { "listen": "prerequest", "script": { - "id": "7cba83e4-7c91-45cf-92bd-583d22882cad", "exec": [ "const {Property} = require('postman-collection');\r", "var xff = pm.collectionVariables.get('X-Forwarded-For');\r", @@ -3651,11 +4506,12 @@ " value: xff\r", "});" ], - "type": "text/javascript" + "type": "text/javascript", + "id": "5db56e2d-beea-4c35-ad5c-0821e4827c89" } } ], - "id": "1c3bdecd-846e-482d-aef5-8cf9957af323", + "id": "2814846e-5762-42e8-adef-a47c76acb06c", "protocolProfileBehavior": { "disableBodyPruning": true }, @@ -3695,7 +4551,8 @@ ] } }, - "response": [] + "response": [], + "uid": "13872198-2814846e-5762-42e8-adef-a47c76acb06c" }, { "name": "Get Public Key", @@ -3709,11 +4566,11 @@ "});" ], "type": "text/javascript", - "id": "13612403-9af5-4248-b79f-53294102aab5" + "id": "2824bbc2-dcc8-49d3-bbf5-593d32de8651" } } ], - "id": "3f18f71e-dff2-4e6c-887f-530f5b8dd901", + "id": "a29f188e-0ad9-46d8-9282-473d63ab1cbb", "protocolProfileBehavior": { "disableBodyPruning": true }, @@ -3743,24 +4600,15 @@ ] } }, - "response": [] + "response": [], + "uid": "13872198-a29f188e-0ad9-46d8-9282-473d63ab1cbb" } ], - "auth": { - "type": "bearer", - "bearer": [ - { - "key": "token", - "value": "{{token}}", - "type": "string" - } - ] - }, "event": [ { "listen": "prerequest", "script": { - "id": "e843b75c-a27d-4c6f-bd54-60870722d8d8", + "id": "4be90437-8204-4d9d-918d-09768b990a8e", "type": "text/javascript", "exec": [ "const {Property} = require('postman-collection');", @@ -3785,7 +4633,7 @@ { "listen": "test", "script": { - "id": "f1f15ef0-b0ac-4b31-967f-03e8b2e80fb5", + "id": "86278886-cc27-487e-afcd-d3b28158991c", "type": "text/javascript", "exec": [ "" @@ -3795,94 +4643,88 @@ ], "variable": [ { - "id": "976b8d4c-2b5c-4199-bd21-fddf0e9c9204", "key": "X-Forwarded-For", "value": "" }, { - "id": "b0be61d8-3e49-46ec-8f34-9751bae846c4", "key": "X-Forwarded-For-Admin", "value": "" }, { - "id": "2115e633-b732-4edb-aa53-d037fb45d512", "key": "vehicle_id", "value": "" }, { - "id": "5f6e435d-677f-439d-9a83-f6a17ddbd406", "key": "name", "value": "" }, { - "id": "c583957b-eb70-4989-8692-eb9170d1b6ec", "key": "new_name", "value": "" }, { - "id": "ba19d5ef-b2ec-4be1-a48e-891f208f67d4", "key": "email", "value": "" }, { - "id": "d11f3965-a5b0-4bb6-9cce-26f5ab1ece95", "key": "new_email", "value": "" }, { - "id": "74164c23-852f-4d8f-9cbf-d315b653962c", "key": "password", "value": "" }, { - "id": "b8a812fa-9fb3-4906-934e-988999236b46", "key": "phone", "value": "" }, { - "id": "23de9e91-4ef8-4544-959d-82e9333bf74a", "key": "token", "value": "" }, { - "id": "3ca15d6a-41fe-4f2a-9b29-70eaa64a5638", "key": "VIN", "value": "" }, { - "id": "fe426f51-690f-470f-8bc0-a4d8e2987e54", "key": "PIN", "value": "" }, { - "id": "8510b1ab-0fb8-4e2b-8649-7c53717b75e2", "key": "report_id", "value": "" }, { - "id": "04a90206-9df3-4270-ab46-d891ec756ce2", "key": "product_id", "value": "" }, { - "id": "839cfae5-b1f7-4ba4-ad76-bd1b54a4f32e", "key": "order_id", "value": "" }, { - "id": "e9edb208-a992-4df9-936a-bc87d9eefed3", "key": "video_id", "value": "" }, { - "id": "e9f45f5f-2733-4115-882c-23f2715a598e", "key": "adminToken", "value": "" }, { - "id": "83d244c7-b3e5-4292-ab77-d4f297cc08e1", "key": "email_token", "value": "" + }, + { + "key": "OTP", + "value": "" + }, + { + "key": "post_id", + "value": "" + }, + { + "key": "mechanicToken", + "value": "" } ] } diff --git a/services/community/api/controllers/post_controller.go b/services/community/api/controllers/post_controller.go index 2372f2e5..7115881f 100644 --- a/services/community/api/controllers/post_controller.go +++ b/services/community/api/controllers/post_controller.go @@ -87,15 +87,15 @@ func (s *Server) GetPost(w http.ResponseWriter, r *http.Request) { limit = 50 } - page_param := r.URL.Query().Get("page") - page := 0 - if page_param != "" { - page, err = strconv.Atoi(page_param) + offset := 0 + offset_param := r.URL.Query().Get("offset") + if offset_param != "" { + offset, err = strconv.Atoi(offset_param) if err != nil { - page = 0 + offset = 0 } } - posts, err := models.FindAllPost(s.Client, page, limit) + posts, err := models.FindAllPost(s.Client, offset, limit) if err != nil { responses.ERROR(w, http.StatusInternalServerError, err) diff --git a/services/community/api/models/post.go b/services/community/api/models/post.go index 3d81537e..a6c11de1 100644 --- a/services/community/api/models/post.go +++ b/services/community/api/models/post.go @@ -104,13 +104,13 @@ func GetPostByID(client *mongo.Client, ID string) (Post, error) { } //FindAllPost return all recent post -func FindAllPost(client *mongo.Client, page int, limit int) ([]interface{}, error) { +func FindAllPost(client *mongo.Client, offset int, limit int) ([]interface{}, error) { post := []Post{} options := options.Find() options.SetSort(bson.D{{"_id", -1}}) options.SetLimit(int64(limit)) - options.SetSkip(int64(page * limit)) + options.SetSkip(int64(offset * limit)) collection := client.Database("crapi").Collection("post") cur, err := collection.Find(context.Background(), bson.D{}, options) if err != nil { diff --git a/services/identity/src/main/resources/application.properties b/services/identity/src/main/resources/application.properties index 9a433948..fb846ec8 100644 --- a/services/identity/src/main/resources/application.properties +++ b/services/identity/src/main/resources/application.properties @@ -15,7 +15,7 @@ spring.jpa.hibernate.ddl-auto=update app.jwksJson=${JWKS} -app.jwtExpiration=${JWT_EXPIRATION} +app.jwtExpiration=${JWT_EXPIRATION:604800000} #Mail Configuration mail.from=${SMTP_FROM} diff --git a/services/workshop/crapi/admin.py b/services/workshop/crapi/admin.py index fd70a4eb..c9848ef2 100644 --- a/services/workshop/crapi/admin.py +++ b/services/workshop/crapi/admin.py @@ -19,7 +19,7 @@ from crapi.mechanic.models import ServiceRequest, Mechanic from crapi.shop.models import Order, Product, AppliedCoupon -from user.models import User, UserDetails, Vehicle +from crapi.user.models import User, UserDetails, Vehicle admin.site.register(Order) admin.site.register(User) diff --git a/services/workshop/crapi/apps.py b/services/workshop/crapi/apps.py index f99a502a..f0534e7b 100644 --- a/services/workshop/crapi/apps.py +++ b/services/workshop/crapi/apps.py @@ -55,7 +55,7 @@ def create_products(): logger.info("Created Product: "+str(product.__dict__)) def create_mechanics(): - from user.models import User, UserDetails + from crapi.user.models import User, UserDetails from crapi.mechanic.models import Mechanic mechanic_details_all = [ { @@ -100,7 +100,7 @@ def create_mechanics(): logger.info("Created User: "+str(user.__dict__)) else: user = uset.first() - + if Mechanic.objects.filter(mechanic_code=mechanic_details['mechanic_code']): logger.info("Mechanic already exists. Skipping: " + mechanic_details['mechanic_code'] @@ -133,7 +133,7 @@ def create_reports(): import random import sys import textwrap - from user.models import User, UserDetails, Vehicle + from crapi.user.models import User, UserDetails, Vehicle from crapi.mechanic.models import Mechanic, ServiceRequest from django.utils import timezone count = ServiceRequest.objects.all().count() @@ -159,14 +159,14 @@ def create_reports(): problem_details=textwrap.dedent("""\ My car {} - {} is having issues. Can you give me a call on my mobile {}, - Or send me an email at {} + Or send me an email at {} Thanks, {}. """.format( - vehicle_company.name, + vehicle_company.name, vehicle_model.model, - user.number, - user.email, + user.number, + user.email, user_detail.name) ), status=status, @@ -180,7 +180,7 @@ def create_reports(): def create_orders(): import uuid - from user.models import User, UserDetails + from crapi.user.models import User, UserDetails from crapi.shop.models import Product from crapi.shop.models import Order if Order.objects.all().count() >= 1: @@ -205,9 +205,9 @@ def create_orders(): ) order2.save() logger.info("Created Order:2: "+str(order2.__dict__)) - - - + + + class CRAPIConfig(AppConfig): diff --git a/services/workshop/crapi/mechanic/models.py b/services/workshop/crapi/mechanic/models.py index 4fcc1b38..7d6bf721 100644 --- a/services/workshop/crapi/mechanic/models.py +++ b/services/workshop/crapi/mechanic/models.py @@ -18,7 +18,7 @@ """ from django.db import models -from user.models import User, Vehicle +from crapi.user.models import User, Vehicle from collections import OrderedDict from extended_choices import Choices from django_db_cascade.fields import ForeignKey, OneToOneField diff --git a/services/workshop/crapi/mechanic/serializers.py b/services/workshop/crapi/mechanic/serializers.py index 32643bde..7c666914 100644 --- a/services/workshop/crapi/mechanic/serializers.py +++ b/services/workshop/crapi/mechanic/serializers.py @@ -18,7 +18,7 @@ from rest_framework import serializers from crapi.mechanic.models import Mechanic, ServiceRequest -from user.serializers import UserSerializer, VehicleSerializer +from crapi.user.serializers import UserSerializer, VehicleSerializer class MechanicSerializer(serializers.ModelSerializer): diff --git a/services/workshop/crapi/mechanic/tests.py b/services/workshop/crapi/mechanic/tests.py index b7030257..1c22a92b 100644 --- a/services/workshop/crapi/mechanic/tests.py +++ b/services/workshop/crapi/mechanic/tests.py @@ -150,4 +150,4 @@ def test_bad_request(self): res = self.client.post('/workshop/api/mechanic/signup', self.mechanic, content_type="application/json") - self.assertNotEqual(res.status_code, 200) + self.assertEqual(res.status_code, 400) diff --git a/services/workshop/crapi/mechanic/views.py b/services/workshop/crapi/mechanic/views.py index 35bdc6fa..23c816e7 100644 --- a/services/workshop/crapi/mechanic/views.py +++ b/services/workshop/crapi/mechanic/views.py @@ -25,11 +25,13 @@ from django.db import models from utils.jwt import jwt_auth_required from utils import messages -from user.models import User, Vehicle, UserDetails +from crapi.user.models import User, Vehicle, UserDetails from utils.logging import log_error from .models import Mechanic, ServiceRequest from .serializers import MechanicSerializer, ServiceRequestSerializer, ReceiveReportSerializer, SignUpSerializer - +DEFAULT_LIMIT = 10 +DEFAULT_OFFSET = 0 +MAX_LIMIT = 100 class SignUpView(APIView): """ @@ -204,7 +206,22 @@ def get(self, request, user=None): list of service request object and 200 status if no error message and corresponding status if error """ - service_requests = ServiceRequest.objects.filter(mechanic__user=user) + limit = request.GET.get('limit', str(DEFAULT_LIMIT)) + offset = request.GET.get('offset', str(DEFAULT_OFFSET)) + if not limit.isdigit() or not offset.isdigit(): + return Response( + {'message': messages.INVALID_LIMIT_OR_OFFSET}, + status=status.HTTP_400_BAD_REQUEST + ) + limit = int(limit) + offset = int(offset) + if limit > MAX_LIMIT: + limit = 100 + if limit < 0: + limit = DEFAULT_LIMIT + if offset < 0: + offset = DEFAULT_OFFSET + service_requests = ServiceRequest.objects.filter(mechanic__user=user).order_by('id')[offset:offset+limit] serializer = ServiceRequestSerializer(service_requests, many=True) response_data = dict( service_requests=serializer.data diff --git a/services/workshop/crapi/merchant/serializers.py b/services/workshop/crapi/merchant/serializers.py index 1ffc74f5..09074715 100644 --- a/services/workshop/crapi/merchant/serializers.py +++ b/services/workshop/crapi/merchant/serializers.py @@ -23,5 +23,5 @@ class ContactMechanicSerializer(serializers.Serializer): Serializer for Contact Mechanic model. """ mechanic_api = serializers.CharField() - repeat_request_if_failed = serializers.BooleanField() - number_of_repeats = serializers.IntegerField() + repeat_request_if_failed = serializers.BooleanField(required=False) + number_of_repeats = serializers.IntegerField(required=False) diff --git a/services/workshop/crapi/merchant/tests.py b/services/workshop/crapi/merchant/tests.py index 85edc213..7ba8f65e 100644 --- a/services/workshop/crapi/merchant/tests.py +++ b/services/workshop/crapi/merchant/tests.py @@ -22,7 +22,7 @@ from django.test import TestCase, Client from django.utils import timezone from utils import messages -from user.models import User, Vehicle, VehicleModel, VehicleCompany +from crapi.user.models import User, Vehicle, VehicleModel, VehicleCompany class MerchantTestCase(TestCase): @@ -135,7 +135,7 @@ def test_contact_mechanic(self): self.assertIn('Google', res.json()['response_from_mechanic_api']) - def test_bad_request(self): + def test_repeat_missing_request(self): """ deletes repeat_request_if_failed field from contact_mechanic request body should get a bad request response @@ -146,7 +146,7 @@ def test_bad_request(self): self.contact_mechanic_request_body, **self.user_auth_headers, content_type="application/json") - self.assertNotEqual(res.status_code, 200) + self.assertEqual(res.status_code, 200) def test_receive_report_and_get_report(self): """ diff --git a/services/workshop/crapi/merchant/views.py b/services/workshop/crapi/merchant/views.py index 1f9f2a7a..06f516c5 100644 --- a/services/workshop/crapi/merchant/views.py +++ b/services/workshop/crapi/merchant/views.py @@ -21,7 +21,6 @@ from rest_framework import status from rest_framework.response import Response from rest_framework.views import APIView - from crapi.merchant.serializers import ContactMechanicSerializer from utils.jwt import jwt_auth_required from utils import messages @@ -41,7 +40,7 @@ def post(self, request, user=None): :param request: http request for the view method allowed: POST http request should be authorised by the jwt token of the user - mandatory fields: ['mechanic_api', 'repeat_request_if_failed', 'number_of_repeats'] + mandatory fields: ['mechanic_api'] :param user: User object of the requesting user :returns Response object with response_from_mechanic_api and 200 status if no error @@ -53,8 +52,8 @@ def post(self, request, user=None): log_error(request.path, request.data, status.HTTP_400_BAD_REQUEST, serializer.errors) return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) - repeat_request_if_failed = request_data['repeat_request_if_failed'] - number_of_repeats = request_data['number_of_repeats'] + repeat_request_if_failed = request_data.get('repeat_request_if_failed', False) + number_of_repeats = request_data.get('number_of_repeats', 1) if repeat_request_if_failed and number_of_repeats < 1: return Response( {'message': messages.MIN_NO_OF_REPEATS_FAILED}, diff --git a/services/workshop/crapi/migrations/0001_initial.py b/services/workshop/crapi/migrations/0001_initial.py index e78ef092..35fc5d65 100644 --- a/services/workshop/crapi/migrations/0001_initial.py +++ b/services/workshop/crapi/migrations/0001_initial.py @@ -24,16 +24,87 @@ class Migration(migrations.Migration): initial = True dependencies = [ - ('user', '0001_initial'), ] operations = [ + migrations.CreateModel( + name='User', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('created_on', models.DateTimeField()), + ('email', models.CharField(max_length=255, unique=True)), + ('jwt_token', models.CharField(max_length=500, null=True, unique=True)), + ('number', models.CharField(max_length=255, null=True)), + ('password', models.CharField(max_length=255)), + ('role', models.IntegerField(choices=[(2, 1), (0, 0)], default=0)), + ], + options={ + 'db_table': 'user_login', + 'managed': settings.IS_TESTING + }, + ), + migrations.CreateModel( + name='VehicleCompany', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('name', models.CharField(max_length=255)), + ], + options={ + 'db_table': 'vehicle_company', + 'managed': settings.IS_TESTING + }, + ), + migrations.CreateModel( + name='VehicleModel', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('fuel_type', models.BigIntegerField()), + ('model', models.CharField(max_length=255)), + ('vehicle_img', models.CharField(max_length=255, null=True)), + ('vehiclecompany', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='crapi.VehicleCompany')) + ], + options={ + 'db_table': 'vehicle_model', + 'managed': settings.IS_TESTING + }, + ), + migrations.CreateModel( + name='Vehicle', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('pincode', models.CharField(max_length=255, null=True)), + ('vin', models.CharField(max_length=255)), + ('year', models.BigIntegerField(null=True)), + ('vehicle_model', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='crapi.VehicleModel')), + ('status', models.CharField(max_length=255)), + ('location_id', models.BigIntegerField(null=True)), + ('owner', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='crapi.User')), + ], + options={ + 'db_table': 'vehicle_details', + 'managed': settings.IS_TESTING + }, + ), + migrations.CreateModel( + name='UserDetails', + fields=[ + ('id', models.AutoField(primary_key=True, serialize=False)), + ('available_credit', models.FloatField()), + ('name', models.CharField(max_length=255, null=True)), + ('status', models.CharField(max_length=255, null=True)), + ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='crapi.User')), + ], + options={ + 'db_table': 'user_details', + 'managed': settings.IS_TESTING + }, + ), migrations.CreateModel( name='Mechanic', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('mechanic_code', models.CharField(max_length=100, unique=True)), - ('user', django_db_cascade.fields.ForeignKey(on_delete=django_db_cascade.deletions.DB_CASCADE, to='user.User')), + ('user', django_db_cascade.fields.ForeignKey(on_delete=django_db_cascade.deletions.DB_CASCADE, to='crapi.User')), ], options={ 'db_table': 'mechanic', @@ -60,7 +131,7 @@ class Migration(migrations.Migration): ('updated_on', models.DateTimeField(null=True)), ('status', models.CharField(choices=[('Pending', 'Pending'), ('Finished', 'Finished')], default='Pending', max_length=10)), ('mechanic', django_db_cascade.fields.ForeignKey(on_delete=django_db_cascade.deletions.DB_CASCADE, to='crapi.Mechanic')), - ('vehicle', django_db_cascade.fields.ForeignKey(on_delete=django_db_cascade.deletions.DB_CASCADE, to='user.Vehicle')), + ('vehicle', django_db_cascade.fields.ForeignKey(on_delete=django_db_cascade.deletions.DB_CASCADE, to='crapi.Vehicle')), ], options={ 'db_table': 'service_request', @@ -74,7 +145,7 @@ class Migration(migrations.Migration): ('created_on', models.DateTimeField()), ('status', models.CharField(choices=[('delivered', 'delivered'), ('return pending', 'return pending'), ('returned', 'returned')], default='delivered', max_length=20)), ('product', django_db_cascade.fields.ForeignKey(on_delete=django_db_cascade.deletions.DB_CASCADE, to='crapi.Product')), - ('user', django_db_cascade.fields.ForeignKey(on_delete=django_db_cascade.deletions.DB_CASCADE, to='user.User')), + ('user', django_db_cascade.fields.ForeignKey(on_delete=django_db_cascade.deletions.DB_CASCADE, to='crapi.User')), ], options={ 'db_table': 'order', @@ -85,7 +156,7 @@ class Migration(migrations.Migration): fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('coupon_code', models.CharField(max_length=255)), - ('user', django_db_cascade.fields.ForeignKey(on_delete=django_db_cascade.deletions.DB_CASCADE, to='user.User')), + ('user', django_db_cascade.fields.ForeignKey(on_delete=django_db_cascade.deletions.DB_CASCADE, to='crapi.User')), ], options={ 'db_table': 'applied_coupon', diff --git a/services/workshop/crapi/shop/models.py b/services/workshop/crapi/shop/models.py index ca5003e8..043ea4d4 100644 --- a/services/workshop/crapi/shop/models.py +++ b/services/workshop/crapi/shop/models.py @@ -20,7 +20,7 @@ from django.db import models from django.conf import settings -from user.models import User +from crapi.user.models import User from extended_choices import Choices from django_db_cascade.fields import ForeignKey, OneToOneField from django_db_cascade.deletions import DB_CASCADE @@ -42,7 +42,7 @@ class Meta: def __str__(self): return f"{self.name} - {self.price}" - + class Order(models.Model): """ Order Model diff --git a/services/workshop/crapi/shop/serializers.py b/services/workshop/crapi/shop/serializers.py index 4b9c7a6e..74ef6f35 100644 --- a/services/workshop/crapi/shop/serializers.py +++ b/services/workshop/crapi/shop/serializers.py @@ -18,7 +18,7 @@ from rest_framework import serializers from crapi.shop.models import Order, Product, Coupon -from user.serializers import UserSerializer +from crapi.user.serializers import UserSerializer class ProductSerializer(serializers.ModelSerializer): diff --git a/services/workshop/crapi/shop/tests.py b/services/workshop/crapi/shop/tests.py index 18f54eb2..312a8883 100644 --- a/services/workshop/crapi/shop/tests.py +++ b/services/workshop/crapi/shop/tests.py @@ -24,7 +24,7 @@ from django.test import TestCase, Client from django.utils import timezone from utils import messages -from user.models import User, UserDetails +from crapi.user.models import User, UserDetails from crapi.shop.models import Coupon logger = logging.getLogger('ProductTest') diff --git a/services/workshop/crapi/shop/views.py b/services/workshop/crapi/shop/views.py index 08999eb4..9c50e41b 100644 --- a/services/workshop/crapi/shop/views.py +++ b/services/workshop/crapi/shop/views.py @@ -29,11 +29,11 @@ from utils.helper import basic_auth from crapi.shop.serializers import OrderSerializer, ProductSerializer, CouponSerializer, ProductQuantitySerializer -from user.serializers import UserSerializer +from crapi.user.serializers import UserSerializer from utils.jwt import jwt_auth_required from utils import messages from crapi.shop.models import Order, Product, AppliedCoupon, Coupon -from user.models import UserDetails +from crapi.user.models import UserDetails from utils.logging import log_error from django.core.exceptions import ObjectDoesNotExist @@ -121,7 +121,7 @@ def get(self, request, order_id=None, user=None): payment_response = requests.post( gateway_endpoint, headers={ - "Authorization": gateway_credential, + "Authorization": gateway_credential, "Content-Type": "application/json" }, json=data, diff --git a/services/workshop/crapi/urls.py b/services/workshop/crapi/urls.py index 48953814..5ffa7cf6 100644 --- a/services/workshop/crapi/urls.py +++ b/services/workshop/crapi/urls.py @@ -22,4 +22,5 @@ path('api/mechanic/', include('crapi.mechanic.urls')), path('api/merchant/', include('crapi.merchant.urls')), path('api/shop/', include('crapi.shop.urls')), + path('api/management/', include('crapi.user.urls')), ] diff --git a/services/workshop/user/__init__.py b/services/workshop/crapi/user/__init__.py similarity index 100% rename from services/workshop/user/__init__.py rename to services/workshop/crapi/user/__init__.py diff --git a/services/workshop/user/models.py b/services/workshop/crapi/user/models.py similarity index 99% rename from services/workshop/user/models.py rename to services/workshop/crapi/user/models.py index a82dfe09..a903b0aa 100644 --- a/services/workshop/user/models.py +++ b/services/workshop/crapi/user/models.py @@ -38,6 +38,7 @@ class User(models.Model): ROLE_CHOICES = Choices( ('USER', 1, 'User'), ('MECH', 2, 'Mechanic'), + ('ADMIN', 3, 'Admin'), dict_class = OrderedDict ) role = models.IntegerField(choices=ROLE_CHOICES, default=ROLE_CHOICES.USER) diff --git a/services/workshop/user/apps.py b/services/workshop/crapi/user/sapps.py similarity index 100% rename from services/workshop/user/apps.py rename to services/workshop/crapi/user/sapps.py diff --git a/services/workshop/user/serializers.py b/services/workshop/crapi/user/serializers.py similarity index 77% rename from services/workshop/user/serializers.py rename to services/workshop/crapi/user/serializers.py index 19f43302..cc9a309d 100644 --- a/services/workshop/user/serializers.py +++ b/services/workshop/crapi/user/serializers.py @@ -17,7 +17,7 @@ """ from rest_framework import serializers -from user.models import User, Vehicle +from crapi.user.models import User, UserDetails, Vehicle class UserSerializer(serializers.ModelSerializer): @@ -33,6 +33,20 @@ class Meta: fields = ('email', 'number') +class UserDetailsSerializer(serializers.ModelSerializer): + """ + Serializer for User Details model + """ + user = UserSerializer() + + class Meta: + """ + Meta class for UserSerializer + """ + model = UserDetails + fields = ('user', 'available_credit') + + class VehicleSerializer(serializers.ModelSerializer): """ Serializer for Vehicle model diff --git a/services/workshop/crapi/user/tests.py b/services/workshop/crapi/user/tests.py new file mode 100644 index 00000000..483f12f5 --- /dev/null +++ b/services/workshop/crapi/user/tests.py @@ -0,0 +1,128 @@ +# +# Licensed under the Apache License, Version 2.0 (the “License”); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an “AS IS” BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +""" +contains all the test cases related to shop management +""" +from unittest.mock import patch + +from django.db import connection +from utils.mock_methods import get_sample_admin_user, get_sample_user_data, get_sample_users, mock_jwt_auth_required + +patch('utils.jwt.jwt_auth_required', mock_jwt_auth_required).start() + +import logging +import bcrypt +import json +from django.test import TestCase, Client +from django.utils import timezone +from utils import messages +from crapi.user.views import DEFAULT_LIMIT +from crapi.user.models import User, UserDetails + +logger = logging.getLogger('UserTest') +MAX_USER_COUNT = 40 + +class UserDetailsTestCase(TestCase): + """ + contains all the test cases related to UserDetails + Attributes: + client: Client object used for testing + user: dummy user object + auth_headers: Auth headers for dummy user + """ + + databases = '__all__' + setup_done = False + + def setUp(self): + self.client = Client() + user_data = get_sample_admin_user() + uset = User.objects.filter(email=user_data['email']) + if not uset.exists(): + user = User.objects.create( + email=user_data['email'], + number=user_data['number'], + password=bcrypt.hashpw(user_data['password'].encode('utf-8'), + bcrypt.gensalt()).decode(), + role=user_data['role'], + created_on=timezone.now()) + user_detail = UserDetails.objects.create(available_credit=100, + name=user_data['name'], + status='ACTIVE', + user=user) + user.save() + user_detail.save() + self.auth_headers = { + 'HTTP_AUTHORIZATION': 'Bearer ' + user_data['email'] + } + + def setup_database(self): + self.users_data = get_sample_users(MAX_USER_COUNT) + for user_data in self.users_data: + uset = User.objects.filter(email=user_data['email']) + if not uset.exists(): + try: + cursor = connection.cursor() + cursor.execute("select nextval('user_login_id_seq')") + result = cursor.fetchone() + user_id = result[0] + except Exception as e: + logger.error("Failed to fetch user_login_id_seq"+str(e)) + user_id = 1 + user_i = User.objects.create( + id = user_id, + email=user_data['email'], + number=user_data['number'], + password=bcrypt.hashpw(user_data['password'].encode('utf-8'), + bcrypt.gensalt()).decode(), + role=user_data['role'], + created_on=timezone.now()) + user_details_i = UserDetails.objects.create(available_credit=100, + name=user_data['name'], + status='ACTIVE', + user=user_i) + user_i.save() + user_details_i.save() + logger.info("Created user with id: "+str(user_id)) + + + def test_get_api_management_users_all(self): + """ + tests the get user details api + :return: None + """ + self.setup_database() + response = self.client.get('/workshop/api/management/users/all', **self.auth_headers) + self.assertEqual(response.status_code, 200) + response_data = json.loads(response.content) + self.assertEqual(len(response_data['users']), DEFAULT_LIMIT) + response = self.client.get('/workshop/api/management/users/all?limit=10&offset=0', **self.auth_headers) + self.assertEqual(response.status_code, 200) + response_data = json.loads(response.content) + self.assertEqual(len(response_data['users']), 10) + response2 = self.client.get('/workshop/api/management/users/all?limit=10&offset=10', **self.auth_headers) + self.assertEqual(response2.status_code, 200) + response_data2 = json.loads(response2.content) + self.assertNotEquals(response_data['users'], response_data2['users']) + + + def test_bad_get_api_management_users_all(self): + """ + tests the get user details api + :return: None + """ + response = self.client.get('/workshop/api/management/users/all') + self.assertEqual(response.status_code, 401) + response = self.client.get('/workshop/api/management/users/all?limit=a&offset=-1', **self.auth_headers) + self.assertEqual(response.status_code, 400) + diff --git a/services/workshop/user/migrations/__init__.py b/services/workshop/crapi/user/urls.py similarity index 66% rename from services/workshop/user/migrations/__init__.py rename to services/workshop/crapi/user/urls.py index bfd4bb9d..5ba07973 100644 --- a/services/workshop/user/migrations/__init__.py +++ b/services/workshop/crapi/user/urls.py @@ -12,3 +12,15 @@ # limitations under the License. +""" +shop URL Configuration +The `urlpatterns` list routes URLs to views. +""" +from django.urls import include, re_path + +import crapi.user.views as user_views + +urlpatterns = [ + # Do not change the order of URLs + re_path(r'users/all$', user_views.AdminUserView.as_view()), +] \ No newline at end of file diff --git a/services/workshop/crapi/user/views.py b/services/workshop/crapi/user/views.py new file mode 100644 index 00000000..43c71946 --- /dev/null +++ b/services/workshop/crapi/user/views.py @@ -0,0 +1,79 @@ +# +# Licensed under the Apache License, Version 2.0 (the “License”); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an “AS IS” BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +""" +contains all the views related to Merchant +""" +import logging +import requests +from requests.exceptions import MissingSchema, InvalidURL +from rest_framework import status +from rest_framework.response import Response +from rest_framework.views import APIView +from crapi.user.serializers import UserDetailsSerializer +from crapi.user.models import User, UserDetails +from utils.jwt import jwt_auth_required +from utils import messages +from utils.logging import log_error + +logger = logging.getLogger() +DEFAULT_LIMIT = 30 +DEFAULT_OFFSET = 0 +MAX_LIMIT = 100 + +class AdminUserView(APIView): + """ + View for admin user to fetch user details + """ + + @jwt_auth_required + def get(self, request, user=None): + """ + Admin user view to fetch user details + :param request: http request for the view + method allowed: GET + http request should be authorised by the jwt token of the user + mandatory fields: [] + :returns Response object with + user details and 200 status if no error + message and corresponding status if error + """ + limit = request.GET.get('limit', str(DEFAULT_LIMIT)) + offset = request.GET.get('offset', str(DEFAULT_OFFSET)) + if not limit.isdigit() or not offset.isdigit(): + return Response( + {'message': messages.INVALID_LIMIT_OFFSET}, + status=status.HTTP_400_BAD_REQUEST + ) + limit = int(limit) + offset = int(offset) + if limit > MAX_LIMIT: + limit = MAX_LIMIT + if int(limit) < 0: + limit = DEFAULT_LIMIT + if offset < 0: + offset = DEFAULT_OFFSET + # Sort by id + userdetails = UserDetails.objects.all().order_by('id')[offset:offset+limit] + if not userdetails: + return Response( + {'message': messages.NO_USER_DETAILS}, + status=status.HTTP_404_NOT_FOUND + ) + serializer = UserDetailsSerializer(userdetails, many=True) + response_data = { + "users": serializer.data + } + return Response(response_data, status=status.HTTP_200_OK) + diff --git a/services/workshop/crapi_site/settings.py b/services/workshop/crapi_site/settings.py index e613ee77..73f04479 100644 --- a/services/workshop/crapi_site/settings.py +++ b/services/workshop/crapi_site/settings.py @@ -71,7 +71,7 @@ def get_env_value(env_variable): 'health_check', 'health_check.db', 'crapi.apps.CRAPIConfig', - 'user.apps.UserConfig', + #'user.apps.UserConfig', "django_extensions", ] @@ -154,7 +154,7 @@ def get_env_value(env_variable): 'djongo': { 'level': 'DEBUG', 'handlers': ['console'], - 'propogate': True, + 'propogate': True, }, } diff --git a/services/workshop/requirements.txt b/services/workshop/requirements.txt index 98d3237a..68110067 100644 --- a/services/workshop/requirements.txt +++ b/services/workshop/requirements.txt @@ -15,4 +15,5 @@ PyJWT==2.7.0 pymongo==3.12.3 pyOpenSSL==23.1.1 requests==2.30.0 -Werkzeug==2.0.3 \ No newline at end of file +Werkzeug==2.0.3 +Faker==22.1.0 \ No newline at end of file diff --git a/services/workshop/user/migrations/0001_initial.py b/services/workshop/user/migrations/0001_initial.py deleted file mode 100644 index f0dafa4a..00000000 --- a/services/workshop/user/migrations/0001_initial.py +++ /dev/null @@ -1,102 +0,0 @@ -# -# Licensed under the Apache License, Version 2.0 (the “License”); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an “AS IS” BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -# Generated by Django 2.2.13 on 2020-08-31 14:00 - -from django.db import migrations, models -from django.conf import settings -import django.db.models.deletion - - -class Migration(migrations.Migration): - - initial = True - - dependencies = [ - ] - - operations = [ - migrations.CreateModel( - name='User', - fields=[ - ('id', models.AutoField(primary_key=True, serialize=False)), - ('created_on', models.DateTimeField()), - ('email', models.CharField(max_length=255, unique=True)), - ('jwt_token', models.CharField(max_length=500, null=True, unique=True)), - ('number', models.CharField(max_length=255, null=True)), - ('password', models.CharField(max_length=255)), - ('role', models.IntegerField(choices=[(2, 1), (0, 0)], default=0)), - ], - options={ - 'db_table': 'user_login', - 'managed': settings.IS_TESTING - }, - ), - migrations.CreateModel( - name='VehicleCompany', - fields=[ - ('id', models.AutoField(primary_key=True, serialize=False)), - ('name', models.CharField(max_length=255)), - ], - options={ - 'db_table': 'vehicle_company', - 'managed': settings.IS_TESTING - }, - ), - migrations.CreateModel( - name='VehicleModel', - fields=[ - ('id', models.AutoField(primary_key=True, serialize=False)), - ('fuel_type', models.BigIntegerField()), - ('model', models.CharField(max_length=255)), - ('vehicle_img', models.CharField(max_length=255, null=True)), - ('vehiclecompany', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='user.VehicleCompany')) - ], - options={ - 'db_table': 'vehicle_model', - 'managed': settings.IS_TESTING - }, - ), - migrations.CreateModel( - name='Vehicle', - fields=[ - ('id', models.AutoField(primary_key=True, serialize=False)), - ('pincode', models.CharField(max_length=255, null=True)), - ('vin', models.CharField(max_length=255)), - ('year', models.BigIntegerField(null=True)), - ('vehicle_model', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='user.VehicleModel')), - ('status', models.CharField(max_length=255)), - ('location_id', models.BigIntegerField(null=True)), - ('owner', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='user.User')), - ], - options={ - 'db_table': 'vehicle_details', - 'managed': settings.IS_TESTING - }, - ), - migrations.CreateModel( - name='UserDetails', - fields=[ - ('id', models.AutoField(primary_key=True, serialize=False)), - ('available_credit', models.FloatField()), - ('name', models.CharField(max_length=255, null=True)), - ('status', models.CharField(max_length=255, null=True)), - ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='user.User')), - ], - options={ - 'db_table': 'user_details', - 'managed': settings.IS_TESTING - }, - ), - ] diff --git a/services/workshop/utils/jwt.py b/services/workshop/utils/jwt.py index 89410fa4..bdb4fbda 100644 --- a/services/workshop/utils/jwt.py +++ b/services/workshop/utils/jwt.py @@ -20,7 +20,7 @@ from rest_framework.response import Response from django.conf import settings from utils import messages -from user.models import User +from crapi.user.models import User import urllib3 import logging diff --git a/services/workshop/utils/messages.py b/services/workshop/utils/messages.py index b4bbb3be..65f69d77 100644 --- a/services/workshop/utils/messages.py +++ b/services/workshop/utils/messages.py @@ -41,3 +41,5 @@ INVALID_REPORT_ID = "Please enter a valid report_id value." REPORT_DOES_NOT_EXIST = "The Report does not exist for given report_id." COULD_NOT_CONNECT = "Could not connect to mechanic api." +INVALID_LIMIT_OFFSET = "Param limit and offset values should be integers." +NO_USER_DETAILS = "No user details found." \ No newline at end of file diff --git a/services/workshop/utils/mock_methods.py b/services/workshop/utils/mock_methods.py index 6ce9caf5..185399b7 100644 --- a/services/workshop/utils/mock_methods.py +++ b/services/workshop/utils/mock_methods.py @@ -17,7 +17,10 @@ from rest_framework import status from rest_framework.response import Response from utils import messages -from user.models import User +from crapi.user.models import User +from faker import Faker +Faker.seed(4321) + """ contains all methods that are common and @@ -51,6 +54,39 @@ def get_sample_user_data(): "password": "password", } +def fake_phone_number(fake: Faker) -> str: + return f'{fake.msisdn()[3:]}' + +def get_sample_users(users_count=100): + """ + gives sample users which can be used for testing + """ + fake = Faker() + users = [] + for i in range(users_count): + users.append({ + "name": fake.name(), + "email": fake.email(), + "number": fake_phone_number(fake), + "password": fake.password(), + "role": fake.random_element(elements=dict(User.ROLE_CHOICES).keys()), + }) + return users + +def get_sample_admin_user(): + """ + gives admin user which can be used for testing + """ + return { + "name": "Admin 1", + "email": "admin1@crapi.com", + "number": "9123456700", + "password": "password1", + "role": User.ROLE_CHOICES.ADMIN, + } + + + def mock_jwt_auth_required(func): """ mock function to validate jwt