From cd5df0b9154a9b0508396f197340b0f549ade78f Mon Sep 17 00:00:00 2001 From: Daniel Silva Date: Mon, 26 Aug 2024 11:58:15 -0600 Subject: [PATCH 1/2] #29535 Include postman test for the PATCH case --- .../postman/Workflow_Resource_Tests.json | 121 +++++++++++++++++- 1 file changed, 119 insertions(+), 2 deletions(-) diff --git a/dotcms-postman/src/main/resources/postman/Workflow_Resource_Tests.json b/dotcms-postman/src/main/resources/postman/Workflow_Resource_Tests.json index 63536de96d0d..552bac4d0f1d 100644 --- a/dotcms-postman/src/main/resources/postman/Workflow_Resource_Tests.json +++ b/dotcms-postman/src/main/resources/postman/Workflow_Resource_Tests.json @@ -1,10 +1,10 @@ { "info": { - "_postman_id": "3e3539fd-4915-4514-a0d0-dc1d142a6f7f", + "_postman_id": "2a422520-eec4-42b3-94c3-5126f2691138", "name": "Workflow Resource Tests [/api/v1/workflows]", "description": "Test the necesary validations to every end point of the worlflow resource ", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", - "_exporter_id": "31066048" + "_exporter_id": "4500400" }, "item": [ { @@ -9126,6 +9126,71 @@ }, "response": [] }, + { + "name": "UpdateContent", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200 \", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "", + "", + "pm.test(\"Valid response\", function () {", + " pm.expect(pm.response.text()).to.include(\"SucessRequest\");", + "});", + "", + "var jsonData = pm.response.json();", + "", + "pm.test(\"Key Value updated\", function () {", + " let contentIdentifier = pm.collectionVariables.get(\"contentletIdentifier\");", + " let contentlet = jsonData.entity.results[0][contentIdentifier];", + " pm.expect(contentlet.key).include(\"SucessRequest-Updated\"); ", + " pm.expect(contentlet.value).include(\"SucessRequest-Updated\");", + "});", + "", + "", + "" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "method": "PATCH", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{ \"contentlet\" : {\n \"identifier\": \"{{contentletIdentifier}}\", \n \"key\": \"SucessRequest-Updated{{$timestamp}}\",\n \"value\": \"SucessRequest-Updated{{$timestamp}}\"\n}\n}" + }, + "url": { + "raw": "{{serverURL}}/api/v1/workflow/actions/default/fire/PUBLISH", + "host": [ + "{{serverURL}}" + ], + "path": [ + "api", + "v1", + "workflow", + "actions", + "default", + "fire", + "PUBLISH" + ] + }, + "description": "Updates content fields \"key\" and \"value\" by using the PATCH verb.\n\nAsserts the fields \"key\" and \"value\" were effectively updated." + }, + "response": [] + }, { "name": "Fire Publish BaseType Can Not Be Resolved BadRequest", "event": [ @@ -17413,6 +17478,46 @@ "script": { "type": "text/javascript", "exec": [ + "if (!pm.environment.get('jwt')) {", + " console.log(\"generating....\")", + " const serverURL = pm.environment.get('serverURL'); // Get the server URL from the environment variable", + " const apiUrl = `${serverURL}/api/v1/apitoken`; // Construct the full API URL", + "", + " if (!pm.environment.get('jwt')) {", + " const username = pm.environment.get(\"user\");", + " const password = pm.environment.get(\"password\");", + " const basicAuth = Buffer.from(`${username}:${password}`).toString('base64');", + "", + " const requestOptions = {", + " url: apiUrl,", + " method: \"POST\",", + " header: {", + " \"accept\": \"*/*\",", + " \"content-type\": \"application/json\",", + " \"Authorization\": `Basic ${basicAuth}`", + " },", + " body: {", + " mode: \"raw\",", + " raw: JSON.stringify({", + " \"expirationSeconds\": 7200,", + " \"userId\": \"dotcms.org.1\",", + " \"network\": \"0.0.0.0/0\",", + " \"claims\": {\"label\": \"postman-tests\"}", + " })", + " }", + " };", + "", + " pm.sendRequest(requestOptions, function (err, response) {", + " if (err) {", + " console.log(err);", + " } else {", + " const jwt = response.json().entity.jwt;", + " pm.environment.set('jwt', jwt);", + " console.log(jwt);", + " }", + " });", + " }", + "}", "" ] } @@ -17451,6 +17556,18 @@ { "key": "temporalFileOneId", "value": "" + }, + { + "key": "contentletIdentifier", + "value": "" + }, + { + "key": "contentletInode", + "value": "" + }, + { + "key": "fireActionLanguageKey", + "value": "" } ] } \ No newline at end of file From 48eee639a4e29e0f2a86a397cdc45d86ebcf1ea3 Mon Sep 17 00:00:00 2001 From: Daniel Silva Date: Mon, 26 Aug 2024 14:56:32 -0600 Subject: [PATCH 2/2] #29535 change order of postman --- .../postman/Workflow_Resource_Tests.json | 130 +++++++++--------- 1 file changed, 65 insertions(+), 65 deletions(-) diff --git a/dotcms-postman/src/main/resources/postman/Workflow_Resource_Tests.json b/dotcms-postman/src/main/resources/postman/Workflow_Resource_Tests.json index 552bac4d0f1d..c576f63c1873 100644 --- a/dotcms-postman/src/main/resources/postman/Workflow_Resource_Tests.json +++ b/dotcms-postman/src/main/resources/postman/Workflow_Resource_Tests.json @@ -9126,71 +9126,6 @@ }, "response": [] }, - { - "name": "UpdateContent", - "event": [ - { - "listen": "test", - "script": { - "exec": [ - "pm.test(\"Status code is 200 \", function () {", - " pm.response.to.have.status(200);", - "});", - "", - "", - "", - "pm.test(\"Valid response\", function () {", - " pm.expect(pm.response.text()).to.include(\"SucessRequest\");", - "});", - "", - "var jsonData = pm.response.json();", - "", - "pm.test(\"Key Value updated\", function () {", - " let contentIdentifier = pm.collectionVariables.get(\"contentletIdentifier\");", - " let contentlet = jsonData.entity.results[0][contentIdentifier];", - " pm.expect(contentlet.key).include(\"SucessRequest-Updated\"); ", - " pm.expect(contentlet.value).include(\"SucessRequest-Updated\");", - "});", - "", - "", - "" - ], - "type": "text/javascript", - "packages": {} - } - } - ], - "request": { - "method": "PATCH", - "header": [ - { - "key": "Content-Type", - "value": "application/json" - } - ], - "body": { - "mode": "raw", - "raw": "{ \"contentlet\" : {\n \"identifier\": \"{{contentletIdentifier}}\", \n \"key\": \"SucessRequest-Updated{{$timestamp}}\",\n \"value\": \"SucessRequest-Updated{{$timestamp}}\"\n}\n}" - }, - "url": { - "raw": "{{serverURL}}/api/v1/workflow/actions/default/fire/PUBLISH", - "host": [ - "{{serverURL}}" - ], - "path": [ - "api", - "v1", - "workflow", - "actions", - "default", - "fire", - "PUBLISH" - ] - }, - "description": "Updates content fields \"key\" and \"value\" by using the PATCH verb.\n\nAsserts the fields \"key\" and \"value\" were effectively updated." - }, - "response": [] - }, { "name": "Fire Publish BaseType Can Not Be Resolved BadRequest", "event": [ @@ -9737,6 +9672,71 @@ "description": "Fire any action using the actionId\n\nOptional: If you pass ?inode={inode}, you don't need body here.\n\n@Path(\"/actions/{actionId}/fire\")" }, "response": [] + }, + { + "name": "UpdateContent", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200 \", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "", + "", + "pm.test(\"Valid response\", function () {", + " pm.expect(pm.response.text()).to.include(\"SucessRequest\");", + "});", + "", + "var jsonData = pm.response.json();", + "", + "pm.test(\"Key Value updated\", function () {", + " let contentIdentifier = pm.collectionVariables.get(\"contentletIdentifier\");", + " let contentlet = jsonData.entity.results[0][contentIdentifier];", + " pm.expect(contentlet.key).include(\"SucessRequest-Updated\"); ", + " pm.expect(contentlet.value).include(\"SucessRequest-Updated\");", + "});", + "", + "", + "" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "method": "PATCH", + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": { + "mode": "raw", + "raw": "{ \"contentlet\" : {\n \"identifier\": \"{{contentletIdentifier}}\", \n \"key\": \"SucessRequest-Updated{{$timestamp}}\",\n \"value\": \"SucessRequest-Updated{{$timestamp}}\"\n}\n}" + }, + "url": { + "raw": "{{serverURL}}/api/v1/workflow/actions/default/fire/PUBLISH", + "host": [ + "{{serverURL}}" + ], + "path": [ + "api", + "v1", + "workflow", + "actions", + "default", + "fire", + "PUBLISH" + ] + }, + "description": "Updates content fields \"key\" and \"value\" by using the PATCH verb.\n\nAsserts the fields \"key\" and \"value\" were effectively updated." + }, + "response": [] } ] },