diff --git a/PASSWORD RELATED/password-validator/PASSWORD_VALIDATOR.py b/PASSWORD RELATED/password-validator/PASSWORD_VALIDATOR.py index 76dfbef5..ec06ba8e 100644 --- a/PASSWORD RELATED/password-validator/PASSWORD_VALIDATOR.py +++ b/PASSWORD RELATED/password-validator/PASSWORD_VALIDATOR.py @@ -24,7 +24,7 @@ def passwordValidator(): if ' ' in userPassword: message = 'Invalid Password..your password shouldn\'t contain space(s)' return message - if not any(i in string.ascii_letters for i in userPassword): + if not any(i in string.ascii_uppercase for i in userPassword): message = 'Invalid Password..your password should contain at least ' message += 'an uppercase letter and a lowercase letter' return message diff --git a/PASSWORD RELATED/password-validator/test_password_validator.py b/PASSWORD RELATED/password-validator/test_password_validator.py new file mode 100644 index 00000000..aa5d4aa8 --- /dev/null +++ b/PASSWORD RELATED/password-validator/test_password_validator.py @@ -0,0 +1,16 @@ +import unittest +from unittest.mock import patch + + +class TestPasswordValidator(unittest.TestCase): + + def test_password_must_contain_uppercase(self): + with patch("builtins.input", return_value="abcdef1!"): + from PASSWORD_VALIDATOR import passwordValidator + result = passwordValidator() + + self.assertIn("Invalid Password", result) + + +if __name__ == "__main__": + unittest.main() \ No newline at end of file