1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 describe('Login tests', function() {
10 beforeEach(function() {
11 cy.arvadosFixture('users').as('users')
12 cy.arvadosFixture('api_client_authorizations').as('client_auth')
14 cy.clearLocalStorage()
17 it('logs in successfully with correct token', function() {
18 const active_user = this.users['active']
19 const active_token = this.client_auth['active']['api_token']
20 cy.visit('/token/?api_token='+active_token)
21 cy.url().should('contain', '/projects/')
22 cy.get('button[title="Account Management"]').click()
23 cy.get('ul[role=menu] > li[role=menuitem]').contains(`${active_user['first_name']} ${active_user['last_name']}`)
26 it('fails to log in with expired token', function() {
27 const expired_token = this.client_auth['expired']['api_token']
28 cy.visit('/token/?api_token='+expired_token)
29 cy.contains('Please log in')
30 cy.url().should('not.contain', '/projects/')
33 it('fails to log in with no token', function() {
34 cy.visit('/token/?api_token=')
35 cy.contains('Please log in')
36 cy.url().should('not.contain', '/projects/')
39 it('shows login page on first visit', function() {
41 cy.contains('Please log in')
42 cy.url().should('not.contain', '/projects/')