1
# Copyright (C) 2005-2012, 2015, 2016 Canonical Ltd
1
# Copyright (C) 2005-2012, 2015 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
288
288
self.req_handler = RequestHandler(None, None, None)
290
290
def assertRanges(self, ranges, header, file_size):
291
self.assertEqual(ranges,
291
self.assertEquals(ranges,
292
292
self.req_handler._parse_ranges(header, file_size))
294
294
def test_simple_range(self):
1201
1201
def assertEvaluateProxyBypass(self, expected, host, no_proxy):
1202
1202
handler = _urllib2_wrappers.ProxyHandler()
1203
self.assertEqual(expected,
1203
self.assertEquals(expected,
1204
1204
handler.evaluate_proxy_bypass(host, no_proxy))
1206
1206
def test_empty_user(self):
1602
self.assertEqual((user, password), got_pass)
1602
self.assertEquals((user, password), got_pass)
1605
1605
class TestAuth(http_utils.TestCaseWithWebserver):
2000
2000
self.assertIsInstance(r, type(t))
2001
2001
# Both transports share the some connection
2002
2002
self.assertEqual(t._get_connection(), r._get_connection())
2003
self.assertEqual('http://www.example.com/foo/subdir/', r.base)
2003
self.assertEquals('http://www.example.com/foo/subdir/', r.base)
2005
2005
def test_redirected_to_self_with_slash(self):
2006
2006
t = self._transport('http://www.example.com/foo')
2017
2017
r = t._redirected_to('http://www.example.com/foo',
2018
2018
'http://foo.example.com/foo/subdir')
2019
2019
self.assertIsInstance(r, type(t))
2020
self.assertEqual('http://foo.example.com/foo/subdir/',
2020
self.assertEquals('http://foo.example.com/foo/subdir/',
2021
2021
r.external_url())
2023
2023
def test_redirected_to_same_host_sibling_protocol(self):
2025
2025
r = t._redirected_to('http://www.example.com/foo',
2026
2026
'https://www.example.com/foo')
2027
2027
self.assertIsInstance(r, type(t))
2028
self.assertEqual('https://www.example.com/foo/',
2028
self.assertEquals('https://www.example.com/foo/',
2029
2029
r.external_url())
2031
2031
def test_redirected_to_same_host_different_protocol(self):
2032
2032
t = self._transport('http://www.example.com/foo')
2033
2033
r = t._redirected_to('http://www.example.com/foo',
2034
2034
'ftp://www.example.com/foo')
2035
self.assertNotEqual(type(r), type(t))
2036
self.assertEqual('ftp://www.example.com/foo/', r.external_url())
2035
self.assertNotEquals(type(r), type(t))
2036
self.assertEquals('ftp://www.example.com/foo/', r.external_url())
2038
2038
def test_redirected_to_same_host_specific_implementation(self):
2039
2039
t = self._transport('http://www.example.com/foo')
2040
2040
r = t._redirected_to('http://www.example.com/foo',
2041
2041
'https+urllib://www.example.com/foo')
2042
self.assertEqual('https://www.example.com/foo/', r.external_url())
2042
self.assertEquals('https://www.example.com/foo/', r.external_url())
2044
2044
def test_redirected_to_different_host_same_user(self):
2045
2045
t = self._transport('http://joe@www.example.com/foo')
2047
2047
'https://foo.example.com/foo')
2048
2048
self.assertIsInstance(r, type(t))
2049
2049
self.assertEqual(t._parsed_url.user, r._parsed_url.user)
2050
self.assertEqual('https://joe@foo.example.com/foo/', r.external_url())
2050
self.assertEquals('https://joe@foo.example.com/foo/', r.external_url())
2053
2053
class PredefinedRequestHandler(http_server.TestingHTTPRequestHandler):