blob: 03ea6e37597375666897618741ac7f4a588d5cd2 [file] [log] [blame]
Larbi Gharibb38e3542022-12-07 06:09:10 -05001/*
2 * Copyright (C) 2022 Savoir-faire Linux Inc.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Affero General Public License as
6 * published by the Free Software Foundation; either version 3 of the
7 * License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Affero General Public License for more details.
13 *
14 * You should have received a copy of the GNU Affero General Public
15 * License along with this program. If not, see
16 * <https://www.gnu.org/licenses/>.
17 */
18
19describe('authentication', () => {
20 beforeEach(() => {});
21
Ziwei Wang207ae8e2023-04-03 13:02:31 -040022 it('log in and log out successfully with UI', () => {
23 cy.loginViaUI();
24
25 cy.logoutViaUI();
26 });
27
28 it('login failed with invalid password', () => {
29 const wrongPassword = Date.now();
30
Larbi Gharibb38e3542022-12-07 06:09:10 -050031 cy.visit(Cypress.env('CLIENT_URL'));
32
33 cy.url().should('include', '/login');
34
35 cy.get('[data-cy = "username-input"]')
36 .type(Cypress.env('TEST_USERNAME'))
37 .find('input')
38 .should('have.value', Cypress.env('TEST_USERNAME'));
39
40 cy.get('[data-cy = "password-input"]')
Ziwei Wang207ae8e2023-04-03 13:02:31 -040041 .type(wrongPassword.toString())
Larbi Gharibb38e3542022-12-07 06:09:10 -050042 .find('input')
Ziwei Wang207ae8e2023-04-03 13:02:31 -040043 .should('have.value', wrongPassword.toString());
Larbi Gharibb38e3542022-12-07 06:09:10 -050044
45 cy.get('[data-cy="login-button"]').contains('Log in').click();
46
idillon440e5302023-08-03 20:25:24 -040047 cy.get('.MuiAlert-message').contains('Invalid credentials');
Ziwei Wang207ae8e2023-04-03 13:02:31 -040048 });
Larbi Gharibb38e3542022-12-07 06:09:10 -050049
Ziwei Wang207ae8e2023-04-03 13:02:31 -040050 it('log in without UI', () => {
51 cy.loginWithoutUI();
Larbi Gharibb38e3542022-12-07 06:09:10 -050052
Ziwei Wang207ae8e2023-04-03 13:02:31 -040053 cy.logoutViaUI();
Larbi Gharibb38e3542022-12-07 06:09:10 -050054 });
55});