Fix user tests

This commit is contained in:
Chocobozzz
2017-12-28 16:45:32 +01:00
parent 11ba2ab3f1
commit 5960f92395
2 changed files with 17 additions and 6 deletions

View File

@@ -15,7 +15,7 @@ function authenticate (req: express.Request, res: express.Response, next: expres
if (err) {
return res.status(err.status)
.json({
error: 'Authentication failed.',
error: 'Token is invalid.',
code: err.name
})
.end()
@@ -26,7 +26,18 @@ function authenticate (req: express.Request, res: express.Response, next: expres
}
function token (req: express.Request, res: express.Response, next: express.NextFunction) {
return oAuthServer.token()(req, res, next)
return oAuthServer.token()(req, res, err => {
if (err) {
return res.status(err.status)
.json({
error: 'Authentication failed.',
code: err.name
})
.end()
}
return next()
})
}
// ---------------------------------------------------------------------------

View File

@@ -42,7 +42,7 @@ describe('Test users', function () {
expect(res.body.error)
.to
.equal('invalid_client')
.equal('Authentication failed.')
})
it('Should not login with an invalid client secret', async function () {
@@ -51,7 +51,7 @@ describe('Test users', function () {
expect(res.body.error)
.to
.equal('invalid_client')
.equal('Authentication failed.')
})
it('Should not login with an invalid username', async function () {
@@ -60,7 +60,7 @@ describe('Test users', function () {
expect(res.body.error)
.to
.equal('invalid_grant')
.equal('Authentication failed.')
})
it('Should not login with an invalid password', async function () {
@@ -69,7 +69,7 @@ describe('Test users', function () {
expect(res.body.error)
.to
.equal('invalid_grant')
.equal('Authentication failed.')
})
it('Should not be able to upload a video', async function () {