From 2f3045bce75b965b08aa2ce93ba377ce6785e619 Mon Sep 17 00:00:00 2001 From: Daniel Silva Date: Mon, 26 Aug 2024 17:10:26 -0500 Subject: [PATCH] #29535 Include postman test for the PATCH case (#29751) Includes a postman test for updating content using default workflow + PATCH --- .../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..c576f63c1873 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": [ { @@ -9672,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": [] } ] }, @@ -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