aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/external-plugins/auth-ldap.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/tests/external-plugins/auth-ldap.ts')
-rw-r--r--server/tests/external-plugins/auth-ldap.ts100
1 files changed, 100 insertions, 0 deletions
diff --git a/server/tests/external-plugins/auth-ldap.ts b/server/tests/external-plugins/auth-ldap.ts
new file mode 100644
index 000000000..7aee986c7
--- /dev/null
+++ b/server/tests/external-plugins/auth-ldap.ts
@@ -0,0 +1,100 @@
1/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
2
3import 'mocha'
4import { getMyUserInformation, installPlugin, setAccessTokensToServers, updatePluginSettings, userLogin, uploadVideo, uninstallPlugin } from '../../../shared/extra-utils'
5import { cleanupTests, flushAndRunServer, ServerInfo } from '../../../shared/extra-utils/server/servers'
6import { User } from '@shared/models/users/user.model'
7import { expect } from 'chai'
8
9describe('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})