Skip to content

Commit

Permalink
#29535 Include postman test for the PATCH case (#29751)
Browse files Browse the repository at this point in the history
Includes a postman test for updating content using default workflow +
PATCH
  • Loading branch information
dsilvam authored Aug 26, 2024
1 parent fb1e248 commit 2f3045b
Showing 1 changed file with 119 additions and 2 deletions.
121 changes: 119 additions & 2 deletions dotcms-postman/src/main/resources/postman/Workflow_Resource_Tests.json
Original file line number Diff line number Diff line change
@@ -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": [
{
Expand Down Expand Up @@ -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": []
}
]
},
Expand Down Expand Up @@ -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);",
" }",
" });",
" }",
"}",
""
]
}
Expand Down Expand Up @@ -17451,6 +17556,18 @@
{
"key": "temporalFileOneId",
"value": ""
},
{
"key": "contentletIdentifier",
"value": ""
},
{
"key": "contentletInode",
"value": ""
},
{
"key": "fireActionLanguageKey",
"value": ""
}
]
}

0 comments on commit 2f3045b

Please sign in to comment.