1 /* tslint:disable:no-unused-expression */
11 setAccessTokensToServers,
14 } from '../../../../shared/extra-utils'
15 import { makeGetRequest } from '../../../../shared/extra-utils/requests/requests'
17 describe('Test logs API validators', function () {
18 const path = '/api/v1/server/logs'
19 let server: ServerInfo
20 let userAccessToken = ''
22 // ---------------------------------------------------------------
24 before(async function () {
27 server = await flushAndRunServer(1)
29 await setAccessTokensToServers([ server ])
33 password: 'my super password'
35 await createUser({ url: server.url, accessToken: server.accessToken, username: user.username, password: user.password })
36 userAccessToken = await userLogin(server, user)
39 describe('When getting logs', function () {
41 it('Should fail with a non authenticated user', async function () {
42 await makeGetRequest({
45 statusCodeExpected: 401
49 it('Should fail with a non admin user', async function () {
50 await makeGetRequest({
53 token: userAccessToken,
54 statusCodeExpected: 403
58 it('Should fail with a missing startDate query', async function () {
59 await makeGetRequest({
62 token: server.accessToken,
63 statusCodeExpected: 400
67 it('Should fail with a bad startDate query', async function () {
68 await makeGetRequest({
71 token: server.accessToken,
72 query: { startDate: 'toto' },
73 statusCodeExpected: 400
77 it('Should fail with a bad endDate query', async function () {
78 await makeGetRequest({
81 token: server.accessToken,
82 query: { startDate: new Date().toISOString(), endDate: 'toto' },
83 statusCodeExpected: 400
87 it('Should fail with a bad level parameter', async function () {
88 await makeGetRequest({
91 token: server.accessToken,
92 query: { startDate: new Date().toISOString(), level: 'toto' },
93 statusCodeExpected: 400
97 it('Should succeed with the correct params', async function () {
98 await makeGetRequest({
101 token: server.accessToken,
102 query: { startDate: new Date().toISOString() },
103 statusCodeExpected: 200
108 after(async function () {
109 await cleanupTests([ server ])