diff options
Diffstat (limited to 'server/tests/plugins/external-auth.ts')
-rw-r--r-- | server/tests/plugins/external-auth.ts | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/server/tests/plugins/external-auth.ts b/server/tests/plugins/external-auth.ts index 583100671..042681dbe 100644 --- a/server/tests/plugins/external-auth.ts +++ b/server/tests/plugins/external-auth.ts | |||
@@ -58,7 +58,14 @@ describe('Test external auth plugins', function () { | |||
58 | before(async function () { | 58 | before(async function () { |
59 | this.timeout(30000) | 59 | this.timeout(30000) |
60 | 60 | ||
61 | server = await createSingleServer(1) | 61 | server = await createSingleServer(1, { |
62 | rates_limit: { | ||
63 | login: { | ||
64 | max: 30 | ||
65 | } | ||
66 | } | ||
67 | }) | ||
68 | |||
62 | await setAccessTokensToServers([ server ]) | 69 | await setAccessTokensToServers([ server ]) |
63 | 70 | ||
64 | for (const suffix of [ 'one', 'two', 'three' ]) { | 71 | for (const suffix of [ 'one', 'two', 'three' ]) { |
@@ -70,7 +77,7 @@ describe('Test external auth plugins', function () { | |||
70 | const config = await server.config.getConfig() | 77 | const config = await server.config.getConfig() |
71 | 78 | ||
72 | const auths = config.plugin.registeredExternalAuths | 79 | const auths = config.plugin.registeredExternalAuths |
73 | expect(auths).to.have.lengthOf(8) | 80 | expect(auths).to.have.lengthOf(9) |
74 | 81 | ||
75 | const auth2 = auths.find((a) => a.authName === 'external-auth-2') | 82 | const auth2 = auths.find((a) => a.authName === 'external-auth-2') |
76 | expect(auth2).to.exist | 83 | expect(auth2).to.exist |
@@ -275,7 +282,7 @@ describe('Test external auth plugins', function () { | |||
275 | const config = await server.config.getConfig() | 282 | const config = await server.config.getConfig() |
276 | 283 | ||
277 | const auths = config.plugin.registeredExternalAuths | 284 | const auths = config.plugin.registeredExternalAuths |
278 | expect(auths).to.have.lengthOf(7) | 285 | expect(auths).to.have.lengthOf(8) |
279 | 286 | ||
280 | const auth1 = auths.find(a => a.authName === 'external-auth-2') | 287 | const auth1 = auths.find(a => a.authName === 'external-auth-2') |
281 | expect(auth1).to.not.exist | 288 | expect(auth1).to.not.exist |
@@ -318,7 +325,7 @@ describe('Test external auth plugins', function () { | |||
318 | }) | 325 | }) |
319 | }) | 326 | }) |
320 | 327 | ||
321 | it('Should not login an existing user', async function () { | 328 | it('Should not login an existing user email', async function () { |
322 | await server.users.create({ username: 'existing_user', password: 'super_password' }) | 329 | await server.users.create({ username: 'existing_user', password: 'super_password' }) |
323 | 330 | ||
324 | await loginExternal({ | 331 | await loginExternal({ |
@@ -330,11 +337,33 @@ describe('Test external auth plugins', function () { | |||
330 | }) | 337 | }) |
331 | }) | 338 | }) |
332 | 339 | ||
340 | it('Should be able to login an existing user username and channel', async function () { | ||
341 | await server.users.create({ username: 'existing_user2' }) | ||
342 | await server.users.create({ username: 'existing_user2-1_channel' }) | ||
343 | |||
344 | // Test twice to ensure we don't generate a username on every login | ||
345 | for (let i = 0; i < 2; i++) { | ||
346 | const res = await loginExternal({ | ||
347 | server, | ||
348 | npmName: 'test-external-auth-two', | ||
349 | authName: 'external-auth-7', | ||
350 | username: 'existing_user2' | ||
351 | }) | ||
352 | |||
353 | const token = res.access_token | ||
354 | |||
355 | const myInfo = await server.users.getMyInfo({ token }) | ||
356 | expect(myInfo.username).to.equal('existing_user2-1') | ||
357 | |||
358 | expect(myInfo.videoChannels[0].name).to.equal('existing_user2-1_channel-1') | ||
359 | } | ||
360 | }) | ||
361 | |||
333 | it('Should display the correct configuration', async function () { | 362 | it('Should display the correct configuration', async function () { |
334 | const config = await server.config.getConfig() | 363 | const config = await server.config.getConfig() |
335 | 364 | ||
336 | const auths = config.plugin.registeredExternalAuths | 365 | const auths = config.plugin.registeredExternalAuths |
337 | expect(auths).to.have.lengthOf(6) | 366 | expect(auths).to.have.lengthOf(7) |
338 | 367 | ||
339 | const auth2 = auths.find((a) => a.authName === 'external-auth-2') | 368 | const auth2 = auths.find((a) => a.authName === 'external-auth-2') |
340 | expect(auth2).to.not.exist | 369 | expect(auth2).to.not.exist |