示例#1
0
 def test_wildcard_must_be_left_most(self):
     """
     Raise CertificateError if wildcard is not in the left-most part.
     """
     for hn in [b"foo.b*r.com", b"foo.bar.c*m", b"foo.*", b"foo.*.com"]:
         with pytest.raises(CertificateError):
             _validate_pattern(hn)
示例#2
0
 def test_wildcard_must_be_left_most(self):
     """
     Raise CertificateError if wildcard is not in the left-most part.
     """
     for hn in [b"foo.b*r.com", b"foo.bar.c*m", b"foo.*", b"foo.*.com"]:
         with pytest.raises(CertificateError):
             _validate_pattern(hn)
示例#3
0
 def test_valid_patterns(self):
     """
     Does not throw CertificateError on valid patterns.
     """
     for pattern in [
         b"*.bar.com",
         b"*oo.bar.com",
         b"f*.bar.com",
         b"f*o.bar.com"
     ]:
         _validate_pattern(pattern)
示例#4
0
 def test_valid_patterns(self):
     """
     Does not throw CertificateError on valid patterns.
     """
     for pattern in [
         b"*.bar.com",
         b"*oo.bar.com",
         b"f*.bar.com",
         b"f*o.bar.com"
     ]:
         _validate_pattern(pattern)
示例#5
0
 def test_must_have_at_least_three_parts(self):
     """
     Raise CertificateError if host consists of less than three parts.
     """
     for hn in [
         b"*",
         b"*.com",
         b"*fail.com",
         b"*foo",
         b"foo*",
         b"f*o",
         b"*.example.",
     ]:
         with pytest.raises(CertificateError):
             _validate_pattern(hn)
示例#6
0
 def test_must_have_at_least_three_parts(self):
     """
     Raise CertificateError if host consists of less than three parts.
     """
     for hn in [
         b"*",
         b"*.com",
         b"*fail.com",
         b"*foo",
         b"foo*",
         b"f*o",
         b"*.example.",
     ]:
         with pytest.raises(CertificateError):
             _validate_pattern(hn)
示例#7
0
 def test_allows_only_one_wildcard(self):
     """
     Raise CertificateError on multiple wildcards.
     """
     with pytest.raises(CertificateError):
         _validate_pattern(b"*.*.com")
示例#8
0
 def test_allows_only_one_wildcard(self):
     """
     Raise CertificateError on multiple wildcards.
     """
     with pytest.raises(CertificateError):
         _validate_pattern(b"*.*.com")