diff --git a/backend/test/tests/credentials-get.js b/backend/test/tests/credentials-get.js index 1adda76..5d126d3 100644 --- a/backend/test/tests/credentials-get.js +++ b/backend/test/tests/credentials-get.js @@ -21,5 +21,50 @@ test.run(async function () { type: 'key' } ], 'Result fail for ' + res.config.url); + + //Test query + var res = await req({ + url: '/records/4/credentials', + method: 'get' + }); + + assert.equal(res.status, 200, 'Status should be OK'); + assert.equal(res.data.results, [ + { + id: 2, + description: 'Key Test', + type: 'key' + } + ], 'Result fail for ' + res.config.url); + }); + + await test('user', async function (assert, req) { + //Test query + var res = await req({ + url: '/records/1/credentials', + method: 'get' + }); + + assert.equal(res.status, 200, 'Status should be OK'); + assert.equal(res.data.results, [ + { + id: 1, + description: 'Password Test', + type: 'password' + }, + { + id: 3, + description: 'Key Test 2', + type: 'key' + } + ], 'Result fail for ' + res.config.url); + + //Test permissions + var res = await req({ + url: '/records/4/credentials', + method: 'get' + }); + + assert.equal(res.status, 403, 'Request should fail without permissions.'); }); }); \ No newline at end of file