3357
3357
# requests for child URLs of that to the original URL. i.e., we want to
3358
3358
# POST to "bzr+http://host/foo/.bzr/smart" and never something like
3359
3359
# "bzr+http://host/foo/.bzr/branch/.bzr/smart". So, a cloned
3360
# RemoteHTTPTransport remembers the initial URL, and adjusts the relpaths
3361
# it sends in smart requests accordingly.
3360
# RemoteHTTPTransport remembers the initial URL, and adjusts the
3361
# relpaths it sends in smart requests accordingly.
3362
3362
base_transport = remote.RemoteHTTPTransport('bzr+http://host/path')
3363
3363
new_transport = base_transport.clone('child_dir')
3364
3364
self.assertEqual(base_transport._http_transport,
3385
3385
new_transport._client.remote_path_from_transport(new_transport))
3387
def test__redirect_to(self):
3388
t = remote.RemoteHTTPTransport('bzr+http://www.example.com/foo')
3389
r = t._redirected_to('http://www.example.com/foo',
3390
'http://www.example.com/bar')
3391
self.assertEquals(type(r), type(t))
3393
def test__redirect_sibling_protocol(self):
3394
t = remote.RemoteHTTPTransport('bzr+http://www.example.com/foo')
3395
r = t._redirected_to('http://www.example.com/foo',
3396
'https://www.example.com/bar')
3397
self.assertEquals(type(r), type(t))
3398
self.assertStartsWith(r.base, 'bzr+https')
3400
def test__redirect_to_with_user(self):
3401
t = remote.RemoteHTTPTransport('bzr+http://joe@www.example.com/foo')
3402
r = t._redirected_to('http://www.example.com/foo',
3403
'http://www.example.com/bar')
3404
self.assertEquals(type(r), type(t))
3405
self.assertEquals('joe', t._user)
3406
self.assertEquals(t._user, r._user)
3408
def test_redirected_to_same_host_different_protocol(self):
3409
t = remote.RemoteHTTPTransport('bzr+http://joe@www.example.com/foo')
3410
r = t._redirected_to('http://www.example.com/foo',
3411
'ftp://www.example.com/foo')
3412
self.assertNotEquals(type(r), type(t))
3388
3415
# TODO: Client feature that does get_bundle and then installs that into a
3389
3416
# branch; this can be used in place of the regular pull/fetch operation when
3390
3417
# coming from a smart server.