def test_haveibeenpwned(self, mock_pwned): with self.assertRaises(ValidationError): mock_pwned.return_value = 123 Validator.haveibeenpwned("Hello123") mock_pwned.side_effect = Exception Validator.haveibeenpwned("Hello123j0e32hf") mock_pwned.return_value = False self.assertIsNone(Validator.haveibeenpwned("cjHeW9ihf9u43f9u4b3"))
def haveibeenpwned_checker(self, data, **kwargs): """Check the passphrase against haveibeenpwned if set to true.""" if data.get("haveibeenpwned"): Validator.haveibeenpwned(data["passphrase"])