71
71
def load_tests(standard_tests, module, loader):
72
72
"""Multiply tests for http clients and protocol versions."""
73
73
result = loader.suiteClass()
74
adapter = tests.TestScenarioApplier()
75
remaining_tests = standard_tests
77
# one for each transport
75
# one for each transport implementation
78
76
t_tests, remaining_tests = tests.split_suite_by_condition(
79
remaining_tests, tests.condition_isinstance((
77
standard_tests, tests.condition_isinstance((
80
78
TestHttpTransportRegistration,
81
79
TestHttpTransportUrls,
82
80
Test_redirected_to,
91
89
('pycurl', dict(_transport=PyCurlTransport,
92
90
_server=http_server.HttpServer_PyCurl,
93
91
_qualified_prefix='http+pycurl',)))
94
adapter.scenarios = transport_scenarios
95
tests.adapt_tests(t_tests, adapter, result)
92
tests.multiply_tests(t_tests, transport_scenarios, result)
97
# multiplied by one for each protocol version
94
# each implementation tested with each HTTP version
98
95
tp_tests, remaining_tests = tests.split_suite_by_condition(
99
96
remaining_tests, tests.condition_isinstance((
100
97
SmartHTTPTunnellingTest,
112
109
('HTTP/1.0', dict(_protocol_version='HTTP/1.0')),
113
110
('HTTP/1.1', dict(_protocol_version='HTTP/1.1')),
115
tp_scenarios = tests.multiply_scenarios(adapter.scenarios,
112
tp_scenarios = tests.multiply_scenarios(transport_scenarios,
116
113
protocol_scenarios)
117
adapter.scenarios = tp_scenarios
118
tests.adapt_tests(tp_tests, adapter, result)
114
tests.multiply_tests(tp_tests, tp_scenarios, result)
120
# multiplied by one for each authentication scheme
116
# auth: each auth scheme on all http versions on all implementations.
121
117
tpa_tests, remaining_tests = tests.split_suite_by_condition(
122
118
remaining_tests, tests.condition_isinstance((
126
122
('basic', dict(_auth_scheme='basic')),
127
123
('digest', dict(_auth_scheme='digest')),
129
adapter.scenarios = tests.multiply_scenarios(adapter.scenarios,
130
auth_scheme_scenarios)
131
tests.adapt_tests(tpa_tests, adapter, result)
125
tpa_scenarios = tests.multiply_scenarios(tp_scenarios,
126
auth_scheme_scenarios)
127
tests.multiply_tests(tpa_tests, tpa_scenarios, result)
129
# activity: activity on all http versions on all implementations
133
130
tpact_tests, remaining_tests = tests.split_suite_by_condition(
134
131
remaining_tests, tests.condition_isinstance((
140
137
if tests.HTTPSServerFeature.available():
141
138
activity_scenarios.append(
142
('https', dict(_activity_server=ActivityHTTPSServer,)))
143
adapter.scenarios = tests.multiply_scenarios(tp_scenarios,
145
tests.adapt_tests(tpact_tests, adapter, result)
139
('https', dict(_activity_server=ActivityHTTPSServer)))
140
tpact_scenarios = tests.multiply_scenarios(tp_scenarios,
142
tests.multiply_tests(tpact_tests, tpact_scenarios, result)
147
144
# No parametrization for the remaining tests
148
145
result.addTests(remaining_tests)
216
class TestAuthHeader(tests.TestCase):
218
def parse_header(self, header):
219
ah = _urllib2_wrappers.AbstractAuthHandler()
220
return ah._parse_auth_header(header)
222
def test_empty_header(self):
223
scheme, remainder = self.parse_header('')
224
self.assertEquals('', scheme)
225
self.assertIs(None, remainder)
227
def test_negotiate_header(self):
228
scheme, remainder = self.parse_header('Negotiate')
229
self.assertEquals('negotiate', scheme)
230
self.assertIs(None, remainder)
232
def test_basic_header(self):
233
scheme, remainder = self.parse_header(
234
'Basic realm="Thou should not pass"')
235
self.assertEquals('basic', scheme)
236
self.assertEquals('realm="Thou should not pass"', remainder)
238
def test_digest_header(self):
239
scheme, remainder = self.parse_header(
240
'Digest realm="Thou should not pass"')
241
self.assertEquals('digest', scheme)
242
self.assertEquals('realm="Thou should not pass"', remainder)
219
245
class TestHTTPServer(tests.TestCase):
220
246
"""Test the HTTP servers implementations."""