70
68
from bzrlib.transport.http._pycurl import PyCurlTransport
73
load_tests = load_tests_from_their_variations
76
class VaryByHttpClientImplementation(TestVariation):
71
load_tests = load_tests_from_scenarios
74
def vary_by_http_client_implementation():
77
75
"""Test the two libraries we can use, pycurl and urllib."""
80
transport_scenarios = [
81
('urllib', dict(_transport=_urllib.HttpTransport_urllib,
82
_server=http_server.HttpServer_urllib,
83
_url_protocol='http+urllib',)),
85
if features.pycurl.available():
86
transport_scenarios.append(
87
('pycurl', dict(_transport=PyCurlTransport,
88
_server=http_server.HttpServer_PyCurl,
89
_url_protocol='http+pycurl',)))
90
return transport_scenarios
93
class VaryByHttpProtocolVersion(TestVariation):
76
transport_scenarios = [
77
('urllib', dict(_transport=_urllib.HttpTransport_urllib,
78
_server=http_server.HttpServer_urllib,
79
_url_protocol='http+urllib',)),
81
if features.pycurl.available():
82
transport_scenarios.append(
83
('pycurl', dict(_transport=PyCurlTransport,
84
_server=http_server.HttpServer_PyCurl,
85
_url_protocol='http+pycurl',)))
86
return transport_scenarios
89
def vary_by_http_protocol_version():
94
90
"""Test on http/1.0 and 1.1"""
98
('HTTP/1.0', dict(_protocol_version='HTTP/1.0')),
99
('HTTP/1.1', dict(_protocol_version='HTTP/1.1')),
103
class VaryByHttpProxyAuthScheme(TestVariation):
107
('basic', dict(_auth_server=http_utils.ProxyBasicAuthServer)),
108
('digest', dict(_auth_server=http_utils.ProxyDigestAuthServer)),
110
dict(_auth_server=http_utils.ProxyBasicAndDigestAuthServer)),
114
class VaryByHttpAuthScheme(TestVariation):
118
('basic', dict(_auth_server=http_utils.HTTPBasicAuthServer)),
119
('digest', dict(_auth_server=http_utils.HTTPDigestAuthServer)),
121
dict(_auth_server=http_utils.HTTPBasicAndDigestAuthServer)),
125
class VaryByHttpActivity(TestVariation):
128
activity_scenarios = [
129
('urllib,http', dict(_activity_server=ActivityHTTPServer,
130
_transport=_urllib.HttpTransport_urllib,)),
92
('HTTP/1.0', dict(_protocol_version='HTTP/1.0')),
93
('HTTP/1.1', dict(_protocol_version='HTTP/1.1')),
97
def vary_by_http_proxy_auth_scheme():
99
('basic', dict(_auth_server=http_utils.ProxyBasicAuthServer)),
100
('digest', dict(_auth_server=http_utils.ProxyDigestAuthServer)),
102
dict(_auth_server=http_utils.ProxyBasicAndDigestAuthServer)),
106
def vary_by_http_auth_scheme():
108
('basic', dict(_auth_server=http_utils.HTTPBasicAuthServer)),
109
('digest', dict(_auth_server=http_utils.HTTPDigestAuthServer)),
111
dict(_auth_server=http_utils.HTTPBasicAndDigestAuthServer)),
115
def vary_by_http_activity():
116
activity_scenarios = [
117
('urllib,http', dict(_activity_server=ActivityHTTPServer,
118
_transport=_urllib.HttpTransport_urllib,)),
120
if tests.HTTPSServerFeature.available():
121
activity_scenarios.append(
122
('urllib,https', dict(_activity_server=ActivityHTTPSServer,
123
_transport=_urllib.HttpTransport_urllib,)),)
124
if features.pycurl.available():
125
activity_scenarios.append(
126
('pycurl,http', dict(_activity_server=ActivityHTTPServer,
127
_transport=PyCurlTransport,)),)
132
128
if tests.HTTPSServerFeature.available():
133
activity_scenarios.append(
134
('urllib,https', dict(_activity_server=ActivityHTTPSServer,
135
_transport=_urllib.HttpTransport_urllib,)),)
136
if features.pycurl.available():
137
activity_scenarios.append(
138
('pycurl,http', dict(_activity_server=ActivityHTTPServer,
139
_transport=PyCurlTransport,)),)
140
if tests.HTTPSServerFeature.available():
141
from bzrlib.tests import (
144
# FIXME: Until we have a better way to handle self-signed
145
# certificates (like allowing them in a test specific
146
# authentication.conf for example), we need some specialized pycurl
147
# transport for tests.
148
class HTTPS_pycurl_transport(PyCurlTransport):
150
def __init__(self, base, _from_transport=None):
151
super(HTTPS_pycurl_transport, self).__init__(
152
base, _from_transport)
153
self.cabundle = str(ssl_certs.build_path('ca.crt'))
155
activity_scenarios.append(
156
('pycurl,https', dict(_activity_server=ActivityHTTPSServer,
157
_transport=HTTPS_pycurl_transport,)),)
158
return activity_scenarios
129
from bzrlib.tests import (
132
# FIXME: Until we have a better way to handle self-signed
133
# certificates (like allowing them in a test specific
134
# authentication.conf for example), we need some specialized pycurl
135
# transport for tests.
136
class HTTPS_pycurl_transport(PyCurlTransport):
138
def __init__(self, base, _from_transport=None):
139
super(HTTPS_pycurl_transport, self).__init__(
140
base, _from_transport)
141
self.cabundle = str(ssl_certs.build_path('ca.crt'))
143
activity_scenarios.append(
144
('pycurl,https', dict(_activity_server=ActivityHTTPSServer,
145
_transport=HTTPS_pycurl_transport,)),)
146
return activity_scenarios
161
149
class FakeManager(object):