Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@
"umzug": "^2.1.0",
"underscore": "^1.9.1",
"winston": "^3.1.0",
"xss-clean": "^0.1.1"
"xss-clean": "^0.1.1",
"qs": "^6.5.2"
},
"devDependencies": {
"eslint": "^5.6.1"
Expand Down
8 changes: 5 additions & 3 deletions src/controllers/iofog-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
const logger = require('../logger');
const AuthDecorator = require('../decorators/authorization-decorator');
const FogService = require('../services/iofog-service');
const querystring = require('querystring');
const qs = require('qs');

async function _createFog(req, user) {
logger.info("Parameters:" + JSON.stringify(req.body));
Expand Down Expand Up @@ -43,9 +45,9 @@ async function _getFog(req, user) {
}

async function _getFogList(req, user) {
logger.info("Parameters:" + JSON.stringify(req.body));
const filters = Array.from(req.body);
return await FogService.getFogListWithTransaction(filters, user, false)
logger.info("Parameters:" + JSON.stringify(req.query));
const query = qs.parse(req.query)
return await FogService.getFogListWithTransaction(query.filters, user, false)
}

async function _generateProvisioningKey(req, user) {
Expand Down
4 changes: 2 additions & 2 deletions src/routes/iofog.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const Errors = require('../helpers/errors');

module.exports = [
{
method: 'post',
method: 'get',
path: '/api/v3/iofog-list',
middleware: async (req, res) => {
const successCode = constants.HTTP_CODE_SUCCESS;
Expand Down Expand Up @@ -154,7 +154,7 @@ module.exports = [
code: 404,
errors: [Errors.NotFoundError]
}
]
];

const generateFogProvisioningKey = ResponseDecorator.handleErrors(FogController.generateProvisioningKey, successCode, errCodes);
const responseObject = await generateFogProvisioningKey(req);
Expand Down
49 changes: 29 additions & 20 deletions tests/Controller Testing.postman_collection.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"info": {
"_postman_id": "0c412a3a-7328-4c9e-8919-d2836adccfa1",
"_postman_id": "b585aece-cb86-4f3b-93f3-12552c1c90c5",
"name": "Controller Testing",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "User",
"description": null,
"item": [
{
"name": "Create user",
Expand Down Expand Up @@ -509,6 +510,7 @@
},
{
"name": "General",
"description": null,
"item": [
{
"name": "Status",
Expand Down Expand Up @@ -631,6 +633,7 @@
},
{
"name": "Agent",
"description": null,
"item": [
{
"name": "Create user",
Expand Down Expand Up @@ -856,7 +859,6 @@
"method": "POST",
"header": [
{
"disabled": false,
"key": "Content-Type",
"value": "application/json"
}
Expand Down Expand Up @@ -906,7 +908,6 @@
"method": "GET",
"header": [
{
"disabled": false,
"key": "Content-Type",
"value": "application/json"
},
Expand Down Expand Up @@ -954,7 +955,6 @@
"method": "PATCH",
"header": [
{
"disabled": false,
"key": "Content-Type",
"value": "application/json"
},
Expand Down Expand Up @@ -1008,7 +1008,6 @@
"method": "GET",
"header": [
{
"disabled": false,
"key": "Content-Type",
"value": "application/json"
},
Expand Down Expand Up @@ -1057,7 +1056,6 @@
"method": "PUT",
"header": [
{
"disabled": false,
"key": "Content-Type",
"value": "application/json"
},
Expand Down Expand Up @@ -1108,7 +1106,6 @@
"method": "GET",
"header": [
{
"disabled": false,
"key": "Content-Type",
"value": "application/json"
},
Expand Down Expand Up @@ -1159,7 +1156,6 @@
"method": "GET",
"header": [
{
"disabled": false,
"key": "Content-Type",
"value": "application/json"
},
Expand Down Expand Up @@ -1211,7 +1207,6 @@
"method": "GET",
"header": [
{
"disabled": false,
"key": "Content-Type",
"value": "application/json"
},
Expand Down Expand Up @@ -1262,7 +1257,6 @@
"method": "GET",
"header": [
{
"disabled": false,
"key": "Content-Type",
"value": "application/json"
},
Expand Down Expand Up @@ -1310,7 +1304,6 @@
"method": "GET",
"header": [
{
"disabled": false,
"key": "Content-Type",
"value": "application/json"
},
Expand Down Expand Up @@ -1361,7 +1354,6 @@
"method": "PUT",
"header": [
{
"disabled": false,
"key": "Content-Type",
"value": "application/json"
},
Expand Down Expand Up @@ -1412,7 +1404,6 @@
"method": "GET",
"header": [
{
"disabled": false,
"key": "Content-Type",
"value": "application/json"
},
Expand Down Expand Up @@ -1559,7 +1550,6 @@
"method": "GET",
"header": [
{
"disabled": false,
"key": "Content-Type",
"value": "application/json"
},
Expand Down Expand Up @@ -1657,7 +1647,6 @@
"method": "DELETE",
"header": [
{
"disabled": false,
"key": "Content-Type",
"value": "application/json"
},
Expand Down Expand Up @@ -1735,6 +1724,7 @@
},
{
"name": "Flow",
"description": null,
"item": [
{
"name": "Create user",
Expand Down Expand Up @@ -2121,6 +2111,7 @@
},
{
"name": "Catalog",
"description": null,
"item": [
{
"name": "Create user",
Expand Down Expand Up @@ -2516,6 +2507,7 @@
},
{
"name": "Tunnel",
"description": null,
"item": [
{
"name": "Create user",
Expand Down Expand Up @@ -2859,6 +2851,7 @@
},
{
"name": "Microservices",
"description": null,
"item": [
{
"name": "Create user",
Expand Down Expand Up @@ -3795,6 +3788,7 @@
},
{
"name": "Diagnostics",
"description": null,
"item": [
{
"name": "Create user",
Expand Down Expand Up @@ -4589,6 +4583,7 @@
},
{
"name": "ioFog",
"description": null,
"item": [
{
"name": "Create user",
Expand Down Expand Up @@ -4809,31 +4804,44 @@
}
],
"request": {
"method": "POST",
"method": "GET",
"header": [
{
"key": "Content-Type",
"value": "application/json"
},
{
"key": "Authorization",
"value": "{{user-token}}",
"type": "text"
"value": "{{user-token}}"
}
],
"body": {
"mode": "raw",
"raw": "[\n {\n \"key\": \"uuid\",\n \"value\": \"{{node-id}}\",\n \"condition\": \"equals\"\n }\n]"
"raw": ""
},
"url": {
"raw": "{{host}}/api/v3/iofog-list",
"raw": "{{host}}/api/v3/iofog-list?filters[0][key]=uuid&filters[0][value]={{node-id}}&filters[0][condition]=equals",
"host": [
"{{host}}"
],
"path": [
"api",
"v3",
"iofog-list"
],
"query": [
{
"key": "filters[0][key]",
"value": "uuid"
},
{
"key": "filters[0][value]",
"value": "{{node-id}}"
},
{
"key": "filters[0][condition]",
"value": "equals"
}
]
}
},
Expand Down Expand Up @@ -5282,6 +5290,7 @@
},
{
"name": "Registries",
"description": null,
"item": [
{
"name": "Create user",
Expand Down