]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/tests/api/users/users.ts
refactor error code values for URI compatibility
[github/Chocobozzz/PeerTube.git] / server / tests / api / users / users.ts
index 363236b6270138f02ab6f176c9307a41e1e63487..87ba775f650b3984ae13a0d748c5c9f4473512d0 100644 (file)
@@ -3,7 +3,7 @@
 import 'mocha'
 import * as chai from 'chai'
 import { AbuseState, AbuseUpdate, MyUser, User, UserRole, Video, VideoPlaylistType } from '@shared/models'
-import { CustomConfig } from '@shared/models/server'
+import { CustomConfig, OAuth2ErrorCode } from '@shared/models/server'
 import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
 import {
   addVideoCommentThread,
@@ -93,16 +93,20 @@ describe('Test users', function () {
       const client = { id: 'client', secret: server.client.secret }
       const res = await login(server.url, client, server.user, HttpStatusCode.BAD_REQUEST_400)
 
-      expect(res.body.type).to.equal('invalid_client')
-      expect(res.body.detail).to.contain('client is invalid')
+      expect(res.body.code).to.equal(OAuth2ErrorCode.INVALID_CLIENT)
+      expect(res.body.error).to.contain('client is invalid')
+      expect(res.body.type.startsWith('https://')).to.be.true
+      expect(res.body.type).to.contain(OAuth2ErrorCode.INVALID_CLIENT)
     })
 
     it('Should not login with an invalid client secret', async function () {
       const client = { id: server.client.id, secret: 'coucou' }
       const res = await login(server.url, client, server.user, HttpStatusCode.BAD_REQUEST_400)
 
-      expect(res.body.type).to.equal('invalid_client')
-      expect(res.body.detail).to.contain('client is invalid')
+      expect(res.body.code).to.equal(OAuth2ErrorCode.INVALID_CLIENT)
+      expect(res.body.error).to.contain('client is invalid')
+      expect(res.body.type.startsWith('https://')).to.be.true
+      expect(res.body.type).to.contain(OAuth2ErrorCode.INVALID_CLIENT)
     })
   })
 
@@ -112,16 +116,20 @@ describe('Test users', function () {
       const user = { username: 'captain crochet', password: server.user.password }
       const res = await login(server.url, server.client, user, HttpStatusCode.BAD_REQUEST_400)
 
-      expect(res.body.type).to.equal('invalid_grant')
-      expect(res.body.detail).to.contain('credentials are invalid')
+      expect(res.body.code).to.equal(OAuth2ErrorCode.INVALID_GRANT)
+      expect(res.body.error).to.contain('credentials are invalid')
+      expect(res.body.type.startsWith('https://')).to.be.true
+      expect(res.body.type).to.contain(OAuth2ErrorCode.INVALID_GRANT)
     })
 
     it('Should not login with an invalid password', async function () {
       const user = { username: server.user.username, password: 'mew_three' }
       const res = await login(server.url, server.client, user, HttpStatusCode.BAD_REQUEST_400)
 
-      expect(res.body.type).to.equal('invalid_grant')
-      expect(res.body.detail).to.contain('credentials are invalid')
+      expect(res.body.code).to.equal(OAuth2ErrorCode.INVALID_GRANT)
+      expect(res.body.error).to.contain('credentials are invalid')
+      expect(res.body.type.startsWith('https://')).to.be.true
+      expect(res.body.type).to.contain(OAuth2ErrorCode.INVALID_GRANT)
     })
 
     it('Should not be able to upload a video', async function () {