mirror of
https://github.com/stonith404/pingvin-share.git
synced 2024-11-16 04:10:35 +01:00
653d72bcb9
* add first concept * finished first concept * allow 3 uploads at same time * retry if chunk failed * updated clean temporary files job * fix throttling for chunk uploads * update tests * remove multer * migrate from `MAX_FILE_SIZE` to `MAX_SHARE_SIZE` * improve error handling if file failed to upload * fix promise limit * improve file progress
1626 lines
37 KiB
JSON
1626 lines
37 KiB
JSON
{
|
|
"info": {
|
|
"_postman_id": "38c7001d-4868-484b-935a-84fd3b5e7cf6",
|
|
"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)",
|
|
"",
|
|
" pm.collectionVariables.set(\"COOKIES\", pm.response.headers.get(\"Set-Cookie\"))",
|
|
"}",
|
|
""
|
|
],
|
|
"type": "text/javascript"
|
|
}
|
|
}
|
|
],
|
|
"request": {
|
|
"method": "POST",
|
|
"header": [],
|
|
"body": {
|
|
"mode": "raw",
|
|
"raw": "{\n \"email\": \"system@test.org\",\n \"username\": \"system.test\",\n \"password\": \"J2y8unpJUcJDRv\"\n}",
|
|
"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\")",
|
|
"});",
|
|
"",
|
|
""
|
|
],
|
|
"type": "text/javascript"
|
|
}
|
|
}
|
|
],
|
|
"request": {
|
|
"method": "POST",
|
|
"header": [
|
|
{
|
|
"key": "Accept-Language",
|
|
"value": "de",
|
|
"type": "text"
|
|
}
|
|
],
|
|
"body": {
|
|
"mode": "raw",
|
|
"raw": "{\n \"email\": \"system2@test.org\",\n \"username\": \"system2.test\",\n \"password\": \"N44HcHgeuAvfCT\"\n}",
|
|
"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\")",
|
|
" pm.expect(Object.keys(responseBody).length).be.equal(3)",
|
|
"});",
|
|
""
|
|
],
|
|
"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}",
|
|
"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)",
|
|
"});"
|
|
],
|
|
"type": "text/javascript"
|
|
}
|
|
}
|
|
],
|
|
"protocolProfileBehavior": {
|
|
"disabledSystemHeaders": {
|
|
"content-type": true
|
|
}
|
|
},
|
|
"request": {
|
|
"method": "POST",
|
|
"header": [
|
|
{
|
|
"key": "Content-Type",
|
|
"value": "application/octet-stream",
|
|
"type": "text"
|
|
}
|
|
],
|
|
"body": {
|
|
"mode": "raw",
|
|
"raw": "data:application/octet-stream;base64,VGhpcyBpcyBhIHRlc3QgZmlsZWQgdXNlZCBmb3IgdXBsb2FkaW5nIGluIHRoZSBzeXN0ZW0gdGVzdC4="
|
|
},
|
|
"url": {
|
|
"raw": "{{API_URL}}/shares/:shareId/files?name=test-file.txt&chunkIndex=0&totalChunks=1",
|
|
"host": [
|
|
"{{API_URL}}"
|
|
],
|
|
"path": [
|
|
"shares",
|
|
":shareId",
|
|
"files"
|
|
],
|
|
"query": [
|
|
{
|
|
"key": "name",
|
|
"value": "test-file.txt"
|
|
},
|
|
{
|
|
"key": "chunkIndex",
|
|
"value": "0"
|
|
},
|
|
{
|
|
"key": "totalChunks",
|
|
"value": "1"
|
|
}
|
|
],
|
|
"variable": [
|
|
{
|
|
"key": "shareId",
|
|
"value": "test-share"
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"response": []
|
|
},
|
|
{
|
|
"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)",
|
|
"});"
|
|
],
|
|
"type": "text/javascript"
|
|
}
|
|
}
|
|
],
|
|
"protocolProfileBehavior": {
|
|
"disabledSystemHeaders": {
|
|
"content-type": true
|
|
}
|
|
},
|
|
"request": {
|
|
"method": "POST",
|
|
"header": [
|
|
{
|
|
"key": "Content-Type",
|
|
"value": "application/octet-stream",
|
|
"type": "text"
|
|
}
|
|
],
|
|
"body": {
|
|
"mode": "raw",
|
|
"raw": "data:application/octet-stream;base64,VGhpcyBpcyBhIHRlc3QgZmlsZWQgdXNlZCBmb3IgdXBsb2FkaW5nIGluIHRoZSBzeXN0ZW0gdGVzdC4="
|
|
},
|
|
"url": {
|
|
"raw": "{{API_URL}}/shares/:shareId/files?name=test-file2.txt&chunkIndex=0&totalChunks=1",
|
|
"host": [
|
|
"{{API_URL}}"
|
|
],
|
|
"path": [
|
|
"shares",
|
|
":shareId",
|
|
"files"
|
|
],
|
|
"query": [
|
|
{
|
|
"key": "name",
|
|
"value": "test-file2.txt"
|
|
},
|
|
{
|
|
"key": "chunkIndex",
|
|
"value": "0"
|
|
},
|
|
{
|
|
"key": "totalChunks",
|
|
"value": "1"
|
|
}
|
|
],
|
|
"variable": [
|
|
{
|
|
"key": "shareId",
|
|
"value": "test-share"
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"response": []
|
|
},
|
|
{
|
|
"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\")",
|
|
" pm.expect(Object.keys(responseBody).length).be.equal(3)",
|
|
"});",
|
|
""
|
|
],
|
|
"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": [],
|
|
"body": {
|
|
"mode": "formdata",
|
|
"formdata": [
|
|
{
|
|
"key": "file",
|
|
"type": "file",
|
|
"src": "./test/system/test-file.txt"
|
|
}
|
|
]
|
|
},
|
|
"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": [],
|
|
"body": {
|
|
"mode": "formdata",
|
|
"formdata": [
|
|
{
|
|
"key": "file",
|
|
"type": "file",
|
|
"src": "./test/system/test-file.txt"
|
|
}
|
|
]
|
|
},
|
|
"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)",
|
|
"});",
|
|
"",
|
|
"pm.collectionVariables.set(\"shareToken\", pm.response.json().token)"
|
|
],
|
|
"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);",
|
|
"});",
|
|
"",
|
|
"pm.test(\"Response contains 2 files\", () => {",
|
|
" const responseBody = pm.response.json();",
|
|
" pm.expect(responseBody.files.length).be.equal(2)",
|
|
"});",
|
|
"",
|
|
"",
|
|
"",
|
|
"pm.collectionVariables.set(\"fileId\", pm.response.json().files[0].id)"
|
|
],
|
|
"type": "text/javascript"
|
|
}
|
|
}
|
|
],
|
|
"request": {
|
|
"method": "GET",
|
|
"header": [
|
|
{
|
|
"key": "X-Share-Token",
|
|
"value": "{{shareToken}}",
|
|
"type": "text"
|
|
}
|
|
],
|
|
"url": {
|
|
"raw": "{{API_URL}}/shares/:shareId",
|
|
"host": [
|
|
"{{API_URL}}"
|
|
],
|
|
"path": [
|
|
"shares",
|
|
":shareId"
|
|
],
|
|
"variable": [
|
|
{
|
|
"key": "shareId",
|
|
"value": "test-share"
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"response": []
|
|
},
|
|
{
|
|
"name": "Get file download url",
|
|
"event": [
|
|
{
|
|
"listen": "test",
|
|
"script": {
|
|
"exec": [
|
|
"let URL = require('url');",
|
|
"",
|
|
"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(\"url\")",
|
|
" pm.expect(Object.keys(responseBody).length).be.equal(1)",
|
|
"});",
|
|
"",
|
|
"",
|
|
"const path = URL.parse(pm.response.json().url).path.replace(\"/api/\", \"\")",
|
|
"",
|
|
"pm.collectionVariables.set(\"fileDownloadPath\",path )"
|
|
],
|
|
"type": "text/javascript"
|
|
}
|
|
}
|
|
],
|
|
"protocolProfileBehavior": {
|
|
"disableBodyPruning": true
|
|
},
|
|
"request": {
|
|
"method": "GET",
|
|
"header": [
|
|
{
|
|
"key": "X-Share-Token",
|
|
"value": "{{shareToken}}",
|
|
"type": "text"
|
|
}
|
|
],
|
|
"body": {
|
|
"mode": "formdata",
|
|
"formdata": [
|
|
{
|
|
"key": "file",
|
|
"type": "file",
|
|
"src": "./test/system/test-file.txt"
|
|
},
|
|
{
|
|
"key": "shareId",
|
|
"value": "868c6a44-fb8c-4768-ad0d-ef22feebc8ea",
|
|
"type": "text"
|
|
}
|
|
]
|
|
},
|
|
"url": {
|
|
"raw": "{{API_URL}}/shares/:shareId/files/:fileId/download",
|
|
"host": [
|
|
"{{API_URL}}"
|
|
],
|
|
"path": [
|
|
"shares",
|
|
":shareId",
|
|
"files",
|
|
":fileId",
|
|
"download"
|
|
],
|
|
"variable": [
|
|
{
|
|
"key": "shareId",
|
|
"value": "test-share"
|
|
},
|
|
{
|
|
"key": "fileId",
|
|
"value": "{{fileId}}"
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"response": []
|
|
},
|
|
{
|
|
"name": "Get File",
|
|
"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": [],
|
|
"body": {
|
|
"mode": "formdata",
|
|
"formdata": [
|
|
{
|
|
"key": "file",
|
|
"type": "file",
|
|
"src": "./test/system/test-file.txt"
|
|
},
|
|
{
|
|
"key": "shareId",
|
|
"value": "868c6a44-fb8c-4768-ad0d-ef22feebc8ea",
|
|
"type": "text"
|
|
}
|
|
]
|
|
},
|
|
"url": {
|
|
"raw": "{{API_URL}}/{{fileDownloadPath}}",
|
|
"host": [
|
|
"{{API_URL}}"
|
|
],
|
|
"path": [
|
|
"{{fileDownloadPath}}"
|
|
]
|
|
}
|
|
},
|
|
"response": []
|
|
},
|
|
{
|
|
"name": "Get zip download url",
|
|
"event": [
|
|
{
|
|
"listen": "test",
|
|
"script": {
|
|
"exec": [
|
|
"let URL = require('url');",
|
|
"",
|
|
"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(\"url\")",
|
|
" pm.expect(Object.keys(responseBody).length).be.equal(1)",
|
|
"});",
|
|
"",
|
|
"",
|
|
"const path = URL.parse(pm.response.json().url).path.replace(\"/api/\", \"\")",
|
|
"",
|
|
"pm.collectionVariables.set(\"zipDownloadPath\",path )"
|
|
],
|
|
"type": "text/javascript"
|
|
}
|
|
}
|
|
],
|
|
"protocolProfileBehavior": {
|
|
"disableBodyPruning": true
|
|
},
|
|
"request": {
|
|
"method": "GET",
|
|
"header": [
|
|
{
|
|
"key": "X-Share-Token",
|
|
"value": "{{shareToken}}",
|
|
"type": "text"
|
|
}
|
|
],
|
|
"body": {
|
|
"mode": "formdata",
|
|
"formdata": [
|
|
{
|
|
"key": "file",
|
|
"type": "file",
|
|
"src": "./test/system/test-file.txt"
|
|
},
|
|
{
|
|
"key": "shareId",
|
|
"value": "868c6a44-fb8c-4768-ad0d-ef22feebc8ea",
|
|
"type": "text"
|
|
}
|
|
]
|
|
},
|
|
"url": {
|
|
"raw": "{{API_URL}}/shares/:shareId/files/zip/download",
|
|
"host": [
|
|
"{{API_URL}}"
|
|
],
|
|
"path": [
|
|
"shares",
|
|
":shareId",
|
|
"files",
|
|
"zip",
|
|
"download"
|
|
],
|
|
"variable": [
|
|
{
|
|
"key": "shareId",
|
|
"value": "test-share"
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"response": []
|
|
},
|
|
{
|
|
"name": "Get Zip",
|
|
"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": [],
|
|
"body": {
|
|
"mode": "formdata",
|
|
"formdata": [
|
|
{
|
|
"key": "file",
|
|
"type": "file",
|
|
"src": "./test/system/test-file.txt"
|
|
},
|
|
{
|
|
"key": "shareId",
|
|
"value": "868c6a44-fb8c-4768-ad0d-ef22feebc8ea",
|
|
"type": "text"
|
|
}
|
|
]
|
|
},
|
|
"url": {
|
|
"raw": "{{API_URL}}/{{zipDownloadPath}}",
|
|
"host": [
|
|
"{{API_URL}}"
|
|
],
|
|
"path": [
|
|
"{{zipDownloadPath}}"
|
|
]
|
|
}
|
|
},
|
|
"response": []
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "Negative",
|
|
"item": [
|
|
{
|
|
"name": "Get share - No token",
|
|
"event": [
|
|
{
|
|
"listen": "test",
|
|
"script": {
|
|
"exec": [
|
|
"pm.test(\"Status code is 403\", () => {",
|
|
" pm.response.to.have.status(403);",
|
|
"});"
|
|
],
|
|
"type": "text/javascript"
|
|
}
|
|
}
|
|
],
|
|
"request": {
|
|
"method": "GET",
|
|
"header": [],
|
|
"url": {
|
|
"raw": "{{API_URL}}/shares/:shareId",
|
|
"host": [
|
|
"{{API_URL}}"
|
|
],
|
|
"path": [
|
|
"shares",
|
|
":shareId"
|
|
],
|
|
"variable": [
|
|
{
|
|
"key": "shareId",
|
|
"value": "test-share"
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"response": []
|
|
},
|
|
{
|
|
"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": []
|
|
},
|
|
{
|
|
"name": "Get file download url - No token",
|
|
"event": [
|
|
{
|
|
"listen": "test",
|
|
"script": {
|
|
"exec": [
|
|
"pm.test(\"Status code is 403\", () => {",
|
|
" pm.response.to.have.status(403);",
|
|
"});",
|
|
""
|
|
],
|
|
"type": "text/javascript"
|
|
}
|
|
}
|
|
],
|
|
"protocolProfileBehavior": {
|
|
"disableBodyPruning": true
|
|
},
|
|
"request": {
|
|
"method": "GET",
|
|
"header": [],
|
|
"body": {
|
|
"mode": "formdata",
|
|
"formdata": [
|
|
{
|
|
"key": "file",
|
|
"type": "file",
|
|
"src": "./test/system/test-file.txt"
|
|
},
|
|
{
|
|
"key": "shareId",
|
|
"value": "868c6a44-fb8c-4768-ad0d-ef22feebc8ea",
|
|
"type": "text"
|
|
}
|
|
]
|
|
},
|
|
"url": {
|
|
"raw": "{{API_URL}}/shares/:shareId/files/:fileId/download",
|
|
"host": [
|
|
"{{API_URL}}"
|
|
],
|
|
"path": [
|
|
"shares",
|
|
":shareId",
|
|
"files",
|
|
":fileId",
|
|
"download"
|
|
],
|
|
"variable": [
|
|
{
|
|
"key": "shareId",
|
|
"value": "test-share"
|
|
},
|
|
{
|
|
"key": "fileId",
|
|
"value": "{{fileId}}"
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"response": []
|
|
},
|
|
{
|
|
"name": "Get zip download url - No token",
|
|
"event": [
|
|
{
|
|
"listen": "test",
|
|
"script": {
|
|
"exec": [
|
|
"pm.test(\"Status code is 403\", () => {",
|
|
" pm.response.to.have.status(403);",
|
|
"});",
|
|
""
|
|
],
|
|
"type": "text/javascript"
|
|
}
|
|
}
|
|
],
|
|
"protocolProfileBehavior": {
|
|
"disableBodyPruning": true
|
|
},
|
|
"request": {
|
|
"method": "GET",
|
|
"header": [],
|
|
"body": {
|
|
"mode": "formdata",
|
|
"formdata": [
|
|
{
|
|
"key": "file",
|
|
"type": "file",
|
|
"src": "./test/system/test-file.txt"
|
|
},
|
|
{
|
|
"key": "shareId",
|
|
"value": "868c6a44-fb8c-4768-ad0d-ef22feebc8ea",
|
|
"type": "text"
|
|
}
|
|
]
|
|
},
|
|
"url": {
|
|
"raw": "{{API_URL}}/shares/:shareId/files/zip/download",
|
|
"host": [
|
|
"{{API_URL}}"
|
|
],
|
|
"path": [
|
|
"shares",
|
|
":shareId",
|
|
"files",
|
|
"zip",
|
|
"download"
|
|
],
|
|
"variable": [
|
|
{
|
|
"key": "shareId",
|
|
"value": "test-share"
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"response": []
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
],
|
|
"event": [
|
|
{
|
|
"listen": "prerequest",
|
|
"script": {
|
|
"type": "text/javascript",
|
|
"exec": [
|
|
"pm.request.addHeader(\"Cookie\", pm.collectionVariables.get(\"COOKIES\"))"
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"listen": "test",
|
|
"script": {
|
|
"type": "text/javascript",
|
|
"exec": [
|
|
""
|
|
]
|
|
}
|
|
}
|
|
],
|
|
"variable": [
|
|
{
|
|
"key": "API_URL",
|
|
"value": "http://localhost:8080/api",
|
|
"type": "string"
|
|
}
|
|
]
|
|
} |