+ crashAccessToken = await server.login.getAccessToken({ username: 'crash', password: 'crash password' })
+
+ const body = await server.users.getMyInfo({ token: crashAccessToken })
+
+ expect(body.username).to.equal('crash')
+ expect(body.account.displayName).to.equal('Beautiful Crash')
+ expect(body.account.description).to.equal('Mutant eastern barred bandicoot')
+ expect(body.role).to.equal(UserRole.MODERATOR)
+ })
+
+ 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 display name')
+
+ 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 })
+ })