~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_https_urllib.py

  • Committer: Vincent Ladeuil
  • Date: 2013-05-27 10:22:27 UTC
  • mfrom: (6571.2.1 cmdline-empty-quotes)
  • mto: This revision was merged to the branch mainline in revision 6578.
  • Revision ID: v.ladeuil+lp@free.fr-20130527102227-qfc5dwoz41j5fk1z
Finish cleanup including merging original Ross fix

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")