~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_https_urllib.py

  • Committer: Patch Queue Manager
  • Date: 2014-10-06 16:32:42 UTC
  • mfrom: (6597.2.4 split-diff-tests)
  • Revision ID: pqm@pqm.ubuntu.com-20141006163242-c2cll01cwc24grkk
(vila) Split some tests to be able to get finer grained failures (Vincent
 Ladeuil)

Show diffs side-by-side

added added

removed removed

Lines of Context:
88
88
        self.assertRaises(ValueError,
89
89
                          _urllib2_wrappers.match_hostname, {}, "example.com")
90
90
 
 
91
    def test_wildcards_in_cert(self):
 
92
        def ok(cert, hostname):
 
93
            _urllib2_wrappers.match_hostname(cert, hostname)
 
94
 
 
95
        # Python Issue #17980: avoid denials of service by refusing more than
 
96
        # one wildcard per fragment.
 
97
        cert = {'subject': ((('commonName', 'a*b.com'),),)}
 
98
        ok(cert, 'axxb.com')
 
99
        cert = {'subject': ((('commonName', 'a*b.co*'),),)}
 
100
        ok(cert, 'axxb.com')
 
101
        cert = {'subject': ((('commonName', 'a*b*.com'),),)}
 
102
        try:
 
103
            _urllib2_wrappers.match_hostname(cert, 'axxbxxc.com')
 
104
        except ValueError as e:
 
105
            self.assertIn("too many wildcards", str(e))
 
106
 
91
107
    def test_no_valid_attributes(self):
92
108
        self.assertRaises(CertificateError, _urllib2_wrappers.match_hostname,
93
109
                          {"Problem": "Solved"}, "example.com")