]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/external-plugins/auth-ldap.ts
Merge branch 'release/3.2.0' into develop
[github/Chocobozzz/PeerTube.git] / server / tests / external-plugins / auth-ldap.ts
index 7aee986c78e52e41b9f1ae7cf137c9a7ea4f7906..e4eae7e8c047b858154fcb598ada2838913609ed 100644 (file)
@@ -1,14 +1,25 @@
 /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
 
 import 'mocha'
-import { getMyUserInformation, installPlugin, setAccessTokensToServers, updatePluginSettings, userLogin, uploadVideo, uninstallPlugin } from '../../../shared/extra-utils'
-import { cleanupTests, flushAndRunServer, ServerInfo } from '../../../shared/extra-utils/server/servers'
-import { User } from '@shared/models/users/user.model'
 import { expect } from 'chai'
+import { User } from '@shared/models/users/user.model'
+import {
+  blockUser,
+  getMyUserInformation,
+  installPlugin,
+  setAccessTokensToServers,
+  unblockUser,
+  uninstallPlugin,
+  updatePluginSettings,
+  uploadVideo,
+  userLogin
+} from '../../../shared/extra-utils'
+import { cleanupTests, flushAndRunServer, ServerInfo } from '../../../shared/extra-utils/server/servers'
 
 describe('Official plugin auth-ldap', function () {
   let server: ServerInfo
   let accessToken: string
+  let userId: number
 
   before(async function () {
     this.timeout(30000)
@@ -39,7 +50,7 @@ describe('Official plugin auth-ldap', function () {
         'mail-property': 'mail',
         'search-base': 'ou=people,dc=planetexpress,dc=com',
         'search-filter': '(|(mail={{username}})(uid={{username}}))',
-        'url': 'ldap://ldap:390',
+        'url': 'ldap://localhost:390',
         'username-property': 'uid'
       }
     })
@@ -59,7 +70,7 @@ describe('Official plugin auth-ldap', function () {
         'mail-property': 'mail',
         'search-base': 'ou=people,dc=planetexpress,dc=com',
         'search-filter': '(|(mail={{username}})(uid={{username}}))',
-        'url': 'ldap://ldap:389',
+        'url': 'ldap://localhost:10389',
         'username-property': 'uid'
       }
     })
@@ -82,12 +93,26 @@ describe('Official plugin auth-ldap', function () {
 
     expect(body.username).to.equal('fry')
     expect(body.email).to.equal('fry@planetexpress.com')
+
+    userId = body.id
   })
 
   it('Should upload a video', async function () {
     await uploadVideo(server.url, accessToken, { name: 'my super video' })
   })
 
+  it('Should not be able to login if the user is banned', async function () {
+    await blockUser(server.url, userId, server.accessToken)
+
+    await userLogin(server, { username: 'fry@planetexpress.com', password: 'fry' }, 400)
+  })
+
+  it('Should be able to login if the user is unbanned', async function () {
+    await unblockUser(server.url, userId, server.accessToken)
+
+    await userLogin(server, { username: 'fry@planetexpress.com', password: 'fry' })
+  })
+
   it('Should not login if the plugin is uninstalled', async function () {
     await uninstallPlugin({ url: server.url, accessToken: server.accessToken, npmName: 'peertube-plugin-auth-ldap' })