mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Test dig options for salt.utils.dns.lookup
This commit is contained in:
parent
a05305dce3
commit
a00d708441
2 changed files with 9 additions and 1 deletions
|
@ -45,6 +45,7 @@ try:
|
|||
except ImportError:
|
||||
HAS_DNSPYTHON = False
|
||||
HAS_DIG = salt.utils.path.which('dig') is not None
|
||||
DIG_OPTIONS = '+search +fail +noall +answer +noclass +nottl'
|
||||
HAS_DRILL = salt.utils.path.which('drill') is not None
|
||||
HAS_HOST = salt.utils.path.which('host') is not None
|
||||
HAS_NSLOOKUP = salt.utils.path.which('nslookup') is not None
|
||||
|
@ -229,7 +230,7 @@ def _lookup_dig(name, rdtype, timeout=None, servers=None, secure=None):
|
|||
:param servers: [] of servers to use
|
||||
:return: [] of records or False if error
|
||||
'''
|
||||
cmd = 'dig +search +fail +noall +answer +noclass +nottl -t {0} '.format(rdtype)
|
||||
cmd = 'dig {0} -t {1} '.format(DIG_OPTIONS, rdtype)
|
||||
if servers:
|
||||
cmd += ''.join(['@{0} '.format(srv) for srv in servers])
|
||||
if timeout is not None:
|
||||
|
|
|
@ -14,6 +14,7 @@ from salt.utils.odict import OrderedDict
|
|||
import salt.utils.dns
|
||||
from salt.utils.dns import _to_port, _tree, _weighted_order, _data2rec, _data2rec_group
|
||||
from salt.utils.dns import _lookup_gai, _lookup_dig, _lookup_drill, _lookup_host, _lookup_nslookup
|
||||
import salt.modules.cmdmod
|
||||
|
||||
# Testing
|
||||
from tests.support.unit import skipIf, TestCase
|
||||
|
@ -277,6 +278,12 @@ class DNSlookupsCase(TestCase):
|
|||
msg='Error parsing DNSSEC\'d {0} returns'.format(rec_t)
|
||||
)
|
||||
|
||||
@skipIf(not salt.utils.dns.HAS_DIG, 'dig is not available')
|
||||
def test_dig_options(self):
|
||||
cmd = 'dig {0}'.format(salt.utils.dns.DIG_OPTIONS)
|
||||
cmd = salt.modules.cmdmod.retcode(cmd, python_shell=False, output_loglevel='quiet')
|
||||
self.assertEqual(cmd, 0)
|
||||
|
||||
def test_dig(self):
|
||||
wrong_type = {'retcode': 0, 'stderr': ';; Warning, ignoring invalid type ABC'}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue