Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add validation when a password is generated #2640

Merged
merged 5 commits into from
May 23, 2024

Conversation

EMaksy
Copy link
Member

@EMaksy EMaksy commented May 21, 2024

Description

This pr aims to improve the password generation in order to support our password rules, as the current implementation has a very unlikely case not to meet the requirements.

Password Rules:

  • at least have 8 characters --> added validation to check for minimum length
  • does not have 3 consecutive repeated numbers or letters (example: 111 or aaa) --> added validation for repetitive chars by using a regex rule, which checks for any character that appears three or more times consecutively in a string.
  • does not have 3 consecutive sequential numbers or letters (example: 123 or abc) --> added ASCII code validation for sequence of chars ascending and descending, exluding special chars to allow combinations like 89: or yz{

Also, this pr will ensure the unlikely case that e2e test fail if the generated password does not meet the requirements
It is a follow-up to @rtorrero comment: #2576 (comment)

How was this tested?

Added test for validation functions

@EMaksy EMaksy added enhancement New feature or request javascript Pull requests that update Javascript code labels May 21, 2024
@EMaksy EMaksy self-assigned this May 21, 2024
@EMaksy EMaksy marked this pull request as ready for review May 21, 2024 11:43
Copy link
Contributor

@arbulu89 arbulu89 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @EMaksy
Some comments.

@EMaksy EMaksy force-pushed the improve_generate_password branch 2 times, most recently from b15b788 to 35cc53a Compare May 22, 2024 15:38
Copy link
Contributor

@arbulu89 arbulu89 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really good!
Some comments in the tests, but good to go

expect(firstPassword).not.toBe(secondPassword);
});
});
describe('isValidPassword', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would put some new lines between describe and test entries

assets/js/pages/Users/generatePassword.test.js Outdated Show resolved Hide resolved
@EMaksy EMaksy merged commit fc8734d into user_management May 23, 2024
26 checks passed
@EMaksy EMaksy deleted the improve_generate_password branch May 23, 2024 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request javascript Pull requests that update Javascript code
Development

Successfully merging this pull request may close these issues.

None yet

3 participants