660
660
self.assertEqual(l[2], (3, '34'))
661
661
self.assertEqual(l[3], (9, '9'))
662
662
# The server should have issued 4 requests
663
self.assertEqual(4, self.get_readonly_server().GET_request_nb)
663
self.assertEqual(4, server.GET_request_nb)
665
def test_readv_get_max_size(self):
666
server = self.get_readonly_server()
667
t = self._transport(server.get_url())
668
# force transport to issue multiple requests by limiting the number of
669
# bytes by request. Note that this apply to coalesced offsets only, a
670
# single range ill keep its size even if bigger than the limit.
672
l = list(t.readv('a', ((0, 1), (1, 1), (2, 4), (6, 4))))
673
self.assertEqual(l[0], (0, '0'))
674
self.assertEqual(l[1], (1, '1'))
675
self.assertEqual(l[2], (2, '2345'))
676
self.assertEqual(l[3], (6, '6789'))
677
# The server should have issued 3 requests
678
self.assertEqual(3, server.GET_request_nb)
666
681
class TestSingleRangeRequestServer(TestRangeRequestServer):
987
1002
def _file_tail(self, relpath, tail_amount):
988
1003
code, data = self.transport._get(relpath, [], tail_amount)
989
1004
self.assertTrue(code in (200, 206),'_get returns: %d' % code)
990
data.seek(-tail_amount + 1, 2)
1005
data.seek(-tail_amount, 2)
991
1006
return data.read(tail_amount)
993
1008
def test_range_header(self):
998
1013
self.assertEqual('789', self._file_tail('a', 3))
999
1014
# Syntactically invalid range
1000
self.assertListRaises(errors.InvalidRange,
1015
self.assertListRaises(errors.InvalidHttpRange,
1001
1016
self._file_contents, 'a', [(4, 3)])
1002
1017
# Semantically invalid range
1003
self.assertListRaises(errors.InvalidRange,
1018
self.assertListRaises(errors.InvalidHttpRange,
1004
1019
self._file_contents, 'a', [(42, 128)])
1306
1321
self.assertEquals(expected_prompt, actual_prompt)
1308
1323
def test_no_prompt_for_password_when_using_auth_config(self):
1310
1325
password = 'foo'
1311
1326
stdin_content = 'bar\n' # Not the right password
1312
1327
self.server.add_user(user, password)
1435
1450
def create_transport_readonly_server(self):
1436
1451
return ProxyDigestAuthServer()
1454
class TestAuth_pycurl(object):
1455
"Tests that can't be applied to pycurl."""
1457
def test_prompt_for_password(self):
1458
raise tests.TestNotApplicable(
1459
'pycurl cannot prompt, it handles auth by embedding'
1460
' user:pass in urls only')
1462
def test_no_prompt_for_password_when_using_auth_config(self):
1463
raise tests.TestNotApplicable(
1464
'pycurl does not support authentication.conf'
1465
' since it cannot prompt')
1468
class TestHTTPBasicAuth_pycurl(TestWithTransport_pycurl, TestAuth_pycurl,
1470
"""Test http basic authentication scheme for pycurl"""
1473
class TestHTTPProxyBasicAuth_pycurl(TestWithTransport_pycurl, TestAuth_pycurl,
1474
TestHTTPProxyBasicAuth):
1475
"""Test proxy basic authentication scheme for pycurl"""
1477
def test_empty_pass(self):
1478
raise tests.KnownFailure(
1479
'some versions of pycurl does not handle empty proxy passwords')
1482
class TestHTTPDigestAuth_pycurl(TestWithTransport_pycurl, TestAuth_pycurl,
1483
TestHTTPDigestAuth):
1484
"""Test http digest authentication scheme for pycurl"""
1486
def test_changing_nonce(self):
1487
raise tests.KnownFailure(
1488
'pycurl does not handle a nonce change')
1491
class TestHTTPProxyDigestAuth_pycurl(TestWithTransport_pycurl, TestAuth_pycurl,
1492
TestHTTPProxyDigestAuth):
1493
"""Test http digest authentication scheme for pycurl"""
1495
def test_empty_pass(self):
1496
raise tests.KnownFailure(
1497
'some versions of pycurl does not handle empty proxy passwords')
1499
def test_changing_nonce(self):
1500
raise tests.KnownFailure(
1501
'pycurl does not handle a nonce change')