mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-02-25 18:55:32 -06:00
Begin auth plugin support
This commit is contained in:
@@ -40,7 +40,7 @@ import {
|
||||
getVideoAbusesList, updateCustomSubConfig, getCustomConfig, waitJobs
|
||||
} from '../../../../shared/extra-utils'
|
||||
import { follow } from '../../../../shared/extra-utils/server/follows'
|
||||
import { setAccessTokensToServers } from '../../../../shared/extra-utils/users/login'
|
||||
import { setAccessTokensToServers, logout } from '../../../../shared/extra-utils/users/login'
|
||||
import { getMyVideos } from '../../../../shared/extra-utils/videos/videos'
|
||||
import { UserAdminFlag } from '../../../../shared/models/users/user-flag.model'
|
||||
import { CustomConfig } from '@shared/models/server'
|
||||
@@ -205,11 +205,17 @@ describe('Test users', function () {
|
||||
})
|
||||
|
||||
describe('Logout', function () {
|
||||
it('Should logout (revoke token)')
|
||||
it('Should logout (revoke token)', async function () {
|
||||
await logout(server.url, server.accessToken)
|
||||
})
|
||||
|
||||
it('Should not be able to get the user information')
|
||||
it('Should not be able to get the user information', async function () {
|
||||
await getMyUserInformation(server.url, server.accessToken, 401)
|
||||
})
|
||||
|
||||
it('Should not be able to upload a video')
|
||||
it('Should not be able to upload a video', async function () {
|
||||
await uploadVideo(server.url, server.accessToken, { name: 'video' }, 401)
|
||||
})
|
||||
|
||||
it('Should not be able to remove a video')
|
||||
|
||||
|
||||
61
server/tests/fixtures/peertube-plugin-test-id-pass-auth-one/main.js
vendored
Normal file
61
server/tests/fixtures/peertube-plugin-test-id-pass-auth-one/main.js
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
async function register ({
|
||||
registerIdAndPassAuth,
|
||||
peertubeHelpers
|
||||
}) {
|
||||
registerIdAndPassAuth({
|
||||
type: 'id-and-pass',
|
||||
|
||||
onLogout: () => {
|
||||
peertubeHelpers.logger.info('On logout for auth 1 - 1')
|
||||
},
|
||||
|
||||
getWeight: () => 15,
|
||||
|
||||
login (body) {
|
||||
if (body.id === 'spyro' && body.password === 'spyro password') {
|
||||
return Promise.resolve({
|
||||
username: 'spyro',
|
||||
email: 'spyro@example.com',
|
||||
role: 0,
|
||||
displayName: 'Spyro the Dragon'
|
||||
})
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
})
|
||||
|
||||
registerIdAndPassAuth({
|
||||
type: 'id-and-pass',
|
||||
|
||||
onLogout: () => {
|
||||
peertubeHelpers.logger.info('On logout for auth 1 - 2')
|
||||
},
|
||||
|
||||
getWeight: () => 50,
|
||||
|
||||
login (body) {
|
||||
if (body.id === 'crash' && body.password === 'crash password') {
|
||||
return Promise.resolve({
|
||||
username: 'crash',
|
||||
email: 'crash@example.com',
|
||||
role: 2,
|
||||
displayName: 'Crash Bandicoot'
|
||||
})
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async function unregister () {
|
||||
return
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
register,
|
||||
unregister
|
||||
}
|
||||
|
||||
// ###########################################################################
|
||||
20
server/tests/fixtures/peertube-plugin-test-id-pass-auth-one/package.json
vendored
Normal file
20
server/tests/fixtures/peertube-plugin-test-id-pass-auth-one/package.json
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "peertube-plugin-test-id-pass-auth-one",
|
||||
"version": "0.0.1",
|
||||
"description": "Id and pass auth one",
|
||||
"engine": {
|
||||
"peertube": ">=1.3.0"
|
||||
},
|
||||
"keywords": [
|
||||
"peertube",
|
||||
"plugin"
|
||||
],
|
||||
"homepage": "https://github.com/Chocobozzz/PeerTube",
|
||||
"author": "Chocobozzz",
|
||||
"bugs": "https://github.com/Chocobozzz/PeerTube/issues",
|
||||
"library": "./main.js",
|
||||
"staticDirs": {},
|
||||
"css": [],
|
||||
"clientScripts": [],
|
||||
"translations": {}
|
||||
}
|
||||
37
server/tests/fixtures/peertube-plugin-test-id-pass-auth-three/main.js
vendored
Normal file
37
server/tests/fixtures/peertube-plugin-test-id-pass-auth-three/main.js
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
async function register ({
|
||||
registerIdAndPassAuth,
|
||||
peertubeHelpers
|
||||
}) {
|
||||
registerIdAndPassAuth({
|
||||
type: 'id-and-pass',
|
||||
|
||||
onLogout: () => {
|
||||
peertubeHelpers.logger.info('On logout for auth 3 - 1')
|
||||
},
|
||||
|
||||
getWeight: () => 5,
|
||||
|
||||
login (body) {
|
||||
if (body.id === 'laguna' && body.password === 'laguna password') {
|
||||
return Promise.resolve({
|
||||
username: 'laguna',
|
||||
email: 'laguna@example.com',
|
||||
displayName: 'Laguna Loire'
|
||||
})
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async function unregister () {
|
||||
return
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
register,
|
||||
unregister
|
||||
}
|
||||
|
||||
// ###########################################################################
|
||||
20
server/tests/fixtures/peertube-plugin-test-id-pass-auth-three/package.json
vendored
Normal file
20
server/tests/fixtures/peertube-plugin-test-id-pass-auth-three/package.json
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "peertube-plugin-test-id-pass-auth-three",
|
||||
"version": "0.0.1",
|
||||
"description": "Id and pass auth three",
|
||||
"engine": {
|
||||
"peertube": ">=1.3.0"
|
||||
},
|
||||
"keywords": [
|
||||
"peertube",
|
||||
"plugin"
|
||||
],
|
||||
"homepage": "https://github.com/Chocobozzz/PeerTube",
|
||||
"author": "Chocobozzz",
|
||||
"bugs": "https://github.com/Chocobozzz/PeerTube/issues",
|
||||
"library": "./main.js",
|
||||
"staticDirs": {},
|
||||
"css": [],
|
||||
"clientScripts": [],
|
||||
"translations": {}
|
||||
}
|
||||
36
server/tests/fixtures/peertube-plugin-test-id-pass-auth-two/main.js
vendored
Normal file
36
server/tests/fixtures/peertube-plugin-test-id-pass-auth-two/main.js
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
async function register ({
|
||||
registerIdAndPassAuth,
|
||||
peertubeHelpers
|
||||
}) {
|
||||
registerIdAndPassAuth({
|
||||
type: 'id-and-pass',
|
||||
|
||||
onLogout: () => {
|
||||
peertubeHelpers.logger.info('On logout for auth 2 - 1')
|
||||
},
|
||||
|
||||
getWeight: () => 30,
|
||||
|
||||
login (body) {
|
||||
if (body.id === 'laguna' && body.password === 'laguna password') {
|
||||
return Promise.resolve({
|
||||
username: 'laguna',
|
||||
email: 'laguna@example.com'
|
||||
})
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async function unregister () {
|
||||
return
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
register,
|
||||
unregister
|
||||
}
|
||||
|
||||
// ###########################################################################
|
||||
20
server/tests/fixtures/peertube-plugin-test-id-pass-auth-two/package.json
vendored
Normal file
20
server/tests/fixtures/peertube-plugin-test-id-pass-auth-two/package.json
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "peertube-plugin-test-id-pass-auth-two",
|
||||
"version": "0.0.1",
|
||||
"description": "Id and pass auth two",
|
||||
"engine": {
|
||||
"peertube": ">=1.3.0"
|
||||
},
|
||||
"keywords": [
|
||||
"peertube",
|
||||
"plugin"
|
||||
],
|
||||
"homepage": "https://github.com/Chocobozzz/PeerTube",
|
||||
"author": "Chocobozzz",
|
||||
"bugs": "https://github.com/Chocobozzz/PeerTube/issues",
|
||||
"library": "./main.js",
|
||||
"staticDirs": {},
|
||||
"css": [],
|
||||
"clientScripts": [],
|
||||
"translations": {}
|
||||
}
|
||||
69
server/tests/plugins/id-and-pass-auth.ts
Normal file
69
server/tests/plugins/id-and-pass-auth.ts
Normal file
@@ -0,0 +1,69 @@
|
||||
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
|
||||
|
||||
import 'mocha'
|
||||
import { cleanupTests, flushAndRunServer, ServerInfo } from '../../../shared/extra-utils/server/servers'
|
||||
import { getPluginTestPath, installPlugin, setAccessTokensToServers } from '../../../shared/extra-utils'
|
||||
|
||||
describe('Test id and pass auth plugins', function () {
|
||||
let server: ServerInfo
|
||||
|
||||
before(async function () {
|
||||
this.timeout(30000)
|
||||
|
||||
server = await flushAndRunServer(1)
|
||||
await setAccessTokensToServers([ server ])
|
||||
|
||||
await installPlugin({
|
||||
url: server.url,
|
||||
accessToken: server.accessToken,
|
||||
path: getPluginTestPath('-id-pass-auth-one')
|
||||
})
|
||||
|
||||
await installPlugin({
|
||||
url: server.url,
|
||||
accessToken: server.accessToken,
|
||||
path: getPluginTestPath('-id-pass-auth-two')
|
||||
})
|
||||
})
|
||||
|
||||
it('Should not login', async function() {
|
||||
|
||||
})
|
||||
|
||||
it('Should login Spyro, create the user and use the token', async function() {
|
||||
|
||||
})
|
||||
|
||||
it('Should login Crash, create the user and use the token', async function() {
|
||||
|
||||
})
|
||||
|
||||
it('Should login the first Laguna, create the user and use the token', async function() {
|
||||
|
||||
})
|
||||
|
||||
it('Should update Crash profile', async function () {
|
||||
|
||||
})
|
||||
|
||||
it('Should logout Crash', async function () {
|
||||
|
||||
// test token
|
||||
})
|
||||
|
||||
it('Should have logged the Crash logout', async function () {
|
||||
|
||||
})
|
||||
|
||||
it('Should login Crash and keep the old existing profile', async function () {
|
||||
|
||||
})
|
||||
|
||||
it('Should uninstall the plugin one and do not login existing Crash', async function () {
|
||||
|
||||
})
|
||||
|
||||
after(async function () {
|
||||
await cleanupTests([ server ])
|
||||
})
|
||||
})
|
||||
@@ -1,4 +1,5 @@
|
||||
import './action-hooks'
|
||||
import './id-and-pass-auth'
|
||||
import './filter-hooks'
|
||||
import './translations'
|
||||
import './video-constants'
|
||||
|
||||
Reference in New Issue
Block a user