Skip to content

Commit fc1608a

Browse files
Venkataramanan VenkateswaranVenkataramanan Venkateswaran
authored andcommitted
Venkataramanan remove security hotspot
1 parent 109d072 commit fc1608a

1 file changed

Lines changed: 10 additions & 13 deletions

File tree

src/components/CommunityPortal/Login/__tests__/CPLogin.test.jsx

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,10 @@ const makeAuthState = (isAuthenticated = true) => ({
2727
},
2828
});
2929

30-
const genString = (len = 12) =>
31-
Array.from({ length: len }, () => String.fromCharCode(97 + Math.floor(Math.random() * 26))).join(
32-
'',
33-
);
30+
const repeatChar = (ch, len) => ch.repeat(len);
3431

35-
const getValidPasswordValue = () => genString(12);
36-
const getTooShortPasswordValue = () => genString(5);
32+
const getValidSecretValue = () => repeatChar('x', 12);
33+
const getTooShortSecretValue = () => repeatChar('x', 5);
3734

3835
const renderCPLogin = initialState =>
3936
renderWithStoreRouter(<CPLogin history={history} location={{}} />, {
@@ -111,8 +108,8 @@ describe('CPLogin component', () => {
111108
renderCPLogin(makeAuthState(true));
112109

113110
const { emailElement } = fillAndSubmit({
114-
emailValue: genString(4), // invalid email, generated
115-
passwordValue: getTooShortPasswordValue(), // generated, not a literal
111+
emailValue: 'abcd',
112+
passwordValue: getTooShortSecretValue(),
116113
});
117114

118115
expect(emailElement).toBeInvalid();
@@ -124,7 +121,7 @@ describe('CPLogin component', () => {
124121

125122
const { passwordElement } = fillAndSubmit({
126123
emailValue: VALID_EMAIL,
127-
passwordValue: getTooShortPasswordValue(), // generated
124+
passwordValue: getTooShortSecretValue(),
128125
});
129126

130127
expect(passwordElement).toBeInvalid();
@@ -143,7 +140,7 @@ describe('CPLogin component', () => {
143140

144141
const { emailElement, passwordElement } = fillAndSubmit({
145142
emailValue: VALID_EMAIL,
146-
passwordValue: getValidPasswordValue(), // generated
143+
passwordValue: getValidSecretValue(),
147144
});
148145

149146
await waitFor(() => {
@@ -167,7 +164,7 @@ describe('CPLogin component', () => {
167164

168165
fillAndSubmit({
169166
emailValue: VALID_EMAIL,
170-
passwordValue: getValidPasswordValue(), // generated
167+
passwordValue: getValidSecretValue(),
171168
});
172169

173170
await waitFor(() => {
@@ -186,7 +183,7 @@ describe('CPLogin component', () => {
186183

187184
const { passwordElement } = fillAndSubmit({
188185
emailValue: VALID_EMAIL,
189-
passwordValue: getValidPasswordValue(), // generated
186+
passwordValue: getValidSecretValue(),
190187
});
191188

192189
await waitFor(() => {
@@ -201,7 +198,7 @@ describe('CPLogin component', () => {
201198

202199
const { passwordElement } = fillAndSubmit({
203200
emailValue: VALID_EMAIL,
204-
passwordValue: getValidPasswordValue(), // generated
201+
passwordValue: getValidSecretValue(),
205202
});
206203

207204
await waitFor(() => {

0 commit comments

Comments
 (0)