aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/plugins/external-auth.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-07 10:33:49 +0200
committerChocobozzz <me@florianbigard.com>2021-07-20 15:27:17 +0200
commitae2abfd3aed3e75d39a316b49b914d187faa7475 (patch)
tree4d5060dc310f3d8cdcd5829779522f49b3d10e71 /server/tests/plugins/external-auth.ts
parent9c6327f803aaf4200672f1fc40b2f43786daca47 (diff)
downloadPeerTube-ae2abfd3aed3e75d39a316b49b914d187faa7475.tar.gz
PeerTube-ae2abfd3aed3e75d39a316b49b914d187faa7475.tar.zst
PeerTube-ae2abfd3aed3e75d39a316b49b914d187faa7475.zip
Introduce plugins command
Diffstat (limited to 'server/tests/plugins/external-auth.ts')
-rw-r--r--server/tests/plugins/external-auth.ts47
1 files changed, 17 insertions, 30 deletions
diff --git a/server/tests/plugins/external-auth.ts b/server/tests/plugins/external-auth.ts
index 5addb45c7..424302786 100644
--- a/server/tests/plugins/external-auth.ts
+++ b/server/tests/plugins/external-auth.ts
@@ -2,27 +2,26 @@
2 2
3import 'mocha' 3import 'mocha'
4import { expect } from 'chai' 4import { expect } from 'chai'
5import { ServerConfig, User, UserRole } from '@shared/models' 5import { HttpStatusCode } from '@shared/core-utils'
6import { 6import {
7 cleanupTests,
8 createUser,
7 decodeQueryString, 9 decodeQueryString,
10 flushAndRunServer,
8 getConfig, 11 getConfig,
9 getExternalAuth,
10 getMyUserInformation, 12 getMyUserInformation,
11 getPluginTestPath,
12 installPlugin,
13 loginUsingExternalToken, 13 loginUsingExternalToken,
14 logout, 14 logout,
15 PluginsCommand,
15 refreshToken, 16 refreshToken,
17 ServerInfo,
16 setAccessTokensToServers, 18 setAccessTokensToServers,
17 uninstallPlugin,
18 updateMyUser, 19 updateMyUser,
19 wait,
20 userLogin, 20 userLogin,
21 updatePluginSettings, 21 wait,
22 createUser 22 waitUntilLog
23} from '../../../shared/extra-utils' 23} from '@shared/extra-utils'
24import { cleanupTests, flushAndRunServer, ServerInfo, waitUntilLog } from '../../../shared/extra-utils/server/servers' 24import { ServerConfig, User, UserRole } from '@shared/models'
25import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
26 25
27async function loginExternal (options: { 26async function loginExternal (options: {
28 server: ServerInfo 27 server: ServerInfo
@@ -33,13 +32,12 @@ async function loginExternal (options: {
33 statusCodeExpected?: HttpStatusCode 32 statusCodeExpected?: HttpStatusCode
34 statusCodeExpectedStep2?: HttpStatusCode 33 statusCodeExpectedStep2?: HttpStatusCode
35}) { 34}) {
36 const res = await getExternalAuth({ 35 const res = await options.server.pluginsCommand.getExternalAuth({
37 url: options.server.url,
38 npmName: options.npmName, 36 npmName: options.npmName,
39 npmVersion: '0.0.1', 37 npmVersion: '0.0.1',
40 authName: options.authName, 38 authName: options.authName,
41 query: options.query, 39 query: options.query,
42 statusCodeExpected: options.statusCodeExpected || HttpStatusCode.FOUND_302 40 expectedStatus: options.statusCodeExpected || HttpStatusCode.FOUND_302
43 }) 41 })
44 42
45 if (res.status !== HttpStatusCode.FOUND_302) return 43 if (res.status !== HttpStatusCode.FOUND_302) return
@@ -75,11 +73,7 @@ describe('Test external auth plugins', function () {
75 await setAccessTokensToServers([ server ]) 73 await setAccessTokensToServers([ server ])
76 74
77 for (const suffix of [ 'one', 'two', 'three' ]) { 75 for (const suffix of [ 'one', 'two', 'three' ]) {
78 await installPlugin({ 76 await server.pluginsCommand.install({ path: PluginsCommand.getPluginTestPath('-external-auth-' + suffix) })
79 url: server.url,
80 accessToken: server.accessToken,
81 path: getPluginTestPath('-external-auth-' + suffix)
82 })
83 } 77 }
84 }) 78 })
85 79
@@ -98,15 +92,14 @@ describe('Test external auth plugins', function () {
98 }) 92 })
99 93
100 it('Should redirect for a Cyan login', async function () { 94 it('Should redirect for a Cyan login', async function () {
101 const res = await getExternalAuth({ 95 const res = await server.pluginsCommand.getExternalAuth({
102 url: server.url,
103 npmName: 'test-external-auth-one', 96 npmName: 'test-external-auth-one',
104 npmVersion: '0.0.1', 97 npmVersion: '0.0.1',
105 authName: 'external-auth-1', 98 authName: 'external-auth-1',
106 query: { 99 query: {
107 username: 'cyan' 100 username: 'cyan'
108 }, 101 },
109 statusCodeExpected: HttpStatusCode.FOUND_302 102 expectedStatus: HttpStatusCode.FOUND_302
110 }) 103 })
111 104
112 const location = res.header.location 105 const location = res.header.location
@@ -275,9 +268,7 @@ describe('Test external auth plugins', function () {
275 }) 268 })
276 269
277 it('Should unregister external-auth-2 and do not login existing Kefka', async function () { 270 it('Should unregister external-auth-2 and do not login existing Kefka', async function () {
278 await updatePluginSettings({ 271 await server.pluginsCommand.updateSettings({
279 url: server.url,
280 accessToken: server.accessToken,
281 npmName: 'peertube-plugin-test-external-auth-one', 272 npmName: 'peertube-plugin-test-external-auth-one',
282 settings: { disableKefka: true } 273 settings: { disableKefka: true }
283 }) 274 })
@@ -309,11 +300,7 @@ describe('Test external auth plugins', function () {
309 }) 300 })
310 301
311 it('Should uninstall the plugin one and do not login Cyan', async function () { 302 it('Should uninstall the plugin one and do not login Cyan', async function () {
312 await uninstallPlugin({ 303 await server.pluginsCommand.uninstall({ npmName: 'peertube-plugin-test-external-auth-one' })
313 url: server.url,
314 accessToken: server.accessToken,
315 npmName: 'peertube-plugin-test-external-auth-one'
316 })
317 304
318 await loginExternal({ 305 await loginExternal({
319 server, 306 server,