X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fplugins%2Fplugin-router.ts;h=24e6a1e834701c97c4d6b088a66135a8753871d1;hb=819b656439e5f0ec2ae5de9357502cdfe3196197;hp=cf4130f4b1af5aeb73fd916e96926f16425ba3c2;hpb=5e2b2e2775421cd98286d6e2f75cf38aae7a212c;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/plugins/plugin-router.ts b/server/tests/plugins/plugin-router.ts index cf4130f4b..24e6a1e83 100644 --- a/server/tests/plugins/plugin-router.ts +++ b/server/tests/plugins/plugin-router.ts @@ -10,6 +10,7 @@ import { setAccessTokensToServers, uninstallPlugin } from '../../../shared/extra-utils' import { expect } from 'chai' +import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' describe('Test plugin helpers', function () { let server: ServerInfo @@ -36,13 +37,34 @@ describe('Test plugin helpers', function () { const res = await makeGetRequest({ url: server.url, path: path + 'ping', - statusCodeExpected: 200 + statusCodeExpected: HttpStatusCode.OK_200 }) expect(res.body.message).to.equal('pong') } }) + it('Should check if authenticated', async function () { + for (const path of basePaths) { + const res = await makeGetRequest({ + url: server.url, + path: path + 'is-authenticated', + token: server.accessToken, + statusCodeExpected: 200 + }) + + expect(res.body.isAuthenticated).to.equal(true) + + const secRes = await makeGetRequest({ + url: server.url, + path: path + 'is-authenticated', + statusCodeExpected: 200 + }) + + expect(secRes.body.isAuthenticated).to.equal(false) + } + }) + it('Should mirror post body', async function () { const body = { hello: 'world', @@ -55,7 +77,7 @@ describe('Test plugin helpers', function () { url: server.url, path: path + 'form/post/mirror', fields: body, - statusCodeExpected: 200 + statusCodeExpected: HttpStatusCode.OK_200 }) expect(res.body).to.deep.equal(body) @@ -73,14 +95,14 @@ describe('Test plugin helpers', function () { await makeGetRequest({ url: server.url, path: path + 'ping', - statusCodeExpected: 404 + statusCodeExpected: HttpStatusCode.NOT_FOUND_404 }) await makePostBodyRequest({ url: server.url, path: path + 'ping', fields: {}, - statusCodeExpected: 404 + statusCodeExpected: HttpStatusCode.NOT_FOUND_404 }) } })