]>
Commit | Line | Data |
---|---|---|
829b794a C |
1 | /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ |
2 | ||
3 | import 'mocha' | |
4 | import { getMyUserInformation, installPlugin, setAccessTokensToServers, updatePluginSettings, userLogin, uploadVideo, uninstallPlugin } from '../../../shared/extra-utils' | |
5 | import { cleanupTests, flushAndRunServer, ServerInfo } from '../../../shared/extra-utils/server/servers' | |
6 | import { User } from '@shared/models/users/user.model' | |
7 | import { expect } from 'chai' | |
8 | ||
9 | describe('Official plugin auth-ldap', function () { | |
10 | let server: ServerInfo | |
11 | let accessToken: string | |
12 | ||
13 | before(async function () { | |
14 | this.timeout(30000) | |
15 | ||
16 | server = await flushAndRunServer(1) | |
17 | await setAccessTokensToServers([ server ]) | |
18 | ||
19 | await installPlugin({ | |
20 | url: server.url, | |
21 | accessToken: server.accessToken, | |
22 | npmName: 'peertube-plugin-auth-ldap' | |
23 | }) | |
24 | }) | |
25 | ||
26 | it('Should not login with without LDAP settings', async function () { | |
27 | await userLogin(server, { username: 'fry', password: 'fry' }, 400) | |
28 | }) | |
29 | ||
30 | it('Should not login with bad LDAP settings', async function () { | |
31 | await updatePluginSettings({ | |
32 | url: server.url, | |
33 | accessToken: server.accessToken, | |
34 | npmName: 'peertube-plugin-auth-ldap', | |
35 | settings: { | |
36 | 'bind-credentials': 'GoodNewsEveryone', | |
37 | 'bind-dn': 'cn=admin,dc=planetexpress,dc=com', | |
38 | 'insecure-tls': false, | |
39 | 'mail-property': 'mail', | |
40 | 'search-base': 'ou=people,dc=planetexpress,dc=com', | |
41 | 'search-filter': '(|(mail={{username}})(uid={{username}}))', | |
42 | 'url': 'ldap://ldap:390', | |
43 | 'username-property': 'uid' | |
44 | } | |
45 | }) | |
46 | ||
47 | await userLogin(server, { username: 'fry', password: 'fry' }, 400) | |
48 | }) | |
49 | ||
50 | it('Should not login with good LDAP settings but wrong username/password', async function () { | |
51 | await updatePluginSettings({ | |
52 | url: server.url, | |
53 | accessToken: server.accessToken, | |
54 | npmName: 'peertube-plugin-auth-ldap', | |
55 | settings: { | |
56 | 'bind-credentials': 'GoodNewsEveryone', | |
57 | 'bind-dn': 'cn=admin,dc=planetexpress,dc=com', | |
58 | 'insecure-tls': false, | |
59 | 'mail-property': 'mail', | |
60 | 'search-base': 'ou=people,dc=planetexpress,dc=com', | |
61 | 'search-filter': '(|(mail={{username}})(uid={{username}}))', | |
62 | 'url': 'ldap://ldap:389', | |
63 | 'username-property': 'uid' | |
64 | } | |
65 | }) | |
66 | ||
67 | await userLogin(server, { username: 'fry', password: 'bad password' }, 400) | |
68 | await userLogin(server, { username: 'fryr', password: 'fry' }, 400) | |
69 | }) | |
70 | ||
71 | it('Should login with the appropriate username/password', async function () { | |
72 | accessToken = await userLogin(server, { username: 'fry', password: 'fry' }) | |
73 | }) | |
74 | ||
75 | it('Should login with the appropriate email/password', async function () { | |
76 | accessToken = await userLogin(server, { username: 'fry@planetexpress.com', password: 'fry' }) | |
77 | }) | |
78 | ||
79 | it('Should login get my profile', async function () { | |
80 | const res = await getMyUserInformation(server.url, accessToken) | |
81 | const body: User = res.body | |
82 | ||
83 | expect(body.username).to.equal('fry') | |
84 | expect(body.email).to.equal('fry@planetexpress.com') | |
85 | }) | |
86 | ||
87 | it('Should upload a video', async function () { | |
88 | await uploadVideo(server.url, accessToken, { name: 'my super video' }) | |
89 | }) | |
90 | ||
91 | it('Should not login if the plugin is uninstalled', async function () { | |
92 | await uninstallPlugin({ url: server.url, accessToken: server.accessToken, npmName: 'peertube-plugin-auth-ldap' }) | |
93 | ||
94 | await userLogin(server, { username: 'fry@planetexpress.com', password: 'fry' }, 400) | |
95 | }) | |
96 | ||
97 | after(async function () { | |
98 | await cleanupTests([ server ]) | |
99 | }) | |
100 | }) |