~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_http.py

(jelmer) Fix some issues with http redirects. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1997
1997
        self.assertIsInstance(r, type(t))
1998
1998
        # Both transports share the some connection
1999
1999
        self.assertEqual(t._get_connection(), r._get_connection())
 
2000
        self.assertEquals('http://www.example.com/foo/subdir/', r.base)
2000
2001
 
2001
2002
    def test_redirected_to_self_with_slash(self):
2002
2003
        t = self._transport('http://www.example.com/foo')
2013
2014
        r = t._redirected_to('http://www.example.com/foo',
2014
2015
                             'http://foo.example.com/foo/subdir')
2015
2016
        self.assertIsInstance(r, type(t))
 
2017
        self.assertEquals('http://foo.example.com/foo/subdir/',
 
2018
            r.external_url())
2016
2019
 
2017
2020
    def test_redirected_to_same_host_sibling_protocol(self):
2018
2021
        t = self._transport('http://www.example.com/foo')
2019
2022
        r = t._redirected_to('http://www.example.com/foo',
2020
2023
                             'https://www.example.com/foo')
2021
2024
        self.assertIsInstance(r, type(t))
 
2025
        self.assertEquals('https://www.example.com/foo/',
 
2026
            r.external_url())
2022
2027
 
2023
2028
    def test_redirected_to_same_host_different_protocol(self):
2024
2029
        t = self._transport('http://www.example.com/foo')
2025
2030
        r = t._redirected_to('http://www.example.com/foo',
2026
2031
                             'ftp://www.example.com/foo')
2027
2032
        self.assertNotEquals(type(r), type(t))
 
2033
        self.assertEquals('ftp://www.example.com/foo/', r.external_url())
 
2034
 
 
2035
    def test_redirected_to_same_host_specific_implementation(self):
 
2036
        t = self._transport('http://www.example.com/foo')
 
2037
        r = t._redirected_to('http://www.example.com/foo',
 
2038
                             'https+urllib://www.example.com/foo')
 
2039
        self.assertEquals('https://www.example.com/foo/', r.external_url())
2028
2040
 
2029
2041
    def test_redirected_to_different_host_same_user(self):
2030
2042
        t = self._transport('http://joe@www.example.com/foo')
2032
2044
                             'https://foo.example.com/foo')
2033
2045
        self.assertIsInstance(r, type(t))
2034
2046
        self.assertEqual(t._parsed_url.user, r._parsed_url.user)
 
2047
        self.assertEquals('https://joe@foo.example.com/foo/', r.external_url())
2035
2048
 
2036
2049
 
2037
2050
class PredefinedRequestHandler(http_server.TestingHTTPRequestHandler):