From 0991cb4cfd8b23613084ee1958b03b6cdf45e925 Mon Sep 17 00:00:00 2001 From: Heitor Mattosinho Date: Mon, 26 Oct 2020 17:26:37 -0300 Subject: [PATCH 1/3] feat (UserController): change Password endpoint --- .../app/Controllers/Http/v1/UserController.js | 37 ++++++++++++++++++- src/adonisjs/app/Models/v1/User.js | 2 + src/adonisjs/start/routes.js | 1 + 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/src/adonisjs/app/Controllers/Http/v1/UserController.js b/src/adonisjs/app/Controllers/Http/v1/UserController.js index f8d210d..31dc448 100644 --- a/src/adonisjs/app/Controllers/Http/v1/UserController.js +++ b/src/adonisjs/app/Controllers/Http/v1/UserController.js @@ -6,6 +6,7 @@ const Database = use('Database') const Helpers = use('Helpers') +const Hash = use('Hash') const Case = use('App/Models/v1/Case') const User = use('App/Models/v1/User') @@ -114,9 +115,43 @@ class UserController { await storeduser.merge(newUser) await storeduser.save() return response.json(storeduser) - } else return response.status(500).json('user not found') + } else{ + console.log('save user error'); + return response.status(500).json('user not found') + } + } catch (e) { + return response.status(e.status).json({ message: e.message }) + } + } + + async updatePassword ({ params, request, response, auth }) { + try { + // console.log('updating password....') + const oldPassword = request.input('oldPassword') + const newPassword = request.input('newPassword') + // console.log('-======================',auth.user.id) + const user = await User.find(auth.user.id) + + if (user != null && await Hash.verify(oldPassword, auth.user.password) && newPassword != oldPassword) { + user.password = newPassword + await user.save() + console.log('Password changed successfully.') + return response.json('Password changed successfully.') + } else if(!await Hash.verify(oldPassword, auth.user.password)){ + console.log('Old password incorrect.') + return response.json('Old password incorrect.') + }else if(newPassword === oldPassword){ + console.log('Passwords must be different.') + return response.json('Passwords must be different.') + }else { + console.log('Update password error, try again.') + return response.json('Update password error, try again.') + + } } catch (e) { return response.status(e.status).json({ message: e.message }) + } finally{ + console.log('finally ended password update'); } } diff --git a/src/adonisjs/app/Models/v1/User.js b/src/adonisjs/app/Models/v1/User.js index 38d05a2..958bae1 100644 --- a/src/adonisjs/app/Models/v1/User.js +++ b/src/adonisjs/app/Models/v1/User.js @@ -84,6 +84,8 @@ class User extends Model { * it to the database. */ this.addHook('beforeCreate', 'UserHook.hashPassword') + this.addHook('beforeUpdate', 'UserHook.hashPassword') + } // Attach role and permissions of a user diff --git a/src/adonisjs/start/routes.js b/src/adonisjs/start/routes.js index 6de4b0c..0cb03c6 100644 --- a/src/adonisjs/start/routes.js +++ b/src/adonisjs/start/routes.js @@ -24,6 +24,7 @@ Route.group(() => { Route.get( 'quests', 'v1/UserController.list_quests').middleware(['auth']) Route.get( 'cases_by_quest', 'v1/UserController.list_cases_by_quests').middleware(['auth']) + Route.put( 'password', 'v1/UserController.updatePassword').middleware(['auth']) Route.get( ':id', 'v1/UserController.show').middleware(['auth']) Route.put( ':id', 'v1/UserController.update').middleware(['auth']) Route.delete(':id', 'v1/UserController.destroy').middleware(['auth']) From 783622813493e935f3b8bd8b3c59051b3154b41f Mon Sep 17 00:00:00 2001 From: Heitor Mattosinho Date: Mon, 26 Oct 2020 18:16:31 -0300 Subject: [PATCH 2/3] refactor (AuthController/check): send username when token valid --- src/adonisjs/app/Controllers/Http/v1/AuthController.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/adonisjs/app/Controllers/Http/v1/AuthController.js b/src/adonisjs/app/Controllers/Http/v1/AuthController.js index 14ad3c6..47e2ba9 100644 --- a/src/adonisjs/app/Controllers/Http/v1/AuthController.js +++ b/src/adonisjs/app/Controllers/Http/v1/AuthController.js @@ -8,8 +8,9 @@ class AuthController { async checkToken ({ request, auth, response }) { try { // console.log('====Checking token...') - await auth.check() - response.json('token valid') + if(await auth.check()){ + response.json({token:'token valid', username: auth.user.username}) + } // console.log('====Token valid') } catch (error) { // console.log('====Token invalid') @@ -17,7 +18,7 @@ class AuthController { } async login ({ request, auth, response, session }) { - Logger.info('login attempt via v2/auth/login (SESSION)') + Logger.info('login attempt via v1/auth/login (SESSION)') const { email, password } = request.all() try { if (await auth.remember(true).attempt(email, password)) { From 46aa31b8c2d70ed9f2315d86efdc91cb8998282e Mon Sep 17 00:00:00 2001 From: Heitor Mattosinho Date: Mon, 26 Oct 2020 18:16:52 -0300 Subject: [PATCH 3/3] feat (postman): new change password endpoint --- harena-manager.postman_collection.json | 1141 ++++++++++++------------ 1 file changed, 560 insertions(+), 581 deletions(-) diff --git a/harena-manager.postman_collection.json b/harena-manager.postman_collection.json index 76b030a..d907419 100644 --- a/harena-manager.postman_collection.json +++ b/harena-manager.postman_collection.json @@ -1,6 +1,6 @@ { "info": { - "_postman_id": "5cb3e4a3-351f-4715-ae83-501115912a54", + "_postman_id": "a7148259-5898-4ce9-a853-563722df2d28", "name": "harena-manager", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" }, @@ -17,7 +17,7 @@ { "listen": "test", "script": { - "id": "991d4448-5e29-4531-84cd-348bb58cf90a", + "id": "7e4ca188-f483-438b-92e4-faabcb68e232", "exec": [ "var response = pm.response.json();", "pm.environment.set(\"user-token\", response.token);", @@ -78,7 +78,7 @@ { "listen": "test", "script": { - "id": "70ec4ae6-d3a7-4630-8167-685795925637", + "id": "4d239fcd-b358-47f3-874b-0f0fe8eb2be6", "exec": [ "" ], @@ -125,7 +125,7 @@ { "listen": "prerequest", "script": { - "id": "025d8438-f2d5-43cd-bad4-2e3de683943e", + "id": "7cc84993-51ae-49e5-9d6a-fbcf06c938e3", "type": "text/javascript", "exec": [ "" @@ -135,7 +135,7 @@ { "listen": "test", "script": { - "id": "c1496d0d-9a83-456a-988b-e766fa8db99d", + "id": "e8d036f7-f38d-4f12-9350-332845532e2f", "type": "text/javascript", "exec": [ "" @@ -147,12 +147,12 @@ "_postman_isSubFolder": true }, { - "name": "/auth/login (session)", + "name": "/auth/login session", "event": [ { "listen": "test", "script": { - "id": "d769f095-ffaa-4882-a451-423ba34b4095", + "id": "62c53a04-7306-4590-ac1f-e0a0415ee3c5", "exec": [ "var response = pm.response.json();", "console.log(response)", @@ -199,12 +199,12 @@ "response": [] }, { - "name": "/auth/logout (session)", + "name": "/auth/logout session", "event": [ { "listen": "test", "script": { - "id": "afbfed8c-6d3e-4cbd-ae6f-423c308d7dfc", + "id": "005e1c53-285c-4eb4-a33d-7039ac2a6002", "exec": [ "pm.environment.set(\"user-token\", 'revoked');" ], @@ -232,7 +232,7 @@ "response": [] }, { - "name": "/auth/checkToken (session)", + "name": "/auth/checkToken session", "request": { "method": "GET", "header": [], @@ -256,13 +256,66 @@ { "name": "user", "item": [ + { + "name": "/cases_by_quest", + "event": [ + { + "listen": "test", + "script": { + "id": "8d76235e-2ca8-4773-802b-41b22c5d37c0", + "exec": [ + "var response = pm.response.json();", + "", + "", + "pm.test(\"Status code is 200 or 201\", function () {", + " ", + " pm.expect(pm.response.code).to.be.oneOf([200,201]);", + " ", + "});" + ], + "type": "text/javascript" + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [], + "body": { + "mode": "formdata", + "formdata": [ + { + "key": "quest_id", + "value": "aa9da08a-1bd4-4a57-b4bf-076a889d6046", + "type": "text" + } + ], + "options": { + "formdata": {} + } + }, + "url": { + "raw": "{{api-base-url}}/user/cases_by_quest", + "host": [ + "{{api-base-url}}" + ], + "path": [ + "user", + "cases_by_quest" + ] + } + }, + "response": [] + }, { "name": "/user/:id", "event": [ { "listen": "test", "script": { - "id": "d1364c49-a450-4491-bd3a-de651e7188f2", + "id": "db6e3ed4-8ce6-44a3-b4da-60fbd5ec5e80", "exec": [ "pm.test(\"Status code is 200\", function () {", " pm.response.to.have.status(200);", @@ -289,12 +342,12 @@ "response": [] }, { - "name": "/user/cases (wip)", + "name": "/user/cases", "event": [ { "listen": "test", "script": { - "id": "12c4bf6e-f464-49ba-acc5-ed4aafd4ae33", + "id": "ad5da6f0-b5b5-4792-baa7-502b215827c4", "exec": [ "var response = pm.response.json();", "", @@ -321,12 +374,12 @@ "formdata": [ { "key": "clearance", - "value": "1", + "value": "4", "type": "text" }, { - "key": "filterBy", - "value": "edit", + "key": "published", + "value": "\n", "type": "text", "disabled": true } @@ -349,12 +402,12 @@ "response": [] }, { - "name": "/user/quests (broken)", + "name": "/user/quests", "event": [ { "listen": "test", "script": { - "id": "d08c0268-88dc-4592-9416-f4cb15e5d7a0", + "id": "d53aca1e-8cff-4141-bfc2-53fca7af2fa8", "exec": [ "" ], @@ -379,15 +432,16 @@ "response": [] }, { - "name": "/cases_by_quest (broken)", + "name": "/user/cases_by_institution (to trash)", "event": [ { "listen": "test", "script": { - "id": "2f7a1321-4786-4ac4-b524-9073788c8c4b", + "id": "0f147b45-e953-4eda-ac7a-811ca797cd98", "exec": [ "var response = pm.response.json();", "", + "// pm.environment.set(\"case-id\", response.token);", "", "pm.test(\"Status code is 200 or 201\", function () {", " ", @@ -407,25 +461,19 @@ "header": [], "body": { "mode": "formdata", - "formdata": [ - { - "key": "quest_id", - "value": "aa9da08a-1bd4-4a57-b4bf-076a889d6046", - "type": "text" - } - ], + "formdata": [], "options": { "formdata": {} } }, "url": { - "raw": "{{api-base-url}}/user/cases_by_quest", + "raw": "{{api-base-url}}/user/cases_by_institution", "host": [ "{{api-base-url}}" ], "path": [ "user", - "cases_by_quest" + "cases_by_institution" ] } }, @@ -437,7 +485,7 @@ { "listen": "test", "script": { - "id": "b85b40cc-c535-4ddb-80d1-65879f0e68b0", + "id": "145c56e0-caff-4d47-8fdf-d2f6905abbdd", "exec": [ "var response = pm.response.json();", "", @@ -462,22 +510,22 @@ "formdata": [ { "key": "username", - "value": "dudu", + "value": "edu", "type": "text" }, { "key": "email", - "value": "dudu@email.com", + "value": "edu@email.com", "type": "text" }, { "key": "password", - "value": "dudu", + "value": "edu", "type": "text" }, { "key": "login", - "value": "dudu", + "value": "edu", "type": "text" }, { @@ -487,7 +535,7 @@ }, { "key": "grade", - "value": "student", + "value": "aluno", "type": "text" } ], @@ -512,36 +560,69 @@ "request": { "method": "PUT", "header": [], + "body": { + "mode": "formdata", + "formdata": [ + { + "key": "username", + "value": "username", + "type": "text" + }, + { + "key": "email", + "value": "email@example", + "type": "text" + }, + { + "key": "login", + "value": "login", + "type": "text" + } + ] + }, "url": { - "raw": "{{api-base-url}}/user/{{user-id}}?login=adrubal2", + "raw": "{{api-base-url}}/user/{{user-id}}", "host": [ "{{api-base-url}}" ], "path": [ "user", "{{user-id}}" - ], - "query": [ - { - "key": "username", - "value": "{{user-username}}", - "disabled": true - }, - { - "key": "email", - "value": "{{user-email}}", - "disabled": true - }, + ] + } + }, + "response": [] + }, + { + "name": "/user/password", + "request": { + "method": "PUT", + "header": [], + "body": { + "mode": "formdata", + "formdata": [ { - "key": "password", - "value": "{{user-password}}", - "disabled": true + "key": "oldPassword", + "value": "super", + "type": "text" }, { - "key": "login", - "value": "adrubal2" + "key": "newPassword", + "value": "secret", + "type": "text" } ] + }, + "url": { + "raw": "{{api-base-url}}/user/password/", + "host": [ + "{{api-base-url}}" + ], + "path": [ + "user", + "password", + "" + ] } }, "response": [] @@ -552,7 +633,7 @@ { "listen": "test", "script": { - "id": "abd566c9-5809-4581-b79f-42a1a24da45d", + "id": "dcbba21c-af88-435a-9948-8d03adfac96f", "exec": [ "pm.test(\"Status code is 200 or 204\", function () {", " ", @@ -611,7 +692,7 @@ { "listen": "test", "script": { - "id": "d5247cf3-0c31-4943-a4a1-a287fb5397d2", + "id": "d358db71-a30f-45df-b924-31f9856e2795", "exec": [ "var response = pm.response.json();", "console.log(response.id)", @@ -642,7 +723,7 @@ "formdata": [ { "key": "title", - "value": "caso casual", + "value": "Caso final - minhoooo", "type": "text" }, { @@ -688,23 +769,21 @@ { "key": "institution", "value": "minho", - "type": "text", - "disabled": true + "type": "text" }, { "key": "permissionEntity", - "value": "institution", + "value": "university", "type": "text" }, { "key": "permissionSubjectId", - "value": "317def91-a484-4b55-958e-4e51c7f5a916", - "description": "can be id of any table, which is defined by permissionEntity param", + "value": "8575db0a-e0aa-434c-8ca4-29d7ded3937a", "type": "text" }, { "key": "permissionClearance", - "value": "1", + "value": "read", "type": "text" } ], @@ -725,7 +804,76 @@ "response": [] }, { - "name": "/case/:id (update to PUT)", + "name": "/case/link/user", + "event": [ + { + "listen": "test", + "script": { + "id": "b49b1ec2-2db6-4c3e-b47c-68588064b4cb", + "exec": [ + "var response = pm.response.json();", + "", + "// pm.environment.set(\"case-uuid\", response.uuid);", + "", + "pm.test(\"Status code is 200 or 201\", function () {", + " ", + " pm.expect(pm.response.code).to.be.oneOf([200,201]);", + " ", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "value": "application/x-www-form-urlencoded", + "type": "text" + } + ], + "body": { + "mode": "formdata", + "formdata": [ + { + "key": "caseId", + "value": "ad129f0e-0b4b-41bf-a18e-b2f6d2205f2d", + "type": "text" + }, + { + "key": "userId", + "value": "a4f64e13-1ef6-4c25-9b11-be8dc9778408", + "type": "text" + }, + { + "key": "permission", + "value": "read", + "type": "text" + } + ], + "options": { + "formdata": {} + } + }, + "url": { + "raw": "{{api-base-url}}/case/link/user", + "host": [ + "{{api-base-url}}" + ], + "path": [ + "case", + "link", + "user" + ] + } + }, + "response": [] + }, + { + "name": "/case/:id", "request": { "method": "POST", "header": [], @@ -796,160 +944,70 @@ "response": [] }, { - "name": "/case?:id", + "name": "/case", + "request": { + "method": "DELETE", + "header": [], + "url": { + "raw": "{{api-base-url}}/case/{{case-id}}", + "host": [ + "{{api-base-url}}" + ], + "path": [ + "case", + "{{case-id}}" + ] + } + }, + "response": [] + } + ], + "protocolProfileBehavior": {} + }, + { + "name": "player", + "item": [ + { + "name": "/player/quests", "event": [ { "listen": "test", "script": { - "id": "78b510e6-adbc-4084-a781-00c0e120cb8b", + "id": "6a4896f8-c94a-4be5-b72e-6a37db0822c9", "exec": [ - "var response = pm.response.json();", - "console.log(response.id)", - "pm.environment.set(\"case-id\", response.id);", - "", - "pm.test(\"Status code is 200 or 201\", function () {", - " ", - " pm.expect(pm.response.code).to.be.oneOf([200,201]);", - " ", - "});" + "" ], "type": "text/javascript" } } ], "request": { - "method": "PUT", - "header": [ - { - "key": "Content-Type", - "name": "Content-Type", - "type": "text", - "value": "application/x-www-form-urlencoded" - } - ], - "body": { - "mode": "formdata", - "formdata": [ - { - "key": "title", - "value": "caso casual2", - "type": "text" - }, - { - "key": "source", - "value": "# Presentation (quiz, end)\n\nWrite here the **stem** of your quiz.\n\n> Write here the **lead-in** of your quiz.\n+ Answer-key <-> Presentation References \"Feedback for Answer-key\" >((right))\n+ Distractor 1 <-> \"Feedback for Distractor 1\"\n+ Distractor 2 <-> \"Feedback for Distractor 2\"\n+ Distractor 3 <-> \"Feedback for Distractor 3\"\n\n* Next Case -> Case.Next ((right))?\n\n# Note (note)\n\n**You answered:** ^Previous.input1^.\n\n\n\n^parameter^\n\n# Presentation References (note)\n\n**You answered:** ^Previous.input1^.\n\n\n\n^parameter^\n\nReferences <-> References\n\n# References (note_references)\n\n* [Enter References](References)\n\n___ Flow ___\n\n* Sequential:\n * _sequential_\n\n___ Data ___\n\n* theme: simple(red)\n* namespaces:\n * evidence: http://purl.org/versum/evidence/\n* templates:\n * categories:\n * detailed: simple/knot/description", - "type": "text" - }, - { - "key": "description", - "value": "test description", - "type": "text" - }, - { - "key": "language", - "value": "en", - "type": "text" - }, - { - "key": "domain", - "value": "test domain", - "type": "text" - }, - { - "key": "specialty", - "value": "test specialty ", - "type": "text" - }, - { - "key": "keywords", - "value": "keyword4;kw6", - "type": "text" - }, - { - "key": "originalDate", - "value": "1987-09-13", - "type": "text" - }, - { - "key": "complexity", - "value": "Undergraduate", - "type": "text" - }, - { - "key": "institution", - "value": "minho", - "type": "text", - "disabled": true - }, - { - "key": "permissionEntity", - "value": "user", - "type": "text" - }, - { - "key": "permissionSubjectId", - "value": "e672bd5c-1412-46f2-b674-561d1eb914e5", - "description": "can be id of any table, which is defined by permissionEntity param", - "type": "text" - }, - { - "key": "permissionClearance", - "value": "4", - "type": "text" - } - ], - "options": { - "formdata": {} - } - }, - "url": { - "raw": "{{api-base-url}}/case/{{case-id}}", - "host": [ - "{{api-base-url}}" - ], - "path": [ - "case", - "{{case-id}}" - ] - } - }, - "response": [] - }, - { - "name": "/case/:id", - "request": { - "method": "DELETE", - "header": [], - "url": { - "raw": "{{api-base-url}}/case/4b317e97-8b04-4f7b-995c-0dafb5c6e95c", - "host": [ - "{{api-base-url}}" - ], - "path": [ - "case", - "4b317e97-8b04-4f7b-995c-0dafb5c6e95c" - ] - } - }, - "response": [] - } - ], - "protocolProfileBehavior": {} - }, - { - "name": "category", - "item": [ - { - "name": "/category/cases", - "event": [ - { - "listen": "test", - "script": { - "id": "044676ee-f127-4025-a648-809b90281551", - "exec": [ - "" - ], - "type": "text/javascript" + "method": "GET", + "header": [], + "url": { + "raw": "{{api-base-url}}/player/quests", + "host": [ + "{{api-base-url}}" + ], + "path": [ + "player", + "quests" + ] + } + }, + "response": [] + }, + { + "name": "/player/quest/cases", + "event": [ + { + "listen": "test", + "script": { + "id": "e4d4a6d3-357b-4d04-aa09-2d744abe950e", + "exec": [ + "" + ], + "type": "text/javascript" } } ], @@ -962,237 +1020,9 @@ "body": { "mode": "formdata", "formdata": [ - { - "key": "categoryId", - "value": "quiz-da-emergencia", - "type": "text" - }, - { - "key": "clearance", - "value": "1", - "type": "text" - }, - { - "key": "published", - "value": "1", - "type": "text" - } - ], - "options": { - "formdata": {} - } - }, - "url": { - "raw": "{{api-base-url}}/category/cases", - "host": [ - "{{api-base-url}}" - ], - "path": [ - "category", - "cases" - ] - } - }, - "response": [] - }, - { - "name": "/category", - "event": [ - { - "listen": "test", - "script": { - "id": "0f970d95-e8d3-40bf-9732-d1f80b57ef5e", - "exec": [ - "var response = pm.response.json();", - "", - "pm.environment.set(\"quest-id\", response.id);" - ], - "type": "text/javascript" - } - } - ], - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "name": "Content-Type", - "type": "text", - "value": "application/x-www-form-urlencoded" - } - ], - "body": { - "mode": "formdata", - "formdata": [ - { - "key": "id", - "value": "desafio-pocus", - "type": "text" - }, - { - "key": "title", - "value": "Desafio POCUS", - "type": "text" - }, - { - "key": "artifact_id", - "value": "desafio-pocus-image", - "type": "text" - } - ], - "options": { - "formdata": {} - } - }, - "url": { - "raw": "{{api-base-url}}/category/", - "host": [ - "{{api-base-url}}" - ], - "path": [ - "category", - "" - ] - } - }, - "response": [] - }, - { - "name": "/category/link/case", - "request": { - "method": "POST", - "header": [], - "body": { - "mode": "formdata", - "formdata": [ - { - "key": "categoryId", - "value": "decisoes-extremas", - "type": "text" - }, - { - "key": "caseId", - "value": "150f89f4-ff11-4795-9d20-a424c025be19", - "type": "text" - }, - { - "key": "orderPosition", - "value": "0", - "type": "text" - } - ], - "options": { - "formdata": {} - } - }, - "url": { - "raw": "{{api-base-url}}/category/link/case", - "host": [ - "{{api-base-url}}" - ], - "path": [ - "category", - "link", - "case" - ] - } - }, - "response": [] - }, - { - "name": "/category/list", - "protocolProfileBehavior": { - "disableBodyPruning": true - }, - "request": { - "method": "GET", - "header": [], - "body": { - "mode": "formdata", - "formdata": [] - }, - "url": { - "raw": "{{api-base-url}}/category/list", - "host": [ - "{{api-base-url}}" - ], - "path": [ - "category", - "list" - ] - } - }, - "response": [] - }, - { - "name": "/category/:id", - "request": { - "method": "PUT", - "header": [], - "url": { - "raw": "{{api-base-url}}/category/decisoes-extremas?title=Desafio POCUS2&artifactId=desafio-de-eletrocardiograma-image", - "host": [ - "{{api-base-url}}" - ], - "path": [ - "category", - "decisoes-extremas" - ], - "query": [ - { - "key": "title", - "value": "Desafio POCUS2" - }, - { - "key": "artifactId", - "value": "desafio-de-eletrocardiograma-image" - } - ] - } - }, - "response": [] - } - ], - "protocolProfileBehavior": {} - }, - { - "name": "artifact", - "item": [ - { - "name": "/artifact", - "request": { - "method": "POST", - "header": [ - { - "key": "Content-Type", - "name": "Content-Type", - "value": "multipart/form-data", - "type": "text" - } - ], - "body": { - "mode": "formdata", - "formdata": [ - { - "key": "file", - "type": "file", - "src": "/home/hmatt/Desktop/Jacinto-images/pocus-challenge.png" - }, - { - "key": "caseId", - "value": "8fac1e26-5824-4b19-9d7b-5091e10856b3", - "type": "text", - "disabled": true - }, { "key": "questId", - "value": "5131b64a-04ff-4aec-af98-0edab334fd02", - "type": "text", - "disabled": true - }, - { - "key": "id", - "value": "desafio-pocus-image", + "value": "ea8dbc12-e879-46e6-b5d7-e67ad88e841b", "type": "text" } ], @@ -1201,70 +1031,32 @@ } }, "url": { - "raw": "{{api-base-url}}/artifact", - "host": [ - "{{api-base-url}}" - ], - "path": [ - "artifact" - ] - } - }, - "response": [] - }, - { - "name": "/artifact (missing check permissions)", - "request": { - "method": "DELETE", - "header": [], - "url": { - "raw": "{{api-base-url}}/artifact/2958b5c9-aa7b-4bf1-882d-4bb47b6f40c4", + "raw": "{{api-base-url}}/player/quest/cases", "host": [ "{{api-base-url}}" ], "path": [ - "artifact", - "2958b5c9-aa7b-4bf1-882d-4bb47b6f40c4" + "player", + "quest", + "cases" ] } }, "response": [] } ], - "event": [ - { - "listen": "prerequest", - "script": { - "id": "ccd62b65-6666-4819-b321-5415554e07e3", - "type": "text/javascript", - "exec": [ - "" - ] - } - }, - { - "listen": "test", - "script": { - "id": "571e27c0-bd7b-4fc9-a441-fdc61a7eb12a", - "type": "text/javascript", - "exec": [ - "" - ] - } - } - ], "protocolProfileBehavior": {} }, { - "name": "player (not tested)", + "name": "author", "item": [ { - "name": "/player/quests", + "name": "/author/quests", "event": [ { "listen": "test", "script": { - "id": "c5e09c82-6f01-4c0c-9120-29e86cde5cc9", + "id": "1fca660b-8774-4143-814c-db7afee7efd3", "exec": [ "" ], @@ -1276,12 +1068,12 @@ "method": "GET", "header": [], "url": { - "raw": "{{api-base-url}}/player/quests", + "raw": "{{api-base-url}}/author/quests", "host": [ "{{api-base-url}}" ], "path": [ - "player", + "author", "quests" ] } @@ -1289,12 +1081,12 @@ "response": [] }, { - "name": "/player/quest/cases", + "name": "/author/quest/cases", "event": [ { "listen": "test", "script": { - "id": "c29ee0b0-d979-4d12-a5eb-87abd6e72430", + "id": "d71fe530-8ff2-4d64-8793-5d77ceaf5ccb", "exec": [ "" ], @@ -1313,7 +1105,7 @@ "formdata": [ { "key": "questId", - "value": "ea8dbc12-e879-46e6-b5d7-e67ad88e841b", + "value": "5131b64a-04ff-4aec-af98-0edab334fd02", "type": "text" } ], @@ -1322,12 +1114,12 @@ } }, "url": { - "raw": "{{api-base-url}}/player/quest/cases", + "raw": "{{api-base-url}}/author/quest/cases", "host": [ "{{api-base-url}}" ], "path": [ - "player", + "author", "quest", "cases" ] @@ -1336,89 +1128,46 @@ "response": [] } ], - "event": [ - { - "listen": "prerequest", - "script": { - "id": "60463d47-ab27-4ae1-a05d-d6932c08c882", - "type": "text/javascript", - "exec": [ - "" - ] - } - }, - { - "listen": "test", - "script": { - "id": "cf51bf0a-20a4-454d-be84-34c592b5900d", - "type": "text/javascript", - "exec": [ - "" - ] - } - } - ], "protocolProfileBehavior": {} }, { - "name": "author (not tested)", + "name": "artifact", "item": [ { - "name": "/author/quests", - "event": [ - { - "listen": "test", - "script": { - "id": "b8107155-ec9a-4503-a34b-eef0c3bc0fcc", - "exec": [ - "" - ], - "type": "text/javascript" - } - } - ], + "name": "/artifact", "request": { - "method": "GET", - "header": [], - "url": { - "raw": "{{api-base-url}}/author/quests", - "host": [ - "{{api-base-url}}" - ], - "path": [ - "author", - "quests" - ] - } - }, - "response": [] - }, - { - "name": "/author/quest/cases", - "event": [ - { - "listen": "test", - "script": { - "id": "cbbb9286-0b0a-474c-a4b5-41002a5cdb95", - "exec": [ - "" - ], - "type": "text/javascript" + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "value": "multipart/form-data", + "type": "text" } - } - ], - "protocolProfileBehavior": { - "disableBodyPruning": true - }, - "request": { - "method": "GET", - "header": [], + ], "body": { "mode": "formdata", "formdata": [ + { + "key": "file", + "type": "file", + "src": "/home/hmatt/Desktop/Jacinto-images/desafio-pocus.png" + }, + { + "key": "caseId", + "value": "8fac1e26-5824-4b19-9d7b-5091e10856b3", + "type": "text", + "disabled": true + }, { "key": "questId", "value": "5131b64a-04ff-4aec-af98-0edab334fd02", + "type": "text", + "disabled": true + }, + { + "key": "id", + "value": "desafio-pocus-image", "type": "text" } ], @@ -1427,14 +1176,30 @@ } }, "url": { - "raw": "{{api-base-url}}/author/quest/cases", + "raw": "{{api-base-url}}/artifact", "host": [ "{{api-base-url}}" ], "path": [ - "author", - "quest", - "cases" + "artifact" + ] + } + }, + "response": [] + }, + { + "name": "/artifact", + "request": { + "method": "DELETE", + "header": [], + "url": { + "raw": "{{api-base-url}}/artifact/2958b5c9-aa7b-4bf1-882d-4bb47b6f40c4", + "host": [ + "{{api-base-url}}" + ], + "path": [ + "artifact", + "2958b5c9-aa7b-4bf1-882d-4bb47b6f40c4" ] } }, @@ -1445,7 +1210,7 @@ { "listen": "prerequest", "script": { - "id": "ac098c7e-4332-43ce-bd6b-7fa92a865f68", + "id": "7bc7d2a4-7bbc-48af-8fee-153860cad3d5", "type": "text/javascript", "exec": [ "" @@ -1455,7 +1220,7 @@ { "listen": "test", "script": { - "id": "ad1e47e5-49c5-4bb8-8bb4-0306e956b625", + "id": "d36a0f4e-2db8-434c-b0bc-770d22e17c89", "type": "text/javascript", "exec": [ "" @@ -1466,7 +1231,7 @@ "protocolProfileBehavior": {} }, { - "name": "quest (unstable)", + "name": "quest", "item": [ { "name": "/quest/users", @@ -1474,7 +1239,7 @@ { "listen": "test", "script": { - "id": "7dd4479e-3e8c-41e8-b5ca-092234faa06a", + "id": "69612a32-fec9-4c59-b25d-2b672a45cbf1", "exec": [ "" ], @@ -1515,12 +1280,12 @@ "response": [] }, { - "name": "/quest (broken)", + "name": "/quest", "event": [ { "listen": "test", "script": { - "id": "26e390fb-2f7e-4bc8-9c66-1ac226a63f56", + "id": "eb43d5c2-763e-4c25-ac0a-0b2ddf2179cb", "exec": [ "var response = pm.response.json();", "", @@ -1577,7 +1342,7 @@ "response": [] }, { - "name": "/quest/link/user (not tested)", + "name": "/quest/link/user", "request": { "method": "POST", "header": [], @@ -1619,7 +1384,7 @@ "response": [] }, { - "name": "/quest/link/case (not tested)", + "name": "/quest/link/case", "request": { "method": "POST", "header": [], @@ -1663,6 +1428,220 @@ ], "protocolProfileBehavior": {} }, + { + "name": "category", + "item": [ + { + "name": "/category/cases", + "event": [ + { + "listen": "test", + "script": { + "id": "626a67ae-8150-4f96-bc9f-2f7c16c9bde9", + "exec": [ + "" + ], + "type": "text/javascript" + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [], + "body": { + "mode": "formdata", + "formdata": [ + { + "key": "categoryId", + "value": "decisoesExtremas", + "type": "text" + } + ], + "options": { + "formdata": {} + } + }, + "url": { + "raw": "{{api-base-url}}/category/cases", + "host": [ + "{{api-base-url}}" + ], + "path": [ + "category", + "cases" + ] + } + }, + "response": [] + }, + { + "name": "/category", + "event": [ + { + "listen": "test", + "script": { + "id": "3b6e6f6b-df17-42e8-959a-513e0dedc099", + "exec": [ + "var response = pm.response.json();", + "", + "pm.environment.set(\"quest-id\", response.id);" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "type": "text", + "value": "application/x-www-form-urlencoded" + } + ], + "body": { + "mode": "formdata", + "formdata": [ + { + "key": "id", + "value": "desafio-pocus", + "type": "text" + }, + { + "key": "title", + "value": "Desafio POCUS", + "type": "text" + }, + { + "key": "template", + "value": "desafio-pocus", + "type": "text" + }, + { + "key": "artifact_id", + "value": "desafio-pocus-image", + "type": "text" + } + ], + "options": { + "formdata": {} + } + }, + "url": { + "raw": "{{api-base-url}}/category/", + "host": [ + "{{api-base-url}}" + ], + "path": [ + "category", + "" + ] + } + }, + "response": [] + }, + { + "name": "/category/link/case", + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "formdata", + "formdata": [ + { + "key": "categoryId", + "value": "decisoes-extremas", + "type": "text" + }, + { + "key": "caseId", + "value": "150f89f4-ff11-4795-9d20-a424c025be19", + "type": "text" + }, + { + "key": "orderPosition", + "value": "0", + "type": "text" + } + ], + "options": { + "formdata": {} + } + }, + "url": { + "raw": "{{api-base-url}}/category/link/case", + "host": [ + "{{api-base-url}}" + ], + "path": [ + "category", + "link", + "case" + ] + } + }, + "response": [] + }, + { + "name": "/category/list", + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [], + "body": { + "mode": "formdata", + "formdata": [] + }, + "url": { + "raw": "{{api-base-url}}/category/list", + "host": [ + "{{api-base-url}}" + ], + "path": [ + "category", + "list" + ] + } + }, + "response": [] + }, + { + "name": "/category/:id", + "request": { + "method": "PUT", + "header": [], + "url": { + "raw": "{{api-base-url}}/category/desafio-pocus?artifactId=desafio-pocus-image&title=Desafio Pocus", + "host": [ + "{{api-base-url}}" + ], + "path": [ + "category", + "desafio-pocus" + ], + "query": [ + { + "key": "artifactId", + "value": "desafio-pocus-image" + }, + { + "key": "title", + "value": "Desafio Pocus" + } + ] + } + }, + "response": [] + } + ], + "protocolProfileBehavior": {} + }, { "name": "admin", "item": [ @@ -1672,7 +1651,7 @@ { "listen": "test", "script": { - "id": "e9e927dd-a062-4c2c-a53a-426febd03445", + "id": "0da4e91e-5a5a-43c6-8fef-223dce72f31f", "exec": [ "var response = pm.response.json();", "", @@ -1720,7 +1699,7 @@ { "listen": "test", "script": { - "id": "3b93f744-c5b9-4657-a42c-4ab5e002a7a6", + "id": "edfe7693-8604-45bf-b2bf-600cea846dc0", "exec": [ "var response = pm.response.json();", "", @@ -1777,7 +1756,7 @@ { "listen": "test", "script": { - "id": "111bda7d-bf1c-4f25-b77c-74c8ceee2a03", + "id": "540ef4ca-e4a5-499d-b06b-e538b4702286", "exec": [ "" ], @@ -1807,7 +1786,7 @@ { "listen": "test", "script": { - "id": "ed683b4a-66ee-4311-bbe8-c3c8132f6029", + "id": "6055d49e-f43b-4c6e-8a1f-b63e32c17e11", "exec": [ "" ], @@ -1839,7 +1818,7 @@ { "listen": "test", "script": { - "id": "3eab3634-1332-4d35-b870-065289ac4907", + "id": "222550fd-5a12-4a17-bcef-a3ae88e1be3f", "exec": [ "" ], @@ -1907,7 +1886,7 @@ { "listen": "test", "script": { - "id": "0ab72452-d863-4c6f-8b1e-3edad8c9e203", + "id": "29920f59-a6b7-4f3e-8909-b7171419cb07", "exec": [ "" ], @@ -1967,7 +1946,7 @@ { "listen": "test", "script": { - "id": "8cb10d35-29b4-4bf9-9509-d0d0e999c967", + "id": "519ed505-fbc6-4eb8-995e-c704486a84b7", "exec": [ "" ], @@ -2054,7 +2033,7 @@ { "listen": "test", "script": { - "id": "db01cfae-e3cd-4356-99ec-6368d13819f3", + "id": "f1647ef8-7e68-4b0a-8bfe-91b84283904f", "exec": [ "" ], @@ -2132,7 +2111,7 @@ { "listen": "test", "script": { - "id": "17834a20-07bf-4b9d-8395-627e092c5494", + "id": "94c53d16-ddb2-40c4-8c24-9849f2caf53c", "exec": [ "" ], @@ -2178,7 +2157,7 @@ { "listen": "test", "script": { - "id": "8f8151f7-4a69-4ab3-b3dc-6389ad72c862", + "id": "7667499e-a7f5-4236-9eb6-3e8ca72e7e27", "exec": [ "var response = pm.response.json();", "", @@ -2279,7 +2258,7 @@ { "listen": "prerequest", "script": { - "id": "3927cd99-79b1-4c21-aafe-6f36290aaa96", + "id": "304b8626-14c1-4881-8a2a-881c9fa0d3bc", "type": "text/javascript", "exec": [ "" @@ -2289,7 +2268,7 @@ { "listen": "test", "script": { - "id": "9522c5ea-7ebe-42be-92b2-ac52bf674283", + "id": "67ec55a1-a62c-4dc7-bcfe-0d21b1d13da8", "type": "text/javascript", "exec": [ ""