test_azure_security_service.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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) == 3,
  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("sg2")
  23. print("Get ( " + "Name - " + sgl.name + " Id - " + sgl.id + " )")
  24. self.assertTrue(
  25. sgl.name == "sec_group2",
  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.")