diff options
Diffstat (limited to 'packages/tests/fixtures/peertube-plugin-test-id-pass-auth-one')
-rw-r--r-- | packages/tests/fixtures/peertube-plugin-test-id-pass-auth-one/main.js | 69 | ||||
-rw-r--r-- | packages/tests/fixtures/peertube-plugin-test-id-pass-auth-one/package.json | 20 |
2 files changed, 89 insertions, 0 deletions
diff --git a/packages/tests/fixtures/peertube-plugin-test-id-pass-auth-one/main.js b/packages/tests/fixtures/peertube-plugin-test-id-pass-auth-one/main.js new file mode 100644 index 000000000..f58faa847 --- /dev/null +++ b/packages/tests/fixtures/peertube-plugin-test-id-pass-auth-one/main.js | |||
@@ -0,0 +1,69 @@ | |||
1 | async function register ({ | ||
2 | registerIdAndPassAuth, | ||
3 | peertubeHelpers, | ||
4 | settingsManager, | ||
5 | unregisterIdAndPassAuth | ||
6 | }) { | ||
7 | registerIdAndPassAuth({ | ||
8 | authName: 'spyro-auth', | ||
9 | |||
10 | onLogout: () => { | ||
11 | peertubeHelpers.logger.info('On logout for auth 1 - 1') | ||
12 | }, | ||
13 | |||
14 | getWeight: () => 15, | ||
15 | |||
16 | login (body) { | ||
17 | if (body.id === 'spyro' && body.password === 'spyro password') { | ||
18 | return Promise.resolve({ | ||
19 | username: 'spyro', | ||
20 | email: 'spyro@example.com', | ||
21 | role: 2, | ||
22 | displayName: 'Spyro the Dragon' | ||
23 | }) | ||
24 | } | ||
25 | |||
26 | return null | ||
27 | } | ||
28 | }) | ||
29 | |||
30 | registerIdAndPassAuth({ | ||
31 | authName: 'crash-auth', | ||
32 | |||
33 | onLogout: () => { | ||
34 | peertubeHelpers.logger.info('On logout for auth 1 - 2') | ||
35 | }, | ||
36 | |||
37 | getWeight: () => 50, | ||
38 | |||
39 | login (body) { | ||
40 | if (body.id === 'crash' && body.password === 'crash password') { | ||
41 | return Promise.resolve({ | ||
42 | username: 'crash', | ||
43 | email: 'crash@example.com', | ||
44 | role: 1, | ||
45 | displayName: 'Crash Bandicoot' | ||
46 | }) | ||
47 | } | ||
48 | |||
49 | return null | ||
50 | } | ||
51 | }) | ||
52 | |||
53 | settingsManager.onSettingsChange(settings => { | ||
54 | if (settings.disableSpyro) { | ||
55 | unregisterIdAndPassAuth('spyro-auth') | ||
56 | } | ||
57 | }) | ||
58 | } | ||
59 | |||
60 | async function unregister () { | ||
61 | return | ||
62 | } | ||
63 | |||
64 | module.exports = { | ||
65 | register, | ||
66 | unregister | ||
67 | } | ||
68 | |||
69 | // ########################################################################### | ||
diff --git a/packages/tests/fixtures/peertube-plugin-test-id-pass-auth-one/package.json b/packages/tests/fixtures/peertube-plugin-test-id-pass-auth-one/package.json new file mode 100644 index 000000000..f8ad18a90 --- /dev/null +++ b/packages/tests/fixtures/peertube-plugin-test-id-pass-auth-one/package.json | |||
@@ -0,0 +1,20 @@ | |||
1 | { | ||
2 | "name": "peertube-plugin-test-id-pass-auth-one", | ||
3 | "version": "0.0.1", | ||
4 | "description": "Id and pass auth one", | ||
5 | "engine": { | ||
6 | "peertube": ">=1.3.0" | ||
7 | }, | ||
8 | "keywords": [ | ||
9 | "peertube", | ||
10 | "plugin" | ||
11 | ], | ||
12 | "homepage": "https://github.com/Chocobozzz/PeerTube", | ||
13 | "author": "Chocobozzz", | ||
14 | "bugs": "https://github.com/Chocobozzz/PeerTube/issues", | ||
15 | "library": "./main.js", | ||
16 | "staticDirs": {}, | ||
17 | "css": [], | ||
18 | "clientScripts": [], | ||
19 | "translations": {} | ||
20 | } | ||