aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-04-22 15:16:35 +0200
committerChocobozzz <me@florianbigard.com>2021-04-22 15:16:35 +0200
commit6290699080cbcc5e454982c55a451ee23223ee2c (patch)
tree0989b7a146403e347b541b59b3bb4d056f8258ca /server/tests
parent0f319334065fae8756fe7c7eec333000474d07ba (diff)
downloadPeerTube-6290699080cbcc5e454982c55a451ee23223ee2c.tar.gz
PeerTube-6290699080cbcc5e454982c55a451ee23223ee2c.tar.zst
PeerTube-6290699080cbcc5e454982c55a451ee23223ee2c.zip
Fix plugin helpers tests
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/fixtures/peertube-plugin-test-four/main.js3
-rw-r--r--server/tests/plugins/plugin-helpers.ts7
2 files changed, 4 insertions, 6 deletions
diff --git a/server/tests/fixtures/peertube-plugin-test-four/main.js b/server/tests/fixtures/peertube-plugin-test-four/main.js
index 6930ac511..6ed0c20d2 100644
--- a/server/tests/fixtures/peertube-plugin-test-four/main.js
+++ b/server/tests/fixtures/peertube-plugin-test-four/main.js
@@ -88,8 +88,9 @@ async function register ({
88 return res.json({ routerRoute }) 88 return res.json({ routerRoute })
89 }) 89 })
90 90
91 router.get('/user', async (req, res) => { 91 router.get('/user', (req, res) => {
92 const user = peertubeHelpers.user.getAuthUser(res) 92 const user = peertubeHelpers.user.getAuthUser(res)
93 if (!user) return res.sendStatus(404)
93 94
94 const isAdmin = user.role === 0 95 const isAdmin = user.role === 0
95 const isModerator = user.role === 1 96 const isModerator = user.role === 1
diff --git a/server/tests/plugins/plugin-helpers.ts b/server/tests/plugins/plugin-helpers.ts
index 2ac070b41..20020ec41 100644
--- a/server/tests/plugins/plugin-helpers.ts
+++ b/server/tests/plugins/plugin-helpers.ts
@@ -117,13 +117,11 @@ describe('Test plugin helpers', function () {
117 describe('User', function () { 117 describe('User', function () {
118 118
119 it('Should not get a user if not authenticated', async function () { 119 it('Should not get a user if not authenticated', async function () {
120 const res = await makeGetRequest({ 120 await makeGetRequest({
121 url: servers[0].url, 121 url: servers[0].url,
122 path: '/plugins/test-four/router/user', 122 path: '/plugins/test-four/router/user',
123 statusCodeExpected: HttpStatusCode.OK_200 123 statusCodeExpected: HttpStatusCode.NOT_FOUND_404
124 }) 124 })
125
126 expect(res.body.user).to.be.undefined
127 }) 125 })
128 126
129 it('Should get a user if authenticated', async function () { 127 it('Should get a user if authenticated', async function () {
@@ -134,7 +132,6 @@ describe('Test plugin helpers', function () {
134 statusCodeExpected: HttpStatusCode.OK_200 132 statusCodeExpected: HttpStatusCode.OK_200
135 }) 133 })
136 134
137 expect(res.body.user).to.exist
138 expect(res.body.username).to.equal('root') 135 expect(res.body.username).to.equal('root')
139 expect(res.body.isAdmin).to.be.true 136 expect(res.body.isAdmin).to.be.true
140 expect(res.body.isModerator).to.be.false 137 expect(res.body.isModerator).to.be.false