From cbadad29e19d25fecbe60fb29d8637974b8413d3 Mon Sep 17 00:00:00 2001 From: DELLIE Date: Thu, 24 Sep 2026 09:56:56 +0000 Subject: [PATCH] Fix password validator uppercase validation --- .../password-validator/PASSWORD_VALIDATOR.py | 2 +- .../test_password_validator.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 PASSWORD RELATED/password-validator/test_password_validator.py 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