Merge pull request #10366 from rallytime/dig_test

More dig tests
This commit is contained in:
Mike Place 2014-02-11 14:33:17 -07:00
commit 012e4ed900

View File

@ -18,7 +18,7 @@ class DigTestCase(TestCase):
def test_check_ip_ipv6(self):
self.assertTrue(dig.check_ip('1111:2222:3333:4444:5555:6666:7777:8888'), msg='Not a valid ip address')
@skipIf(True, 'Temp commented out')
@skipIf(True, 'Waiting for 2014.1 release')
def test_check_ip_ipv6_valid(self):
self.assertTrue(dig.check_ip('2607:fa18:0:3::4'))
@ -39,7 +39,12 @@ class DigTestCase(TestCase):
'74.125.193.147'
})
with patch.dict(dig.__salt__, {'cmd.run_all': dig_mock}):
self.assertEqual(dig.A('www.google.com'), ['74.125.193.104', '74.125.193.105', '74.125.193.99', '74.125.193.106', '74.125.193.103', '74.125.193.147'])
self.assertEqual(dig.A('www.google.com'), ['74.125.193.104',
'74.125.193.105',
'74.125.193.99',
'74.125.193.106',
'74.125.193.103',
'74.125.193.147'])
@skipIf(True, 'Waiting for 2014.1 release')
def test_aaaa(self):
@ -48,4 +53,40 @@ class DigTestCase(TestCase):
'pid': 25451, 'retcode': 0, 'stderr': '', 'stdout': '2607:f8b0:400f:801::1014'
})
with patch.dict(dig.__salt__, {'cmd.run_all': dig_mock}):
self.assertEqual(dig.AAAA('www.google.com'), ['2607:f8b0:400f:801::1014'])
self.assertEqual(dig.AAAA('www.google.com'), ['2607:f8b0:400f:801::1014'])
@patch('salt.modules.dig.A', MagicMock(return_value=['ns4.google.com.']))
def test_ns(self):
dig.__salt__ = {}
dig_mock = MagicMock(return_value={
'pid': 26136, 'retcode': 0, 'stderr': '', 'stdout': 'ns4.google.com.'
})
with patch.dict(dig.__salt__, {'cmd.run_all': dig_mock}):
self.assertEqual(dig.NS('google.com'), ['ns4.google.com.'])
def test_spf(self):
dig.__salt__ = {}
dig_mock = MagicMock(return_value={'pid': 26795,
'retcode': 0,
'stderr': '',
'stdout': 'v=spf1'
' include:_spf.google.com '
'ip4:216.73.93.70/31 '
'ip4:216.73.93.72/31 ~all'})
with patch.dict(dig.__salt__, {'cmd.run_all': dig_mock}):
self.assertEqual(dig.SPF('google.com'),
['216.73.93.70/31', '216.73.93.72/31'])
@skipIf(True, 'Waiting for 2014.1 release')
def test_spf_redir(self):
'''
Test was written after a bug was found when a domain is redirecting the SPF ipv4 range
'''
dig.__salt__ = {}
dig_mock = MagicMock(return_value={'pid': 27282,
'retcode': 0,
'stderr': '',
'stdout': 'v=spf1 a mx '
'include:_spf.xmission.com ?all'})
with patch.dict(dig.__salt__, {'cmd.run_all': dig_mock}):
self.assertEqual(dig.SPF('xmission.com'), ['198.60.22.0/24', '166.70.13.0/24'])