+ await loginExternal({
+ server,
+ npmName: 'test-external-auth-two',
+ authName: 'external-auth-4',
+ username: 'kefka',
+ expectedStatusStep2: HttpStatusCode.BAD_REQUEST_400
+ })
+ })
+
+ it('Should not login an existing user email', async function () {
+ await server.users.create({ username: 'existing_user', password: 'super_password' })
+
+ await loginExternal({
+ server,
+ npmName: 'test-external-auth-two',
+ authName: 'external-auth-6',
+ username: 'existing_user',
+ expectedStatusStep2: HttpStatusCode.BAD_REQUEST_400
+ })
+ })
+
+ it('Should be able to login an existing user username and channel', async function () {
+ await server.users.create({ username: 'existing_user2' })
+ await server.users.create({ username: 'existing_user2-1_channel' })
+
+ // Test twice to ensure we don't generate a username on every login
+ for (let i = 0; i < 2; i++) {
+ const res = await loginExternal({
+ server,
+ npmName: 'test-external-auth-two',
+ authName: 'external-auth-7',
+ username: 'existing_user2'
+ })
+
+ const token = res.access_token
+
+ const myInfo = await server.users.getMyInfo({ token })
+ expect(myInfo.username).to.equal('existing_user2-1')
+
+ expect(myInfo.videoChannels[0].name).to.equal('existing_user2-1_channel-1')
+ }
+ })
+
+ it('Should display the correct configuration', async function () {
+ const config = await server.config.getConfig()