From 94ff4c2335ace54b36b2bca96f63226ee8f575b1 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 16 Apr 2018 10:48:17 +0200 Subject: Add auth documentation --- server/tests/api/check-params/users.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'server/tests') diff --git a/server/tests/api/check-params/users.ts b/server/tests/api/check-params/users.ts index ee591d620..a3e415b94 100644 --- a/server/tests/api/check-params/users.ts +++ b/server/tests/api/check-params/users.ts @@ -308,6 +308,26 @@ describe('Test users API validators', function () { }) }) + describe('When getting a user', function () { + before(async function () { + const res = await getUsersList(server.url, server.accessToken) + + userId = res.body.data[1].id + }) + + it('Should fail with an non authenticated user', async function () { + await makeGetRequest({ url: server.url, path: path + userId, token: 'super token', statusCodeExpected: 401 }) + }) + + it('Should fail with a non admin user', async function () { + await makeGetRequest({ url: server.url, path, token: userAccessToken, statusCodeExpected: 403 }) + }) + + it('Should succeed with the correct params', async function () { + await makeGetRequest({ url: server.url, path: path + userId, token: server.accessToken, statusCodeExpected: 200 }) + }) + }) + describe('When updating a user', function () { before(async function () { -- cgit v1.2.3