/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to brzlib/tests/https_server.py

  • Committer: Jelmer Vernooij
  • Date: 2017-05-21 12:41:27 UTC
  • mto: This revision was merged to the branch mainline in revision 6623.
  • Revision ID: jelmer@jelmer.uk-20170521124127-iv8etg0vwymyai6y
s/bzr/brz/ in apport config.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
"""HTTPS test server, available when ssl python module is available"""
18
18
 
19
19
import ssl
 
20
import sys
20
21
 
21
 
from . import (
 
22
from brzlib.tests import (
22
23
    http_server,
23
24
    ssl_certs,
24
25
    test_server,
31
32
        self.key_file = key_file
32
33
        self.cert_file = cert_file
33
34
 
34
 
    def _get_ssl_request(self, sock, addr):
 
35
    def _get_ssl_request (self, sock, addr):
35
36
        """Wrap the socket with SSL"""
36
37
        ssl_sock = ssl.wrap_socket(sock, server_side=True,
37
38
                                   keyfile=self.key_file,
50
51
        if serving:
51
52
            try:
52
53
                request.do_handshake()
53
 
            except ssl.SSLError:
 
54
            except ssl.SSLError, e:
54
55
                # FIXME: We proabaly want more tests to capture which ssl
55
56
                # errors are worth reporting but mostly our tests want an https
56
57
                # server that works -- vila 2012-01-19
58
59
        return serving
59
60
 
60
61
    def ignored_exceptions_during_shutdown(self, e):
 
62
        if (sys.version < (2, 7) and isinstance(e, TypeError)
 
63
            and e.args[0] == "'member_descriptor' object is not callable"):
 
64
            # Fixed in python-2.7 (and some Ubuntu 2.6) there is a bug where
 
65
            # the ssl socket fail to raise a socket.error when trying to read
 
66
            # from a closed socket. This is rarely observed in practice but
 
67
            # still make valid selftest runs fail if not caught.
 
68
            return True
61
69
        base = test_server.TestingTCPServerMixin
62
70
        return base.ignored_exceptions_during_shutdown(self, e)
63
71
 
126
134
 
127
135
    # urls returned by this server should require the urllib client impl
128
136
    _url_protocol = 'https+urllib'
 
137
 
 
138
 
 
139
class HTTPSServer_PyCurl(HTTPSServer):
 
140
    """Subclass of HTTPSServer that gives http+pycurl urls.
 
141
 
 
142
    This is for use in testing: connections to this server will always go
 
143
    through pycurl where possible.
 
144
    """
 
145
 
 
146
    # We don't care about checking the pycurl availability as
 
147
    # this server will be required only when pycurl is present
 
148
 
 
149
    # urls returned by this server should require the pycurl client impl
 
150
    _url_protocol = 'https+pycurl'