mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-02-25 18:55:32 -06:00
Add ability to unregister plugin auths
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
async function register ({
|
||||
registerExternalAuth,
|
||||
peertubeHelpers
|
||||
peertubeHelpers,
|
||||
settingsManager,
|
||||
unregisterExternalAuth
|
||||
}) {
|
||||
{
|
||||
const result = registerExternalAuth({
|
||||
@@ -53,6 +55,12 @@ async function register ({
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
settingsManager.onSettingsChange(settings => {
|
||||
if (settings.disableKefka) {
|
||||
unregisterExternalAuth('external-auth-2')
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async function unregister () {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
async function register ({
|
||||
registerIdAndPassAuth,
|
||||
peertubeHelpers
|
||||
peertubeHelpers,
|
||||
settingsManager,
|
||||
unregisterIdAndPassAuth
|
||||
}) {
|
||||
registerIdAndPassAuth({
|
||||
authName: 'spyro-auth',
|
||||
@@ -47,6 +49,12 @@ async function register ({
|
||||
return null
|
||||
}
|
||||
})
|
||||
|
||||
settingsManager.onSettingsChange(settings => {
|
||||
if (settings.disableSpyro) {
|
||||
unregisterIdAndPassAuth('spyro-auth')
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async function unregister () {
|
||||
|
||||
@@ -16,7 +16,9 @@ import {
|
||||
setAccessTokensToServers,
|
||||
uninstallPlugin,
|
||||
updateMyUser,
|
||||
wait
|
||||
wait,
|
||||
userLogin,
|
||||
updatePluginSettings
|
||||
} from '../../../shared/extra-utils'
|
||||
import { cleanupTests, flushAndRunServer, ServerInfo, waitUntilLog } from '../../../shared/extra-utils/server/servers'
|
||||
|
||||
@@ -258,6 +260,40 @@ describe('Test external auth plugins', function () {
|
||||
await getMyUserInformation(server.url, kefkaAccessToken, 401)
|
||||
})
|
||||
|
||||
it('Should unregister external-auth-2 and do not login existing Kefka', async function () {
|
||||
await updatePluginSettings({
|
||||
url: server.url,
|
||||
accessToken: server.accessToken,
|
||||
npmName: 'peertube-plugin-test-external-auth-one',
|
||||
settings: { disableKefka: true }
|
||||
})
|
||||
|
||||
await userLogin(server, { username: 'kefka', password: 'fake' }, 400)
|
||||
|
||||
await loginExternal({
|
||||
server,
|
||||
npmName: 'test-external-auth-one',
|
||||
authName: 'external-auth-2',
|
||||
query: {
|
||||
username: 'kefka'
|
||||
},
|
||||
username: 'kefka',
|
||||
statusCodeExpected: 404
|
||||
})
|
||||
})
|
||||
|
||||
it('Should have disabled this auth', async function () {
|
||||
const res = await getConfig(server.url)
|
||||
|
||||
const config: ServerConfig = res.body
|
||||
|
||||
const auths = config.plugin.registeredExternalAuths
|
||||
expect(auths).to.have.lengthOf(2)
|
||||
|
||||
const auth1 = auths.find(a => a.authName === 'external-auth-2')
|
||||
expect(auth1).to.not.exist
|
||||
})
|
||||
|
||||
it('Should uninstall the plugin one and do not login Cyan', async function () {
|
||||
await uninstallPlugin({
|
||||
url: server.url,
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
updateMyUser,
|
||||
userLogin,
|
||||
wait,
|
||||
login, refreshToken, getConfig
|
||||
login, refreshToken, getConfig, updatePluginSettings
|
||||
} 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,
|
||||
|
||||
Reference in New Issue
Block a user