aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/tests/plugins/external-auth.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-07-16 10:42:24 +0200
committerChocobozzz <me@florianbigard.com>2021-07-20 15:27:18 +0200
commitc0e8b12e7fd554ba4d2ceb0c4900804c6a4c63ea (patch)
treebaf29753ac5d4598643e3bee719f8df0cc36c59d /server/tests/plugins/external-auth.ts
parent08642a765ea514a00f159db898edf14c376fbe6c (diff)
downloadPeerTube-c0e8b12e7fd554ba4d2ceb0c4900804c6a4c63ea.tar.gz
PeerTube-c0e8b12e7fd554ba4d2ceb0c4900804c6a4c63ea.tar.zst
PeerTube-c0e8b12e7fd554ba4d2ceb0c4900804c6a4c63ea.zip
Refactor requests
Diffstat (limited to 'server/tests/plugins/external-auth.ts')
-rw-r--r--server/tests/plugins/external-auth.ts20
1 files changed, 10 insertions, 10 deletions
diff --git a/server/tests/plugins/external-auth.ts b/server/tests/plugins/external-auth.ts
index c0834a14c..a2828603a 100644
--- a/server/tests/plugins/external-auth.ts
+++ b/server/tests/plugins/external-auth.ts
@@ -2,7 +2,7 @@
2 2
3import 'mocha' 3import 'mocha'
4import { expect } from 'chai' 4import { expect } from 'chai'
5import { HttpStatusCode } from '@shared/core-utils' 5import { HttpStatusCode } from '@shared/models'
6import { 6import {
7 cleanupTests, 7 cleanupTests,
8 decodeQueryString, 8 decodeQueryString,
@@ -20,15 +20,15 @@ async function loginExternal (options: {
20 authName: string 20 authName: string
21 username: string 21 username: string
22 query?: any 22 query?: any
23 statusCodeExpected?: HttpStatusCode 23 expectedStatus?: HttpStatusCode
24 statusCodeExpectedStep2?: HttpStatusCode 24 expectedStatusStep2?: HttpStatusCode
25}) { 25}) {
26 const res = await options.server.plugins.getExternalAuth({ 26 const res = await options.server.plugins.getExternalAuth({
27 npmName: options.npmName, 27 npmName: options.npmName,
28 npmVersion: '0.0.1', 28 npmVersion: '0.0.1',
29 authName: options.authName, 29 authName: options.authName,
30 query: options.query, 30 query: options.query,
31 expectedStatus: options.statusCodeExpected || HttpStatusCode.FOUND_302 31 expectedStatus: options.expectedStatus || HttpStatusCode.FOUND_302
32 }) 32 })
33 33
34 if (res.status !== HttpStatusCode.FOUND_302) return 34 if (res.status !== HttpStatusCode.FOUND_302) return
@@ -39,7 +39,7 @@ async function loginExternal (options: {
39 const resLogin = await options.server.login.loginUsingExternalToken({ 39 const resLogin = await options.server.login.loginUsingExternalToken({
40 username: options.username, 40 username: options.username,
41 externalAuthToken: externalAuthToken as string, 41 externalAuthToken: externalAuthToken as string,
42 expectedStatus: options.statusCodeExpectedStep2 42 expectedStatus: options.expectedStatusStep2
43 }) 43 })
44 44
45 return resLogin.body 45 return resLogin.body
@@ -268,7 +268,7 @@ describe('Test external auth plugins', function () {
268 username: 'kefka' 268 username: 'kefka'
269 }, 269 },
270 username: 'kefka', 270 username: 'kefka',
271 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 271 expectedStatus: HttpStatusCode.NOT_FOUND_404
272 }) 272 })
273 }) 273 })
274 274
@@ -293,7 +293,7 @@ describe('Test external auth plugins', function () {
293 username: 'cyan' 293 username: 'cyan'
294 }, 294 },
295 username: 'cyan', 295 username: 'cyan',
296 statusCodeExpected: HttpStatusCode.NOT_FOUND_404 296 expectedStatus: HttpStatusCode.NOT_FOUND_404
297 }) 297 })
298 298
299 await server.login.login({ user: { username: 'cyan', password: null }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 }) 299 await server.login.login({ user: { username: 'cyan', password: null }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
@@ -307,7 +307,7 @@ describe('Test external auth plugins', function () {
307 npmName: 'test-external-auth-two', 307 npmName: 'test-external-auth-two',
308 authName: 'external-auth-4', 308 authName: 'external-auth-4',
309 username: 'kefka2', 309 username: 'kefka2',
310 statusCodeExpectedStep2: HttpStatusCode.BAD_REQUEST_400 310 expectedStatusStep2: HttpStatusCode.BAD_REQUEST_400
311 }) 311 })
312 312
313 await loginExternal({ 313 await loginExternal({
@@ -315,7 +315,7 @@ describe('Test external auth plugins', function () {
315 npmName: 'test-external-auth-two', 315 npmName: 'test-external-auth-two',
316 authName: 'external-auth-4', 316 authName: 'external-auth-4',
317 username: 'kefka', 317 username: 'kefka',
318 statusCodeExpectedStep2: HttpStatusCode.BAD_REQUEST_400 318 expectedStatusStep2: HttpStatusCode.BAD_REQUEST_400
319 }) 319 })
320 }) 320 })
321 321
@@ -327,7 +327,7 @@ describe('Test external auth plugins', function () {
327 npmName: 'test-external-auth-two', 327 npmName: 'test-external-auth-two',
328 authName: 'external-auth-6', 328 authName: 'external-auth-6',
329 username: 'existing_user', 329 username: 'existing_user',
330 statusCodeExpectedStep2: HttpStatusCode.BAD_REQUEST_400 330 expectedStatusStep2: HttpStatusCode.BAD_REQUEST_400
331 }) 331 })
332 }) 332 })
333 333