Ejemplo n.º 1
0
    def test_get_http_proxy_macos_none(self):
        '''
            Test to make sure that we correctly return when theres no proxy set
        '''
        mock = MagicMock(return_value='Enabled: No\nServer:\nPort: 0\nAuthenticated Proxy Enabled: 0')

        with patch.dict(proxy.__salt__, {'cmd.run': mock}):
            out = proxy.get_http_proxy()
            mock.assert_called_once_with('networksetup -getwebproxy Ethernet')
            self.assertEqual({}, out)
Ejemplo n.º 2
0
    def test_get_http_proxy_osx_none(self):
        '''
            Test to make sure that we correctly return when theres no proxy set
        '''
        proxy.__grains__['os'] = 'Darwin'
        mock = MagicMock(return_value='Enabled: No\nServer:\nPort: 0\nAuthenticated Proxy Enabled: 0')

        with patch.dict(proxy.__salt__, {'cmd.run': mock}):
            out = proxy.get_http_proxy()
            mock.assert_called_once_with('networksetup -getwebproxy Ethernet')
            self.assertEqual({}, out)
Ejemplo n.º 3
0
def test_get_http_proxy_macos_none():
    """
    Test to make sure that we correctly return when there's no proxy set
    """
    mock = MagicMock(
        return_value=
        "Enabled: No\nServer:\nPort: 0\nAuthenticated Proxy Enabled: 0")

    with patch.dict(proxy.__salt__, {"cmd.run": mock}):
        out = proxy.get_http_proxy()
        mock.assert_called_once_with("networksetup -getwebproxy Ethernet")
        assert {} == out
Ejemplo n.º 4
0
    def test_get_http_proxy_macos(self):
        """
        Test to make sure that we correctly get the current proxy info
        on macOS
        """
        mock = MagicMock(return_value=(
            "Enabled: Yes\nServer: 192.168.0.1\nPort: 3128\nAuthenticated Proxy"
            " Enabled: 0"))
        expected = {"enabled": True, "server": "192.168.0.1", "port": "3128"}

        with patch.dict(proxy.__salt__, {"cmd.run": mock}):
            out = proxy.get_http_proxy()
            mock.assert_called_once_with("networksetup -getwebproxy Ethernet")
            self.assertEqual(expected, out)
Ejemplo n.º 5
0
    def test_get_http_proxy_macos(self):
        '''
            Test to make sure that we correctly get the current proxy info
            on macOS
        '''
        mock = MagicMock(
            return_value=
            'Enabled: Yes\nServer: 192.168.0.1\nPort: 3128\nAuthenticated Proxy Enabled: 0'
        )
        expected = {'enabled': True, 'server': '192.168.0.1', 'port': '3128'}

        with patch.dict(proxy.__salt__, {'cmd.run': mock}):
            out = proxy.get_http_proxy()
            mock.assert_called_once_with('networksetup -getwebproxy Ethernet')
            self.assertEqual(expected, out)
Ejemplo n.º 6
0
    def test_get_http_proxy_osx(self):
        '''
            Test to make sure that we correctly get the current proxy info
            on OSX
        '''
        proxy.__grains__['os'] = 'Darwin'
        mock = MagicMock(return_value='Enabled: Yes\nServer: 192.168.0.1\nPort: 3128\nAuthenticated Proxy Enabled: 0')
        expected = {
            'enabled': True,
            'server': '192.168.0.1',
            'port': '3128'
        }

        with patch.dict(proxy.__salt__, {'cmd.run': mock}):
            out = proxy.get_http_proxy()
            mock.assert_called_once_with('networksetup -getwebproxy Ethernet')
            self.assertEqual(expected, out)
Ejemplo n.º 7
0
 def test_get_http_proxy_windows(self):
     '''
     Test to make sure that we correctly get the current proxy info on
     Windows
     '''
     result = {'vdata': 'http=192.168.0.1:3128;https=192.168.0.2:3128;ftp=192.168.0.3:3128'}
     mock = MagicMock(return_value=result)
     expected = {'server': '192.168.0.1',
                 'port': '3128'}
     with patch.dict(proxy.__grains__, {'os': 'Windows'}):
         with patch.dict(proxy.__salt__, {'reg.read_value': mock}):
             out = proxy.get_http_proxy()
             mock.assert_called_once_with(
                 hive='HKEY_CURRENT_USER',
                 key='SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings',
                 vname='ProxyServer')
             self.assertEqual(expected, out)
Ejemplo n.º 8
0
 def test_get_http_proxy_windows(self):
     '''
         Test to make sure that we correctly get the current proxy info
         on Windows
     '''
     proxy.__grains__['os'] = 'Windows'
     result = {
         'vdata': 'http=192.168.0.1:3128;https=192.168.0.2:3128;ftp=192.168.0.3:3128'
     }
     mock = MagicMock(return_value=result)
     expected = {
         'server': '192.168.0.1',
         'port': '3128'
     }
     with patch.dict(proxy.__salt__, {'reg.read_value': mock}):
         out = proxy.get_http_proxy()
         mock.assert_called_once_with('HKEY_CURRENT_USER',
                                      'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings',
                                      'ProxyServer')
         self.assertEqual(expected, out)
Ejemplo n.º 9
0
 def test_get_http_proxy_windows(self):
     """
     Test to make sure that we correctly get the current proxy info on
     Windows
     """
     result = {
         "vdata":
         "http=192.168.0.1:3128;https=192.168.0.2:3128;ftp=192.168.0.3:3128"
     }
     mock = MagicMock(return_value=result)
     expected = {"server": "192.168.0.1", "port": "3128"}
     with patch.dict(proxy.__grains__, {"os": "Windows"}), patch.dict(
             proxy.__utils__, {"reg.read_value": mock}):
         out = proxy.get_http_proxy()
         mock.assert_called_once_with(
             hive="HKEY_CURRENT_USER",
             key=
             "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings",
             vname="ProxyServer",
         )
         self.assertEqual(expected, out)