test_azure_security_service.py 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import json
  2. import unittest
  3. import uuid
  4. from cloudbridge.cloud.interfaces import TestMockHelperMixin
  5. from test.helpers import ProviderTestBase
  6. import test.helpers as helpers
  7. class AzureSecurityServiceTestCase(ProviderTestBase):
  8. def __init__(self, methodName, provider):
  9. super(AzureSecurityServiceTestCase, self).__init__(
  10. methodName=methodName, provider=provider)
  11. @helpers.skipIfNoService(['security.security_groups'])
  12. def test_azure_security_group_list(self):
  13. sgl = self.provider.security.security_groups.list()
  14. found_sg = [g.name for g in sgl]
  15. for group in sgl:
  16. print("List( " + "Name-" + group.name + " Id-" + group.id + " Rules - " + " )")
  17. self.assertTrue(
  18. len(sgl) == 2,
  19. "Count should be 3")
  20. @helpers.skipIfNoService(['security.security_groups'])
  21. def test_azure_security_group_get_found(self):
  22. sgl = self.provider.security.security_groups.get("sg3")
  23. print("Get ( " + "Name - " + sgl.name + " Id - " + sgl.id + " )")
  24. self.assertTrue(
  25. sgl.name == "sec_group3",
  26. "SG name should be sec_group2")
  27. @helpers.skipIfNoService(['security.security_groups'])
  28. def test_azure_security_group_get_not_found(self):
  29. sgl = self.provider.security.security_groups.get("sg4")
  30. print(str(sgl))
  31. self.assertTrue(
  32. sgl == None,
  33. "Security group does not exist. Should return None.")
  34. @helpers.skipIfNoService(['security.security_groups'])
  35. def test_azure_security_group_delete_IdExists(self):
  36. sg = self.provider.security.security_groups.delete("sg2")
  37. print("Delete - ")
  38. self.assertEqual(sg, True)
  39. @helpers.skipIfNoService(['security.security_groups'])
  40. def test_azure_security_group_delete_IdNotExist(self):
  41. sg = self.provider.security.security_groups.delete("sg5")
  42. self.assertEqual(sg, False)