Example #1
0
 def test_PasswordSchema_password_equal_to_max(self):
     password = fake.pystr(
         min_chars=Limits.MAX_USER_PASSWORD_LENGTH,
         max_chars=Limits.MAX_USER_PASSWORD_LENGTH,
     )
     body = get_mock_password_body(password=password)
     errors = password_schema.validate(body)
     assert not errors
Example #2
0
 def test_PasswordSchema_no_password(self):
     body = get_mock_password_body()
     del body["password"]
     errors = password_schema.validate(body)
     assert errors == {
         "password": [
             "Missing data for required field.",
         ],
     }
Example #3
0
 def test_PasswordSchema_password_greater_than_max(self):
     password = fake.pystr(
         min_chars=Limits.MAX_USER_PASSWORD_LENGTH + 1,
         max_chars=Limits.MAX_USER_PASSWORD_LENGTH + 1,
     )
     body = get_mock_password_body(password=password)
     errors = password_schema.validate(body)
     assert errors == {
         "password": [
             f"Length must be between {Limits.MIN_USER_PASSWORD_LENGTH} "
             f"and {Limits.MAX_USER_PASSWORD_LENGTH}.",
         ],
     }
Example #4
0
 def test_PasswordSchema_unrecognised_field(self):
     body = get_mock_password_body()
     key = fake.pystr()
     body[key] = fake.pystr()
     assert not password_schema.validate(body)
     assert key not in password_schema.dump(body)