diff --git a/src/fides/api/schemas/user.py b/src/fides/api/schemas/user.py index c1c538dfa5..91a1a0e102 100644 --- a/src/fides/api/schemas/user.py +++ b/src/fides/api/schemas/user.py @@ -10,7 +10,6 @@ from fides.api.schemas.oauth import AccessToken - class PrivacyRequestReviewer(FidesSchema): """Data we can expose via the PrivacyRequest.reviewer relation""" @@ -38,13 +37,13 @@ def validate_username(cls, username: str) -> str: @field_validator("password") @classmethod - def validate_password(cls, password: str) -> str: + def validate_password_field(cls, password: str) -> str: """Add some password requirements""" decoded_password = decode_password(password) - return UserCreate._validate_password(decoded_password) + return UserCreate.validate_password(decoded_password) @staticmethod - def _validate_password(password: str) -> str: + def validate_password(password: str) -> str: """ Validate password requirements. Raises: @@ -54,7 +53,7 @@ def _validate_password(password: str) -> str: """ if len(password) < 8: raise ValueError("Password must have at least eight characters.") - if re.search("[\d]", password) is None: + if re.search(r"[\d]", password) is None: raise ValueError("Password must have at least one number.") if re.search("[A-Z]", password) is None: raise ValueError("Password must have at least one capital letter.") @@ -118,7 +117,7 @@ class UserPasswordReset(FidesSchema): def validate_new_password(cls, password: str) -> str: """Add some password requirements""" decoded_password = decode_password(password) - return UserCreate._validate_password(decoded_password) + return UserCreate.validate_password(decoded_password) class UserForcePasswordReset(FidesSchema): @@ -131,7 +130,7 @@ class UserForcePasswordReset(FidesSchema): def validate_new_password(cls, password: str) -> str: """Add some password requirements""" decoded_password = decode_password(password) - return UserCreate._validate_password(decoded_password) + return UserCreate.validate_password(decoded_password) class UserUpdate(FidesSchema): diff --git a/tests/ops/api/v1/endpoints/test_user_endpoints.py b/tests/ops/api/v1/endpoints/test_user_endpoints.py index 7d1f16078d..665f3b4071 100644 --- a/tests/ops/api/v1/endpoints/test_user_endpoints.py +++ b/tests/ops/api/v1/endpoints/test_user_endpoints.py @@ -987,9 +987,18 @@ def test_force_update_different_user_password( [ ("short", "Value error, Password must have at least eight characters."), ("longerpassword", "Value error, Password must have at least one number."), - ("longer55password", "Value error, Password must have at least one capital letter."), - ("LONGER55PASSWORD", "Value error, Password must have at least one lowercase letter."), - ("LoNgEr55paSSworD", "Value error, Password must have at least one symbol."), + ( + "longer55password", + "Value error, Password must have at least one capital letter.", + ), + ( + "LONGER55PASSWORD", + "Value error, Password must have at least one lowercase letter.", + ), + ( + "LoNgEr55paSSworD", + "Value error, Password must have at least one symbol.", + ), ], ) def test_force_update_bad_password(