]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/fixtures/peertube-plugin-test-id-pass-auth-two/main.js
Speed up plugin transcoding tests
[github/Chocobozzz/PeerTube.git] / server / tests / fixtures / peertube-plugin-test-id-pass-auth-two / main.js
index edfc870c026780e85eb98d5cdabfe72ecf1d3561..ceab7b60de3a96284e0ed688aaac6b9b2da9aebf 100644 (file)
@@ -3,7 +3,7 @@ async function register ({
   peertubeHelpers
 }) {
   registerIdAndPassAuth({
-    type: 'id-and-pass',
+    authName: 'laguna-auth',
 
     onLogout: () => {
       peertubeHelpers.logger.info('On logout for auth 2 - 1')
@@ -11,6 +11,24 @@ async function register ({
 
     getWeight: () => 30,
 
+    hookTokenValidity: (options) => {
+      if (options.type === 'refresh') {
+        return { valid: false }
+      }
+
+      if (options.type === 'access') {
+        const token = options.token
+        const now = new Date()
+        now.setTime(now.getTime() - 5000)
+
+        const createdAt = new Date(token.createdAt)
+
+        return { valid: createdAt.getTime() >= now.getTime() }
+      }
+
+      return { valid: true }
+    },
+
     login (body) {
       if (body.id === 'laguna' && body.password === 'laguna password') {
         return Promise.resolve({