X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Ftests%2Fexternal-plugins%2Fauth-ldap.ts;h=ef624152e6160bdf343f65f34c59c51b8a76a52d;hb=89d241a79c262b9775c233b73cff080043ebb5e6;hp=8153e2b8117fd04335193aba2478a71d1efe3a08;hpb=41d1d075011174e73dccb74006181a92a618d7b4;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/tests/external-plugins/auth-ldap.ts b/server/tests/external-plugins/auth-ldap.ts index 8153e2b81..ef624152e 100644 --- a/server/tests/external-plugins/auth-ldap.ts +++ b/server/tests/external-plugins/auth-ldap.ts @@ -3,9 +3,7 @@ import 'mocha' import { expect } from 'chai' import { HttpStatusCode } from '@shared/core-utils' -import { User } from '@shared/models/users/user.model' -import { blockUser, getMyUserInformation, setAccessTokensToServers, unblockUser, uploadVideo } from '../../../shared/extra-utils' -import { cleanupTests, flushAndRunServer, ServerInfo } from '../../../shared/extra-utils/server/servers' +import { cleanupTests, flushAndRunServer, ServerInfo, setAccessTokensToServers } from '@shared/extra-utils' describe('Official plugin auth-ldap', function () { let server: ServerInfo @@ -18,15 +16,15 @@ describe('Official plugin auth-ldap', function () { server = await flushAndRunServer(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', @@ -40,11 +38,11 @@ describe('Official plugin auth-ldap', 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 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', @@ -58,22 +56,20 @@ describe('Official plugin auth-ldap', function () { } }) - 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 res = await getMyUserInformation(server.url, accessToken) - const body: User = res.body - + const body = await server.users.getMyInfo({ token: accessToken }) expect(body.username).to.equal('fry') expect(body.email).to.equal('fry@planetexpress.com') @@ -81,28 +77,28 @@ 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 blockUser(server.url, userId, server.accessToken) + 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 unblockUser(server.url, userId, server.accessToken) + 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 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 })