53
53
from bzrlib.tests.variations import (
55
55
multiply_tests_by_variations,
56
multiply_tests_by_their_variations,
57
58
from bzrlib.transport import (
164
165
TestHttpTransportUrls,
165
166
Test_redirected_to,
167
multiply_tests_by_variations(
168
t_tests, [VaryByHttpClientImplementation()], result)
168
multiply_tests_by_their_variations(t_tests, result)
170
170
# some tests are parametrized by the protocol version only
171
171
p_tests, remaining_tests = tests.split_suite_by_condition(
172
172
remaining_tests, tests.condition_isinstance((
173
173
TestAuthOnRedirected,
175
multiply_tests_by_variations(
176
p_tests, [VaryByHttpProtocolVersion()], result)
175
multiply_tests_by_their_variations(p_tests, result)
178
177
# each implementation tested with each HTTP version
179
178
tp_tests, remaining_tests = tests.split_suite_by_condition(
190
189
TestSpecificRequestHandler,
192
multiply_tests_by_variations(
194
VaryByHttpClientImplementation(),
195
VaryByHttpProtocolVersion(),
191
multiply_tests_by_their_variations(tp_tests, result)
199
193
# proxy auth: each auth scheme on all http versions on all implementations.
200
194
tppa_tests, remaining_tests = tests.split_suite_by_condition(
201
195
remaining_tests, tests.condition_isinstance((
204
multiply_tests_by_variations(
206
VaryByHttpClientImplementation(),
207
VaryByHttpProtocolVersion(),
208
VaryByHttpProxyAuthScheme(),
198
multiply_tests_by_their_variations(tppa_tests, result)
211
200
# auth: each auth scheme on all http versions on all implementations.
212
201
tpa_tests, remaining_tests = tests.split_suite_by_condition(
213
202
remaining_tests, tests.condition_isinstance((
216
multiply_tests_by_variations(
218
VaryByHttpClientImplementation(),
219
VaryByHttpProtocolVersion(),
220
VaryByHttpAuthScheme(),
205
multiply_tests_by_their_variations(tpa_tests, result)
223
207
# activity: on all http[s] versions on all implementations
224
208
tpact_tests, remaining_tests = tests.split_suite_by_condition(
225
209
remaining_tests, tests.condition_isinstance((
228
multiply_tests_by_variations(
230
VaryByHttpActivity(),
231
VaryByHttpProtocolVersion(),
212
multiply_tests_by_their_variations(tpact_tests, result)
234
214
# No parametrization for the remaining tests
235
215
result.addTests(remaining_tests)
445
425
class TestHttpTransportUrls(tests.TestCase):
446
427
"""Test the http urls."""
429
variations = [VaryByHttpClientImplementation()]
448
431
def test_abs_url(self):
449
432
"""Construction of absolute http URLs"""
450
433
t = self._transport('http://bazaar-vcs.org/bzr/bzr.dev/')
519
502
class TestHTTPConnections(http_utils.TestCaseWithWebserver):
520
503
"""Test the http connections."""
506
VaryByHttpClientImplementation(),
507
VaryByHttpProtocolVersion(),
523
511
http_utils.TestCaseWithWebserver.setUp(self)
524
512
self.build_tree(['foo/', 'foo/bar'], line_endings='binary',
569
557
class TestHttpTransportRegistration(tests.TestCase):
570
558
"""Test registrations of various http implementations"""
560
variations = [VaryByHttpClientImplementation()]
572
562
def test_http_registered(self):
573
563
t = transport.get_transport('%s://foo.com/' % self._url_protocol)
574
564
self.assertIsInstance(t, transport.Transport)
578
568
class TestPost(tests.TestCase):
571
VaryByHttpClientImplementation(),
572
VaryByHttpProtocolVersion(),
580
575
def test_post_body_is_received(self):
581
576
server = RecordingServer(expect_body_tail='end-of-body',
582
577
scheme=self._url_protocol)
629
624
Daughter classes are expected to override _req_handler_class
628
VaryByHttpClientImplementation(),
629
VaryByHttpProtocolVersion(),
632
632
# Provide a useful default
633
633
_req_handler_class = http_server.TestingHTTPRequestHandler
1099
1099
class TestLimitedRangeRequestServer(http_utils.TestCaseWithWebserver):
1100
1100
"""Tests readv requests against a server erroring out on too much ranges."""
1103
VaryByHttpClientImplementation(),
1104
VaryByHttpProtocolVersion(),
1102
1107
# Requests with more range specifiers will error out
1103
1108
range_limit = 3
1178
1183
to the file names).
1187
VaryByHttpClientImplementation(),
1188
VaryByHttpProtocolVersion(),
1181
1191
# FIXME: We don't have an https server available, so we don't
1182
1192
# test https connections. --vila toolongago
1280
1290
class TestRanges(http_utils.TestCaseWithWebserver):
1281
1291
"""Test the Range header in GET methods."""
1294
VaryByHttpClientImplementation(),
1295
VaryByHttpProtocolVersion(),
1283
1298
def setUp(self):
1284
1299
http_utils.TestCaseWithWebserver.setUp(self)
1285
1300
self.build_tree_contents([('a', '0123456789')],)
1325
1340
class TestHTTPRedirections(http_utils.TestCaseWithRedirectedWebserver):
1326
1341
"""Test redirection between http servers."""
1344
VaryByHttpClientImplementation(),
1345
VaryByHttpProtocolVersion(),
1328
1348
def setUp(self):
1329
1349
super(TestHTTPRedirections, self).setUp()
1330
1350
self.build_tree_contents([('a', '0123456789'),
1393
1413
-- vila 20070212
1417
VaryByHttpClientImplementation(),
1418
VaryByHttpProtocolVersion(),
1396
1421
def setUp(self):
1397
1422
if (features.pycurl.available()
1398
1423
and self._transport == PyCurlTransport):
1443
1468
class TestDoCatchRedirections(http_utils.TestCaseWithRedirectedWebserver):
1444
1469
"""Test transport.do_catching_redirections."""
1472
VaryByHttpClientImplementation(),
1473
VaryByHttpProtocolVersion(),
1446
1476
def setUp(self):
1447
1477
super(TestDoCatchRedirections, self).setUp()
1448
1478
self.build_tree_contents([('a', '0123456789'),],)
1490
1520
class TestAuth(http_utils.TestCaseWithWebserver):
1491
1521
"""Test authentication scheme"""
1524
VaryByHttpClientImplementation(),
1525
VaryByHttpProtocolVersion(),
1526
VaryByHttpAuthScheme(),
1493
1529
_auth_header = 'Authorization'
1494
1530
_password_prompt_prefix = ''
1495
1531
_username_prompt_prefix = ''
1699
1735
class TestProxyAuth(TestAuth):
1700
1736
"""Test proxy authentication schemes."""
1739
VaryByHttpClientImplementation(),
1740
VaryByHttpProtocolVersion(),
1741
VaryByHttpProxyAuthScheme(),
1702
1744
_auth_header = 'Proxy-authorization'
1703
1745
_password_prompt_prefix = 'Proxy '
1704
1746
_username_prompt_prefix = 'Proxy '
1761
1803
class SmartHTTPTunnellingTest(tests.TestCaseWithTransport):
1806
VaryByHttpClientImplementation(),
1807
VaryByHttpProtocolVersion(),
1763
1810
def setUp(self):
1764
1811
super(SmartHTTPTunnellingTest, self).setUp()
1765
1812
# We use the VFS layer as part of HTTP tunnelling tests.
1855
1902
class Test_redirected_to(tests.TestCase):
1904
variations = [VaryByHttpClientImplementation()]
1857
1906
def test_redirected_to_subdir(self):
1858
1907
t = self._transport('http://www.example.com/foo')
1859
1908
r = t._redirected_to('http://www.example.com/foo',
1967
2016
be able to predict the activity on the client socket.
2020
VaryByHttpActivity(),
2021
VaryByHttpProtocolVersion(),
1970
2024
def setUp(self):
1971
2025
tests.TestCase.setUp(self)
1972
2026
self.server = self._activity_server(self._protocol_version)
2131
2185
class TestAuthOnRedirected(http_utils.TestCaseWithRedirectedWebserver):
2132
2186
"""Test authentication on the redirected http server."""
2188
variations = [VaryByHttpProtocolVersion()]
2134
2190
_auth_header = 'Authorization'
2135
2191
_password_prompt_prefix = ''
2136
2192
_username_prompt_prefix = ''