~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_http.py

  • Committer: John Arbash Meinel
  • Date: 2007-03-05 20:51:42 UTC
  • mfrom: (2298.7.1 87765)
  • mto: This revision was merged to the branch mainline in revision 2315.
  • Revision ID: john@arbash-meinel.com-20070305205142-3xhccyveuakkrj87
(Vincent Ladeuil) invalid proxy vars should not cause a traceback (bug #87765)

Show diffs side-by-side

added added

removed removed

Lines of Context:
693
693
 
694
694
 
695
695
class TestHttpProxyWhiteBox(TestCase):
696
 
    """Whitebox test proxy http authorization."""
 
696
    """Whitebox test proxy http authorization.
 
697
 
 
698
    These tests concern urllib implementation only.
 
699
    """
697
700
 
698
701
    def setUp(self):
699
702
        TestCase.setUp(self)
741
744
        self.assertEqual('Basic ' + 'joe:foo'.encode('base64').strip(),
742
745
                         request.headers['Proxy-authorization'])
743
746
 
 
747
    def test_invalid_proxy(self):
 
748
        """A proxy env variable without scheme"""
 
749
        self._install_env({'http_proxy': 'host:1234'})
 
750
        self.assertRaises(errors.InvalidURL, self._proxied_request)
744
751
 
745
752
 
746
753
class TestProxyHttpServer(object):
772
779
                                  ('foo-proxied', 'proxied contents of foo\n')])
773
780
        # Let's setup some attributes for tests
774
781
        self.server = self.get_readonly_server()
775
 
        self.no_proxy_host = 'localhost:%d' % self.server.port
 
782
        # FIXME: We should not rely on 'localhost' being the hostname
 
783
        self.proxy_address = 'localhost:%d' % self.server.port
 
784
        self.no_proxy_host = self.proxy_address
776
785
        # The secondary server is the proxy
777
786
        self.proxy = self.get_secondary_server()
778
787
        self.proxy_url = self.proxy.get_url()
842
851
        self.not_proxied_in_env({'ALL_PROXY': self.proxy_url,
843
852
                                 'NO_PROXY': self.no_proxy_host})
844
853
 
 
854
    def test_http_proxy_without_scheme(self):
 
855
        self.assertRaises(errors.InvalidURL,
 
856
                          self.proxied_in_env,
 
857
                          {'http_proxy': self.proxy_address})
 
858
 
845
859
 
846
860
class TestProxyHttpServer_urllib(TestProxyHttpServer,
847
861
                                 TestCaseWithTwoWebservers):
870
884
    def test_HTTP_PROXY_with_NO_PROXY(self):
871
885
        raise TestSkipped()
872
886
 
 
887
    def test_http_proxy_without_scheme(self):
 
888
        # pycurl *ignores* invalid proxy env variables. If that
 
889
        # ever change in the future, this test will fail
 
890
        # indicating that pycurl do not ignore anymore such
 
891
        # variables.
 
892
        self.not_proxied_in_env({'http_proxy': self.proxy_address})
 
893
 
873
894
 
874
895
class TestRanges(object):
875
896
    """Test the Range header in GET methods..