]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/plugins/id-and-pass-auth.ts
Allow to specify transcoding and import jobs concurrency
[github/Chocobozzz/PeerTube.git] / server / tests / plugins / id-and-pass-auth.ts
index 6c10730aafc8f1a628f20704422492be3ac45a4d..cbba638c2bab3788fbe39509fe9f8f21155cd916 100644 (file)
@@ -12,7 +12,7 @@ import {
   updateMyUser,
   userLogin,
   wait,
-  login, refreshToken, getConfig
+  login, refreshToken, getConfig, updatePluginSettings, getUsersList
 } from '../../../shared/extra-utils'
 import { User, UserRole, ServerConfig } from '@shared/models'
 import { expect } from 'chai'
@@ -179,6 +179,30 @@ describe('Test id and pass auth plugins', function () {
     await waitUntilLog(server, 'valid email')
   })
 
+  it('Should unregister spyro-auth and do not login existing Spyro', async function () {
+    await updatePluginSettings({
+      url: server.url,
+      accessToken: server.accessToken,
+      npmName: 'peertube-plugin-test-id-pass-auth-one',
+      settings: { disableSpyro: true }
+    })
+
+    await userLogin(server, { username: 'spyro', password: 'spyro password' }, 400)
+    await userLogin(server, { username: 'spyro', password: 'fake' }, 400)
+  })
+
+  it('Should have disabled this auth', async function () {
+    const res = await getConfig(server.url)
+
+    const config: ServerConfig = res.body
+
+    const auths = config.plugin.registeredIdAndPassAuths
+    expect(auths).to.have.lengthOf(7)
+
+    const spyroAuth = auths.find(a => a.authName === 'spyro-auth')
+    expect(spyroAuth).to.not.exist
+  })
+
   it('Should uninstall the plugin one and do not login existing Crash', async function () {
     await uninstallPlugin({
       url: server.url,
@@ -201,6 +225,20 @@ describe('Test id and pass auth plugins', function () {
     expect(crashAuth).to.not.exist
   })
 
+  it('Should display plugin auth information in users list', async function () {
+    const res = await getUsersList(server.url, server.accessToken)
+
+    const users: User[] = res.body.data
+
+    const root = users.find(u => u.username === 'root')
+    const crash = users.find(u => u.username === 'crash')
+    const laguna = users.find(u => u.username === 'laguna')
+
+    expect(root.pluginAuth).to.be.null
+    expect(crash.pluginAuth).to.equal('peertube-plugin-test-id-pass-auth-one')
+    expect(laguna.pluginAuth).to.equal('peertube-plugin-test-id-pass-auth-two')
+  })
+
   after(async function () {
     await cleanupTests([ server ])
   })