aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/fixtures/peertube-plugin-test-id-pass-auth-three/main.js
blob: caa6a7ccdc4ff471df24f975f145f4fc04ff2ef5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
async function register ({
  registerIdAndPassAuth,
  peertubeHelpers
}) {
  registerIdAndPassAuth({
    authName: 'laguna-bad-auth',

    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
    }
  })

  registerIdAndPassAuth({
    authName: 'ward-auth',

    getWeight: () => 5,

    login (body) {
      if (body.id === 'ward') {
        return Promise.resolve({
          username: 'ward-42',
          email: 'ward@example.com'
        })
      }

      return null
    }
  })

  registerIdAndPassAuth({
    authName: 'kiros-auth',

    getWeight: () => 5,

    login (body) {
      if (body.id === 'kiros') {
        return Promise.resolve({
          username: 'kiros',
          email: 'kiros@example.com',
          displayName: 'a'.repeat(5000)
        })
      }

      return null
    }
  })

  registerIdAndPassAuth({
    authName: 'raine-auth',

    getWeight: () => 5,

    login (body) {
      if (body.id === 'raine') {
        return Promise.resolve({
          username: 'raine',
          email: 'raine@example.com',
          role: 42
        })
      }

      return null
    }
  })

  registerIdAndPassAuth({
    authName: 'ellone-auth',

    getWeight: () => 5,

    login (body) {
      if (body.id === 'ellone') {
        return Promise.resolve({
          username: 'ellone'
        })
      }

      return null
    }
  })
}

async function unregister () {
  return
}

module.exports = {
  register,
  unregister
}

// ###########################################################################