コード例 #1
0
ファイル: test_validators.py プロジェクト: brightcove/shhh
    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"))
コード例 #2
0
 def haveibeenpwned_checker(self, data, **kwargs):
     """Check the passphrase against haveibeenpwned if set to true."""
     if data.get("haveibeenpwned"):
         Validator.haveibeenpwned(data["passphrase"])