diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2021-06-02 14:28:30 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2021-06-02 16:57:07 +0200 |
commit | 81628e5069e0168b11857f276fe8e03b93102dde (patch) | |
tree | e83cae17853a2e92817c65472a9f63b8e058a5be /server/tests/api | |
parent | 3866ea02d4a5c8e4c69a5d8633a883e3733414b9 (diff) | |
download | PeerTube-81628e5069e0168b11857f276fe8e03b93102dde.tar.gz PeerTube-81628e5069e0168b11857f276fe8e03b93102dde.tar.zst PeerTube-81628e5069e0168b11857f276fe8e03b93102dde.zip |
refactor error code values for URI compatibility
Diffstat (limited to 'server/tests/api')
-rw-r--r-- | server/tests/api/users/users.ts | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/server/tests/api/users/users.ts b/server/tests/api/users/users.ts index 464c11d34..87ba775f6 100644 --- a/server/tests/api/users/users.ts +++ b/server/tests/api/users/users.ts | |||
@@ -3,7 +3,7 @@ | |||
3 | import 'mocha' | 3 | import 'mocha' |
4 | import * as chai from 'chai' | 4 | import * as chai from 'chai' |
5 | import { AbuseState, AbuseUpdate, MyUser, User, UserRole, Video, VideoPlaylistType } from '@shared/models' | 5 | import { AbuseState, AbuseUpdate, MyUser, User, UserRole, Video, VideoPlaylistType } from '@shared/models' |
6 | import { CustomConfig } from '@shared/models/server' | 6 | import { CustomConfig, OAuth2ErrorCode } from '@shared/models/server' |
7 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' | 7 | import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' |
8 | import { | 8 | import { |
9 | addVideoCommentThread, | 9 | addVideoCommentThread, |
@@ -93,20 +93,20 @@ describe('Test users', function () { | |||
93 | const client = { id: 'client', secret: server.client.secret } | 93 | const client = { id: 'client', secret: server.client.secret } |
94 | const res = await login(server.url, client, server.user, HttpStatusCode.BAD_REQUEST_400) | 94 | const res = await login(server.url, client, server.user, HttpStatusCode.BAD_REQUEST_400) |
95 | 95 | ||
96 | expect(res.body.code).to.equal('invalid_client') | 96 | expect(res.body.code).to.equal(OAuth2ErrorCode.INVALID_CLIENT) |
97 | expect(res.body.error).to.contain('client is invalid') | 97 | expect(res.body.error).to.contain('client is invalid') |
98 | expect(res.body.type.startsWith('https://')).to.be.true | 98 | expect(res.body.type.startsWith('https://')).to.be.true |
99 | expect(res.body.type).to.contain('invalid_client') | 99 | expect(res.body.type).to.contain(OAuth2ErrorCode.INVALID_CLIENT) |
100 | }) | 100 | }) |
101 | 101 | ||
102 | it('Should not login with an invalid client secret', async function () { | 102 | it('Should not login with an invalid client secret', async function () { |
103 | const client = { id: server.client.id, secret: 'coucou' } | 103 | const client = { id: server.client.id, secret: 'coucou' } |
104 | const res = await login(server.url, client, server.user, HttpStatusCode.BAD_REQUEST_400) | 104 | const res = await login(server.url, client, server.user, HttpStatusCode.BAD_REQUEST_400) |
105 | 105 | ||
106 | expect(res.body.code).to.equal('invalid_client') | 106 | expect(res.body.code).to.equal(OAuth2ErrorCode.INVALID_CLIENT) |
107 | expect(res.body.error).to.contain('client is invalid') | 107 | expect(res.body.error).to.contain('client is invalid') |
108 | expect(res.body.type.startsWith('https://')).to.be.true | 108 | expect(res.body.type.startsWith('https://')).to.be.true |
109 | expect(res.body.type).to.contain('invalid_client') | 109 | expect(res.body.type).to.contain(OAuth2ErrorCode.INVALID_CLIENT) |
110 | }) | 110 | }) |
111 | }) | 111 | }) |
112 | 112 | ||
@@ -116,20 +116,20 @@ describe('Test users', function () { | |||
116 | const user = { username: 'captain crochet', password: server.user.password } | 116 | const user = { username: 'captain crochet', password: server.user.password } |
117 | const res = await login(server.url, server.client, user, HttpStatusCode.BAD_REQUEST_400) | 117 | const res = await login(server.url, server.client, user, HttpStatusCode.BAD_REQUEST_400) |
118 | 118 | ||
119 | expect(res.body.code).to.equal('invalid_grant') | 119 | expect(res.body.code).to.equal(OAuth2ErrorCode.INVALID_GRANT) |
120 | expect(res.body.error).to.contain('credentials are invalid') | 120 | expect(res.body.error).to.contain('credentials are invalid') |
121 | expect(res.body.type.startsWith('https://')).to.be.true | 121 | expect(res.body.type.startsWith('https://')).to.be.true |
122 | expect(res.body.type).to.contain('invalid_grant') | 122 | expect(res.body.type).to.contain(OAuth2ErrorCode.INVALID_GRANT) |
123 | }) | 123 | }) |
124 | 124 | ||
125 | it('Should not login with an invalid password', async function () { | 125 | it('Should not login with an invalid password', async function () { |
126 | const user = { username: server.user.username, password: 'mew_three' } | 126 | const user = { username: server.user.username, password: 'mew_three' } |
127 | const res = await login(server.url, server.client, user, HttpStatusCode.BAD_REQUEST_400) | 127 | const res = await login(server.url, server.client, user, HttpStatusCode.BAD_REQUEST_400) |
128 | 128 | ||
129 | expect(res.body.code).to.equal('invalid_grant') | 129 | expect(res.body.code).to.equal(OAuth2ErrorCode.INVALID_GRANT) |
130 | expect(res.body.error).to.contain('credentials are invalid') | 130 | expect(res.body.error).to.contain('credentials are invalid') |
131 | expect(res.body.type.startsWith('https://')).to.be.true | 131 | expect(res.body.type.startsWith('https://')).to.be.true |
132 | expect(res.body.type).to.contain('invalid_grant') | 132 | expect(res.body.type).to.contain(OAuth2ErrorCode.INVALID_GRANT) |
133 | }) | 133 | }) |
134 | 134 | ||
135 | it('Should not be able to upload a video', async function () { | 135 | it('Should not be able to upload a video', async function () { |