forked from mattermost/mattermost-webapp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
authentication_2_spec.js
179 lines (124 loc) · 6.48 KB
/
authentication_2_spec.js
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// ***************************************************************
// - [#] indicates a test step (e.g. # Go to a page)
// - [*] indicates an assertion (e.g. * Check the title)
// - Use element ID when selecting an element. Create one if none.
// ***************************************************************
// Stage: @prod
// Group: @system_console @authentication @mfa
import * as TIMEOUTS from '../../fixtures/timeouts';
import {getRandomId} from '../../utils';
describe('Authentication', () => {
beforeEach(() => {
// # Log in as admin.
cy.apiAdminLogin();
});
it('MM-T1771 - Minimum password length error field shows below 5 and above 64', () => {
cy.visit('/admin_console/authentication/password');
cy.findByPlaceholderText('E.g.: "5"', {timeout: TIMEOUTS.ONE_MIN}).clear().type('88');
cy.findByText('Save').click();
// * Ensure error appears when saving a password outside of the limits
cy.findByText('Minimum password length must be a whole number greater than or equal to 5 and less than or equal to 64.', {timeout: TIMEOUTS.ONE_MIN}).
should('exist').
and('be.visible');
cy.findByPlaceholderText('E.g.: "5"').clear().type('3');
cy.findByText('Save').click();
// * Ensure error appears when saving a password outside of the limits
cy.findByText('Minimum password length must be a whole number greater than or equal to 5 and less than or equal to 64.', {timeout: TIMEOUTS.ONE_MIN}).
should('exist').
and('be.visible');
});
it('MM-T1772 - Change minimum password length, verify help text and error message', () => {
cy.visit('/admin_console/authentication/password');
cy.findByPlaceholderText('E.g.: "5"', {timeout: TIMEOUTS.ONE_MIN}).clear().type('7');
cy.findByRole('button', {name: 'Save'}).click();
cy.findByText('Your password must contain between 7 and 64 characters.').should('be.visible');
cy.apiLogout();
// # Go to sign up with email page
cy.visit('/signup_email');
cy.get('#email', {timeout: TIMEOUTS.ONE_MIN}).type(`Hossein_Is_The_Best_PROGRAMMER${getRandomId()}@BestInTheWorld.com`);
cy.get('#name').clear().type(`BestUsername${getRandomId()}`);
cy.get('#password').clear().type('less');
cy.findByText('Create Account').click();
// * Assert the error is what is expected;
cy.findByText('Your password must contain between 7 and 64 characters.').should('be.visible');
cy.get('#password').clear().type('greaterthan7');
cy.findByText('Create Account').click();
// * Assert that we are not shown an MFA screen and instead a Teams You Can join page
cy.findByText('Teams you can join:', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible');
});
it('MM-T1773 - Minimum password length field resets to default after saving invalid value', () => {
cy.visit('/admin_console/authentication/password');
cy.findByPlaceholderText('E.g.: "5"', {timeout: TIMEOUTS.ONE_MIN}).clear().type('10');
cy.findByRole('button', {name: 'Save'}).click();
cy.reload();
// * Ensure the limit 10 appears
cy.findByPlaceholderText('E.g.: "5"').invoke('val').should('equal', '10');
cy.findByPlaceholderText('E.g.: "5"').clear();
cy.findByRole('button', {name: 'Save'}).click();
// * Ensure the limit 10 appears
cy.findByPlaceholderText('E.g.: "5"').invoke('val').should('equal', '5');
});
it('MM-T1774 - Select all Password Requirements, verify help text and error on bad password', () => {
cy.apiUpdateConfig({
PasswordSettings: {
Lowercase: true,
Number: true,
Uppercase: true,
Symbol: true,
},
});
cy.apiLogout();
// # Go to sign up with email page
cy.visit('/signup_email');
cy.get('#email', {timeout: TIMEOUTS.ONE_MIN}).type(`Hossein_Is_The_Best_PROGRAMMER${getRandomId()}@BestInTheWorld.com`);
cy.get('#name').clear().type(`BestUsernameInTheWorld${getRandomId()}`);
['NOLOWERCASE123!', 'noupppercase123!', 'NoNumber!', 'NoSymbol123'].forEach((option) => {
cy.get('#password').clear().type(option);
cy.findByText('Create Account').click();
// * Assert the error is what is expected;
cy.findByText('Your password must contain between 5 and 64 characters made up of at least one lowercase letter, at least one uppercase letter, at least one number, and at least one symbol (e.g. "~!@#$%^&*()").').should('be.visible');
});
});
it('MM-T1777 - Multi-factor Authentication option hidden in Account Settings when disabled', () => {
cy.apiUpdateConfig({
ServiceSettings: {
EnableMultifactorAuthentication: false,
},
});
cy.visit('/');
cy.toAccountSettingsModal();
cy.findByLabelText('security').click();
// * Assert that Multifactor Authentication text does not exist
cy.findByText('Multi-factor Authentication').should('not.exist');
});
it('MM-T1779 - Multi-factor Authentication option appears in Account Settings when enabled', () => {
cy.apiUpdateConfig({
ServiceSettings: {
EnableMultifactorAuthentication: true,
},
});
cy.visit('/');
cy.toAccountSettingsModal();
cy.findByLabelText('security').click();
// * Assert that Multifactor Authentication text does exist
cy.findByText('Multi-factor Authentication').should('be.visible');
});
it('MM-T1780 - Multi-factor Authentication false: User can log in without being prompted for MFA', () => {
cy.apiUpdateConfig({
ServiceSettings: {
EnableMultifactorAuthentication: true,
EnforceMultifactorAuthentication: false,
},
});
cy.apiCreateUser().then(({user: newUser}) => {
cy.apiLogout();
// # Login as a new user and visit default page
cy.apiLogin(newUser);
cy.visit('/');
// * Assert that we are not shown a MFA screen and instead a Teams You Can join page
cy.findByText('Teams you can join:', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible');
});
});
});