Exemple #1
0
 def test_get_http_proxy_ignores_user_in_httpproxy(self, mock_host):
     mock_host.return_value = None
     with patch.dict(os.environ,
                     {'http_proxy': 'http://*****:*****@foo.com:80'}):
         h, p = restutil._get_http_proxy()
         self.assertEqual("foo.com", h)
         self.assertEqual(80, p)
Exemple #2
0
 def test_get_http_proxy_ignores_user_in_httpproxy(self, mock_host):
     mock_host.return_value = None
     with patch.dict(os.environ, {
                                 'http_proxy' : 'http://*****:*****@foo.com:80'
                             }):
         h, p = restutil._get_http_proxy()
         self.assertEqual("foo.com", h)
         self.assertEqual(80, p)
Exemple #3
0
 def test_get_http_proxy_configuration_requires_host(self, mock_host, mock_port):
     mock_host.return_value = None
     mock_port.return_value = None
     h, p = restutil._get_http_proxy()
     self.assertEqual(None, h)
     self.assertEqual(None, p)
     self.assertEqual(1, mock_host.call_count)
     self.assertEqual(0, mock_port.call_count)
Exemple #4
0
 def test_get_http_proxy_configuration_overrides_env(self, mock_host, mock_port):
     mock_host.return_value = "host"
     mock_port.return_value = None
     h, p = restutil._get_http_proxy()
     self.assertEqual("host", h)
     self.assertEqual(None, p)
     self.assertEqual(1, mock_host.call_count)
     self.assertEqual(1, mock_port.call_count)
Exemple #5
0
 def test_get_http_proxy_configuration_requires_host(self, mock_host, mock_port):
     mock_host.return_value = None
     mock_port.return_value = None
     h, p = restutil._get_http_proxy() # pylint: disable=protected-access,invalid-name
     self.assertEqual(None, h)
     self.assertEqual(None, p)
     self.assertEqual(1, mock_host.call_count)
     self.assertEqual(0, mock_port.call_count)
Exemple #6
0
 def test_get_http_proxy_ignores_user_in_httpproxy(self, mock_host):
     mock_host.return_value = None
     with patch.dict(os.environ, {
                                 'http_proxy' : 'http://*****:*****@foo.com:80'
                             }):
         h, p = restutil._get_http_proxy() # pylint: disable=protected-access,invalid-name
         self.assertEqual("foo.com", h)
         self.assertEqual(80, p)
Exemple #7
0
 def test_get_http_proxy_configuration_requires_host(self, mock_host, mock_port):
     mock_host.return_value = None
     mock_port.return_value = None
     h, p = restutil._get_http_proxy()
     self.assertEqual(None, h)
     self.assertEqual(None, p)
     self.assertEqual(1, mock_host.call_count)
     self.assertEqual(0, mock_port.call_count)
Exemple #8
0
 def test_get_http_proxy_configuration_overrides_env(self, mock_host, mock_port):
     mock_host.return_value = "host"
     mock_port.return_value = None
     h, p = restutil._get_http_proxy()
     self.assertEqual("host", h)
     self.assertEqual(None, p)
     self.assertEqual(1, mock_host.call_count)
     self.assertEqual(1, mock_port.call_count)
Exemple #9
0
 def test_get_http_proxy_https_uses_httpsproxy(self, mock_host):
     mock_host.return_value = None
     with patch.dict(os.environ, {
                                 'http_proxy' : 'http://foo.com:80',
                                 'https_proxy' : 'https://bar.com:443'
                             }):
         h, p = restutil._get_http_proxy(secure=True)
         self.assertEqual("bar.com", h)
         self.assertEqual(443, p)
Exemple #10
0
 def test_get_http_proxy_configuration_requires_host(
         self, mock_host, mock_port):
     mock_host.return_value = None
     mock_port.return_value = None
     h, p = restutil._get_http_proxy()
     self.assertEqual(None, h)
     self.assertEqual(None, p)
     mock_host.assert_called_once()
     mock_port.assert_not_called()
Exemple #11
0
 def test_get_http_proxy_https_uses_httpsproxy(self, mock_host):
     mock_host.return_value = None
     with patch.dict(os.environ, {
                                 'http_proxy' : 'http://foo.com:80',
                                 'https_proxy' : 'https://bar.com:443'
                             }):
         h, p = restutil._get_http_proxy(secure=True) # pylint: disable=protected-access,invalid-name
         self.assertEqual("bar.com", h)
         self.assertEqual(443, p)
Exemple #12
0
 def test_get_http_proxy_http_uses_httpproxy(self, mock_host):
     mock_host.return_value = None
     with patch.dict(os.environ, {
                                 'http_proxy' : 'http://foo.com:80',
                                 'https_proxy' : 'https://bar.com:443'
                             }):
         h, p = restutil._get_http_proxy()
         self.assertEqual("foo.com", h)
         self.assertEqual(80, p)
Exemple #13
0
 def test_get_http_proxy_none_is_default(self, mock_host, mock_port):
     mock_host.return_value = None
     mock_port.return_value = None
     h, p = restutil._get_http_proxy()
     self.assertEqual(None, h)
     self.assertEqual(None, p)
Exemple #14
0
 def test_get_http_proxy_none_is_default(self, mock_host, mock_port):
     mock_host.return_value = None
     mock_port.return_value = None
     h, p = restutil._get_http_proxy()
     self.assertEqual(None, h)
     self.assertEqual(None, p)
Exemple #15
0
 def test_get_http_proxy_none_is_default(self, mock_host, mock_port):
     mock_host.return_value = None
     mock_port.return_value = None
     h, p = restutil._get_http_proxy() # pylint: disable=protected-access,invalid-name
     self.assertEqual(None, h)
     self.assertEqual(None, p)