Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
describe('user authentication', () => {
beforeEach(() => {
cy.visit(window.location.origin);
})
//edit profile bug
it('should block unauthenticated user from entering a protected route', () => {
cy.checkProtectedRoutes();
});
it('should display login errors when nothing is typed', () => {
cy.get(':nth-child(1) > .nav-link').click();
cy.location("pathname").should("equal", '/services');
cy.get('.btn').should("contain", "Sign In").click();
cy.origin('https://portal.openslice.eu', () => {
cy.location("pathname").should("equal", "/auth/realms/openslice/protocol/openid-connect/auth");
cy.get('#kc-login').click();
cy.get('#input-error').should('be.visible').and('contain','Invalid username or password.');
cy.get('[aria-invalid="true"]').should('have.length', 2); //the 2 input fields should have selector aria-invalid = 'true'
});
});
it('should display login errors when credentials are wrong', () => {
cy.get(':nth-child(1) > .nav-link').click();
cy.location("pathname").should("equal", '/services');
cy.get('.btn').should("contain", "Sign In").click();
cy.origin('https://portal.openslice.eu', () => {
cy.location("pathname").should("equal", "/auth/realms/openslice/protocol/openid-connect/auth");
cy.get('#username').type('test').blur();
cy.get('#password').type('test').blur();
cy.get('#kc-login').click();
cy.get('#input-error').should('be.visible').and('contain','Invalid username or password.');
cy.get('[aria-invalid="true"]').should('have.length', 2); //the 2 input fields should have selector aria-invalid = 'true'
});
});
it('should login, logout', () => {
cy.loginPath(':nth-child(2) > .container > .row > :nth-child(2) > a > .btn', '/services');
cy.get('#navbarDropdown2').click();
cy.window().then((win) => {
expect(win.localStorage.getItem('access_token')).to.exist;
})
cy.get(':nth-child(2) > .dropdown > .dropdown-menu > :nth-child(8)').click();
cy.location("pathname").should("equal", "/");
});
it.skip('forget password should work', () => {
cy.get(':nth-child(1) > .nav-link').click();
cy.location("pathname").should("equal", '/services');
cy.get('.btn').should("contain", "Sign In").click();
cy.origin('https://portal.openslice.eu', () => {
cy.location("pathname").should("equal", "/auth/realms/openslice/protocol/openid-connect/auth");
cy.get(':nth-child(2) > span > a').click();
cy.location("pathname").should("equal", "/auth/realms/openslice/login-actions/reset-credentials");
cy.get('#username').should('exist');
});
});
context('register form', () => {
beforeEach(() => {
cy.get(':nth-child(1) > .nav-link').click();
cy.location("pathname").should("equal", '/services');
cy.get('.btn').should("contain", "Sign In").click();
cy.origin('https://portal.openslice.eu', () => {
cy.location("pathname").should("equal", "/auth/realms/openslice/protocol/openid-connect/auth");
cy.get('#kc-registration > span > a').click();
cy.location("pathname").should("equal", "/auth/realms/openslice/login-actions/registration");
});
})
it('register form should not be empty when submitted', () => {
cy.origin('https://portal.openslice.eu/auth/realms/openslice/login-actions/registration', () => {
cy.get('.pf-c-button').click();
cy.get('#input-error-firstname').should('exist').and('contain', 'Please specify first name.');
cy.get('#input-error-lastname').should('exist').and('contain', 'Please specify last name.');
cy.get('#input-error-email').should('exist').and('contain', 'Please specify email.');
cy.get('#input-error-username').should('exist').and('contain', 'Please specify username.');
cy.get('#input-error-password').should('exist').and('contain', 'Please specify password.');
});
});
it('invalid email', () => {
cy.origin('https://portal.openslice.eu/auth/realms/openslice/login-actions/registration', () => {
cy.get('#email').type('email');
cy.get('.pf-c-button').click();
cy.get('#input-error-email').should('exist').and('contain','Invalid email address.');
cy.get('#email').type('@example.com');
cy.get('.pf-c-button').click();
cy.get('#input-error-email').should('not.exist');
});
});
it('confirm password field should be the same with password', () => {
cy.origin('https://portal.openslice.eu/auth/realms/openslice/login-actions/registration', () => {
cy.get('#password').type('123');
cy.get('#password-confirm').type('1234');
cy.get('.pf-c-button').click();
cy.get('#input-error-password-confirm').should('exist').and('contain',"Password confirmation doesn't match.");
cy.get('#password').type('123');
cy.get('#password-confirm').type('123');
cy.get('.pf-c-button').click();
cy.get('#input-error-password-confirm').should('not.exist');
});
});
})
})