aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/external-plugins/auth-ldap.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-13 11:05:15 +0200
committerChocobozzz <me@florianbigard.com>2021-07-20 15:27:18 +0200
commit41d1d075011174e73dccb74006181a92a618d7b4 (patch)
tree4dc1af0e266977f062cf9716837d04de1cdd628d /server/tests/external-plugins/auth-ldap.ts
parent6c5065a011b099618681a37bd77eaa7bd3db752e (diff)
downloadPeerTube-41d1d075011174e73dccb74006181a92a618d7b4.tar.gz
PeerTube-41d1d075011174e73dccb74006181a92a618d7b4.tar.zst
PeerTube-41d1d075011174e73dccb74006181a92a618d7b4.zip
Introduce login command
Diffstat (limited to 'server/tests/external-plugins/auth-ldap.ts')
-rw-r--r--server/tests/external-plugins/auth-ldap.ts27
1 files changed, 17 insertions, 10 deletions
diff --git a/server/tests/external-plugins/auth-ldap.ts b/server/tests/external-plugins/auth-ldap.ts
index 0d4edbee0..8153e2b81 100644
--- a/server/tests/external-plugins/auth-ldap.ts
+++ b/server/tests/external-plugins/auth-ldap.ts
@@ -2,8 +2,9 @@
2 2
3import 'mocha' 3import 'mocha'
4import { expect } from 'chai' 4import { expect } from 'chai'
5import { HttpStatusCode } from '@shared/core-utils'
5import { User } from '@shared/models/users/user.model' 6import { User } from '@shared/models/users/user.model'
6import { blockUser, getMyUserInformation, setAccessTokensToServers, unblockUser, uploadVideo, userLogin } from '../../../shared/extra-utils' 7import { blockUser, getMyUserInformation, setAccessTokensToServers, unblockUser, uploadVideo } from '../../../shared/extra-utils'
7import { cleanupTests, flushAndRunServer, ServerInfo } from '../../../shared/extra-utils/server/servers' 8import { cleanupTests, flushAndRunServer, ServerInfo } from '../../../shared/extra-utils/server/servers'
8 9
9describe('Official plugin auth-ldap', function () { 10describe('Official plugin auth-ldap', function () {
@@ -21,7 +22,7 @@ describe('Official plugin auth-ldap', function () {
21 }) 22 })
22 23
23 it('Should not login with without LDAP settings', async function () { 24 it('Should not login with without LDAP settings', async function () {
24 await userLogin(server, { username: 'fry', password: 'fry' }, 400) 25 await server.loginCommand.login({ user: { username: 'fry', password: 'fry' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
25 }) 26 })
26 27
27 it('Should not login with bad LDAP settings', async function () { 28 it('Should not login with bad LDAP settings', async function () {
@@ -39,7 +40,7 @@ describe('Official plugin auth-ldap', function () {
39 } 40 }
40 }) 41 })
41 42
42 await userLogin(server, { username: 'fry', password: 'fry' }, 400) 43 await server.loginCommand.login({ user: { username: 'fry', password: 'fry' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
43 }) 44 })
44 45
45 it('Should not login with good LDAP settings but wrong username/password', async function () { 46 it('Should not login with good LDAP settings but wrong username/password', async function () {
@@ -57,16 +58,16 @@ describe('Official plugin auth-ldap', function () {
57 } 58 }
58 }) 59 })
59 60
60 await userLogin(server, { username: 'fry', password: 'bad password' }, 400) 61 await server.loginCommand.login({ user: { username: 'fry', password: 'bad password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
61 await userLogin(server, { username: 'fryr', password: 'fry' }, 400) 62 await server.loginCommand.login({ user: { username: 'fryr', password: 'fry' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
62 }) 63 })
63 64
64 it('Should login with the appropriate username/password', async function () { 65 it('Should login with the appropriate username/password', async function () {
65 accessToken = await userLogin(server, { username: 'fry', password: 'fry' }) 66 accessToken = await server.loginCommand.getAccessToken({ username: 'fry', password: 'fry' })
66 }) 67 })
67 68
68 it('Should login with the appropriate email/password', async function () { 69 it('Should login with the appropriate email/password', async function () {
69 accessToken = await userLogin(server, { username: 'fry@planetexpress.com', password: 'fry' }) 70 accessToken = await server.loginCommand.getAccessToken({ username: 'fry@planetexpress.com', password: 'fry' })
70 }) 71 })
71 72
72 it('Should login get my profile', async function () { 73 it('Should login get my profile', async function () {
@@ -86,19 +87,25 @@ describe('Official plugin auth-ldap', function () {
86 it('Should not be able to login if the user is banned', async function () { 87 it('Should not be able to login if the user is banned', async function () {
87 await blockUser(server.url, userId, server.accessToken) 88 await blockUser(server.url, userId, server.accessToken)
88 89
89 await userLogin(server, { username: 'fry@planetexpress.com', password: 'fry' }, 400) 90 await server.loginCommand.login({
91 user: { username: 'fry@planetexpress.com', password: 'fry' },
92 expectedStatus: HttpStatusCode.BAD_REQUEST_400
93 })
90 }) 94 })
91 95
92 it('Should be able to login if the user is unbanned', async function () { 96 it('Should be able to login if the user is unbanned', async function () {
93 await unblockUser(server.url, userId, server.accessToken) 97 await unblockUser(server.url, userId, server.accessToken)
94 98
95 await userLogin(server, { username: 'fry@planetexpress.com', password: 'fry' }) 99 await server.loginCommand.login({ user: { username: 'fry@planetexpress.com', password: 'fry' } })
96 }) 100 })
97 101
98 it('Should not login if the plugin is uninstalled', async function () { 102 it('Should not login if the plugin is uninstalled', async function () {
99 await server.pluginsCommand.uninstall({ npmName: 'peertube-plugin-auth-ldap' }) 103 await server.pluginsCommand.uninstall({ npmName: 'peertube-plugin-auth-ldap' })
100 104
101 await userLogin(server, { username: 'fry@planetexpress.com', password: 'fry' }, 400) 105 await server.loginCommand.login({
106 user: { username: 'fry@planetexpress.com', password: 'fry' },
107 expectedStatus: HttpStatusCode.BAD_REQUEST_400
108 })
102 }) 109 })
103 110
104 after(async function () { 111 after(async function () {