aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorcjd242018-04-23 15:32:02 +0100
committercjd242018-04-23 15:32:02 +0100
commit3987d5068881341c27150e37eff1794a27901cac (patch)
tree6165dff18f9f0a31e4eecec056d264732f99bdd0 /test
parentPANIC COMMITS OMMGGGGG (diff)
parentALL TESTS FIXXXXXXXED (diff)
downloadmedicine-3987d5068881341c27150e37eff1794a27901cac.tar.gz
medicine-3987d5068881341c27150e37eff1794a27901cac.zip

merge conflict

Diffstat (limited to 'test')
-rw-r--r--test/JH.postman_environment.json (renamed from test/JH_environment.json)8
-rw-r--r--test/integration/auth.routes.test.ts4
-rw-r--r--test/integration/protocol.routes.test.ts19
-rw-r--r--test/postman.json763
-rw-r--r--test/postman.json.json245
-rw-r--r--test/test-db.ts26
6 files changed, 698 insertions, 367 deletions
diff --git a/test/JH_environment.json b/test/JH.postman_environment.json
index bf72d78..493f718 100644
--- a/test/JH_environment.json
+++ b/test/JH.postman_environment.json
@@ -35,18 +35,18 @@
{
"enabled": true,
"key": "access_token",
- "value": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJvYmplY3QiOnsidXNlcm5hbWUiOiJoYWZlZXoiLCJwYXNzd29yZEludGVybmFsIjpudWxsLCJjcmVhdGlvbkRhdGUiOiIyMDE4LTA0LTE2VDE2OjExOjU5LjU0M1oiLCJ1cGRhdGVkQXQiOiIyMDE4LTA0LTE2VDE2OjExOjU5LjU0M1oiLCJ1c2VyR3JvdXBzIjpbeyJpZCI6MSwibmFtZSI6ImxvZ2dpbmciLCJjYW5DcmVhdGVVc2VycyI6bnVsbCwiY2FuRGVsZXRlVXNlcnMiOm51bGwsImNhbkVkaXRVc2VycyI6bnVsbCwiY2FuQ3JlYXRlUHJvamVjdHMiOm51bGwsImNhbkRlbGV0ZVByb2plY3RzIjpudWxsLCJjYW5FZGl0UHJvamVjdHMiOm51bGwsImNhbkFjY2Vzc0xvZ3MiOnRydWUsImlzSW50ZXJu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2LjA3NloiLCJ1c2VyR3JvdXBzIjpbeyJpZCI6MSwibmFtZSI6ImxvZ2dpbmciLCJjYW5DcmVhdGVVc2VycyI6bnVsbCwiY2FuRGVsZXRlVXNlcnMiOm51bGwsImNhbkVkaXRVc2VycyI6bnVsbCwiY2FuQ3JlYXRlUHJvamVjdHMiOm51bGwsImNhbkRlbGV0ZVByb2plY3RzIjpudWxsLCJjYW5FZGl0UHJvamVjdHMiOm51bGwsImNhbkFjY2Vzc0xvZ3MiOnRydWUsImlzSW50ZXJuYWwiOmZhbHNlLCJkZXNjcmlwdGlvbiI6IkFsbG93cyBQb3N0IHRvIExvZyIsIlVzZXJIYXNQcml2aWxlZ2UiOnsidXNlcm5hbWUiOiJoYWZlZXoiLCJwcml2aWxlZ2VJZCI6MX19LHsiaWQiOjIsIm5hbWUiOiJhZG1pbiIsImNhbkNyZWF0ZVVzZXJzIjp0cnVlLCJjYW5EZWxldGVVc2VycyI6dHJ1ZSwiY2FuRWRpdFVzZXJzIjp0cnVlLCJjYW5DcmVhdGVQcm9qZWN0cyI6dHJ1ZSwiY2FuRGVsZXRlUHJvamVjdHMiOnRydWUsImNhbkVkaXRQcm9qZWN0cyI6dHJ1ZSwiY2FuQWNjZXNzTG9ncyI6bnVsbCwiaXNJbnRlcm5hbCI6ZmFsc2UsImRlc2NyaXB0aW9uIjoiU3lzdGVtcyBhZG1pbiIsIlVzZXJIYXNQcml2aWxlZ2UiOnsidXNlcm5hbWUiOiJoYWZlZXoiLCJwcml2aWxlZ2VJZCI6Mn19XSwicHJvamVjdHMiOltdfSwiaWF0IjoxNTI0NDg2NTM1LCJleHAiOjE1MjQ1MDgxMzV9.Ycd-xVki5MyqK8t2LVlpUAAMzb7U8uZ2rPF3zL_DBMQ",
"type": "text"
}
],
- "timestamp": 1523895383946,
+ "timestamp": 1524486535310,
"_postman_variable_scope": "environment",
- "_postman_exported_at": "2018-04-16T16:30:59.939Z",
+ "_postman_exported_at": "2018-04-23T13:00:27.101Z",
"_postman_exported_using": "Postman/5.5.2"
} \ No newline at end of file
diff --git a/test/integration/auth.routes.test.ts b/test/integration/auth.routes.test.ts
index 29c0cfc..c090984 100644
--- a/test/integration/auth.routes.test.ts
+++ b/test/integration/auth.routes.test.ts
@@ -80,10 +80,10 @@ describe('authentication', () => {
grant_type: 'password'
}).then((res) => {
// File-not-found is a valid response
- expect(res).to.have.status(404);
+ expect(res).to.have.status(401);
}).catch((reason) => {
// Unauthorised is a valid response
- expect(reason).to.have.status(401);
+ expect(reason).to.have.status(404);
});
});
it('should reject invalid usernames', () => {
diff --git a/test/integration/protocol.routes.test.ts b/test/integration/protocol.routes.test.ts
index 77b39f0..d289de3 100644
--- a/test/integration/protocol.routes.test.ts
+++ b/test/integration/protocol.routes.test.ts
@@ -100,11 +100,12 @@ const completeProtocol: MochaForEachInput[] = [
'debug',
'info',
'security',
- 'warning',
+ 'warn',
'error',
'critical',
'success',
- 'failure'
+ 'failure',
+ 'verbose'
]),
message: types.anything,
label: optional(types.string),
@@ -215,8 +216,8 @@ const completeProtocol: MochaForEachInput[] = [
}, 200],
['post', '/projects/mocky2', {}, 200],
['get', '/projects/mocky/properties', null, 200],
- ['post', '/projects/mocky/files/foler/file?action=overwrite', {}, 200],
- ['get', '/projects/mocky/files/foler/file', null, 200]
+ ['post', '/projects/mocky/files/file?overwrite=true&truncate=true', {}, 200],
+ ['get', '/projects/mocky/files/file', null, 404]
//['get', '/projects/mocky/files_by_id/file1', null, 200]
];
@@ -308,9 +309,12 @@ describe('routes : protocol', () => {
describe('GET invalid routes', () => {
// Should invalid routes also possibly be 401?
- it.skip('should have response code 404', () => {
+ it('should have response code 404', () => {
return chai.request(app).get('/invalid/route')
.set('Authorization', `Bearer ${token}`)
+ .then((res: ChaiHttp.Response) => {
+ expect(res.status).to.equal(404);
+ })
.catch((err) => {
expect(err.status).to.equal(404);
});
@@ -326,9 +330,12 @@ describe('routes : protocol', () => {
describe('POST invalid routes', () => {
// Should invalid routes also possibly be 401?
- it.skip('should have response code 404', () => {
+ it('should have response code 404', () => {
return chai.request(app).post('/invalid/route')
.set('Authorization', `Bearer ${token}`)
+ .then((res: ChaiHttp.Response) => {
+ expect(res.status).to.equal(404);
+ })
.catch((err) => {
expect(err.status).to.equal(404);
});
diff --git a/test/postman.json b/test/postman.json
index 164bdc1..4168de6 100644
--- a/test/postman.json
+++ b/test/postman.json
@@ -1,81 +1,188 @@
{
+ "variables": [],
"info": {
- "name": "JH",
- "_postman_id": "323a3189-bd95-4f51-b985-d2ca626300ec",
+
+ "name": "JH-Tests",
+ "_postman_id": "026d9590-14ae-08df-9cc1-7a592aebdf02",
"description": "",
- "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
+ "schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json"
},
"item": [
{
"name": "authorised",
- "description": null,
+ "description": "",
"item": [
{
- "name": "/projects",
+ "name": "/projects/",
"request": {
- "auth": {
- "type": "bearer",
- "bearer": [
+ "url": {
+ "raw": "{{host}}/{{endpoint}}/projects/{{dummy_project}}?action=create",
+ "host": [
+ "{{host}}"
+ ],
+ "path": [
+ "{{endpoint}}",
+ "projects",
+ "{{dummy_project}}"
+ ],
+ "query": [
{
- "key": "token",
- "value": "{{access_token}}",
- "type": "string"
+ "key": "action",
+ "value": "create",
+ "equals": true,
+ "description": ""
}
- ]
+ ],
+ "variable": []
},
- "method": "GET",
+ "method": "POST",
"header": [
{
- "key": "",
- "value": "",
- "disabled": true
+ "key": "Content-Type",
+ "value": "application/json",
+ "description": ""
+ },
+ {
+ "key": "Authorization",
+ "value": "Bearer {{access_token}}",
+ "description": ""
}
],
- "body": {},
+ "body": {
+ "mode": "raw",
+ "raw": "{}"
+ },
+ "description": ""
+ },
+ "response": []
+ },
+ {
+ "name": "/projects/abc/files",
+ "request": {
"url": {
- "raw": "{{host}}/{{endpoint}}/projects",
+ "raw": "{{host}}/{{endpoint}}/projects/{{dummy_project}}/files/file?overwrite=true&truncate=true",
"host": [
"{{host}}"
],
"path": [
"{{endpoint}}",
- "projects"
- ]
+ "projects",
+ "{{dummy_project}}",
+ "files",
+ "file"
+ ],
+ "query": [
+ {
+ "key": "overwrite",
+ "value": "true",
+ "equals": true,
+ "description": ""
+ },
+ {
+ "key": "truncate",
+ "value": "true",
+ "equals": true,
+ "description": ""
+ }
+ ],
+ "variable": []
+ },
+ "method": "POST",
+ "header": [
+ {
+ "key": "Authorization",
+ "value": "Bearer {{access_token}}",
+ "description": ""
+ },
+ {
+ "key": "Content-Type",
+ "value": "image/jpeg",
+ "description": ""
+ }
+ ],
+ "body": {
+ "mode": "file",
+ "file": {
+ "src": ""
+ }
},
"description": ""
},
"response": []
},
{
- "name": "/log",
+ "name": "/projects/abc/files copy",
"request": {
- "auth": {
- "type": "bearer",
- "bearer": [
+ "url": {
+ "raw": "{{host}}/{{endpoint}}/projects/{{dummy_project}}/files/file?action=move",
+ "host": [
+ "{{host}}"
+ ],
+ "path": [
+ "{{endpoint}}",
+ "projects",
+ "{{dummy_project}}",
+ "files",
+ "file"
+ ],
+ "query": [
{
- "key": "token",
- "value": "{{access_token}}",
- "type": "string"
+ "key": "action",
+ "value": "move",
+ "equals": true,
+ "description": ""
}
- ]
+ ],
+ "variable": []
+ },
+ "method": "POST",
+ "header": [
+ {
+ "key": "Authorization",
+ "value": "Bearer {{access_token}}",
+ "description": ""
+ },
+ {
+ "key": "Content-Type",
+ "value": "application/json",
+ "description": ""
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n\t\"path\": \"newFile\"\n}"
},
+ "description": ""
+ },
+ "response": []
+ },
+ {
+ "name": "/projects/abc/files",
+ "request": {
+ "url": "{{host}}/{{endpoint}}/projects/{{dummy_project}}/files/",
"method": "GET",
"header": [
{
- "key": "",
- "value": "",
+ "key": "Authorization",
+ "value": "Bearer {{access_token}}",
+ "description": ""
+ },
+ {
+ "key": "Content-Type",
+ "value": "image/png",
+ "description": "",
"disabled": true
}
],
- "body": {},
- "url": {
- "raw": "{{host}}/{{endpoint}}/log",
- "host": [
- "{{host}}"
- ],
- "path": [
- "{{endpoint}}",
- "log"
+ "body": {
+ "mode": "formdata",
+ "formdata": [
+ {
+ "key": "pres",
+ "value": "",
+ "description": "",
+ "type": "file"
+ }
]
},
"description": ""
@@ -83,104 +190,576 @@
"response": []
},
{
+ "name": "/projects",
+ "request": {
+ "url": "{{host}}/{{endpoint}}/projects",
+ "method": "GET",
+ "header": [
+ {
+ "key": "Authorization",
+ "value": "Bearer {{access_token}}",
+ "description": ""
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
+ "description": ""
+ },
+ "response": []
+ },
+ {
+ "name": "/log",
+ "request": {
+ "url": "{{host}}/{{endpoint}}/log",
+ "method": "GET",
+ "header": [
+ {
+ "key": "Authorization",
+ "value": "Bearer {{access_token}}",
+ "description": ""
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
+ "description": ""
+ },
+ "response": []
+ },
+ {
"name": "/_supported_protocols",
"request": {
- "auth": {
- "type": "noauth"
+ "url": "{{host}}/{{endpoint}}/_supported_protocols_",
+ "method": "GET",
+ "header": [
+ {
+ "key": "Authorization",
+ "value": "Bearer {{access_token}}",
+ "description": "",
+ "disabled": true
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": ""
},
+ "description": ""
+ },
+ "response": []
+ },
+ {
+ "name": "/project_roles",
+ "request": {
+ "url": "{{host}}/{{endpoint}}/project_roles",
"method": "GET",
"header": [
{
- "key": "",
- "value": "",
+ "key": "Authorization",
+ "value": "Bearer {{access_token}}",
+ "description": "",
+ "disabled": true
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
+ "description": ""
+ },
+ "response": []
+ },
+ {
+ "name": "/project_roles copy",
+ "request": {
+ "url": "{{host}}/{{endpoint}}/current_user",
+ "method": "GET",
+ "header": [
+ {
+ "key": "authorization",
+ "value": "bearer {{access_token}}",
+ "description": ""
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
+ "description": ""
+ },
+ "response": []
+ },
+ {
+ "name": "/projects/abc/files_by_id",
+ "request": {
+ "url": "{{host}}/{{endpoint}}/projects/{{dummy_project}}/files_by_id/d124ef49-e9e3-4794-bf50-76f40797b5d5",
+ "method": "GET",
+ "header": [
+ {
+ "key": "Authorization",
+ "value": "Bearer {{access_token}}",
+ "description": ""
+ },
+ {
+ "key": "Content-Type",
+ "value": "image/png",
+ "description": "",
"disabled": true
}
],
- "body": {},
+ "body": {
+ "mode": "formdata",
+ "formdata": [
+ {
+ "key": "pres",
+ "value": "",
+ "description": "",
+ "type": "file"
+ }
+ ]
+ },
+ "description": ""
+ },
+ "response": []
+ },
+ {
+ "name": "/",
+ "request": {
+ "url": "{{host}}/",
+ "method": "GET",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
+ "description": ""
+ },
+ "response": []
+ },
+ {
+ "name": "/properties",
+ "request": {
+ "url": "{{host}}/{{endpoint}}/properties",
+ "method": "GET",
+ "header": [
+ {
+ "key": "Authorization",
+ "value": "Bearer {{access_token}}",
+ "description": ""
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
+ "description": ""
+ },
+ "response": []
+ },
+ {
+ "name": "/projects/ copy",
+ "request": {
+ "url": "{{host}}/{{endpoint}}/projects/{{dummy_project}}",
+ "method": "POST",
+ "header": [
+ {
+ "key": "Content-Type",
+ "value": "application/json",
+ "description": ""
+ },
+ {
+ "key": "Authorization",
+ "value": "Bearer {{access_token}}",
+ "description": ""
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": "{}"
+ },
+ "description": ""
+ },
+ "response": []
+ },
+ {
+ "name": "/log",
+ "request": {
+ "url": "{{host}}/{{endpoint}}/log",
+ "method": "POST",
+ "header": [
+ {
+ "key": "Authorization",
+ "value": "Bearer {{access_token}}",
+ "description": ""
+ },
+ {
+ "key": "Content-Type`",
+ "value": "application/json",
+ "description": ""
+ },
+ {
+ "key": "Content-Type",
+ "value": "application/json",
+ "description": ""
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": "[{\n\t\"component\": \"anything\",\n\t\"level\": \"info\",\n\t\"value\": \"1000\"\n}]"
+ },
+ "description": ""
+ },
+ "response": []
+ },
+ {
+ "name": "/properties",
+ "request": {
"url": {
- "raw": "{{host}}/{{endpoint}}/_supported_protocols_",
+ "raw": "{{host}}/{{endpoint}}/properties?action=update",
"host": [
"{{host}}"
],
"path": [
"{{endpoint}}",
- "_supported_protocols_"
- ]
+ "properties"
+ ],
+ "query": [
+ {
+ "key": "action",
+ "value": "update",
+ "equals": true,
+ "description": ""
+ }
+ ],
+ "variable": []
+ },
+ "method": "POST",
+ "header": [
+ {
+ "key": "Content-Type",
+ "value": "application/json",
+ "description": ""
+ },
+ {
+ "key": "Authorization",
+ "value": "Bearer {{access_token}}",
+ "description": ""
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": "[{\n\t\"id\": \"project_example\",\n\t\"value\": 10\n}]"
},
"description": ""
},
"response": []
},
{
- "name": "/project_roles",
+ "name": "/user_privileges",
"request": {
- "auth": {
- "type": "bearer",
- "bearer": [
- {
- "key": "token",
- "value": "{{access_token}}",
- "type": "string"
- }
- ]
+ "url": "{{host}}/{{endpoint}}/user_privileges",
+ "method": "GET",
+ "header": [
+ {
+ "key": "Authorization",
+ "value": "Bearer {{access_token}}",
+ "description": ""
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": ""
},
+ "description": ""
+ },
+ "response": []
+ },
+ {
+ "name": "/users",
+ "request": {
+ "url": "{{host}}/{{endpoint}}/users",
"method": "GET",
"header": [
{
- "key": "",
- "value": "",
- "disabled": true
+ "key": "Authorization",
+ "value": "Bearer {{access_token}}",
+ "description": ""
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
+ "description": ""
+ },
+ "response": []
+ },
+ {
+ "name": "/users/:username",
+ "request": {
+ "url": "{{host}}/{{endpoint}}/users/{{dummy_admin_username}}",
+ "method": "GET",
+ "header": [
+ {
+ "key": "Authorization",
+ "value": "Bearer {{access_token}}",
+ "description": ""
}
],
- "body": {},
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
+ "description": ""
+ },
+ "response": []
+ },
+ {
+ "name": "/users/:username?action=create",
+ "request": {
"url": {
- "raw": "{{host}}/{{endpoint}}/project_roles",
+ "raw": "{{host}}/{{endpoint}}/users/{{new_username}}?action=create",
"host": [
"{{host}}"
],
"path": [
"{{endpoint}}",
- "project_roles"
- ]
+ "users",
+ "{{new_username}}"
+ ],
+ "query": [
+ {
+ "key": "action",
+ "value": "create",
+ "equals": true,
+ "description": ""
+ }
+ ],
+ "variable": []
+ },
+ "method": "POST",
+ "header": [
+ {
+ "key": "Authorization",
+ "value": "Bearer {{access_token}}",
+ "description": ""
+ },
+ {
+ "key": "Content-Type",
+ "value": "application/json",
+ "description": ""
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n\t\"privileges\": [],\n\t\"password\": \"newPass\"\n}"
},
"description": ""
},
"response": []
},
{
- "name": "/projects/",
+ "name": "/users/:username?action=update",
"request": {
- "auth": {
- "type": "bearer",
- "bearer": [
+ "url": {
+ "raw": "{{host}}/{{endpoint}}/users/{{new_username}}?action=update",
+ "host": [
+ "{{host}}"
+ ],
+ "path": [
+ "{{endpoint}}",
+ "users",
+ "{{new_username}}"
+ ],
+ "query": [
{
- "key": "token",
- "value": "{{access_token}}",
- "type": "string"
+ "key": "action",
+ "value": "update",
+ "equals": true,
+ "description": ""
}
- ]
+ ],
+ "variable": []
},
"method": "POST",
"header": [
{
+ "key": "Authorization",
+ "value": "Bearer {{access_token}}",
+ "description": ""
+ },
+ {
"key": "Content-Type",
- "value": "application/json"
+ "value": "application/json",
+ "description": ""
}
],
"body": {
"mode": "raw",
- "raw": "{}"
+ "raw": "{\n\t\"password\": \"newPass2\"\n}"
},
+ "description": ""
+ },
+ "response": []
+ },
+ {
+ "name": "/users/:username?action=delete",
+ "request": {
"url": {
- "raw": "{{host}}/{{endpoint}}/projects/{{dummy_project}}",
+ "raw": "{{host}}/{{endpoint}}/users/{{new_username}}?action=delete",
"host": [
"{{host}}"
],
"path": [
"{{endpoint}}",
- "projects",
- "{{dummy_project}}"
- ]
+ "users",
+ "{{new_username}}"
+ ],
+ "query": [
+ {
+ "key": "action",
+ "value": "delete",
+ "equals": true,
+ "description": ""
+ }
+ ],
+ "variable": []
+ },
+ "method": "POST",
+ "header": [
+ {
+ "key": "Authorization",
+ "value": "Bearer {{access_token}}",
+ "description": ""
+ },
+ {
+ "key": "Content-Type",
+ "value": "application/json",
+ "description": ""
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
+ "description": ""
+ },
+ "response": []
+ },
+ {
+ "name": "/users/:username/properties",
+ "request": {
+ "url": "{{host}}/{{endpoint}}/users/{{new_username}}/properties",
+ "method": "GET",
+ "header": [
+ {
+ "key": "Authorization",
+ "value": "Bearer {{access_token}}",
+ "description": ""
+ },
+ {
+ "key": "Content-Type",
+ "value": "application/json",
+ "description": "",
+ "disabled": true
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
+ "description": ""
+ },
+ "response": []
+ },
+ {
+ "name": "/current_user",
+ "request": {
+ "url": "{{host}}/{{endpoint}}/current_user",
+ "method": "GET",
+ "header": [
+ {
+ "key": "Authorization",
+ "value": "Bearer {{access_token}}",
+ "description": ""
+ },
+ {
+ "key": "Content-Type",
+ "value": "application/json",
+ "description": "",
+ "disabled": true
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
+ "description": ""
+ },
+ "response": []
+ },
+ {
+ "name": "/current_user",
+ "request": {
+ "url": "{{host}}/{{endpoint}}/current_user",
+ "method": "POST",
+ "header": [
+ {
+ "key": "Authorization",
+ "value": "Bearer {{access_token}}",
+ "description": ""
+ },
+ {
+ "key": "Content-Type",
+ "value": "application/json",
+ "description": ""
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n\t\"password\": {\n\t\t\"old\": \"pass\",\n\t\t\"new\": \"pass2\"\n\t}\n}"
+ },
+ "description": ""
+ },
+ "response": []
+ },
+ {
+ "name": "/projects/:project_name",
+ "request": {
+ "url": "{{host}}/{{endpoint}}/projects/{{dummy_project}}",
+ "method": "GET",
+ "header": [
+ {
+ "key": "Authorization",
+ "value": "Bearer {{access_token}}",
+ "description": ""
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
+ "description": ""
+ },
+ "response": []
+ },
+ {
+ "name": "/projects/:project_name/properties",
+ "request": {
+ "url": "{{host}}/{{endpoint}}/projects/{{dummy_project}}/properties",
+ "method": "GET",
+ "header": [
+ {
+ "key": "Authorization",
+ "value": "Bearer {{access_token}}",
+ "description": ""
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": ""
},
"description": ""
},
@@ -192,19 +771,8 @@
"name": "/oauth/token",
"event": [
{
- "listen": "prerequest",
- "script": {
- "id": "7cbb2980-4092-4675-af5e-cfcbd1c00b81",
- "type": "text/javascript",
- "exec": [
- ""
- ]
- }
- },
- {
"listen": "test",
"script": {
- "id": "7ce27395-de92-457b-97cc-7728824c821d",
"type": "text/javascript",
"exec": [
"let res = JSON.parse(responseBody);",
@@ -215,9 +783,7 @@
}
],
"request": {
- "auth": {
- "type": "noauth"
- },
+ "url": "{{host}}/{{endpoint}}/oauth/token",
"method": "POST",
"header": [
{
@@ -248,20 +814,9 @@
}
]
},
- "url": {
- "raw": "{{host}}/{{endpoint}}/oauth/token",
- "host": [
- "{{host}}"
- ],
- "path": [
- "{{endpoint}}",
- "oauth",
- "token"
- ]
- },
"description": "wefrwrbjk;"
},
"response": []
}
]
-} \ No newline at end of file
+}
diff --git a/test/postman.json.json b/test/postman.json.json
deleted file mode 100644
index 14771e0..0000000
--- a/test/postman.json.json
+++ /dev/null
@@ -1,245 +0,0 @@
-{
- "variables": [],
- "info": {
- "name": "JH",
- "_postman_id": "d9fad1ce-92af-fc2c-ff74-074fc681c7ee",
- "description": "",
- "schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json"
- },
- "item": [
- {
- "name": "authorised",
- "description": "",
- "item": [
- {
- "name": "/projects",
- "request": {
- "url": "{{host}}/{{endpoint}}/projects",
- "method": "GET",
- "header": [
- {
- "key": "",
- "value": "",
- "disabled": true
- }
- ],
- "body": {
- "mode": "raw",
- "raw": ""
- },
- "description": ""
- },
- "response": []
- },
- {
- "name": "/log",
- "request": {
- "url": "{{host}}/{{endpoint}}/log",
- "method": "GET",
- "header": [
- {
- "key": "",
- "value": "",
- "disabled": true
- }
- ],
- "body": {
- "mode": "raw",
- "raw": ""
- },
- "description": ""
- },
- "response": []
- },
- {
- "name": "/_supported_protocols",
- "request": {
- "url": "{{host}}/{{endpoint}}/_supported_protocols_",
- "method": "GET",
- "header": [
- {
- "key": "Authorization",
- "value": "Bearer {{access_token}}",
- "description": "",
- "disabled": true
- }
- ],
- "body": {},
- "description": ""
- },
- "response": []
- },
- {
- "name": "/project_roles",
- "request": {
- "url": "{{host}}/{{endpoint}}/project_roles",
- "method": "GET",
- "header": [
- {
- "key": "Authorization",
- "value": "Bearer {{access_token}}",
- "description": "",
- "disabled": true
- }
- ],
- "body": {},
- "description": ""
- },
- "response": []
- },
- {
- "name": "/projects/",
- "request": {
- "url": "{{host}}/{{endpoint}}/projects/{{dummy_project}}",
- "method": "POST",
- "header": [
- {
- "key": "Content-Type",
- "value": "application/json",
- "description": ""
- },
- {
- "key": "Authorization",
- "value": "Bearer {{access_token}}",
- "description": ""
- }
- ],
- "body": {
- "mode": "raw",
- "raw": "{}"
- },
- "description": ""
- },
- "response": []
- },
- {
- "name": "/projects/abc/files_by_id",
- "request": {
- "url": "{{host}}/{{endpoint}}/projects/{{dummy_project}}/files_by_id/d124ef49-e9e3-4794-bf50-76f40797b5d5",
- "method": "GET",
- "header": [
- {
- "key": "Authorization",
- "value": "Bearer {{access_token}}",
- "description": ""
- },
- {
- "key": "Content-Type",
- "value": "image/png",
- "description": "",
- "disabled": true
- }
- ],
- "body": {
- "mode": "formdata",
- "formdata": [
- {
- "key": "pres",
- "description": "",
- "type": "file",
- "src": "triangle_down_black.png"
- }
- ]
- },
- "description": ""
- },
- "response": []
- },
- {
- "name": "/projects/abc/files",
- "request": {
- "url": "{{host}}/{{endpoint}}/projects/{{dummy_project}}/files/path/to/image.png",
- "method": "POST",
- "header": [
- {
- "key": "Authorization",
- "value": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJvYmplY3QiOnsidXNlcm5hbWUiOiJoYWZlZXoiLCJwYXNzd29yZEludGVybmFsIjpudWxsLCJjcmVhdGlvbkRhdGUiOiIyMDE4LTA0LTE2VDEyOjA1OjUyLjQ2N1oiLCJ1cGRhdGVkQXQiOiIyMDE4LTA0LTE2VDEyOjA1OjUyLjQ2N1oiLCJ1c2VyR3JvdXBzIjpbeyJpZCI6MSwibmFtZSI6ImxvZ2dpbmciLCJjYW5DcmVhdGVVc2VycyI6bnVsbCwiY2FuRGVsZXRlVXNlcnMiOm51bGwsImNhbkVkaXRVc2VycyI6bnVsbCwiY2FuQ3JlYXRlUHJvamVjdHMiOm51bGwsImNhbkRlbGV0ZVByb2plY3RzIjpudWxsLCJjYW5FZGl0UHJvamVjdHMiOm51bGwsImNhbkFjY2Vzc0xvZ3MiOnRydWUsImlzSW50ZXJuYWwiOmZhbHNlLCJkZXNjcmlwdGlvbiI6IkFsbG93cyBQb3N0IHRvIExvZyIsIlVzZXJIYXNQcml2aWxlZ2UiOnsidXNlcm5hbWUiOiJoYWZlZXoiLCJwcml2aWxlZ2VJZCI6MX19LHsiaWQiOjIsIm5hbWUiOiJhZG1pbiIsImNhbkNyZWF0ZVVzZXJzIjp0cnVlLCJjYW5EZWxldGVVc2VycyI6dHJ1ZSwiY2FuRWRpdFVzZXJzIjp0cnVlLCJjYW5DcmVhdGVQcm9qZWN0cyI6dHJ1ZSwiY2FuRGVsZXRlUHJvamVjdHMiOnRydWUsImNhbkVkaXRQcm9qZWN0cyI6dHJ1ZSwiY2FuQWNjZXNzTG9ncyI6bnVsbCwiaXNJbnRlcm5hbCI6ZmFsc2UsImRlc2NyaXB0aW9uIjoiU3lzdGVtcyBhZG1pbiIsIlVzZXJIYXNQcml2aWxlZ2UiOnsidXNlcm5hbWUiOiJoYWZlZXoiLCJwcml2aWxlZ2VJZCI6Mn19XSwicHJvamVjdHMiOltdfSwiaWF0IjoxNTIzODgwMzU2LCJleHAiOjE1MjM5MDE5NTZ9.LrRWCzjBQmPtEkthmPJvVdl6XsYqA4Myqw-VFHMbQ8o",
- "description": ""
- },
- {
- "key": "Content-Type",
- "value": "image/png",
- "description": ""
- }
- ],
- "body": {
- "mode": "formdata",
- "formdata": [
- {
- "key": "triangle",
- "description": "",
- "type": "file",
- "src": "triangle_down_black.png"
- }
- ]
- },
- "description": ""
- },
- "response": []
- },
- {
- "name": "/",
- "request": {
- "url": "{{host}}/",
- "method": "GET",
- "header": [],
- "body": {},
- "description": ""
- },
- "response": []
- }
- ]
- },
- {
- "name": "/oauth/token",
- "event": [
- {
- "listen": "test",
- "script": {
- "type": "text/javascript",
- "exec": [
- "let res = JSON.parse(responseBody);",
- "postman.setEnvironmentVariable(\"access_token\", res.access_token);",
- "postman.setEnvironmentVariable(\"refresh_token\", res.refresh_token);"
- ]
- }
- }
- ],
- "request": {
- "url": "{{host}}/{{endpoint}}/oauth/token",
- "method": "POST",
- "header": [
- {
- "key": "Content-Type",
- "value": "application/x-www-form-urlencoded"
- }
- ],
- "body": {
- "mode": "urlencoded",
- "urlencoded": [
- {
- "key": "grant_type",
- "value": "password",
- "description": "",
- "type": "text"
- },
- {
- "key": "username",
- "value": "{{dummy_admin_username}}",
- "description": "",
- "type": "text"
- },
- {
- "key": "password",
- "value": "{{dummy_admin_pass}}",
- "description": "",
- "type": "text"
- }
- ]
- },
- "description": "wefrwrbjk;"
- },
- "response": []
- }
- ]
-} \ No newline at end of file
diff --git a/test/test-db.ts b/test/test-db.ts
index ef980c5..9a32cb2 100644
--- a/test/test-db.ts
+++ b/test/test-db.ts
@@ -2,7 +2,12 @@ import { default as Project } from '../src/db/model/Project';
import { default as User } from '../src/db/model/User';
import { default as UserGroup } from '../src/db/model/UserGroup';
import { default as File } from '../src/db/model/File';
+import { View, addSubFileToFolder, copyFile, createProjectFolder, deleteFile,
+ saveFile, views, preprocess } from '../src/files';
+import * as fs from 'fs-extra';
import { FileTypeName } from '../src/files';
+import { uuid } from '../src/uuid';
+
import { Sequelize } from 'sequelize-typescript';
import * as sqlite from 'sqlite3';
@@ -37,14 +42,15 @@ export interface Projec {
contributors: Credentials[];
creationDate: Date;
lastActivity: Date;
+ rootFolderId: string;
}
export interface Filee {
- name: string,
- path: string,
- uuid: string,
- creator: Credentials,
- type: FileTypeName
+ name: string;
+ path: string;
+ uuid: string;
+ creator: Credentials;
+ type: FileTypeName;
}
export const addUser: (database?: Database, admin?: boolean) =>
@@ -92,11 +98,19 @@ export const addProjec: (database: Database, user: Credentials) =>
Promise<Projec> = async(
database: Database, user: Credentials
): Promise<Projec> => {
+ createProjectFolder('mocky');
+ const file: File = new File({
+ uuid: uuid.generate()
+ });
+ file.mimetype = 'inode/directory';
+ file.name = '';
+ await file.save();
const mockProject: Projec = {
name: 'mocky',
contributors: [user],
creationDate: new Date(),
- lastActivity: new Date()
+ lastActivity: new Date(),
+ rootFolderId: file.uuid
};
await new Project(mockProject).save();