From 20bafcb61bee2a9a10a500908850c9a7d5e3c8c5 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 22 Jul 2021 11:15:17 +0200 Subject: Move apicache in peertube Allow us to upgrade to node 16 --- server/tests/feeds/feeds.ts | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) (limited to 'server/tests') diff --git a/server/tests/feeds/feeds.ts b/server/tests/feeds/feeds.ts index 5667207c0..55b434846 100644 --- a/server/tests/feeds/feeds.ts +++ b/server/tests/feeds/feeds.ts @@ -8,6 +8,7 @@ import { createMultipleServers, createSingleServer, doubleFollow, + makeGetRequest, PeerTubeServer, setAccessTokensToServers, waitJobs @@ -52,9 +53,7 @@ describe('Test syndication feeds', () => { } { - const attr = { username: 'john', password: 'password' } - await servers[0].users.create({ username: attr.username, password: attr.password }) - userAccessToken = await servers[0].login.getAccessToken(attr) + userAccessToken = await servers[0].users.generateUserAndToken('john') const user = await servers[0].users.getMyInfo({ token: userAccessToken }) userAccountId = user.account.id @@ -108,6 +107,41 @@ describe('Test syndication feeds', () => { expect(JSON.parse(jsonText)).to.be.jsonSchema({ type: 'object' }) } }) + + it('Should serve the endpoint with a classic request', async function () { + await makeGetRequest({ + url: servers[0].url, + path: '/feeds/videos.xml', + accept: 'application/xml', + expectedStatus: HttpStatusCode.OK_200 + }) + }) + + it('Should serve the endpoint as a cached request', async function () { + const res = await makeGetRequest({ + url: servers[0].url, + path: '/feeds/videos.xml', + accept: 'application/xml', + expectedStatus: HttpStatusCode.OK_200 + }) + + expect(res.headers['x-api-cache-cached']).to.equal('true') + }) + + it('Should not serve the endpoint as a cached request', async function () { + const res = await makeGetRequest({ + url: servers[0].url, + path: '/feeds/videos.xml?v=186', + accept: 'application/xml', + expectedStatus: HttpStatusCode.OK_200 + }) + + expect(res.headers['x-api-cache-cached']).to.not.exist + }) + + it('Should refuse to serve the endpoint without accept header', async function () { + await makeGetRequest({ url: servers[0].url, path: '/feeds/videos.xml', expectedStatus: HttpStatusCode.NOT_ACCEPTABLE_406 }) + }) }) describe('Videos feed', function () { -- cgit v1.2.3