1 /* tslint:disable:no-unused-expression */
11 setAccessTokensToServers,
13 } from '../../../../shared/utils'
14 import { makeGetRequest } from '../../../../shared/utils/requests/requests'
16 describe('Test logs API validators', function () {
17 const path = '/api/v1/server/logs'
18 let server: ServerInfo
19 let userAccessToken = ''
21 // ---------------------------------------------------------------
23 before(async function () {
28 server = await runServer(1)
30 await setAccessTokensToServers([ server ])
34 password: 'my super password'
36 await createUser(server.url, server.accessToken, user.username, user.password)
37 userAccessToken = await userLogin(server, user)
40 describe('When getting logs', function () {
42 it('Should fail with a non authenticated user', async function () {
43 await makeGetRequest({
46 statusCodeExpected: 401
50 it('Should fail with a non admin user', async function () {
51 await makeGetRequest({
54 token: userAccessToken,
55 statusCodeExpected: 403
59 it('Should fail with a missing startDate query', async function () {
60 await makeGetRequest({
63 token: server.accessToken,
64 statusCodeExpected: 400
68 it('Should fail with a bad startDate query', async function () {
69 await makeGetRequest({
72 token: server.accessToken,
73 query: { startDate: 'toto' },
74 statusCodeExpected: 400
78 it('Should fail with a bad endDate query', async function () {
79 await makeGetRequest({
82 token: server.accessToken,
83 query: { startDate: new Date().toISOString(), endDate: 'toto' },
84 statusCodeExpected: 400
88 it('Should fail with a bad level parameter', async function () {
89 await makeGetRequest({
92 token: server.accessToken,
93 query: { startDate: new Date().toISOString(), level: 'toto' },
94 statusCodeExpected: 400
98 it('Should succeed with the correct params', async function () {
99 await makeGetRequest({
102 token: server.accessToken,
103 query: { startDate: new Date().toISOString() },
104 statusCodeExpected: 200
109 after(async function () {
110 killallServers([ server ])
112 // Keep the logs if the test failed