-
Notifications
You must be signed in to change notification settings - Fork 467
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…4267) * Implementing SonarQube feedback. * #23603 : Allow users to write code when creating a file * Adding more code changes and Postman tests. * Fixing other Postman Tests. * #23603 : Forbid access to Temp File update method for Anonymous Users. * Implementing SonarQube feedback. * Implementing SonarQube feedback. * #23603 : Creating new branch based on master. * Implementing JS feedback from Manuel Rojas. * Implementing more JS feedback from Manuel Rojas.
- Loading branch information
1 parent
124ec30
commit b6f0095
Showing
7 changed files
with
945 additions
and
292 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,279 @@ | ||
{ | ||
"info": { | ||
"_postman_id": "1faea77b-c035-4129-a215-3608487d19b3", | ||
"_postman_id": "b65639a1-cec6-4b6c-b8b6-ab483db33b5b", | ||
"name": "TempAPI", | ||
"description": "Verifies that the Temp File API is working as expected. It allows users to create temporary files in the dotCMS assets folder.", | ||
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", | ||
"_exporter_id": "11174695" | ||
"_exporter_id": "5403727" | ||
}, | ||
"item": [ | ||
{ | ||
"name": "Temp File As Plain Text", | ||
"item": [ | ||
{ | ||
"name": "Create Temp File", | ||
"event": [ | ||
{ | ||
"listen": "prerequest", | ||
"script": { | ||
"exec": [ | ||
"let randomNumber = Math.floor(Math.random() * 100);", | ||
"pm.collectionVariables.set(\"tempFileName\", randomNumber + \"-test-temp-file.txt\");" | ||
], | ||
"type": "text/javascript" | ||
} | ||
}, | ||
{ | ||
"listen": "test", | ||
"script": { | ||
"exec": [ | ||
"pm.test(\"Test Temporary File creation HTTP Status must be successful\", function() {", | ||
" pm.response.to.have.status(200);", | ||
"});", | ||
"", | ||
"pm.collectionVariables.set(\"tempFileId\", pm.response.json().tempFiles[0].id);" | ||
], | ||
"type": "text/javascript" | ||
} | ||
} | ||
], | ||
"request": { | ||
"auth": { | ||
"type": "basic", | ||
"basic": [ | ||
{ | ||
"key": "username", | ||
"value": "[email protected]", | ||
"type": "string" | ||
}, | ||
{ | ||
"key": "password", | ||
"value": "admin", | ||
"type": "string" | ||
} | ||
] | ||
}, | ||
"method": "PUT", | ||
"header": [ | ||
{ | ||
"key": "Origin", | ||
"value": "localhost", | ||
"type": "text" | ||
} | ||
], | ||
"body": { | ||
"mode": "raw", | ||
"raw": "{\n \"fileName\": \"{{tempFileName}}\",\n \"fileContent\": \"This is the content of the Temporary File.\"\n}", | ||
"options": { | ||
"raw": { | ||
"language": "json" | ||
} | ||
} | ||
}, | ||
"url": { | ||
"raw": "{{serverURL}}/api/v1/temp/id/new", | ||
"host": [ | ||
"{{serverURL}}" | ||
], | ||
"path": [ | ||
"api", | ||
"v1", | ||
"temp", | ||
"id", | ||
"new" | ||
] | ||
} | ||
}, | ||
"response": [] | ||
}, | ||
{ | ||
"name": "Update Existing Temp File Content", | ||
"event": [ | ||
{ | ||
"listen": "test", | ||
"script": { | ||
"exec": [ | ||
"pm.test(\"Test Temporary File update HTTP Status must be successful\", function() {", | ||
" pm.response.to.have.status(200);", | ||
"});", | ||
"", | ||
"pm.test(\"Temporary File ID must be the same\", function() {", | ||
" let tempFileId = pm.collectionVariables.get(\"tempFileId\");", | ||
" pm.expect(pm.response.json().tempFiles[0].id).to.eql(tempFileId, \"An error occurred when checking the temp file ID\");", | ||
"});" | ||
], | ||
"type": "text/javascript" | ||
} | ||
} | ||
], | ||
"request": { | ||
"auth": { | ||
"type": "basic", | ||
"basic": [ | ||
{ | ||
"key": "username", | ||
"value": "[email protected]", | ||
"type": "string" | ||
}, | ||
{ | ||
"key": "password", | ||
"value": "admin", | ||
"type": "string" | ||
} | ||
] | ||
}, | ||
"method": "PUT", | ||
"header": [ | ||
{ | ||
"key": "Origin", | ||
"value": "localhost", | ||
"type": "text" | ||
} | ||
], | ||
"body": { | ||
"mode": "raw", | ||
"raw": "{\n \"fileName\": \"{{tempFileName}}\",\n \"fileContent\": \"This is the new content of the Temporary File.\"\n}", | ||
"options": { | ||
"raw": { | ||
"language": "json" | ||
} | ||
} | ||
}, | ||
"url": { | ||
"raw": "{{serverURL}}/api/v1/temp/id/{{tempFileId}}", | ||
"host": [ | ||
"{{serverURL}}" | ||
], | ||
"path": [ | ||
"api", | ||
"v1", | ||
"temp", | ||
"id", | ||
"{{tempFileId}}" | ||
] | ||
} | ||
}, | ||
"response": [] | ||
}, | ||
{ | ||
"name": "Update Non-Existent Temp File", | ||
"event": [ | ||
{ | ||
"listen": "test", | ||
"script": { | ||
"exec": [ | ||
"pm.test(\"Non-Existing Test Temporary File creation HTTP Status must be successful\", function() {", | ||
" pm.response.to.have.status(200);", | ||
"});", | ||
"", | ||
"pm.test(\"New Temporary File ID must NOT match the previous one\", function() {", | ||
" let tempFileId = pm.collectionVariables.get(\"tempFileId\");", | ||
" pm.expect(pm.response.json().tempFiles[0].id).to.not.eql(tempFileId, \"An error occurred when checking different temp file IDs\");", | ||
"});" | ||
], | ||
"type": "text/javascript" | ||
} | ||
}, | ||
{ | ||
"listen": "prerequest", | ||
"script": { | ||
"exec": [ | ||
"let randomNumber = Math.floor(Math.random() * 100);", | ||
"pm.collectionVariables.set(\"tempFileName\", \"new-\" + randomNumber + \"-test-temp-file.txt\");" | ||
], | ||
"type": "text/javascript" | ||
} | ||
} | ||
], | ||
"request": { | ||
"auth": { | ||
"type": "basic", | ||
"basic": [ | ||
{ | ||
"key": "username", | ||
"value": "[email protected]", | ||
"type": "string" | ||
}, | ||
{ | ||
"key": "password", | ||
"value": "admin", | ||
"type": "string" | ||
} | ||
] | ||
}, | ||
"method": "PUT", | ||
"header": [ | ||
{ | ||
"key": "Origin", | ||
"value": "localhost", | ||
"type": "text" | ||
} | ||
], | ||
"body": { | ||
"mode": "raw", | ||
"raw": "{\n \"fileName\": \"{{tempFileName}}\",\n \"fileContent\": \"Here is some test content.\"\n}", | ||
"options": { | ||
"raw": { | ||
"language": "json" | ||
} | ||
} | ||
}, | ||
"url": { | ||
"raw": "{{serverURL}}/api/v1/temp/id/non-existent-id", | ||
"host": [ | ||
"{{serverURL}}" | ||
], | ||
"path": [ | ||
"api", | ||
"v1", | ||
"temp", | ||
"id", | ||
"non-existent-id" | ||
] | ||
} | ||
}, | ||
"response": [] | ||
} | ||
], | ||
"description": "This request collection creates Temporary Files provided as plain text instead of binary files." | ||
}, | ||
{ | ||
"name": "Upload Multiple with one wrong file", | ||
"event": [ | ||
{ | ||
"listen": "test", | ||
"script": { | ||
"exec": [ | ||
"var jsonData = pm.response.json();", | ||
"pm.test(\"Checking file names and operation status code\", function () {", | ||
" var jsonData = pm.response.json();", | ||
" let found = false;", | ||
" jsonData.tempFiles.forEach((item) => {", | ||
"", | ||
"pm.test(\"File name check\", function () {", | ||
" pm.expect(jsonData.tempFiles[0].fileName).to.eql('Landscape_2009_romantic_country_garden.jpeg');", | ||
" pm.expect(jsonData.tempFiles[1].fileName).to.eql('16475687531_eac8a30914_b.jpeg');", | ||
" pm.expect(jsonData.tempFiles[2].errorCode).to.eql('400');", | ||
"});", | ||
" if (item.fileName == \"Landscape_2009_romantic_country_garden.jpeg\") {", | ||
" found = true;", | ||
" }", | ||
"", | ||
" });", | ||
" pm.expect(found).to.eq(true, \"Expected image 'Landscape_2009_romantic_country_garden.jpeg' was not found.\")", | ||
" found = false;", | ||
" jsonData.tempFiles.forEach((item) => {", | ||
"", | ||
" if (item.fileName == \"16475687531_eac8a30914_b.jpeg\") {", | ||
" found = true;", | ||
" }", | ||
"", | ||
" });", | ||
" pm.expect(found).to.eq(true, \"Expected image '16475687531_eac8a30914_b.jpeg' was not found.\")", | ||
" found = false;", | ||
" jsonData.tempFiles.forEach((item) => {", | ||
"", | ||
" if (item.errorCode == \"400\") {", | ||
" found = true;", | ||
" }", | ||
"", | ||
" });", | ||
" pm.expect(found).to.eq(true, \"Expected error code '400' not found.\")", | ||
"});", | ||
"" | ||
], | ||
"type": "text/javascript" | ||
|
@@ -157,5 +410,35 @@ | |
}, | ||
"response": [] | ||
} | ||
], | ||
"event": [ | ||
{ | ||
"listen": "prerequest", | ||
"script": { | ||
"type": "text/javascript", | ||
"exec": [ | ||
"" | ||
] | ||
} | ||
}, | ||
{ | ||
"listen": "test", | ||
"script": { | ||
"type": "text/javascript", | ||
"exec": [ | ||
"" | ||
] | ||
} | ||
} | ||
], | ||
"variable": [ | ||
{ | ||
"key": "tempFileName", | ||
"value": "" | ||
}, | ||
{ | ||
"key": "tempFileId", | ||
"value": "" | ||
} | ||
] | ||
} |
Oops, something went wrong.