test_win_dns_client.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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.helpers import destructiveTest, slowTest
  7. from tests.support.unit import skipIf
  8. @skipIf(not salt.utils.platform.is_windows(), "windows test only")
  9. @pytest.mark.windows_whitelisted
  10. class WinDNSTest(ModuleCase):
  11. """
  12. Test for salt.modules.win_dns_client
  13. """
  14. @destructiveTest
  15. @slowTest
  16. def test_add_remove_dns(self):
  17. """
  18. Test add and removing a dns server
  19. """
  20. # Get a list of interfaces on the system
  21. interfaces = self.run_function("network.interfaces_names")
  22. skipIf(interfaces.count == 0, "This test requires a network interface")
  23. interface = interfaces[0]
  24. dns = "8.8.8.8"
  25. # add dns server
  26. self.assertTrue(
  27. self.run_function("win_dns_client.add_dns", [dns, interface], index=42)
  28. )
  29. srvs = self.run_function("win_dns_client.get_dns_servers", interface=interface)
  30. self.assertIn(dns, srvs)
  31. # remove dns server
  32. self.assertTrue(
  33. self.run_function("win_dns_client.rm_dns", [dns], interface=interface)
  34. )
  35. srvs = self.run_function("win_dns_client.get_dns_servers", interface=interface)
  36. self.assertNotIn(dns, srvs)