aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/fixtures
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-04-24 11:33:01 +0200
committerChocobozzz <chocobozzz@cpy.re>2020-05-04 16:21:39 +0200
commite307e4fce39853d445d086f92b8c556c363ee15d (patch)
tree0f3faaf3c73222db0fb55b72260c787aeeeb05eb /server/tests/fixtures
parente1c5503114deef954731904695cd40dccfcef555 (diff)
downloadPeerTube-e307e4fce39853d445d086f92b8c556c363ee15d.tar.gz
PeerTube-e307e4fce39853d445d086f92b8c556c363ee15d.tar.zst
PeerTube-e307e4fce39853d445d086f92b8c556c363ee15d.zip
Add ability for auth plugins to hook tokens validity
Diffstat (limited to 'server/tests/fixtures')
-rw-r--r--server/tests/fixtures/peertube-plugin-test-id-pass-auth-two/main.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/server/tests/fixtures/peertube-plugin-test-id-pass-auth-two/main.js b/server/tests/fixtures/peertube-plugin-test-id-pass-auth-two/main.js
index c0e560019..ceab7b60d 100644
--- a/server/tests/fixtures/peertube-plugin-test-id-pass-auth-two/main.js
+++ b/server/tests/fixtures/peertube-plugin-test-id-pass-auth-two/main.js
@@ -11,6 +11,24 @@ async function register ({
11 11
12 getWeight: () => 30, 12 getWeight: () => 30,
13 13
14 hookTokenValidity: (options) => {
15 if (options.type === 'refresh') {
16 return { valid: false }
17 }
18
19 if (options.type === 'access') {
20 const token = options.token
21 const now = new Date()
22 now.setTime(now.getTime() - 5000)
23
24 const createdAt = new Date(token.createdAt)
25
26 return { valid: createdAt.getTime() >= now.getTime() }
27 }
28
29 return { valid: true }
30 },
31
14 login (body) { 32 login (body) {
15 if (body.id === 'laguna' && body.password === 'laguna password') { 33 if (body.id === 'laguna' && body.password === 'laguna password') {
16 return Promise.resolve({ 34 return Promise.resolve({