From 2306107442b4344c2e80e022399f0d1a6d6fadb1 Mon Sep 17 00:00:00 2001 From: Railag Date: Mon, 5 Nov 2018 16:47:02 +0300 Subject: [PATCH] EWC-312 postman QA catalog --- src/services/catalog-service.js | 7 +- ...Controller Testing.postman_collection.json | 397 +++++++++++++++++- 2 files changed, 401 insertions(+), 3 deletions(-) diff --git a/src/services/catalog-service.js b/src/services/catalog-service.js index a9dc3dc26..97b37069f 100644 --- a/src/services/catalog-service.js +++ b/src/services/catalog-service.js @@ -99,7 +99,7 @@ const _updateCatalogItemIOTypes = async function (data, where, transaction) { inputType = AppHelper.deleteUndefinedFields(inputType); await CatalogItemInputTypeManager.update({catalogItemId: data.id}, inputType, transaction); } - if (data.outputType && data.outputType.length !=0) { + if (data.outputType && data.outputType.length !== 0) { let outputType = { infoType: data.outputType.infoType, infoFormat: data.outputType.infoFormat @@ -118,7 +118,10 @@ const listCatalogItems = async function (user, isCLI, transaction) { ? {} : {exclude: ["userId"]}; - return await CatalogItemManager.findAllWithDependencies(where, attributes, transaction); + const catalogItems = await CatalogItemManager.findAllWithDependencies(where, attributes, transaction); + return { + catalogItems: catalogItems + } }; const getCatalogItem = async function (id, user, isCLI, transaction) { diff --git a/tests/Controller Testing.postman_collection.json b/tests/Controller Testing.postman_collection.json index 30494c3e1..9cf9116a0 100644 --- a/tests/Controller Testing.postman_collection.json +++ b/tests/Controller Testing.postman_collection.json @@ -2118,6 +2118,401 @@ "response": [] } ] + }, + { + "name": "Catalog", + "item": [ + { + "name": "Create user", + "event": [ + { + "listen": "test", + "script": { + "id": "954febdd-1a16-4db0-bdff-bd13fc50a451", + "exec": [ + "tests[\"Status code is 201\"] = responseCode.code === 201;", + "", + "var data = JSON.parse(responseBody);", + "", + "tests[\"Response validation passed\"] = data.hasOwnProperty('userId') && data.firstName && data.lastName && data.email && data.hasOwnProperty('emailActivated');" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"firstName\": \"John\",\n \"lastName\": \"Doe\",\n \"email\": \"user@domain.com\",\n \"password\": \"#Bugs4Fun\"\n}" + }, + "url": { + "raw": "{{host}}/api/v3/user/signup", + "host": [ + "{{host}}" + ], + "path": [ + "api", + "v3", + "user", + "signup" + ] + } + }, + "response": [] + }, + { + "name": "Login", + "event": [ + { + "listen": "test", + "script": { + "id": "4f7a9f52-12cc-49d0-9e2f-147b6f5cb6fa", + "exec": [ + "tests[\"Status code is 200\"] = responseCode.code === 200;", + "", + "var data = JSON.parse(responseBody);", + "", + "tests[\"Response validation passed\"] = data.accessToken;", + "", + "", + "postman.setGlobalVariable(\"user-token\", data.accessToken);", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"email\": \"user@domain.com\",\n \"password\": \"#Bugs4Fun\"\n}" + }, + "url": { + "raw": "{{host}}/api/v3/user/login", + "host": [ + "{{host}}" + ], + "path": [ + "api", + "v3", + "user", + "login" + ] + } + }, + "response": [] + }, + { + "name": "New Catalog Item", + "event": [ + { + "listen": "test", + "script": { + "id": "4f7a9f52-12cc-49d0-9e2f-147b6f5cb6fa", + "exec": [ + "tests[\"Status code is 201\"] = responseCode.code === 201;", + "", + "var data = JSON.parse(responseBody);", + "", + "tests[\"Response validation passed\"] = data.hasOwnProperty('id');", + "", + "postman.setGlobalVariable(\"item-id\", data.id);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Authorization", + "value": "{{user-token}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"name\": \"string\",\n \"description\": \"string\",\n \"category\": \"string\",\n \"images\": [\n {\n \"containerImage\": \"x86 docker image name\",\n \"fogTypeId\": 1\n },\n {\n \"containerImage\": \"ARM docker image name\",\n \"fogTypeId\": 2\n }\n ],\n \"publisher\": \"string\",\n \"diskRequired\": 0,\n \"ramRequired\": 0,\n \"picture\": \"string\",\n \"isPublic\": true,\n \"registryId\": 1,\n \"inputType\": {\n \"infoType\": \"string\",\n \"infoFormat\": \"string\"\n },\n \"outputType\": {\n \"infoType\": \"string\",\n \"infoFormat\": \"string\"\n },\n \"configExample\": \"string\"\n}" + }, + "url": { + "raw": "{{host}}/api/v3/catalog/microservices", + "host": [ + "{{host}}" + ], + "path": [ + "api", + "v3", + "catalog", + "microservices" + ] + } + }, + "response": [] + }, + { + "name": "Get Catalog Items", + "event": [ + { + "listen": "test", + "script": { + "id": "4f7a9f52-12cc-49d0-9e2f-147b6f5cb6fa", + "exec": [ + "tests[\"Status code is 200\"] = responseCode.code === 200;", + "", + "var data = JSON.parse(responseBody);", + "", + "tests[\"Response validation passed\"] = data.hasOwnProperty('catalogItems');" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Authorization", + "value": "{{user-token}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "{{host}}/api/v3/catalog/microservices", + "host": [ + "{{host}}" + ], + "path": [ + "api", + "v3", + "catalog", + "microservices" + ] + } + }, + "response": [] + }, + { + "name": "Get Catalog Item By Id", + "event": [ + { + "listen": "test", + "script": { + "id": "4f7a9f52-12cc-49d0-9e2f-147b6f5cb6fa", + "exec": [ + "tests[\"Status code is 200\"] = responseCode.code === 200;", + "", + "var data = JSON.parse(responseBody);", + "", + "tests[\"Response validation passed\"] = data.hasOwnProperty('id') && data.name && data.description && data.category && data.configExample", + "&& data.publisher && data.hasOwnProperty('diskRequired') && data.hasOwnProperty('ramRequired') && data.picture && data.hasOwnProperty('isPublic')", + "&& data.hasOwnProperty('registryId') && data.hasOwnProperty('images') && data.hasOwnProperty('inputType') && data.hasOwnProperty('outputType');" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Authorization", + "value": "{{user-token}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "{{host}}/api/v3/catalog/microservices/{{item-id}}", + "host": [ + "{{host}}" + ], + "path": [ + "api", + "v3", + "catalog", + "microservices", + "{{item-id}}" + ] + } + }, + "response": [] + }, + { + "name": "Update Catalog Item", + "event": [ + { + "listen": "test", + "script": { + "id": "4f7a9f52-12cc-49d0-9e2f-147b6f5cb6fa", + "exec": [ + "tests[\"Status code is 204\"] = responseCode.code === 204;", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "PATCH", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Authorization", + "value": "{{user-token}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"name\": \"string\",\n \"description\": \"string\",\n \"category\": \"string\",\n \"images\": [\n {\n \"containerImage\": \"x86 docker image name\",\n \"fogTypeId\": 1\n },\n {\n \"containerImage\": \"ARM docker image name\",\n \"fogTypeId\": 2\n }\n ],\n \"publisher\": \"string\",\n \"diskRequired\": 0,\n \"ramRequired\": 0,\n \"picture\": \"string\",\n \"isPublic\": true,\n \"registryId\": 1,\n \"inputType\": {\n \"infoType\": \"string\",\n \"infoFormat\": \"string\"\n },\n \"outputType\": {\n \"infoType\": \"string\",\n \"infoFormat\": \"string\"\n },\n \"configExample\": \"string\"\n}\n" + }, + "url": { + "raw": "{{host}}/api/v3/catalog/microservices/{{item-id}}", + "host": [ + "{{host}}" + ], + "path": [ + "api", + "v3", + "catalog", + "microservices", + "{{item-id}}" + ] + } + }, + "response": [] + }, + { + "name": "Delete Catalog Item By Id", + "event": [ + { + "listen": "test", + "script": { + "id": "4f7a9f52-12cc-49d0-9e2f-147b6f5cb6fa", + "exec": [ + "tests[\"Status code is 204\"] = responseCode.code === 204;", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "DELETE", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Authorization", + "value": "{{user-token}}", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "{{host}}/api/v3/catalog/microservices/{{item-id}}", + "host": [ + "{{host}}" + ], + "path": [ + "api", + "v3", + "catalog", + "microservices", + "{{item-id}}" + ] + } + }, + "response": [] + }, + { + "name": "Delete user", + "event": [ + { + "listen": "test", + "script": { + "id": "954febdd-1a16-4db0-bdff-bd13fc50a451", + "exec": [ + "tests[\"Status code is 204\"] = responseCode.code === 204;" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "DELETE", + "header": [ + { + "key": "Authorization", + "value": "{{user-token}}" + }, + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "" + }, + "url": { + "raw": "{{host}}/api/v3/user/profile", + "host": [ + "{{host}}" + ], + "path": [ + "api", + "v3", + "user", + "profile" + ] + } + }, + "response": [] + } + ] } ], "event": [ @@ -2144,7 +2539,7 @@ ], "variable": [ { - "id": "1a291aeb-b1ca-4099-9e67-89604a5093b1", + "id": "828a5d14-b19c-440a-a801-d8651e8d975b", "key": "host", "value": "localhost:51121", "type": "string"