diff options
Diffstat (limited to 'server/tests/plugins/plugin-router.ts')
-rw-r--r-- | server/tests/plugins/plugin-router.ts | 43 |
1 files changed, 18 insertions, 25 deletions
diff --git a/server/tests/plugins/plugin-router.ts b/server/tests/plugins/plugin-router.ts index 24e6a1e83..b1ac9e2fe 100644 --- a/server/tests/plugins/plugin-router.ts +++ b/server/tests/plugins/plugin-router.ts | |||
@@ -1,19 +1,20 @@ | |||
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ | 1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | 2 | ||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import { cleanupTests, flushAndRunServer, ServerInfo } from '../../../shared/extra-utils/server/servers' | 4 | import { expect } from 'chai' |
5 | import { | 5 | import { |
6 | getPluginTestPath, | 6 | cleanupTests, |
7 | installPlugin, | 7 | createSingleServer, |
8 | makeGetRequest, | 8 | makeGetRequest, |
9 | makePostBodyRequest, | 9 | makePostBodyRequest, |
10 | setAccessTokensToServers, uninstallPlugin | 10 | PeerTubeServer, |
11 | } from '../../../shared/extra-utils' | 11 | PluginsCommand, |
12 | import { expect } from 'chai' | 12 | setAccessTokensToServers |
13 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | 13 | } from '@shared/extra-utils' |
14 | import { HttpStatusCode } from '@shared/models' | ||
14 | 15 | ||
15 | describe('Test plugin helpers', function () { | 16 | describe('Test plugin helpers', function () { |
16 | let server: ServerInfo | 17 | let server: PeerTubeServer |
17 | const basePaths = [ | 18 | const basePaths = [ |
18 | '/plugins/test-five/router/', | 19 | '/plugins/test-five/router/', |
19 | '/plugins/test-five/0.0.1/router/' | 20 | '/plugins/test-five/0.0.1/router/' |
@@ -22,14 +23,10 @@ describe('Test plugin helpers', function () { | |||
22 | before(async function () { | 23 | before(async function () { |
23 | this.timeout(30000) | 24 | this.timeout(30000) |
24 | 25 | ||
25 | server = await flushAndRunServer(1) | 26 | server = await createSingleServer(1) |
26 | await setAccessTokensToServers([ server ]) | 27 | await setAccessTokensToServers([ server ]) |
27 | 28 | ||
28 | await installPlugin({ | 29 | await server.plugins.install({ path: PluginsCommand.getPluginTestPath('-five') }) |
29 | url: server.url, | ||
30 | accessToken: server.accessToken, | ||
31 | path: getPluginTestPath('-five') | ||
32 | }) | ||
33 | }) | 30 | }) |
34 | 31 | ||
35 | it('Should answer "pong"', async function () { | 32 | it('Should answer "pong"', async function () { |
@@ -37,7 +34,7 @@ describe('Test plugin helpers', function () { | |||
37 | const res = await makeGetRequest({ | 34 | const res = await makeGetRequest({ |
38 | url: server.url, | 35 | url: server.url, |
39 | path: path + 'ping', | 36 | path: path + 'ping', |
40 | statusCodeExpected: HttpStatusCode.OK_200 | 37 | expectedStatus: HttpStatusCode.OK_200 |
41 | }) | 38 | }) |
42 | 39 | ||
43 | expect(res.body.message).to.equal('pong') | 40 | expect(res.body.message).to.equal('pong') |
@@ -50,7 +47,7 @@ describe('Test plugin helpers', function () { | |||
50 | url: server.url, | 47 | url: server.url, |
51 | path: path + 'is-authenticated', | 48 | path: path + 'is-authenticated', |
52 | token: server.accessToken, | 49 | token: server.accessToken, |
53 | statusCodeExpected: 200 | 50 | expectedStatus: 200 |
54 | }) | 51 | }) |
55 | 52 | ||
56 | expect(res.body.isAuthenticated).to.equal(true) | 53 | expect(res.body.isAuthenticated).to.equal(true) |
@@ -58,7 +55,7 @@ describe('Test plugin helpers', function () { | |||
58 | const secRes = await makeGetRequest({ | 55 | const secRes = await makeGetRequest({ |
59 | url: server.url, | 56 | url: server.url, |
60 | path: path + 'is-authenticated', | 57 | path: path + 'is-authenticated', |
61 | statusCodeExpected: 200 | 58 | expectedStatus: 200 |
62 | }) | 59 | }) |
63 | 60 | ||
64 | expect(secRes.body.isAuthenticated).to.equal(false) | 61 | expect(secRes.body.isAuthenticated).to.equal(false) |
@@ -77,7 +74,7 @@ describe('Test plugin helpers', function () { | |||
77 | url: server.url, | 74 | url: server.url, |
78 | path: path + 'form/post/mirror', | 75 | path: path + 'form/post/mirror', |
79 | fields: body, | 76 | fields: body, |
80 | statusCodeExpected: HttpStatusCode.OK_200 | 77 | expectedStatus: HttpStatusCode.OK_200 |
81 | }) | 78 | }) |
82 | 79 | ||
83 | expect(res.body).to.deep.equal(body) | 80 | expect(res.body).to.deep.equal(body) |
@@ -85,24 +82,20 @@ describe('Test plugin helpers', function () { | |||
85 | }) | 82 | }) |
86 | 83 | ||
87 | it('Should remove the plugin and remove the routes', async function () { | 84 | it('Should remove the plugin and remove the routes', async function () { |
88 | await uninstallPlugin({ | 85 | await server.plugins.uninstall({ npmName: 'peertube-plugin-test-five' }) |
89 | url: server.url, | ||
90 | accessToken: server.accessToken, | ||
91 | npmName: 'peertube-plugin-test-five' | ||
92 | }) | ||
93 | 86 | ||
94 | for (const path of basePaths) { | 87 | for (const path of basePaths) { |
95 | await makeGetRequest({ | 88 | await makeGetRequest({ |
96 | url: server.url, | 89 | url: server.url, |
97 | path: path + 'ping', | 90 | path: path + 'ping', |
98 | statusCodeExpected: HttpStatusCode.NOT_FOUND_404 | 91 | expectedStatus: HttpStatusCode.NOT_FOUND_404 |
99 | }) | 92 | }) |
100 | 93 | ||
101 | await makePostBodyRequest({ | 94 | await makePostBodyRequest({ |
102 | url: server.url, | 95 | url: server.url, |
103 | path: path + 'ping', | 96 | path: path + 'ping', |
104 | fields: {}, | 97 | fields: {}, |
105 | statusCodeExpected: HttpStatusCode.NOT_FOUND_404 | 98 | expectedStatus: HttpStatusCode.NOT_FOUND_404 |
106 | }) | 99 | }) |
107 | } | 100 | } |
108 | }) | 101 | }) |