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,
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)
})
})
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 () {