1
0
mirror of https://github.com/stonith404/pingvin-share.git synced 2024-11-05 23:40:12 +01:00
pingvin-share/backend/test/newman-system-tests.json

1265 lines
28 KiB
JSON
Raw Normal View History

2022-10-13 23:25:04 +02:00
{
"info": {
2023-01-31 15:43:54 +01:00
"_postman_id": "cd31bdf9-d558-42da-9231-154721476cd2",
2022-10-13 23:25:04 +02:00
"name": "Pingvin Share Testing",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"_exporter_id": "17822132"
},
"item": [
{
"name": "_setup",
"item": [
{
"name": "Sign Up",
"event": [
{
"listen": "test",
"script": {
"exec": [
"if(pm.response.to.have.status(201)){",
" const token = pm.response.json()[\"accessToken\"]",
" // Get user id",
" const jwtPayload = JSON.parse(atob(token.split('.')[1]));",
" const userId = jwtPayload[\"sub\"]",
" pm.collectionVariables.set(\"USER_ID\", userId)",
2023-01-04 15:58:15 +01:00
"",
" pm.collectionVariables.set(\"COOKIES\", pm.response.headers.get(\"Set-Cookie\"))",
2022-10-13 23:25:04 +02:00
"}",
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"email\": \"system@test.org\",\n \"username\": \"system.test\",\n \"password\": \"J2y8unpJUcJDRv\"\n}",
2022-10-13 23:25:04 +02:00
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{API_URL}}/auth/signUp",
"host": [
"{{API_URL}}"
],
"path": [
"auth",
"signUp"
]
}
},
"response": []
}
]
},
{
"name": "Auth",
"item": [
{
"name": "Positive",
"item": [
{
"name": "Sign Up",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 201\", () => {",
" pm.response.to.have.status(201);",
"});",
"",
"pm.test(\"Response contains tokens\", () => {",
" const responseBody = pm.response.json();",
" pm.expect(responseBody).to.have.property(\"accessToken\")",
" pm.expect(responseBody).to.have.property(\"refreshToken\")",
"});",
2023-01-04 15:58:15 +01:00
"",
2022-10-13 23:25:04 +02:00
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Accept-Language",
"value": "de",
"type": "text"
}
],
"body": {
"mode": "raw",
2023-01-04 15:58:15 +01:00
"raw": "{\n \"email\": \"system2@test.org\",\n \"username\": \"system2.test\",\n \"password\": \"N44HcHgeuAvfCT\"\n}",
2022-10-13 23:25:04 +02:00
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{API_URL}}/auth/signUp",
"host": [
"{{API_URL}}"
],
"path": [
"auth",
"signUp"
]
}
},
"response": []
},
{
"name": "Sign In",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", () => {",
" pm.response.to.have.status(200);",
"});",
"",
"pm.test(\"Response contains tokens\", () => {",
" const responseBody = pm.response.json();",
" pm.expect(responseBody).to.have.property(\"accessToken\")",
" pm.expect(responseBody).to.have.property(\"refreshToken\")",
"});",
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Accept-Language",
"value": "de",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"email\": \"system2@test.org\",\n \"password\": \"N44HcHgeuAvfCT\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{API_URL}}/auth/signIn",
"host": [
"{{API_URL}}"
],
"path": [
"auth",
"signIn"
]
}
},
"response": []
}
]
},
{
"name": "Negative",
"item": [
{
"name": "Sign Up - Without email",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 400\", () => {",
" pm.response.to.have.status(400);",
"});"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Accept-Language",
"value": "de",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"password\": \"N44HcHgeuAvfCT\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{API_URL}}/auth/signUp",
"host": [
"{{API_URL}}"
],
"path": [
"auth",
"signUp"
]
}
},
"response": []
},
{
"name": "Sign Up - Without password",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 400\", () => {",
" pm.response.to.have.status(400);",
"});"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Accept-Language",
"value": "de",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"email\": \"system3@test.org\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{API_URL}}/auth/signUp",
"host": [
"{{API_URL}}"
],
"path": [
"auth",
"signUp"
]
}
},
"response": []
},
{
"name": "Sign In - Wrong email",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 401\", () => {",
" pm.response.to.have.status(401);",
"});",
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Accept-Language",
"value": "de",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"email\": \"wrong-email@test.org\",\n \"password\": \"N44HcHgeuAvfCT\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{API_URL}}/auth/signIn",
"host": [
"{{API_URL}}"
],
"path": [
"auth",
"signIn"
]
}
},
"response": []
},
{
"name": "Sign In - Wrong password",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 401\", () => {",
" pm.response.to.have.status(401);",
"});",
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Accept-Language",
"value": "de",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"email\": \"system2@test.org\",\n \"password\": \"wrong-password\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{API_URL}}/auth/signIn",
"host": [
"{{API_URL}}"
],
"path": [
"auth",
"signIn"
]
}
},
"response": []
}
]
}
]
},
{
"name": "Create Share",
"item": [
{
"name": "Positive",
"item": [
{
"name": "Check share id availability",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", () => {",
" pm.response.to.have.status(200);",
"});",
"",
"pm.test(\"Response body correct\", () => {",
" const responseBody = pm.response.json();",
" pm.expect(responseBody.isAvailable).to.be.equal(true)",
" pm.expect(Object.keys(responseBody).length).be.equal(1)",
"});",
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{API_URL}}/shares/isShareIdAvailable/:id",
"host": [
"{{API_URL}}"
],
"path": [
"shares",
"isShareIdAvailable",
":id"
],
"variable": [
{
"key": "id",
"value": "test-share"
}
]
}
},
"response": []
},
{
"name": "Create Share",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 201\", () => {",
" pm.response.to.have.status(201);",
"});",
"",
"pm.test(\"Response body correct\", () => {",
" const responseBody = pm.response.json();",
" pm.expect(responseBody).to.have.property(\"id\")",
" pm.expect(responseBody).to.have.property(\"expiration\")",
2022-12-13 18:44:17 +01:00
" pm.expect(Object.keys(responseBody).length).be.equal(3)",
2022-10-13 23:25:04 +02:00
"});",
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"id\": \"test-share\",\n \"expiration\": \"1-day\",\n \"recipients\": [],\n \"security\": {\n \"password\": \"share-password\",\n \"maxViews\": 1\n }\n}",
2022-10-13 23:25:04 +02:00
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{API_URL}}/shares",
"host": [
"{{API_URL}}"
],
"path": [
"shares"
]
}
},
"response": []
},
{
"name": "Upload file",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 201\", () => {",
" pm.response.to.have.status(201);",
"});",
"",
"pm.test(\"Response body correct\", () => {",
" const responseBody = pm.response.json();",
" pm.expect(responseBody).to.have.property(\"id\")",
" pm.expect(responseBody.name).to.be.equal(\"test-file.txt\")",
" pm.expect(Object.keys(responseBody).length).be.equal(2)",
2022-10-13 23:25:04 +02:00
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disabledSystemHeaders": {
"content-type": true
}
},
2022-10-13 23:25:04 +02:00
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/octet-stream",
"type": "text"
}
],
2022-10-13 23:25:04 +02:00
"body": {
"mode": "raw",
"raw": "data:application/octet-stream;base64,VGhpcyBpcyBhIHRlc3QgZmlsZWQgdXNlZCBmb3IgdXBsb2FkaW5nIGluIHRoZSBzeXN0ZW0gdGVzdC4="
2022-10-13 23:25:04 +02:00
},
"url": {
"raw": "{{API_URL}}/shares/:shareId/files?name=test-file.txt&chunkIndex=0&totalChunks=1",
2022-10-13 23:25:04 +02:00
"host": [
"{{API_URL}}"
],
"path": [
"shares",
":shareId",
"files"
],
"query": [
{
"key": "name",
"value": "test-file.txt"
},
{
"key": "chunkIndex",
"value": "0"
},
{
"key": "totalChunks",
"value": "1"
}
],
2022-10-13 23:25:04 +02:00
"variable": [
{
"key": "shareId",
"value": "test-share"
}
]
}
},
"response": []
},
2022-12-13 18:44:17 +01:00
{
"name": "Upload file 2",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 201\", () => {",
" pm.response.to.have.status(201);",
"});",
"",
"pm.test(\"Response body correct\", () => {",
" const responseBody = pm.response.json();",
" pm.expect(responseBody.name).to.be.equal(\"test-file2.txt\")",
" pm.expect(Object.keys(responseBody).length).be.equal(2)",
2022-12-13 18:44:17 +01:00
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disabledSystemHeaders": {
"content-type": true
}
},
2022-12-13 18:44:17 +01:00
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/octet-stream",
"type": "text"
}
],
2022-12-13 18:44:17 +01:00
"body": {
"mode": "raw",
"raw": "data:application/octet-stream;base64,VGhpcyBpcyBhIHRlc3QgZmlsZWQgdXNlZCBmb3IgdXBsb2FkaW5nIGluIHRoZSBzeXN0ZW0gdGVzdC4="
2022-12-13 18:44:17 +01:00
},
"url": {
"raw": "{{API_URL}}/shares/:shareId/files?name=test-file2.txt&chunkIndex=0&totalChunks=1",
2022-12-13 18:44:17 +01:00
"host": [
"{{API_URL}}"
],
"path": [
"shares",
":shareId",
"files"
],
"query": [
{
"key": "name",
"value": "test-file2.txt"
},
{
"key": "chunkIndex",
"value": "0"
},
{
"key": "totalChunks",
"value": "1"
}
],
2022-12-13 18:44:17 +01:00
"variable": [
{
"key": "shareId",
"value": "test-share"
}
]
}
},
"response": []
},
2022-10-13 23:25:04 +02:00
{
"name": "Complete share",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 202\", () => {",
" pm.response.to.have.status(202);",
"});",
"",
"pm.test(\"Response body correct\", () => {",
" const responseBody = pm.response.json();",
" pm.expect(responseBody).to.have.property(\"id\")",
" pm.expect(responseBody).to.have.property(\"expiration\")",
2022-12-13 18:44:17 +01:00
" pm.expect(Object.keys(responseBody).length).be.equal(3)",
2022-10-13 23:25:04 +02:00
"});",
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [],
"url": {
"raw": "{{API_URL}}/shares/:id/complete",
"host": [
"{{API_URL}}"
],
"path": [
"shares",
":id",
"complete"
],
"variable": [
{
"key": "id",
"value": "test-share"
}
]
}
},
"response": []
}
]
},
{
"name": "Negative",
"item": [
{
"name": "Check share id availability - Already exists",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", () => {",
" pm.response.to.have.status(200);",
"});",
"",
"pm.test(\"Response body correct\", () => {",
" const responseBody = pm.response.json();",
" pm.expect(responseBody.isAvailable).to.be.equal(false)",
" pm.expect(Object.keys(responseBody).length).be.equal(1)",
"});",
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "{{API_URL}}/shares/isShareIdAvailable/:id",
"host": [
"{{API_URL}}"
],
"path": [
"shares",
"isShareIdAvailable",
":id"
],
"variable": [
{
"key": "id",
"value": "test-share"
}
]
}
},
"response": []
},
{
"name": "Create Share - Already exists",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 400\", () => {",
" pm.response.to.have.status(400);",
"});"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"id\": \"test-share\",\n \"expiration\" : \"2-months\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{API_URL}}/shares",
"host": [
"{{API_URL}}"
],
"path": [
"shares"
]
}
},
"response": []
},
{
"name": "Create Share - Id less than 3 chars",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 400\", () => {",
" pm.response.to.have.status(400);",
"});"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"id\": \"ab\",\n \"expiration\" : \"2-months\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{API_URL}}/shares",
"host": [
"{{API_URL}}"
],
"path": [
"shares"
]
}
},
"response": []
},
{
"name": "Upload file - Share already completed",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 400\", () => {",
" pm.response.to.have.status(400);",
"});",
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [],
"url": {
"raw": "{{API_URL}}/shares/:shareId/files",
"host": [
"{{API_URL}}"
],
"path": [
"shares",
":shareId",
"files"
],
"variable": [
{
"key": "shareId",
"value": "test-share"
}
]
}
},
"response": []
},
{
"name": "Upload file - Share not found",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 404\", () => {",
" pm.response.to.have.status(404);",
"});",
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [],
"url": {
"raw": "{{API_URL}}/shares/:shareId/files",
"host": [
"{{API_URL}}"
],
"path": [
"shares",
":shareId",
"files"
],
"variable": [
{
"key": "shareId",
"value": "not-found"
}
]
}
},
"response": []
},
{
"name": "Complete share - Not found",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 404\", () => {",
" pm.response.to.have.status(404);",
"});",
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [],
"url": {
"raw": "{{API_URL}}/shares/:id/complete",
"host": [
"{{API_URL}}"
],
"path": [
"shares",
":id",
"complete"
],
"variable": [
{
"key": "id",
"value": "not-found"
}
]
}
},
"response": []
},
{
"name": "Complete share - Already completed",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 400\", () => {",
" pm.response.to.have.status(400);",
"});"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [],
"url": {
"raw": "{{API_URL}}/shares/:id/complete",
"host": [
"{{API_URL}}"
],
"path": [
"shares",
":id",
"complete"
],
"variable": [
{
"key": "id",
"value": "test-share"
}
]
}
},
"response": []
}
]
}
]
},
{
"name": "Get Share",
"item": [
{
"name": "Positive",
"item": [
{
"name": "Get share token",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", () => {",
" pm.response.to.have.status(200);",
"});",
"",
"pm.test(\"Response body correct\", () => {",
" const responseBody = pm.response.json();",
" pm.expect(responseBody).to.have.property(\"token\")",
" pm.expect(Object.keys(responseBody).length).be.equal(1)",
"});",
"",
2023-01-31 15:43:54 +01:00
"pm.collectionVariables.set(\"COOKIES\", `${pm.collectionVariables.get(\"COOKIES\")};${pm.response.headers.get(\"Set-Cookie\")}`)",
""
2022-10-13 23:25:04 +02:00
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"password\" : \"share-password\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{API_URL}}/shares/:shareId/token",
"host": [
"{{API_URL}}"
],
"path": [
"shares",
":shareId",
"token"
],
"variable": [
{
"key": "shareId",
"value": "test-share"
}
]
}
},
"response": []
},
{
"name": "Get share",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", () => {",
" pm.response.to.have.status(200);",
"});",
"",
2022-12-13 18:44:17 +01:00
"pm.test(\"Response contains 2 files\", () => {",
2022-10-13 23:25:04 +02:00
" const responseBody = pm.response.json();",
2022-12-13 18:44:17 +01:00
" pm.expect(responseBody.files.length).be.equal(2)",
2022-10-13 23:25:04 +02:00
"});",
"",
"pm.collectionVariables.set(\"fileId\", pm.response.json().files[0].id)"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
2023-01-31 15:43:54 +01:00
"header": [],
2022-10-13 23:25:04 +02:00
"url": {
"raw": "{{API_URL}}/shares/:shareId",
"host": [
"{{API_URL}}"
],
"path": [
"shares",
":shareId"
],
"variable": [
{
"key": "shareId",
"value": "test-share"
}
]
}
},
"response": []
},
{
2023-01-31 15:43:54 +01:00
"name": "Get File",
2022-10-13 23:25:04 +02:00
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", () => {",
" pm.response.to.have.status(200);",
2023-01-31 15:43:54 +01:00
"});"
2022-10-13 23:25:04 +02:00
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
2023-01-31 15:43:54 +01:00
"header": [],
2022-10-13 23:25:04 +02:00
"url": {
2023-01-31 15:43:54 +01:00
"raw": "{{API_URL}}/shares/:shareId/files/{{fileId}}",
2022-10-13 23:25:04 +02:00
"host": [
"{{API_URL}}"
],
"path": [
"shares",
":shareId",
"files",
2023-01-31 15:43:54 +01:00
"{{fileId}}"
2022-10-13 23:25:04 +02:00
],
"variable": [
{
"key": "shareId",
"value": "test-share"
}
]
}
},
"response": []
},
{
2023-01-31 15:43:54 +01:00
"name": "Get Zip",
2022-10-13 23:25:04 +02:00
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", () => {",
" pm.response.to.have.status(200);",
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableBodyPruning": true
},
"request": {
"method": "GET",
"header": [],
"url": {
2023-01-31 15:43:54 +01:00
"raw": "{{API_URL}}/shares/:shareId/files/zip",
2022-10-13 23:25:04 +02:00
"host": [
"{{API_URL}}"
],
"path": [
"shares",
":shareId",
"files",
2023-01-31 15:43:54 +01:00
"zip"
2022-10-13 23:25:04 +02:00
],
"variable": [
{
"key": "shareId",
"value": "test-share"
}
]
}
},
"response": []
}
]
},
{
"name": "Negative",
"item": [
{
"name": "Get share token - Wrong password",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 403\", () => {",
" pm.response.to.have.status(403);",
"});"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"password\" : \"wrong-password\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{API_URL}}/shares/:shareId/token",
"host": [
"{{API_URL}}"
],
"path": [
"shares",
":shareId",
"token"
],
"variable": [
{
"key": "shareId",
"value": "test-share"
}
]
}
},
"response": []
},
{
"name": "Get share token - Visitor limit exceeded",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 403\", () => {",
" pm.response.to.have.status(403);",
"});"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\n \"password\" : \"share-password\"\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{API_URL}}/shares/:shareId/token",
"host": [
"{{API_URL}}"
],
"path": [
"shares",
":shareId",
"token"
],
"variable": [
{
"key": "shareId",
"value": "test-share"
}
]
}
},
"response": []
}
]
}
]
}
],
"event": [
{
"listen": "prerequest",
"script": {
"type": "text/javascript",
"exec": [
2023-01-04 15:58:15 +01:00
"pm.request.addHeader(\"Cookie\", pm.collectionVariables.get(\"COOKIES\"))"
2022-10-13 23:25:04 +02:00
]
}
},
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
""
]
}
}
],
"variable": [
{
"key": "API_URL",
"value": "http://localhost:8080/api",
"type": "string"
}
]
}