Exemple #1
0
    def test_get_ftp_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_ftp_proxy()
            mock.assert_called_once_with("networksetup -getftpproxy Ethernet")
            self.assertEqual(expected, out)
Exemple #2
0
    def test_get_ftp_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_ftp_proxy()
            mock.assert_called_once_with('networksetup -getftpproxy Ethernet')
            self.assertEqual(expected, out)
Exemple #3
0
    def test_get_ftp_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_ftp_proxy()
            mock.assert_called_once_with('networksetup -getftpproxy Ethernet')
            self.assertEqual(expected, out)
Exemple #4
0
 def test_get_ftp_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.3',
                 'port': '3128'}
     with patch.dict(proxy.__grains__, {'os': 'Windows'}):
         with patch.dict(proxy.__salt__, {'reg.read_value': mock}):
             out = proxy.get_ftp_proxy()
             mock.assert_called_once_with(
                 hive='HKEY_CURRENT_USER',
                 key='SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings',
                 vname='ProxyServer')
             self.assertEqual(expected, out)
Exemple #5
0
 def test_get_ftp_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.3',
         'port': '3128'
     }
     with patch.dict(proxy.__salt__, {'reg.read_value': mock}):
         out = proxy.get_ftp_proxy()
         mock.assert_called_once_with('HKEY_CURRENT_USER',
                                      'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings',
                                      'ProxyServer')
         self.assertEqual(expected, out)
Exemple #6
0
 def test_get_ftp_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.3", "port": "3128"}
     with patch.dict(proxy.__grains__, {"os": "Windows"}), patch.dict(
             proxy.__utils__, {"reg.read_value": mock}):
         out = proxy.get_ftp_proxy()
         mock.assert_called_once_with(
             hive="HKEY_CURRENT_USER",
             key=
             "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings",
             vname="ProxyServer",
         )
         self.assertEqual(expected, out)