+ expect(body.role.id).to.equal(UserRole.MODERATOR)
+ })
+
+ it('Should login Laguna and update the profile', async function () {
+ {
+ await server.users.update({ userId: lagunaId, videoQuota: 43000, videoQuotaDaily: 43100 })
+ await server.users.updateMe({ token: lagunaAccessToken, displayName: 'laguna updated' })
+
+ const body = await server.users.getMyInfo({ token: lagunaAccessToken })
+ expect(body.username).to.equal('laguna')
+ expect(body.account.displayName).to.equal('laguna updated')
+ expect(body.videoQuota).to.equal(43000)
+ expect(body.videoQuotaDaily).to.equal(43100)
+ }
+
+ {
+ const body = await server.login.login({ user: { username: 'laguna', password: 'laguna password' } })
+ lagunaAccessToken = body.access_token
+ lagunaRefreshToken = body.refresh_token
+ }
+
+ {
+ const body = await server.users.getMyInfo({ token: lagunaAccessToken })
+ expect(body.username).to.equal('laguna')
+ expect(body.account.displayName).to.equal('Laguna Loire')
+ expect(body.videoQuota).to.equal(42000)
+ expect(body.videoQuotaDaily).to.equal(43100)
+ }
+ })
+
+ it('Should reject token of laguna by the plugin hook', async function () {
+ this.timeout(10000)
+
+ await wait(5000)
+
+ await server.users.getMyInfo({ token: lagunaAccessToken, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })
+ })
+
+ it('Should reject an invalid username, email, role or display name', async function () {
+ const command = server.login
+
+ await command.login({ user: { username: 'ward', password: 'ward password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ await server.servers.waitUntilLog('valid username')
+
+ await command.login({ user: { username: 'kiros', password: 'kiros password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ await server.servers.waitUntilLog('valid displayName')
+
+ await command.login({ user: { username: 'raine', password: 'raine password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ await server.servers.waitUntilLog('valid role')
+
+ await command.login({ user: { username: 'ellone', password: 'elonne password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ await server.servers.waitUntilLog('valid email')
+ })
+
+ it('Should unregister spyro-auth and do not login existing Spyro', async function () {
+ await server.plugins.updateSettings({
+ npmName: 'peertube-plugin-test-id-pass-auth-one',
+ settings: { disableSpyro: true }
+ })
+
+ const command = server.login
+ await command.login({ user: { username: 'spyro', password: 'spyro password' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ await command.login({ user: { username: 'spyro', password: 'fake' }, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })
+ })
+
+ it('Should have disabled this auth', async function () {
+ const config = await server.config.getConfig()
+
+ const auths = config.plugin.registeredIdAndPassAuths
+ expect(auths).to.have.lengthOf(7)
+
+ const spyroAuth = auths.find(a => a.authName === 'spyro-auth')
+ expect(spyroAuth).to.not.exist