Making Test Suites
We have improved the validation functions validateUsername and validatePassword adding the following rules for the username and password respectively:
- The username should be between 3 and 20 characters in length and it can only contain alphanumeric characters.
- The password should be at least 8 characters long and it should contain a combination of lower and uppercase letters along with at least one number or symbol;
Your task is to:
- Organize the test cases present in
validation.jsTest Script, into appropriate describe blocks. - Write test cases to test case code in
auth.js. Make sure to enclose the test cases in properdescribeblocks;
Following are the test cases you have to write in the __test__/auth.js file:
Test ID: 1
- Title: Hash a valid password;
- Precondition: The hashPassword function is available;
- Test Steps:
- Pass the string 'examplePassword123' to the hashPassword function;
- Expected Result: The function should return a string that is different from the input password;
Test ID: 2
- Title: Hash an empty password;
- Precondition: The hashPassword function is available;
- Test Steps:
- Pass an empty string '' to the hashPassword function;
- Expected Result: The function should return a non-empty string;
Test ID: 3
- Title: Compare a valid password with its correct hash;
- Precondition: The comparePassword and hashPassword functions are available;
- Test Steps:
- Hash the string 'examplePassword123' using the hashPassword function;
- Pass the original password 'examplePassword123' and the generated hash to the comparePassword function;
- Expected Result: The function should return true, indicating the password matches the hash;
Test ID: 4
- Title: Compare a valid password with an incorrect hash;
- Precondition: The comparePassword and hashPassword functions are available;
- Test Steps:
- Hash the string 'examplePassword123' using the hashPassword function;
- Pass a different password 'wrongPassword456' and the generated hash to the comparePassword function;
- Expected Result: The function should return false, indicating the password does not match the hash;
Tutto è chiaro?
Grazie per i tuoi commenti!
Sezione 2. Capitolo 8
Chieda ad AI
Chieda ad AI
Chieda pure quello che desidera o provi una delle domande suggerite per iniziare la nostra conversazione
Fantastico!
Completion tasso migliorato a 3.85
Making Test Suites
Scorri per mostrare il menu
We have improved the validation functions validateUsername and validatePassword adding the following rules for the username and password respectively:
- The username should be between 3 and 20 characters in length and it can only contain alphanumeric characters.
- The password should be at least 8 characters long and it should contain a combination of lower and uppercase letters along with at least one number or symbol;
Your task is to:
- Organize the test cases present in
validation.jsTest Script, into appropriate describe blocks. - Write test cases to test case code in
auth.js. Make sure to enclose the test cases in properdescribeblocks;
Following are the test cases you have to write in the __test__/auth.js file:
Test ID: 1
- Title: Hash a valid password;
- Precondition: The hashPassword function is available;
- Test Steps:
- Pass the string 'examplePassword123' to the hashPassword function;
- Expected Result: The function should return a string that is different from the input password;
Test ID: 2
- Title: Hash an empty password;
- Precondition: The hashPassword function is available;
- Test Steps:
- Pass an empty string '' to the hashPassword function;
- Expected Result: The function should return a non-empty string;
Test ID: 3
- Title: Compare a valid password with its correct hash;
- Precondition: The comparePassword and hashPassword functions are available;
- Test Steps:
- Hash the string 'examplePassword123' using the hashPassword function;
- Pass the original password 'examplePassword123' and the generated hash to the comparePassword function;
- Expected Result: The function should return true, indicating the password matches the hash;
Test ID: 4
- Title: Compare a valid password with an incorrect hash;
- Precondition: The comparePassword and hashPassword functions are available;
- Test Steps:
- Hash the string 'examplePassword123' using the hashPassword function;
- Pass a different password 'wrongPassword456' and the generated hash to the comparePassword function;
- Expected Result: The function should return false, indicating the password does not match the hash;
Tutto è chiaro?
Grazie per i tuoi commenti!
Sezione 2. Capitolo 8