447
450
'"GET /foo/bar HTTP/1.1" 200 - "-" "bzr/%s'
448
451
% bzrlib.__version__) > -1)
450
def test_get_smart_medium(self):
451
# For HTTP, get_smart_medium should return the transport object.
452
server = self.get_readonly_server()
453
http_transport = self._transport(server.get_url())
454
medium = http_transport.get_smart_medium()
455
self.assertIs(medium, http_transport)
457
453
def test_has_on_bogus_host(self):
458
454
# Get a free address and don't 'accept' on it, so that we
459
455
# can be sure there is no http handler there, but set a
1667
1663
return http_utils.HTTPServerWithSmarts(
1668
1664
protocol_version=self._protocol_version)
1666
def test_open_bzrdir(self):
1667
branch = self.make_branch('relpath')
1668
http_server = self.get_readonly_server()
1669
url = http_server.get_url() + 'relpath'
1670
bd = bzrdir.BzrDir.open(url)
1671
self.assertIsInstance(bd, _mod_remote.RemoteBzrDir)
1670
1673
def test_bulk_data(self):
1671
1674
# We should be able to send and receive bulk data in a single message.
1672
1675
# The 'readv' command in the smart protocol both sends and receives
1738
1741
# No need to build a valid smart request here, the server will not even
1739
1742
# try to interpret it.
1740
1743
self.assertRaises(errors.SmartProtocolError,
1741
t.send_http_smart_request, 'whatever')
1744
t.get_smart_medium().send_http_smart_request,
1747
class Test_redirected_to(tests.TestCase):
1749
def test_redirected_to_subdir(self):
1750
t = self._transport('http://www.example.com/foo')
1751
r = t._redirected_to('http://www.example.com/foo',
1752
'http://www.example.com/foo/subdir')
1753
self.assertIsInstance(r, type(t))
1754
# Both transports share the some connection
1755
self.assertEquals(t._get_connection(), r._get_connection())
1757
def test_redirected_to_self_with_slash(self):
1758
t = self._transport('http://www.example.com/foo')
1759
r = t._redirected_to('http://www.example.com/foo',
1760
'http://www.example.com/foo/')
1761
self.assertIsInstance(r, type(t))
1762
# Both transports share the some connection (one can argue that we
1763
# should return the exact same transport here, but that seems
1765
self.assertEquals(t._get_connection(), r._get_connection())
1767
def test_redirected_to_host(self):
1768
t = self._transport('http://www.example.com/foo')
1769
r = t._redirected_to('http://www.example.com/foo',
1770
'http://foo.example.com/foo/subdir')
1771
self.assertIsInstance(r, type(t))
1773
def test_redirected_to_same_host_sibling_protocol(self):
1774
t = self._transport('http://www.example.com/foo')
1775
r = t._redirected_to('http://www.example.com/foo',
1776
'https://www.example.com/foo')
1777
self.assertIsInstance(r, type(t))
1779
def test_redirected_to_same_host_different_protocol(self):
1780
t = self._transport('http://www.example.com/foo')
1781
r = t._redirected_to('http://www.example.com/foo',
1782
'ftp://www.example.com/foo')
1783
self.assertNotEquals(type(r), type(t))
1785
def test_redirected_to_different_host_same_user(self):
1786
t = self._transport('http://joe@www.example.com/foo')
1787
r = t._redirected_to('http://www.example.com/foo',
1788
'https://foo.example.com/foo')
1789
self.assertIsInstance(r, type(t))
1790
self.assertEquals(t._user, r._user)