1
0

test_win_dns_client.py 1.3 KB

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