test_win_dns_client.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # -*- coding: utf-8 -*-
  2. # Import Python libs
  3. from __future__ import absolute_import
  4. import pytest
  5. # Import Salt Testing libs
  6. from tests.support.case import ModuleCase
  7. from tests.support.unit import skipIf
  8. # Import Salt libs
  9. import salt.utils.platform
  10. @skipIf(not salt.utils.platform.is_windows(), 'windows test only')
  11. @pytest.mark.windows_whitelisted
  12. class WinDNSTest(ModuleCase):
  13. '''
  14. Test for salt.modules.win_dns_client
  15. '''
  16. @pytest.mark.destructive_test
  17. def test_add_remove_dns(self):
  18. '''
  19. Test add and removing a dns server
  20. '''
  21. # Get a list of interfaces on the system
  22. interfaces = self.run_function('network.interfaces_names')
  23. skipIf(interfaces.count == 0, 'This test requires a network interface')
  24. interface = interfaces[0]
  25. dns = '8.8.8.8'
  26. # add dns server
  27. self.assertTrue(self.run_function('win_dns_client.add_dns', [dns, interface], index=42))
  28. srvs = self.run_function('win_dns_client.get_dns_servers', interface=interface)
  29. self.assertIn(dns, srvs)
  30. # remove dns server
  31. self.assertTrue(self.run_function('win_dns_client.rm_dns', [dns], interface=interface))
  32. srvs = self.run_function('win_dns_client.get_dns_servers', interface=interface)
  33. self.assertNotIn(dns, srvs)