コード例 #1
0
ファイル: test_validators.py プロジェクト: brightcove/shhh
    def test_secret(self):
        not_valid = (None, "", 151 * "*")
        with self.assertRaises(ValidationError):
            for s in not_valid:
                Validator.secret(s)

        self.assertIsNone(Validator.secret(30 * "*"))
コード例 #2
0
ファイル: test_validators.py プロジェクト: brightcove/shhh
    def test_tries(self):
        not_valid = (-1, 0, 2, 11)
        with self.assertRaises(ValidationError):
            for t in not_valid:
                Validator.tries(t)

        for t in range(3, 11):
            self.assertIsNone(Validator.tries(t))
コード例 #3
0
ファイル: test_validators.py プロジェクト: brightcove/shhh
    def test_days(self):
        not_valid = (-1, 0, 8, 10)
        with self.assertRaises(ValidationError):
            for d in not_valid:
                Validator.days(d)

        for d in range(1, 8):
            self.assertIsNone(Validator.days(d))
コード例 #4
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"))
コード例 #5
0
ファイル: test_validators.py プロジェクト: smallwat3r/shhh
    def test_secret(self):
        # We need the app context as we need to access the app config
        app = create_app(env="testing")
        app_context = app.app_context()
        app_context.push()

        not_valid = (None, "", 251 * "*")
        for s in not_valid:
            with self.assertRaises(ValidationError):
                Validator.secret(s)

        self.assertIsNone(Validator.secret(30 * "*"))
コード例 #6
0
ファイル: test_validators.py プロジェクト: brightcove/shhh
    def test_strength(self):
        not_valid = (
            "weak",
            "Weak",
            "Weak1",
            "weak_but_long",
            "weak_but_long_1",
            "Weak_but_long",
        )
        with self.assertRaises(ValidationError):
            for word in not_valid:
                Validator.strength(word)

        self.assertIsNone(Validator.strength("UPPERlower9211"))
コード例 #7
0
 def haveibeenpwned_checker(self, data, **kwargs):
     """Check the passphrase against haveibeenpwned if set to true."""
     if data.get("haveibeenpwned"):
         Validator.haveibeenpwned(data["passphrase"])
コード例 #8
0
ファイル: test_validators.py プロジェクト: brightcove/shhh
 def test_slug(self):
     not_valid = (None, "")
     with self.assertRaises(ValidationError):
         for s in not_valid:
             Validator.slug(s)
コード例 #9
0
ファイル: test_validators.py プロジェクト: brightcove/shhh
 def test_passphrase(self):
     not_valid = (None, "")
     with self.assertRaises(ValidationError):
         for s in not_valid:
             Validator.passphrase(s)
コード例 #10
0
ファイル: test_validators.py プロジェクト: smallwat3r/shhh
 def test_tries(self):
     not_valid = (0, -1, 15)
     for tries in not_valid:
         with self.assertRaises(ValidationError):
             Validator.tries(tries)
コード例 #11
0
ファイル: test_validators.py プロジェクト: smallwat3r/shhh
 def test_expire(self):
     not_valid = ("80d", "3.5m", "1y", "0", "i do not exist", 23)
     for expire in not_valid:
         with self.assertRaises(ValidationError):
             Validator.expire(expire)