diff options
author | Chocobozzz <me@florianbigard.com> | 2017-12-28 16:45:32 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2017-12-28 16:45:32 +0100 |
commit | 5960f92395e81cc851d4536325bee72ba930de3f (patch) | |
tree | 4ede6c7bd9a52090a8a429c7e6b008a72c27d4fa /server | |
parent | 11ba2ab3f1e3ec29b3765fa0c1ff4ed410c851a9 (diff) | |
download | PeerTube-5960f92395e81cc851d4536325bee72ba930de3f.tar.gz PeerTube-5960f92395e81cc851d4536325bee72ba930de3f.tar.zst PeerTube-5960f92395e81cc851d4536325bee72ba930de3f.zip |
Fix user tests
Diffstat (limited to 'server')
-rw-r--r-- | server/middlewares/oauth.ts | 15 | ||||
-rw-r--r-- | server/tests/api/users/users.ts | 8 |
2 files changed, 17 insertions, 6 deletions
diff --git a/server/middlewares/oauth.ts b/server/middlewares/oauth.ts index 9976993e0..41a3fb718 100644 --- a/server/middlewares/oauth.ts +++ b/server/middlewares/oauth.ts | |||
@@ -15,7 +15,7 @@ function authenticate (req: express.Request, res: express.Response, next: expres | |||
15 | if (err) { | 15 | if (err) { |
16 | return res.status(err.status) | 16 | return res.status(err.status) |
17 | .json({ | 17 | .json({ |
18 | error: 'Authentication failed.', | 18 | error: 'Token is invalid.', |
19 | code: err.name | 19 | code: err.name |
20 | }) | 20 | }) |
21 | .end() | 21 | .end() |
@@ -26,7 +26,18 @@ function authenticate (req: express.Request, res: express.Response, next: expres | |||
26 | } | 26 | } |
27 | 27 | ||
28 | function token (req: express.Request, res: express.Response, next: express.NextFunction) { | 28 | function token (req: express.Request, res: express.Response, next: express.NextFunction) { |
29 | return oAuthServer.token()(req, res, next) | 29 | return oAuthServer.token()(req, res, err => { |
30 | if (err) { | ||
31 | return res.status(err.status) | ||
32 | .json({ | ||
33 | error: 'Authentication failed.', | ||
34 | code: err.name | ||
35 | }) | ||
36 | .end() | ||
37 | } | ||
38 | |||
39 | return next() | ||
40 | }) | ||
30 | } | 41 | } |
31 | 42 | ||
32 | // --------------------------------------------------------------------------- | 43 | // --------------------------------------------------------------------------- |
diff --git a/server/tests/api/users/users.ts b/server/tests/api/users/users.ts index b7ec3bc0f..a13807b5c 100644 --- a/server/tests/api/users/users.ts +++ b/server/tests/api/users/users.ts | |||
@@ -42,7 +42,7 @@ describe('Test users', function () { | |||
42 | 42 | ||
43 | expect(res.body.error) | 43 | expect(res.body.error) |
44 | .to | 44 | .to |
45 | .equal('invalid_client') | 45 | .equal('Authentication failed.') |
46 | }) | 46 | }) |
47 | 47 | ||
48 | it('Should not login with an invalid client secret', async function () { | 48 | it('Should not login with an invalid client secret', async function () { |
@@ -51,7 +51,7 @@ describe('Test users', function () { | |||
51 | 51 | ||
52 | expect(res.body.error) | 52 | expect(res.body.error) |
53 | .to | 53 | .to |
54 | .equal('invalid_client') | 54 | .equal('Authentication failed.') |
55 | }) | 55 | }) |
56 | 56 | ||
57 | it('Should not login with an invalid username', async function () { | 57 | it('Should not login with an invalid username', async function () { |
@@ -60,7 +60,7 @@ describe('Test users', function () { | |||
60 | 60 | ||
61 | expect(res.body.error) | 61 | expect(res.body.error) |
62 | .to | 62 | .to |
63 | .equal('invalid_grant') | 63 | .equal('Authentication failed.') |
64 | }) | 64 | }) |
65 | 65 | ||
66 | it('Should not login with an invalid password', async function () { | 66 | it('Should not login with an invalid password', async function () { |
@@ -69,7 +69,7 @@ describe('Test users', function () { | |||
69 | 69 | ||
70 | expect(res.body.error) | 70 | expect(res.body.error) |
71 | .to | 71 | .to |
72 | .equal('invalid_grant') | 72 | .equal('Authentication failed.') |
73 | }) | 73 | }) |
74 | 74 | ||
75 | it('Should not be able to upload a video', async function () { | 75 | it('Should not be able to upload a video', async function () { |