X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fapi%2Fserver%2Flogs.ts;h=6b1eb776cf2f8d69c124d79471a3c425c6a9688e;hb=9129b7694d577322327ee79e9b9aa64deee92765;hp=b8714c7a104df5a4c90790a591f4380fb72e4a0b;hpb=7024e9120b381b5b3201212f5a18f5cdc14e15ff;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/api/server/logs.ts b/server/tests/api/server/logs.ts index b8714c7a1..6b1eb776c 100644 --- a/server/tests/api/server/logs.ts +++ b/server/tests/api/server/logs.ts @@ -1,11 +1,19 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import * as chai from 'chai' import 'mocha' -import { cleanupTests, flushAndRunServer, ServerInfo, setAccessTokensToServers } from '../../../../shared/extra-utils/index' +import * as chai from 'chai' +import { + cleanupTests, + flushAndRunServer, + killallServers, + makePingRequest, + reRunServer, + ServerInfo, + setAccessTokensToServers +} from '../../../../shared/extra-utils/index' +import { getAuditLogs, getLogs } from '../../../../shared/extra-utils/logs/logs' import { waitJobs } from '../../../../shared/extra-utils/server/jobs' import { uploadVideo } from '../../../../shared/extra-utils/videos/videos' -import { getAuditLogs, getLogs } from '../../../../shared/extra-utils/logs/logs' const expect = chai.expect @@ -20,6 +28,7 @@ describe('Test logs', function () { }) describe('With the standard log file', function () { + it('Should get logs with a start date', async function () { this.timeout(10000) @@ -84,6 +93,34 @@ describe('Test logs', function () { expect(logsString.includes('video 6')).to.be.false } }) + + it('Should log ping requests', async function () { + const now = new Date() + + await makePingRequest(server) + + const res = await getLogs(server.url, server.accessToken, now, undefined, 'info') + const logsString = JSON.stringify(res.body) + + expect(logsString.includes('/api/v1/ping')).to.be.true + }) + + it('Should not log ping requests', async function () { + this.timeout(30000) + + killallServers([ server ]) + + await reRunServer(server, { log: { log_ping_requests: false } }) + + const now = new Date() + + await makePingRequest(server) + + const res = await getLogs(server.url, server.accessToken, now, undefined, 'info') + const logsString = JSON.stringify(res.body) + + expect(logsString.includes('/api/v1/ping')).to.be.false + }) }) describe('With the audit log', function () {