mirror of
https://github.com/valitydev/salt.git
synced 2024-11-06 16:45:27 +00:00
Merge pull request #48430 from rallytime/merge-develop
[develop] Merge forward from 2018.3 to develop
This commit is contained in:
commit
ff9f300563
1
.github/CODEOWNERS
vendored
1
.github/CODEOWNERS
vendored
@ -49,6 +49,7 @@ salt/spm/* @saltstack/team-spm
|
||||
# Team SSH
|
||||
salt/cli/ssh.py @saltstack/team-ssh
|
||||
salt/client/ssh/* @saltstack/team-ssh
|
||||
salt/roster/* @saltstack/team-ssh
|
||||
salt/runners/ssh.py @saltstack/team-ssh
|
||||
salt/**/thin.py @saltstack/team-ssh
|
||||
|
||||
|
@ -14,3 +14,20 @@ Improves timezone detection by using the pytz module.
|
||||
|
||||
Adds ``timezone.list`` to list supported timezones in either Windows or Unix
|
||||
format.
|
||||
|
||||
New Jinja Filter
|
||||
================
|
||||
|
||||
The :jinja_ref:`tojson` filter (from Jinja 2.9 and later) has been ported to
|
||||
Salt, and will be used when this filter is not available. This allows older LTS
|
||||
releases such as CentOS 7 and Ubuntu 14.04 to use this filter.
|
||||
|
||||
You should use this filter any time you wish to dump a list or dictionary into
|
||||
an SLS file, to ensure that the result is able to be loaded by the YAML
|
||||
renderer. For example:
|
||||
|
||||
.. code-block:: jinja
|
||||
|
||||
foo:
|
||||
bar.baz:
|
||||
- some_arg: {{ mydict|tojson }}
|
||||
|
@ -206,8 +206,8 @@ def get_rsa_pub_key(path):
|
||||
'''
|
||||
log.debug('salt.crypt.get_rsa_pub_key: Loading public key')
|
||||
if HAS_M2:
|
||||
with salt.utils.files.fopen(path) as f:
|
||||
data = f.read().replace(b'RSA ', '')
|
||||
with salt.utils.files.fopen(path, 'rb') as f:
|
||||
data = f.read().replace(b'RSA ', b'')
|
||||
bio = BIO.MemoryBuffer(data)
|
||||
key = RSA.load_pub_key_bio(bio)
|
||||
else:
|
||||
|
@ -25,13 +25,13 @@ def __virtual__():
|
||||
'''
|
||||
if salt.utils.platform.is_darwin() or salt.utils.platform.is_windows():
|
||||
return True
|
||||
return (False, 'Module proxy: module only works on Windows or MacOS systems')
|
||||
return False, 'Module proxy: module only works on Windows or MacOS systems'
|
||||
|
||||
|
||||
def _get_proxy_osx(function, network_service):
|
||||
def _get_proxy_osx(cmd_function, network_service):
|
||||
ret = {}
|
||||
|
||||
out = __salt__['cmd.run']('networksetup -{0} {1}'.format(function, network_service))
|
||||
out = __salt__['cmd.run']('networksetup -{0} {1}'.format(cmd_function, network_service))
|
||||
match = re.match('Enabled: (.*)\nServer: (.*)\nPort: (.*)\n', out)
|
||||
if match is not None:
|
||||
g = match.groups()
|
||||
@ -41,8 +41,8 @@ def _get_proxy_osx(function, network_service):
|
||||
return ret
|
||||
|
||||
|
||||
def _set_proxy_osx(function, server, port, user, password, network_service):
|
||||
cmd = 'networksetup -{0} {1} {2} {3}'.format(function, network_service, server, port)
|
||||
def _set_proxy_osx(cmd_function, server, port, user, password, network_service):
|
||||
cmd = 'networksetup -{0} {1} {2} {3}'.format(cmd_function, network_service, server, port)
|
||||
|
||||
if user is not None and password is not None:
|
||||
cmd = cmd + ' On {0} {1}'.format(user, password)
|
||||
@ -58,12 +58,12 @@ def _get_proxy_windows(types=None):
|
||||
if types is None:
|
||||
types = ['http', 'https', 'ftp']
|
||||
|
||||
reg_val = __salt__['reg.read_value']('HKEY_CURRENT_USER',
|
||||
r'SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings',
|
||||
'ProxyServer')
|
||||
servers = reg_val['vdata']
|
||||
servers = __salt__['reg.read_value'](
|
||||
hive='HKEY_CURRENT_USER',
|
||||
key=r'SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings',
|
||||
vname='ProxyServer')['vdata']
|
||||
|
||||
if "=" in servers:
|
||||
if servers and "=" in servers:
|
||||
split = servers.split(";")
|
||||
for s in split:
|
||||
if len(s) == 0:
|
||||
@ -87,16 +87,19 @@ def _get_proxy_windows(types=None):
|
||||
del ret[key]
|
||||
|
||||
# Return enabled info
|
||||
reg_val = __salt__['reg.read_value']('HKEY_CURRENT_USER',
|
||||
r'SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings',
|
||||
'ProxyEnable')
|
||||
enabled = reg_val.get('vdata', 0)
|
||||
ret['enabled'] = True if enabled == 1 else False
|
||||
ret['enabled'] = __salt__['reg.read_value'](
|
||||
hive='HKEY_CURRENT_USER',
|
||||
key=r'SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings',
|
||||
vname='ProxyEnable')['vdata'] == 1
|
||||
|
||||
return ret
|
||||
|
||||
|
||||
def _set_proxy_windows(server, port, types=None, bypass_hosts=None, import_winhttp=True):
|
||||
def _set_proxy_windows(server,
|
||||
port,
|
||||
types=None,
|
||||
bypass_hosts=None,
|
||||
import_winhttp=True):
|
||||
if types is None:
|
||||
types = ['http', 'https', 'ftp']
|
||||
|
||||
@ -104,17 +107,27 @@ def _set_proxy_windows(server, port, types=None, bypass_hosts=None, import_winht
|
||||
for t in types:
|
||||
server_str += '{0}={1}:{2};'.format(t, server, port)
|
||||
|
||||
__salt__['reg.set_value']('HKEY_CURRENT_USER', r'SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings',
|
||||
'ProxyServer', server_str)
|
||||
__salt__['reg.set_value'](
|
||||
hive='HKEY_CURRENT_USER',
|
||||
key=r'SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings',
|
||||
vname='ProxyServer',
|
||||
vdata=server_str)
|
||||
|
||||
__salt__['reg.set_value']('HKEY_CURRENT_USER', r'SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings',
|
||||
'ProxyEnable', 1, vtype='REG_DWORD')
|
||||
__salt__['reg.set_value'](
|
||||
hive='HKEY_CURRENT_USER',
|
||||
key=r'SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings',
|
||||
vname='ProxyEnable',
|
||||
vdata=1,
|
||||
vtype='REG_DWORD')
|
||||
|
||||
if bypass_hosts is not None:
|
||||
bypass_hosts_str = '<local>;{0}'.format(';'.join(bypass_hosts))
|
||||
|
||||
__salt__['reg.set_value']('HKEY_CURRENT_USER', r'SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings',
|
||||
'ProxyOverride', bypass_hosts_str)
|
||||
__salt__['reg.set_value'](
|
||||
hive='HKEY_CURRENT_USER',
|
||||
key=r'SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings',
|
||||
vname='ProxyOverride',
|
||||
vdata=bypass_hosts_str)
|
||||
|
||||
if import_winhttp:
|
||||
cmd = 'netsh winhttp import proxy source=ie'
|
||||
@ -138,15 +151,22 @@ def get_http_proxy(network_service="Ethernet"):
|
||||
salt '*' proxy.get_http_proxy Ethernet
|
||||
'''
|
||||
if __grains__['os'] == 'Windows':
|
||||
return _get_proxy_windows(['http'])
|
||||
return _get_proxy_windows(types=['http'])
|
||||
|
||||
return _get_proxy_osx("getwebproxy", network_service)
|
||||
return _get_proxy_osx(cmd_function="getwebproxy",
|
||||
network_service=network_service)
|
||||
|
||||
|
||||
def set_http_proxy(server, port, user=None, password=None, network_service="Ethernet", bypass_hosts=None):
|
||||
def set_http_proxy(server,
|
||||
port,
|
||||
user=None,
|
||||
password=None,
|
||||
network_service="Ethernet",
|
||||
bypass_hosts=None):
|
||||
'''
|
||||
Sets the http proxy settings. Note: On Windows this will override any other proxy settings you have,
|
||||
the preferred method of updating proxies on windows is using set_proxy.
|
||||
Sets the http proxy settings. Note: On Windows this will override any other
|
||||
proxy settings you have, the preferred method of updating proxies on windows
|
||||
is using set_proxy.
|
||||
|
||||
server
|
||||
The proxy server to use
|
||||
@ -165,8 +185,8 @@ def set_http_proxy(server, port, user=None, password=None, network_service="Ethe
|
||||
macOS
|
||||
|
||||
bypass_hosts
|
||||
The hosts that are allowed to by pass the proxy. Only used on Windows for other OS's use
|
||||
set_proxy_bypass to edit the bypass hosts.
|
||||
The hosts that are allowed to by pass the proxy. Only used on Windows
|
||||
for other OS's use set_proxy_bypass to edit the bypass hosts.
|
||||
|
||||
CLI Example:
|
||||
|
||||
@ -175,9 +195,17 @@ def set_http_proxy(server, port, user=None, password=None, network_service="Ethe
|
||||
salt '*' proxy.set_http_proxy example.com 1080 user=proxy_user password=proxy_pass network_service=Ethernet
|
||||
'''
|
||||
if __grains__['os'] == 'Windows':
|
||||
return _set_proxy_windows(server, port, ['http'], bypass_hosts)
|
||||
return _set_proxy_windows(server=server,
|
||||
port=port,
|
||||
types=['http'],
|
||||
bypass_hosts=bypass_hosts)
|
||||
|
||||
return _set_proxy_osx("setwebproxy", server, port, user, password, network_service)
|
||||
return _set_proxy_osx(cmd_function="setwebproxy",
|
||||
server=server,
|
||||
port=port,
|
||||
user=user,
|
||||
password=password,
|
||||
network_service=network_service)
|
||||
|
||||
|
||||
def get_https_proxy(network_service="Ethernet"):
|
||||
@ -195,15 +223,22 @@ def get_https_proxy(network_service="Ethernet"):
|
||||
salt '*' proxy.get_https_proxy Ethernet
|
||||
'''
|
||||
if __grains__['os'] == 'Windows':
|
||||
return _get_proxy_windows(['https'])
|
||||
return _get_proxy_windows(types=['https'])
|
||||
|
||||
return _get_proxy_osx("getsecurewebproxy", network_service)
|
||||
return _get_proxy_osx(cmd_function="getsecurewebproxy",
|
||||
network_service=network_service)
|
||||
|
||||
|
||||
def set_https_proxy(server, port, user=None, password=None, network_service="Ethernet", bypass_hosts=None):
|
||||
def set_https_proxy(server,
|
||||
port,
|
||||
user=None,
|
||||
password=None,
|
||||
network_service="Ethernet",
|
||||
bypass_hosts=None):
|
||||
'''
|
||||
Sets the https proxy settings. Note: On Windows this will override any other proxy settings you have,
|
||||
the preferred method of updating proxies on windows is using set_proxy.
|
||||
Sets the https proxy settings. Note: On Windows this will override any other
|
||||
proxy settings you have, the preferred method of updating proxies on windows
|
||||
is using set_proxy.
|
||||
|
||||
server
|
||||
The proxy server to use
|
||||
@ -222,8 +257,8 @@ def set_https_proxy(server, port, user=None, password=None, network_service="Eth
|
||||
macOS
|
||||
|
||||
bypass_hosts
|
||||
The hosts that are allowed to by pass the proxy. Only used on Windows for other OS's use
|
||||
set_proxy_bypass to edit the bypass hosts.
|
||||
The hosts that are allowed to by pass the proxy. Only used on Windows
|
||||
for other OS's use set_proxy_bypass to edit the bypass hosts.
|
||||
|
||||
CLI Example:
|
||||
|
||||
@ -232,9 +267,17 @@ def set_https_proxy(server, port, user=None, password=None, network_service="Eth
|
||||
salt '*' proxy.set_https_proxy example.com 1080 user=proxy_user password=proxy_pass network_service=Ethernet
|
||||
'''
|
||||
if __grains__['os'] == 'Windows':
|
||||
return _set_proxy_windows(server, port, ['https'], bypass_hosts)
|
||||
return _set_proxy_windows(server=server,
|
||||
port=port,
|
||||
types=['https'],
|
||||
bypass_hosts=bypass_hosts)
|
||||
|
||||
return _set_proxy_osx("setsecurewebproxy", server, port, user, password, network_service)
|
||||
return _set_proxy_osx(cmd_function="setsecurewebproxy",
|
||||
server=server,
|
||||
port=port,
|
||||
user=user,
|
||||
password=password,
|
||||
network_service=network_service)
|
||||
|
||||
|
||||
def get_ftp_proxy(network_service="Ethernet"):
|
||||
@ -252,12 +295,18 @@ def get_ftp_proxy(network_service="Ethernet"):
|
||||
salt '*' proxy.get_ftp_proxy Ethernet
|
||||
'''
|
||||
if __grains__['os'] == 'Windows':
|
||||
return _get_proxy_windows(['ftp'])
|
||||
return _get_proxy_windows(types=['ftp'])
|
||||
|
||||
return _get_proxy_osx("getftpproxy", network_service)
|
||||
return _get_proxy_osx(cmd_function="getftpproxy",
|
||||
network_service=network_service)
|
||||
|
||||
|
||||
def set_ftp_proxy(server, port, user=None, password=None, network_service="Ethernet", bypass_hosts=None):
|
||||
def set_ftp_proxy(server,
|
||||
port,
|
||||
user=None,
|
||||
password=None,
|
||||
network_service="Ethernet",
|
||||
bypass_hosts=None):
|
||||
'''
|
||||
Sets the ftp proxy settings
|
||||
|
||||
@ -278,8 +327,8 @@ def set_ftp_proxy(server, port, user=None, password=None, network_service="Ether
|
||||
macOS
|
||||
|
||||
bypass_hosts
|
||||
The hosts that are allowed to by pass the proxy. Only used on Windows for other OS's use
|
||||
set_proxy_bypass to edit the bypass hosts.
|
||||
The hosts that are allowed to by pass the proxy. Only used on Windows
|
||||
for other OS's use set_proxy_bypass to edit the bypass hosts.
|
||||
|
||||
CLI Example:
|
||||
|
||||
@ -288,9 +337,17 @@ def set_ftp_proxy(server, port, user=None, password=None, network_service="Ether
|
||||
salt '*' proxy.set_ftp_proxy example.com 1080 user=proxy_user password=proxy_pass network_service=Ethernet
|
||||
'''
|
||||
if __grains__['os'] == 'Windows':
|
||||
return _set_proxy_windows(server, port, ['ftp'], bypass_hosts)
|
||||
return _set_proxy_windows(server=server,
|
||||
port=port,
|
||||
types=['ftp'],
|
||||
bypass_hosts=bypass_hosts)
|
||||
|
||||
return _set_proxy_osx("setftpproxy", server, port, user, password, network_service)
|
||||
return _set_proxy_osx(cmd_function="setftpproxy",
|
||||
server=server,
|
||||
port=port,
|
||||
user=user,
|
||||
password=password,
|
||||
network_service=network_service)
|
||||
|
||||
|
||||
def get_proxy_bypass(network_service="Ethernet"):
|
||||
@ -309,12 +366,16 @@ def get_proxy_bypass(network_service="Ethernet"):
|
||||
|
||||
'''
|
||||
if __grains__['os'] == 'Windows':
|
||||
reg_val = __salt__['reg.read_value']('HKEY_CURRENT_USER',
|
||||
r'SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings',
|
||||
'ProxyOverride')
|
||||
bypass_servers = reg_val['vdata'].replace("<local>", "").split(";")
|
||||
reg_val = __salt__['reg.read_value'](
|
||||
hive='HKEY_CURRENT_USER',
|
||||
key=r'SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings',
|
||||
vname='ProxyOverride')['vdata']
|
||||
|
||||
return bypass_servers
|
||||
# `reg.read_value` returns None if the key doesn't exist
|
||||
if reg_val is None:
|
||||
return []
|
||||
|
||||
return reg_val.replace('<local>', '').split(';')
|
||||
|
||||
out = __salt__['cmd.run']('networksetup -getproxybypassdomains {0}'.format(network_service))
|
||||
|
||||
@ -357,7 +418,12 @@ def set_proxy_win(server, port, types=None, bypass_hosts=None):
|
||||
The password to use if required by the server
|
||||
|
||||
types
|
||||
The types of proxy connections should be setup with this server. Valid types are http and https.
|
||||
The types of proxy connections should be setup with this server. Valid
|
||||
types are:
|
||||
|
||||
- ``http``
|
||||
- ``https``
|
||||
- ``ftp``
|
||||
|
||||
bypass_hosts
|
||||
The hosts that are allowed to by pass the proxy.
|
||||
@ -369,7 +435,10 @@ def set_proxy_win(server, port, types=None, bypass_hosts=None):
|
||||
salt '*' proxy.set_http_proxy example.com 1080 types="['http', 'https']"
|
||||
'''
|
||||
if __grains__['os'] == 'Windows':
|
||||
return _set_proxy_windows(server, port, types, bypass_hosts)
|
||||
return _set_proxy_windows(server=server,
|
||||
port=port,
|
||||
types=types,
|
||||
bypass_hosts=bypass_hosts)
|
||||
|
||||
|
||||
def get_proxy_win():
|
||||
|
@ -923,7 +923,6 @@ def set_policy(vhost,
|
||||
if apply_to:
|
||||
cmd.extend(['--apply-to', apply_to])
|
||||
cmd.extend([name, pattern, definition])
|
||||
res = __salt__['cmd.run_all'](cmd, runas=runas, python_shell=False)
|
||||
res = __salt__['cmd.run_all'](cmd, reset_system_locale=False, runas=runas, python_shell=False)
|
||||
log.debug('Set policy: %s', res['stdout'])
|
||||
return _format_response(res, 'Set')
|
||||
|
@ -37,6 +37,7 @@ def __virtual__():
|
||||
'Devuan',
|
||||
'Arch',
|
||||
'Arch ARM',
|
||||
'Manjaro',
|
||||
'ALT',
|
||||
'SUSE Enterprise Server',
|
||||
'SUSE',
|
||||
|
@ -969,7 +969,8 @@ class SaltAPIHandler(BaseSaltAPIHandler): # pylint: disable=W0223
|
||||
|
||||
# minimum time required for return to complete. By default no waiting, if
|
||||
# we are a syndic then we must wait syndic_wait at a minimum
|
||||
min_wait_time = Future().set_result(True)
|
||||
min_wait_time = Future()
|
||||
min_wait_time.set_result(True)
|
||||
|
||||
# wait syndic a while to avoid missing published events
|
||||
if self.application.opts['order_masters']:
|
||||
|
@ -255,7 +255,12 @@ def _disable(name, started, result=True, **kwargs):
|
||||
return ret
|
||||
|
||||
# Service can be disabled
|
||||
before_toggle_disable_status = __salt__['service.disabled'](name)
|
||||
if salt.utils.platform.is_windows():
|
||||
# service.disabled in Windows returns True for services that are set to
|
||||
# Manual start, so we need to check specifically for Disabled
|
||||
before_toggle_disable_status = __salt__['service.info'](name)['StartType'] in ['Disabled']
|
||||
else:
|
||||
before_toggle_disable_status = __salt__['service.disabled'](name)
|
||||
if before_toggle_disable_status:
|
||||
# Service is disabled
|
||||
if started is True:
|
||||
@ -556,7 +561,12 @@ def dead(name,
|
||||
# command, so it is just an indicator but can not be fully trusted
|
||||
before_toggle_status = __salt__['service.status'](name, sig)
|
||||
if 'service.enabled' in __salt__:
|
||||
before_toggle_enable_status = __salt__['service.enabled'](name)
|
||||
if salt.utils.platform.is_windows():
|
||||
# service.enabled in Windows returns True for services that are set
|
||||
# to Auto start, but services set to Manual can also be disabled
|
||||
before_toggle_enable_status = __salt__['service.info'](name)['StartType'] in ['Auto', 'Manual']
|
||||
else:
|
||||
before_toggle_enable_status = __salt__['service.enabled'](name)
|
||||
else:
|
||||
before_toggle_enable_status = True
|
||||
|
||||
|
@ -23,6 +23,7 @@ import salt.utils.hashutils
|
||||
import salt.utils.xmlutil as xml
|
||||
from salt._compat import ElementTree as ET
|
||||
from salt.exceptions import CommandExecutionError
|
||||
from salt.ext.six.moves.urllib.parse import quote as _quote # pylint: disable=import-error,no-name-in-module
|
||||
from salt.ext import six
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@ -117,6 +118,7 @@ def query(key, keyid, method='GET', params=None, headers=None,
|
||||
location = salt.utils.aws.get_location()
|
||||
|
||||
data = ''
|
||||
fh = None
|
||||
payload_hash = None
|
||||
if method == 'PUT':
|
||||
if local_file:
|
||||
@ -124,6 +126,7 @@ def query(key, keyid, method='GET', params=None, headers=None,
|
||||
|
||||
if path is None:
|
||||
path = ''
|
||||
path = _quote(path)
|
||||
|
||||
if not requesturl:
|
||||
requesturl = (('https' if https_enable else 'http')+'://{0}/{1}').format(endpoint, path)
|
||||
@ -152,7 +155,8 @@ def query(key, keyid, method='GET', params=None, headers=None,
|
||||
try:
|
||||
if method == 'PUT':
|
||||
if local_file:
|
||||
data = salt.utils.files.fopen(local_file, 'r') # pylint: disable=resource-leakage
|
||||
fh = salt.utils.files.fopen(local_file, 'rb') # pylint: disable=resource-leakage
|
||||
data = fh.read() # pylint: disable=resource-leakage
|
||||
result = requests.request(method,
|
||||
requesturl,
|
||||
headers=headers,
|
||||
@ -173,8 +177,8 @@ def query(key, keyid, method='GET', params=None, headers=None,
|
||||
data=data,
|
||||
verify=verify_ssl)
|
||||
finally:
|
||||
if data is not None:
|
||||
data.close()
|
||||
if fh is not None:
|
||||
fh.close()
|
||||
|
||||
err_code = None
|
||||
err_msg = None
|
||||
|
@ -142,7 +142,7 @@ def accept_dict(match, include_rejected=False, include_denied=False):
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
>>> wheel.cmd('accept_dict',
|
||||
>>> wheel.cmd('key.accept_dict',
|
||||
{
|
||||
'minions_pre': [
|
||||
'jerry',
|
||||
|
@ -126,65 +126,56 @@ class ProxyTestCase(TestCase, LoaderModuleMockMixin):
|
||||
|
||||
def test_get_http_proxy_windows(self):
|
||||
'''
|
||||
Test to make sure that we correctly get the current proxy info
|
||||
on Windows
|
||||
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'}):
|
||||
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')
|
||||
mock.assert_called_once_with(
|
||||
hive='HKEY_CURRENT_USER',
|
||||
key='SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings',
|
||||
vname='ProxyServer')
|
||||
self.assertEqual(expected, out)
|
||||
|
||||
def test_get_https_proxy_windows(self):
|
||||
'''
|
||||
Test to make sure that we correctly get the current proxy info
|
||||
on Windows
|
||||
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.2',
|
||||
'port': '3128'}
|
||||
with patch.dict(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.2',
|
||||
'port': '3128'
|
||||
}
|
||||
with patch.dict(proxy.__salt__, {'reg.read_value': mock}):
|
||||
out = proxy.get_https_proxy()
|
||||
mock.assert_called_once_with('HKEY_CURRENT_USER',
|
||||
'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings',
|
||||
'ProxyServer')
|
||||
mock.assert_called_once_with(
|
||||
hive='HKEY_CURRENT_USER',
|
||||
key='SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings',
|
||||
vname='ProxyServer')
|
||||
self.assertEqual(expected, out)
|
||||
|
||||
def test_get_ftp_proxy_windows(self):
|
||||
'''
|
||||
Test to make sure that we correctly get the current proxy info
|
||||
on Windows
|
||||
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'}):
|
||||
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')
|
||||
mock.assert_called_once_with(
|
||||
hive='HKEY_CURRENT_USER',
|
||||
key='SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings',
|
||||
vname='ProxyServer')
|
||||
self.assertEqual(expected, out)
|
||||
|
||||
def test_get_all_proxies_macos_fails(self):
|
||||
@ -196,201 +187,179 @@ class ProxyTestCase(TestCase, LoaderModuleMockMixin):
|
||||
|
||||
def test_get_all_proxies_windows(self):
|
||||
'''
|
||||
Test to make sure that we correctly get the current proxy info
|
||||
on Windows
|
||||
Test to make sure that we correctly get the current proxy info on
|
||||
Windows
|
||||
'''
|
||||
results = [{'vdata': 'http=192.168.0.1:3128;https=192.168.0.2:3128;ftp=192.168.0.3:3128'},
|
||||
{'vdata': 1}]
|
||||
mock = MagicMock(side_effect=results)
|
||||
expected = {'enabled': True,
|
||||
'http': {'server': '192.168.0.1',
|
||||
'port': '3128'},
|
||||
'https': {'server': '192.168.0.2',
|
||||
'port': '3128'},
|
||||
'ftp': {'server': '192.168.0.3',
|
||||
'port': '3128'}}
|
||||
calls = [
|
||||
call(hive='HKEY_CURRENT_USER',
|
||||
key='SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings',
|
||||
vname='ProxyServer'),
|
||||
call(hive='HKEY_CURRENT_USER',
|
||||
key='SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings',
|
||||
vname='ProxyEnable')]
|
||||
with patch.dict(proxy.__grains__, {'os': 'Windows'}):
|
||||
results = [
|
||||
{
|
||||
'vdata': 'http=192.168.0.1:3128;https=192.168.0.2:3128;ftp=192.168.0.3:3128'
|
||||
},
|
||||
{
|
||||
'vdata': 1
|
||||
}
|
||||
]
|
||||
mock = MagicMock(side_effect=results)
|
||||
|
||||
expected = {
|
||||
'enabled': True,
|
||||
'http': {
|
||||
'server': '192.168.0.1',
|
||||
'port': '3128'
|
||||
},
|
||||
'https': {
|
||||
'server': '192.168.0.2',
|
||||
'port': '3128'
|
||||
},
|
||||
'ftp': {
|
||||
'server': '192.168.0.3',
|
||||
'port': '3128'
|
||||
}
|
||||
}
|
||||
with patch.dict(proxy.__salt__, {'reg.read_value': mock}):
|
||||
out = proxy.get_proxy_win()
|
||||
calls = [
|
||||
call('HKEY_CURRENT_USER',
|
||||
'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings',
|
||||
'ProxyServer'),
|
||||
call('HKEY_CURRENT_USER',
|
||||
'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings',
|
||||
'ProxyEnable'),
|
||||
]
|
||||
|
||||
mock.assert_has_calls(calls)
|
||||
self.assertEqual(expected, out)
|
||||
|
||||
def test_set_http_proxy_windows(self):
|
||||
'''
|
||||
Test to make sure that we correctly set the proxy info
|
||||
on Windows
|
||||
Test to make sure that we correctly set the proxy info on Windows
|
||||
'''
|
||||
calls = [
|
||||
call(hive='HKEY_CURRENT_USER',
|
||||
key='SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings',
|
||||
vname='ProxyServer',
|
||||
vdata='http=192.168.0.1:3128;'),
|
||||
call(hive='HKEY_CURRENT_USER',
|
||||
key='SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings',
|
||||
vname='ProxyEnable',
|
||||
vdata=1,
|
||||
vtype='REG_DWORD'),
|
||||
call(hive='HKEY_CURRENT_USER',
|
||||
key='SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings',
|
||||
vname='ProxyOverride',
|
||||
vdata='<local>;.moo.com;.salt.com')]
|
||||
mock_reg = MagicMock()
|
||||
mock_cmd = MagicMock()
|
||||
with patch.dict(proxy.__grains__, {'os': 'Windows'}):
|
||||
mock_reg = MagicMock()
|
||||
mock_cmd = MagicMock()
|
||||
|
||||
with patch.dict(proxy.__salt__, {'reg.set_value': mock_reg, 'cmd.run': mock_cmd}):
|
||||
out = proxy.set_http_proxy('192.168.0.1', 3128, bypass_hosts=['.moo.com', '.salt.com'])
|
||||
|
||||
calls = [
|
||||
call('HKEY_CURRENT_USER',
|
||||
'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings',
|
||||
'ProxyServer',
|
||||
'http=192.168.0.1:3128;'),
|
||||
call('HKEY_CURRENT_USER',
|
||||
'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings',
|
||||
'ProxyEnable',
|
||||
1,
|
||||
vtype='REG_DWORD'),
|
||||
call('HKEY_CURRENT_USER',
|
||||
'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings',
|
||||
'ProxyOverride',
|
||||
'<local>;.moo.com;.salt.com')
|
||||
]
|
||||
with patch.dict(proxy.__salt__, {'reg.set_value': mock_reg,
|
||||
'cmd.run': mock_cmd}):
|
||||
out = proxy.set_http_proxy(server='192.168.0.1',
|
||||
port=3128,
|
||||
bypass_hosts=['.moo.com', '.salt.com'])
|
||||
mock_reg.assert_has_calls(calls)
|
||||
mock_cmd.assert_called_once_with('netsh winhttp import proxy source=ie')
|
||||
self.assertTrue(out)
|
||||
|
||||
def test_set_https_proxy_windows(self):
|
||||
'''
|
||||
Test to make sure that we correctly set the proxy info
|
||||
on Windows
|
||||
Test to make sure that we correctly set the proxy info on Windows
|
||||
'''
|
||||
calls = [
|
||||
call(hive='HKEY_CURRENT_USER',
|
||||
key='SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings',
|
||||
vname='ProxyServer',
|
||||
vdata='https=192.168.0.1:3128;'),
|
||||
call(hive='HKEY_CURRENT_USER',
|
||||
key='SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings',
|
||||
vname='ProxyEnable',
|
||||
vdata=1,
|
||||
vtype='REG_DWORD'),
|
||||
call(hive='HKEY_CURRENT_USER',
|
||||
key='SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings',
|
||||
vname='ProxyOverride',
|
||||
vdata='<local>;.moo.com;.salt.com')]
|
||||
mock_reg = MagicMock()
|
||||
mock_cmd = MagicMock()
|
||||
with patch.dict(proxy.__grains__, {'os': 'Windows'}):
|
||||
mock_reg = MagicMock()
|
||||
mock_cmd = MagicMock()
|
||||
|
||||
with patch.dict(proxy.__salt__, {'reg.set_value': mock_reg, 'cmd.run': mock_cmd}):
|
||||
out = proxy.set_https_proxy('192.168.0.1', 3128, bypass_hosts=['.moo.com', '.salt.com'])
|
||||
|
||||
calls = [
|
||||
call('HKEY_CURRENT_USER',
|
||||
'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings',
|
||||
'ProxyServer',
|
||||
'https=192.168.0.1:3128;'),
|
||||
call('HKEY_CURRENT_USER',
|
||||
'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings',
|
||||
'ProxyEnable',
|
||||
1,
|
||||
vtype='REG_DWORD'),
|
||||
call('HKEY_CURRENT_USER',
|
||||
'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings',
|
||||
'ProxyOverride',
|
||||
'<local>;.moo.com;.salt.com')
|
||||
]
|
||||
with patch.dict(proxy.__salt__, {'reg.set_value': mock_reg,
|
||||
'cmd.run': mock_cmd}):
|
||||
out = proxy.set_https_proxy(server='192.168.0.1',
|
||||
port=3128,
|
||||
bypass_hosts=['.moo.com', '.salt.com'])
|
||||
mock_reg.assert_has_calls(calls)
|
||||
mock_cmd.assert_called_once_with('netsh winhttp import proxy source=ie')
|
||||
self.assertTrue(out)
|
||||
|
||||
def test_set_ftp_proxy_windows(self):
|
||||
'''
|
||||
Test to make sure that we correctly set the proxy info
|
||||
on Windows
|
||||
Test to make sure that we correctly set the proxy info on Windows
|
||||
'''
|
||||
calls = [
|
||||
call(hive='HKEY_CURRENT_USER',
|
||||
key='SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings',
|
||||
vname='ProxyServer',
|
||||
vdata='ftp=192.168.0.1:3128;'),
|
||||
call(hive='HKEY_CURRENT_USER',
|
||||
key='SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings',
|
||||
vname='ProxyEnable',
|
||||
vdata=1,
|
||||
vtype='REG_DWORD'),
|
||||
call(hive='HKEY_CURRENT_USER',
|
||||
key='SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings',
|
||||
vname='ProxyOverride',
|
||||
vdata='<local>;.moo.com;.salt.com')]
|
||||
mock_reg = MagicMock()
|
||||
mock_cmd = MagicMock()
|
||||
with patch.dict(proxy.__grains__, {'os': 'Windows'}):
|
||||
mock_reg = MagicMock()
|
||||
mock_cmd = MagicMock()
|
||||
|
||||
with patch.dict(proxy.__salt__, {'reg.set_value': mock_reg, 'cmd.run': mock_cmd}):
|
||||
out = proxy.set_ftp_proxy('192.168.0.1', 3128, bypass_hosts=['.moo.com', '.salt.com'])
|
||||
|
||||
calls = [
|
||||
call('HKEY_CURRENT_USER',
|
||||
'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings',
|
||||
'ProxyServer',
|
||||
'ftp=192.168.0.1:3128;'),
|
||||
call('HKEY_CURRENT_USER',
|
||||
'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings',
|
||||
'ProxyEnable',
|
||||
1,
|
||||
vtype='REG_DWORD'),
|
||||
call('HKEY_CURRENT_USER',
|
||||
'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings',
|
||||
'ProxyOverride',
|
||||
'<local>;.moo.com;.salt.com')
|
||||
]
|
||||
with patch.dict(proxy.__salt__, {'reg.set_value': mock_reg,
|
||||
'cmd.run': mock_cmd}):
|
||||
out = proxy.set_ftp_proxy(server='192.168.0.1',
|
||||
port=3128,
|
||||
bypass_hosts=['.moo.com', '.salt.com'])
|
||||
mock_reg.assert_has_calls(calls)
|
||||
mock_cmd.assert_called_once_with('netsh winhttp import proxy source=ie')
|
||||
self.assertTrue(out)
|
||||
|
||||
def test_set_proxy_windows(self):
|
||||
'''
|
||||
Test to make sure that we correctly set the proxy info
|
||||
on Windows
|
||||
Test to make sure that we correctly set the proxy info on Windows
|
||||
'''
|
||||
calls = [
|
||||
call(hive='HKEY_CURRENT_USER',
|
||||
key='SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings',
|
||||
vname='ProxyServer',
|
||||
vdata='http=192.168.0.1:3128;https=192.168.0.1:3128;ftp=192.168.0.1:3128;'),
|
||||
call(hive='HKEY_CURRENT_USER',
|
||||
key='SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings',
|
||||
vname='ProxyEnable',
|
||||
vdata=1,
|
||||
vtype='REG_DWORD'),
|
||||
call(hive='HKEY_CURRENT_USER',
|
||||
key='SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings',
|
||||
vname='ProxyOverride',
|
||||
vdata='<local>;.moo.com;.salt.com')]
|
||||
mock_reg = MagicMock()
|
||||
mock_cmd = MagicMock()
|
||||
with patch.dict(proxy.__grains__, {'os': 'Windows'}):
|
||||
mock_reg = MagicMock()
|
||||
mock_cmd = MagicMock()
|
||||
|
||||
with patch.dict(proxy.__salt__, {'reg.set_value': mock_reg, 'cmd.run': mock_cmd}):
|
||||
out = proxy.set_proxy_win('192.168.0.1', 3128, bypass_hosts=['.moo.com', '.salt.com'])
|
||||
|
||||
calls = [
|
||||
call('HKEY_CURRENT_USER',
|
||||
'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings',
|
||||
'ProxyServer',
|
||||
'http=192.168.0.1:3128;https=192.168.0.1:3128;ftp=192.168.0.1:3128;'),
|
||||
call('HKEY_CURRENT_USER',
|
||||
'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings',
|
||||
'ProxyEnable',
|
||||
1,
|
||||
vtype='REG_DWORD'),
|
||||
call('HKEY_CURRENT_USER',
|
||||
'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings',
|
||||
'ProxyOverride',
|
||||
'<local>;.moo.com;.salt.com')
|
||||
]
|
||||
with patch.dict(proxy.__salt__, {'reg.set_value': mock_reg,
|
||||
'cmd.run': mock_cmd}):
|
||||
out = proxy.set_proxy_win(server='192.168.0.1',
|
||||
port=3128,
|
||||
bypass_hosts=['.moo.com', '.salt.com'])
|
||||
mock_reg.assert_has_calls(calls)
|
||||
mock_cmd.assert_called_once_with('netsh winhttp import proxy source=ie')
|
||||
self.assertTrue(out)
|
||||
|
||||
def test_set_proxy_windows_no_ftp(self):
|
||||
'''
|
||||
Test to make sure that we correctly set the proxy info
|
||||
on Windows
|
||||
Test to make sure that we correctly set the proxy info on Windows
|
||||
'''
|
||||
calls = [
|
||||
call(hive='HKEY_CURRENT_USER',
|
||||
key='SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings',
|
||||
vname='ProxyServer',
|
||||
vdata='http=192.168.0.1:3128;https=192.168.0.1:3128;'),
|
||||
call(hive='HKEY_CURRENT_USER',
|
||||
key='SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings',
|
||||
vname='ProxyEnable',
|
||||
vdata=1,
|
||||
vtype='REG_DWORD'),
|
||||
call(hive='HKEY_CURRENT_USER',
|
||||
key='SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings',
|
||||
vname='ProxyOverride',
|
||||
vdata='<local>;.moo.com;.salt.com')]
|
||||
mock_reg = MagicMock()
|
||||
mock_cmd = MagicMock()
|
||||
with patch.dict(proxy.__grains__, {'os': 'Windows'}):
|
||||
mock_reg = MagicMock()
|
||||
mock_cmd = MagicMock()
|
||||
|
||||
with patch.dict(proxy.__salt__, {'reg.set_value': mock_reg, 'cmd.run': mock_cmd}):
|
||||
out = proxy.set_proxy_win('192.168.0.1', 3128, types=['http', 'https'],
|
||||
with patch.dict(proxy.__salt__, {'reg.set_value': mock_reg,
|
||||
'cmd.run': mock_cmd}):
|
||||
out = proxy.set_proxy_win(server='192.168.0.1',
|
||||
port=3128,
|
||||
types=['http', 'https'],
|
||||
bypass_hosts=['.moo.com', '.salt.com'])
|
||||
|
||||
calls = [
|
||||
call('HKEY_CURRENT_USER',
|
||||
'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings',
|
||||
'ProxyServer',
|
||||
'http=192.168.0.1:3128;https=192.168.0.1:3128;'),
|
||||
call('HKEY_CURRENT_USER',
|
||||
'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings',
|
||||
'ProxyEnable',
|
||||
1,
|
||||
vtype='REG_DWORD'),
|
||||
call('HKEY_CURRENT_USER',
|
||||
'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings',
|
||||
'ProxyOverride',
|
||||
'<local>;.moo.com;.salt.com')
|
||||
]
|
||||
mock_reg.assert_has_calls(calls)
|
||||
mock_cmd.assert_called_once_with('netsh winhttp import proxy source=ie')
|
||||
self.assertTrue(out)
|
||||
|
@ -215,7 +215,7 @@ class M2CryptTestCase(TestCase):
|
||||
self.assertEqual(SIG, crypt.sign_message('/keydir/keyname.pem', MSG, passphrase='password'))
|
||||
|
||||
def test_verify_signature(self):
|
||||
with patch('salt.utils.files.fopen', mock_open(read_data=PUBKEY_DATA)):
|
||||
with patch('salt.utils.files.fopen', mock_open(read_data=six.b(PUBKEY_DATA))):
|
||||
self.assertTrue(crypt.verify_signature('/keydir/keyname.pub', MSG, SIG))
|
||||
|
||||
def test_encrypt_decrypt_bin(self):
|
||||
@ -272,30 +272,30 @@ class TestBadCryptodomePubKey(TestCase):
|
||||
class TestM2CryptoRegression47124(TestCase):
|
||||
|
||||
SIGNATURE = (
|
||||
'w\xac\xfe18o\xeb\xfb\x14+\x9e\xd1\xb7\x7fe}\xec\xd6\xe1P\x9e\xab'
|
||||
'\xb5\x07\xe0\xc1\xfd\xda#\x04Z\x8d\x7f\x0b\x1f}:~\xb2s\x860u\x02N'
|
||||
'\xd4q"\xb7\x86*\x8f\x1f\xd0\x9d\x11\x92\xc5~\xa68\xac>\x12H\xc2%y,'
|
||||
'\xe6\xceU\x1e\xa3?\x0c,\xf0u\xbb\xd0[g_\xdd\x8b\xb0\x95:Y\x18\xa5*'
|
||||
'\x99\xfd\xf3K\x92\x92 ({\xd1\xff\xd9F\xc8\xd6K\x86e\xf9\xa8\xad\xb0z'
|
||||
'\xe3\x9dD\xf5k\x8b_<\xe7\xe7\xec\xf3"\'\xd5\xd2M\xb4\xce\x1a\xe3$'
|
||||
'\x9c\x81\xad\xf9\x11\xf6\xf5>)\xc7\xdd\x03&\xf7\x86@ks\xa6\x05\xc2'
|
||||
'\xd0\xbd\x1a7\xfc\xde\xe6\xb0\xad!\x12#\xc86Y\xea\xc5\xe3\xe2\xb3'
|
||||
'\xc9\xaf\xfa\x0c\xf2?\xbf\x93w\x18\x9e\x0b\xa2a\x10:M\x05\x89\xe2W.Q'
|
||||
'\xe8;yGT\xb1\xf2\xc6A\xd2\xc4\xbeN\xb3\xcfS\xaf\x03f\xe2\xb4)\xe7\xf6'
|
||||
'\xdbs\xd0Z}8\xa4\xd2\x1fW*\xe6\x1c"\x8b\xd0\x18w\xb9\x7f\x9e\x96\xa3'
|
||||
'\xd9v\xf7\x833\x8e\x01'
|
||||
b'w\xac\xfe18o\xeb\xfb\x14+\x9e\xd1\xb7\x7fe}\xec\xd6\xe1P\x9e\xab'
|
||||
b'\xb5\x07\xe0\xc1\xfd\xda#\x04Z\x8d\x7f\x0b\x1f}:~\xb2s\x860u\x02N'
|
||||
b'\xd4q"\xb7\x86*\x8f\x1f\xd0\x9d\x11\x92\xc5~\xa68\xac>\x12H\xc2%y,'
|
||||
b'\xe6\xceU\x1e\xa3?\x0c,\xf0u\xbb\xd0[g_\xdd\x8b\xb0\x95:Y\x18\xa5*'
|
||||
b'\x99\xfd\xf3K\x92\x92 ({\xd1\xff\xd9F\xc8\xd6K\x86e\xf9\xa8\xad\xb0z'
|
||||
b'\xe3\x9dD\xf5k\x8b_<\xe7\xe7\xec\xf3"\'\xd5\xd2M\xb4\xce\x1a\xe3$'
|
||||
b'\x9c\x81\xad\xf9\x11\xf6\xf5>)\xc7\xdd\x03&\xf7\x86@ks\xa6\x05\xc2'
|
||||
b'\xd0\xbd\x1a7\xfc\xde\xe6\xb0\xad!\x12#\xc86Y\xea\xc5\xe3\xe2\xb3'
|
||||
b'\xc9\xaf\xfa\x0c\xf2?\xbf\x93w\x18\x9e\x0b\xa2a\x10:M\x05\x89\xe2W.Q'
|
||||
b'\xe8;yGT\xb1\xf2\xc6A\xd2\xc4\xbeN\xb3\xcfS\xaf\x03f\xe2\xb4)\xe7\xf6'
|
||||
b'\xdbs\xd0Z}8\xa4\xd2\x1fW*\xe6\x1c"\x8b\xd0\x18w\xb9\x7f\x9e\x96\xa3'
|
||||
b'\xd9v\xf7\x833\x8e\x01'
|
||||
)
|
||||
|
||||
@skipIf(not HAS_M2, "Skip when m2crypto is not installed")
|
||||
def test_m2crypto_verify_bytes(self):
|
||||
message = salt.utils.stringutils.to_unicode('meh')
|
||||
with patch('salt.utils.files.fopen', mock_open(read_data=PUBKEY_DATA)):
|
||||
with patch('salt.utils.files.fopen', mock_open(read_data=six.b(PUBKEY_DATA))):
|
||||
salt.crypt.verify_signature('/keydir/keyname.pub', message, self.SIGNATURE)
|
||||
|
||||
@skipIf(not HAS_M2, "Skip when m2crypto is not installed")
|
||||
def test_m2crypto_verify_unicode(self):
|
||||
message = salt.utils.stringutils.to_bytes('meh')
|
||||
with patch('salt.utils.files.fopen', mock_open(read_data=PUBKEY_DATA)):
|
||||
with patch('salt.utils.files.fopen', mock_open(read_data=six.b(PUBKEY_DATA))):
|
||||
salt.crypt.verify_signature('/keydir/keyname.pub', message, self.SIGNATURE)
|
||||
|
||||
@skipIf(not HAS_M2, "Skip when m2crypto is not installed")
|
||||
|
Loading…
Reference in New Issue
Block a user