~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_http.py

  • Committer: Mark Hammond
  • Date: 2008-12-28 05:21:23 UTC
  • mfrom: (3920 +trunk)
  • mto: (3932.1.1 prepare-1.11)
  • mto: This revision was merged to the branch mainline in revision 3937.
  • Revision ID: mhammond@skippinet.com.au-20081228052123-f78xs5sbdkotshwf
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
120
120
    t_adapter = TransportAdapter()
121
121
    t_classes= (TestHttpTransportRegistration,
122
122
                TestHttpTransportUrls,
 
123
                Test_redirected_to,
123
124
                )
124
125
    is_testing_for_transports = tests.condition_isinstance(t_classes)
125
126
 
1263
1264
                                  ('bundle',
1264
1265
                                  '# Bazaar revision bundle v0.9\n#\n')
1265
1266
                                  ],)
1266
 
 
 
1267
        # The requests to the old server will be redirected to the new server
1267
1268
        self.old_transport = self._transport(self.old_server.get_url())
1268
1269
 
1269
1270
    def test_redirected(self):
1743
1744
                          t.get_smart_medium().send_http_smart_request,
1744
1745
                          'whatever')
1745
1746
 
 
1747
class Test_redirected_to(tests.TestCase):
 
1748
 
 
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())
 
1756
 
 
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
 
1764
        # overkill).
 
1765
        self.assertEquals(t._get_connection(), r._get_connection())
 
1766
 
 
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))
 
1772
 
 
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))
 
1778
 
 
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))
 
1784
 
 
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)