X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fexternal-plugins%2Fauth-ldap.ts;h=d51d337be77cad6bde42cd86cefcdccda645ecf8;hb=HEAD;hp=d99b3badc9067922761d8e3b72d5876be14f860c;hpb=7926c5f9b3ffcabb1ffb0dcfa5e48b8e0b88fbc0;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/external-plugins/auth-ldap.ts b/server/tests/external-plugins/auth-ldap.ts index d99b3badc..d51d337be 100644 --- a/server/tests/external-plugins/auth-ldap.ts +++ b/server/tests/external-plugins/auth-ldap.ts @@ -1,30 +1,29 @@ /* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */ -import 'mocha' import { expect } from 'chai' -import { HttpStatusCode } from '@shared/core-utils' -import { cleanupTests, flushAndRunServer, ServerInfo, setAccessTokensToServers, uploadVideo } from '@shared/extra-utils' +import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '@shared/server-commands' +import { HttpStatusCode } from '@shared/models' describe('Official plugin auth-ldap', function () { - let server: ServerInfo + let server: PeerTubeServer let accessToken: string let userId: number before(async function () { this.timeout(30000) - server = await flushAndRunServer(1) + server = await createSingleServer(1) await setAccessTokensToServers([ server ]) - await server.pluginsCommand.install({ npmName: 'peertube-plugin-auth-ldap' }) + await server.plugins.install({ npmName: 'peertube-plugin-auth-ldap' }) }) it('Should not login with without LDAP settings', async function () { - await server.loginCommand.login({ user: { username: 'fry', password: 'fry' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) + await server.login.login({ user: { username: 'fry', password: 'fry' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) }) it('Should not login with bad LDAP settings', async function () { - await server.pluginsCommand.updateSettings({ + await server.plugins.updateSettings({ npmName: 'peertube-plugin-auth-ldap', settings: { 'bind-credentials': 'GoodNewsEveryone', @@ -33,16 +32,16 @@ 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://localhost:390', + 'url': 'ldap://127.0.0.1:390', 'username-property': 'uid' } }) - await server.loginCommand.login({ user: { username: 'fry', password: 'fry' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) + await server.login.login({ user: { username: 'fry', password: 'fry' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) }) it('Should not login with good LDAP settings but wrong username/password', async function () { - await server.pluginsCommand.updateSettings({ + await server.plugins.updateSettings({ npmName: 'peertube-plugin-auth-ldap', settings: { 'bind-credentials': 'GoodNewsEveryone', @@ -51,25 +50,25 @@ 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://localhost:10389', + 'url': 'ldap://127.0.0.1:10389', 'username-property': 'uid' } }) - await server.loginCommand.login({ user: { username: 'fry', password: 'bad password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) - await server.loginCommand.login({ user: { username: 'fryr', password: 'fry' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) + await server.login.login({ user: { username: 'fry', password: 'bad password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) + await server.login.login({ user: { username: 'fryr', password: 'fry' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) }) it('Should login with the appropriate username/password', async function () { - accessToken = await server.loginCommand.getAccessToken({ username: 'fry', password: 'fry' }) + accessToken = await server.login.getAccessToken({ username: 'fry', password: 'fry' }) }) it('Should login with the appropriate email/password', async function () { - accessToken = await server.loginCommand.getAccessToken({ username: 'fry@planetexpress.com', password: 'fry' }) + accessToken = await server.login.getAccessToken({ username: 'fry@planetexpress.com', password: 'fry' }) }) it('Should login get my profile', async function () { - const body = await server.usersCommand.getMyInfo({ token: accessToken }) + const body = await server.users.getMyInfo({ token: accessToken }) expect(body.username).to.equal('fry') expect(body.email).to.equal('fry@planetexpress.com') @@ -77,28 +76,36 @@ describe('Official plugin auth-ldap', function () { }) it('Should upload a video', async function () { - await uploadVideo(server.url, accessToken, { name: 'my super video' }) + await server.videos.upload({ token: accessToken, attributes: { name: 'my super video' } }) }) it('Should not be able to login if the user is banned', async function () { - await server.usersCommand.banUser({ userId }) + await server.users.banUser({ userId }) - await server.loginCommand.login({ + await server.login.login({ user: { username: 'fry@planetexpress.com', password: 'fry' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) }) it('Should be able to login if the user is unbanned', async function () { - await server.usersCommand.unbanUser({ userId }) + await server.users.unbanUser({ userId }) - await server.loginCommand.login({ user: { username: 'fry@planetexpress.com', password: 'fry' } }) + await server.login.login({ user: { username: 'fry@planetexpress.com', password: 'fry' } }) + }) + + it('Should not be able to ask password reset', async function () { + await server.users.askResetPassword({ email: 'fry@planetexpress.com', expectedStatus: HttpStatusCode.CONFLICT_409 }) + }) + + it('Should not be able to ask email verification', async function () { + await server.users.askSendVerifyEmail({ email: 'fry@planetexpress.com', expectedStatus: HttpStatusCode.CONFLICT_409 }) }) it('Should not login if the plugin is uninstalled', async function () { - await server.pluginsCommand.uninstall({ npmName: 'peertube-plugin-auth-ldap' }) + await server.plugins.uninstall({ npmName: 'peertube-plugin-auth-ldap' }) - await server.loginCommand.login({ + await server.login.login({ user: { username: 'fry@planetexpress.com', password: 'fry' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })