]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Fix plugin helpers tests
authorChocobozzz <me@florianbigard.com>
Thu, 22 Apr 2021 13:16:35 +0000 (15:16 +0200)
committerChocobozzz <me@florianbigard.com>
Thu, 22 Apr 2021 13:16:35 +0000 (15:16 +0200)
server/tests/fixtures/peertube-plugin-test-four/main.js
server/tests/plugins/plugin-helpers.ts

index 6930ac511343e285c6899505ae6987f7ff6970a0..6ed0c20d219ab5cd5bac361ca289a3ad912c7774 100644 (file)
@@ -88,8 +88,9 @@ async function register ({
       return res.json({ routerRoute })
     })
 
-    router.get('/user', async (req, res) => {
+    router.get('/user', (req, res) => {
       const user = peertubeHelpers.user.getAuthUser(res)
+      if (!user) return res.sendStatus(404)
 
       const isAdmin = user.role === 0
       const isModerator = user.role === 1
index 2ac070b41026156dbf344bfb01209bc9bb0914f4..20020ec41c9e6ef63442584283030643a48b0985 100644 (file)
@@ -117,13 +117,11 @@ describe('Test plugin helpers', function () {
   describe('User', function () {
 
     it('Should not get a user if not authenticated', async function () {
-      const res = await makeGetRequest({
+      await makeGetRequest({
         url: servers[0].url,
         path: '/plugins/test-four/router/user',
-        statusCodeExpected: HttpStatusCode.OK_200
+        statusCodeExpected: HttpStatusCode.NOT_FOUND_404
       })
-
-      expect(res.body.user).to.be.undefined
     })
 
     it('Should get a user if authenticated', async function () {
@@ -134,7 +132,6 @@ describe('Test plugin helpers', function () {
         statusCodeExpected: HttpStatusCode.OK_200
       })
 
-      expect(res.body.user).to.exist
       expect(res.body.username).to.equal('root')
       expect(res.body.isAdmin).to.be.true
       expect(res.body.isModerator).to.be.false