|
@@ -1,20 +1,17 @@
|
|
|
-import test.helpers as helpers
|
|
|
|
|
-from test.helpers import ProviderTestBase
|
|
|
|
|
|
|
+import azure_test.helpers as helpers
|
|
|
|
|
+from azure_test.helpers import ProviderTestBase
|
|
|
|
|
|
|
|
|
|
|
|
|
class AzureSecurityServiceTestCase(ProviderTestBase):
|
|
class AzureSecurityServiceTestCase(ProviderTestBase):
|
|
|
- def __init__(self, methodName, provider):
|
|
|
|
|
- super(AzureSecurityServiceTestCase, self).__init__(
|
|
|
|
|
- methodName=methodName, provider=provider)
|
|
|
|
|
|
|
+ @helpers.skipIfNoService(['security.security_groups'])
|
|
|
|
|
+ def test_azure_security_key_paires(self):
|
|
|
with self.assertRaises(NotImplementedError):
|
|
with self.assertRaises(NotImplementedError):
|
|
|
self.key_pairs = self.provider.security.key_pairs
|
|
self.key_pairs = self.provider.security.key_pairs
|
|
|
|
|
|
|
|
- self.security_groups = self.provider.security.security_groups
|
|
|
|
|
-
|
|
|
|
|
@helpers.skipIfNoService(['security.security_groups'])
|
|
@helpers.skipIfNoService(['security.security_groups'])
|
|
|
def test_azure_security_group_create(self):
|
|
def test_azure_security_group_create(self):
|
|
|
name = "testCreateSecGroup3"
|
|
name = "testCreateSecGroup3"
|
|
|
- sg = self.security_groups.create(
|
|
|
|
|
|
|
+ sg = self.provider.security.security_groups.create(
|
|
|
name=name, description=name, network_id="")
|
|
name=name, description=name, network_id="")
|
|
|
print("Create( " + "Name-" + sg.name + " Id-" + sg.id + " Rules - " + str(sg.rules) + " )")
|
|
print("Create( " + "Name-" + sg.name + " Id-" + sg.id + " Rules - " + str(sg.rules) + " )")
|
|
|
self.assertEqual(name, sg.name)
|
|
self.assertEqual(name, sg.name)
|
|
@@ -33,7 +30,7 @@ class AzureSecurityServiceTestCase(ProviderTestBase):
|
|
|
|
|
|
|
|
@helpers.skipIfNoService(['security.security_groups'])
|
|
@helpers.skipIfNoService(['security.security_groups'])
|
|
|
def test_azure_security_group_list(self):
|
|
def test_azure_security_group_list(self):
|
|
|
- sgl = self.security_groups.list()
|
|
|
|
|
|
|
+ sgl = self.provider.security.security_groups.list()
|
|
|
found_sg = [g.name for g in sgl]
|
|
found_sg = [g.name for g in sgl]
|
|
|
for group in sgl:
|
|
for group in sgl:
|
|
|
print("List( " + "Name-" + group.name + " Id-" + group.id + " Rules - " + " )")
|
|
print("List( " + "Name-" + group.name + " Id-" + group.id + " Rules - " + " )")
|
|
@@ -43,7 +40,7 @@ class AzureSecurityServiceTestCase(ProviderTestBase):
|
|
|
|
|
|
|
|
@helpers.skipIfNoService(['security.security_groups'])
|
|
@helpers.skipIfNoService(['security.security_groups'])
|
|
|
def test_azure_security_group_get_found(self):
|
|
def test_azure_security_group_get_found(self):
|
|
|
- sgl = self.security_groups.get(
|
|
|
|
|
|
|
+ sgl = self.provider.security.security_groups.get(
|
|
|
"/subscriptions/7904d702-e01c-4826-8519-f5a25c866a96/resourceGroups/CloudBridge-Azure'\
|
|
"/subscriptions/7904d702-e01c-4826-8519-f5a25c866a96/resourceGroups/CloudBridge-Azure'\
|
|
|
'/providers/Microsoft.Network/networkSecurityGroups/sg3")
|
|
'/providers/Microsoft.Network/networkSecurityGroups/sg3")
|
|
|
print("Get ( " + "Name - " + sgl.name + " Id - " + sgl.id + " )")
|
|
print("Get ( " + "Name - " + sgl.name + " Id - " + sgl.id + " )")
|
|
@@ -53,7 +50,7 @@ class AzureSecurityServiceTestCase(ProviderTestBase):
|
|
|
|
|
|
|
|
@helpers.skipIfNoService(['security.security_groups'])
|
|
@helpers.skipIfNoService(['security.security_groups'])
|
|
|
def test_azure_security_group_get_not_found(self):
|
|
def test_azure_security_group_get_not_found(self):
|
|
|
- sgl = self.security_groups.get(
|
|
|
|
|
|
|
+ sgl = self.provider.security.security_groups.get(
|
|
|
"/subscriptions/7904d702-e01c-4826-8519-f5a25c866a96/resourceGroups/CloudBridge-Azure'\
|
|
"/subscriptions/7904d702-e01c-4826-8519-f5a25c866a96/resourceGroups/CloudBridge-Azure'\
|
|
|
'/providers/Microsoft.Network/networkSecurityGroups/sg4")
|
|
'/providers/Microsoft.Network/networkSecurityGroups/sg4")
|
|
|
print(str(sgl))
|
|
print(str(sgl))
|
|
@@ -63,7 +60,7 @@ class AzureSecurityServiceTestCase(ProviderTestBase):
|
|
|
|
|
|
|
|
@helpers.skipIfNoService(['security.security_groups'])
|
|
@helpers.skipIfNoService(['security.security_groups'])
|
|
|
def test_azure_security_group_delete_IdExists(self):
|
|
def test_azure_security_group_delete_IdExists(self):
|
|
|
- sg = self.security_groups.delete(
|
|
|
|
|
|
|
+ sg = self.provider.security.security_groups.delete(
|
|
|
"/subscriptions/7904d702-e01c-4826-8519-f5a25c866a96/resourceGroups/CloudBridge-Azure'\
|
|
"/subscriptions/7904d702-e01c-4826-8519-f5a25c866a96/resourceGroups/CloudBridge-Azure'\
|
|
|
'/providers/Microsoft.Network/networkSecurityGroups/sg2")
|
|
'/providers/Microsoft.Network/networkSecurityGroups/sg2")
|
|
|
print("Delete - ")
|
|
print("Delete - ")
|
|
@@ -71,14 +68,14 @@ class AzureSecurityServiceTestCase(ProviderTestBase):
|
|
|
|
|
|
|
|
@helpers.skipIfNoService(['security.security_groups'])
|
|
@helpers.skipIfNoService(['security.security_groups'])
|
|
|
def test_azure_security_group_delete_IdNotExist(self):
|
|
def test_azure_security_group_delete_IdNotExist(self):
|
|
|
- sg = self.security_groups.delete(
|
|
|
|
|
|
|
+ sg = self.provider.security.security_groups.delete(
|
|
|
"/subscriptions/7904d702-e01c-4826-8519-f5a25c866a96/resourceGroups/CloudBridge-Azure'\
|
|
"/subscriptions/7904d702-e01c-4826-8519-f5a25c866a96/resourceGroups/CloudBridge-Azure'\
|
|
|
'/providers/Microsoft.Network/networkSecurityGroups/sg5")
|
|
'/providers/Microsoft.Network/networkSecurityGroups/sg5")
|
|
|
self.assertEqual(sg, False)
|
|
self.assertEqual(sg, False)
|
|
|
|
|
|
|
|
@helpers.skipIfNoService(['security.security_groups'])
|
|
@helpers.skipIfNoService(['security.security_groups'])
|
|
|
def test_azure_security_group_rule_create(self):
|
|
def test_azure_security_group_rule_create(self):
|
|
|
- list = self.security_groups.list()
|
|
|
|
|
|
|
+ list = self.provider.security.security_groups.list()
|
|
|
cb = list.data[0]
|
|
cb = list.data[0]
|
|
|
rules = cb.rules
|
|
rules = cb.rules
|
|
|
for rule in rules:
|
|
for rule in rules:
|
|
@@ -91,7 +88,7 @@ class AzureSecurityServiceTestCase(ProviderTestBase):
|
|
|
|
|
|
|
|
@helpers.skipIfNoService(['security.security_groups'])
|
|
@helpers.skipIfNoService(['security.security_groups'])
|
|
|
def test_azure_security_group_rule_delete(self):
|
|
def test_azure_security_group_rule_delete(self):
|
|
|
- list = self.security_groups.list()
|
|
|
|
|
|
|
+ list = self.provider.security.security_groups.list()
|
|
|
cb = list.data[0]
|
|
cb = list.data[0]
|
|
|
rules = cb.rules
|
|
rules = cb.rules
|
|
|
print("Before deleting Rule - " + str(rules[0]) + " length - " + str(len(rules)))
|
|
print("Before deleting Rule - " + str(rules[0]) + " length - " + str(len(rules)))
|
|
@@ -102,7 +99,7 @@ class AzureSecurityServiceTestCase(ProviderTestBase):
|
|
|
|
|
|
|
|
@helpers.skipIfNoService(['security.security_groups'])
|
|
@helpers.skipIfNoService(['security.security_groups'])
|
|
|
def test_azure_security_group_rule_get_exist(self):
|
|
def test_azure_security_group_rule_get_exist(self):
|
|
|
- list = self.security_groups.list()
|
|
|
|
|
|
|
+ list = self.provider.security.security_groups.list()
|
|
|
cb = list.data[0]
|
|
cb = list.data[0]
|
|
|
rule = cb.get_rule('*', '25', '1', '100')
|
|
rule = cb.get_rule('*', '25', '1', '100')
|
|
|
print("Get Rule - " + str(rule))
|
|
print("Get Rule - " + str(rule))
|
|
@@ -110,7 +107,7 @@ class AzureSecurityServiceTestCase(ProviderTestBase):
|
|
|
|
|
|
|
|
@helpers.skipIfNoService(['security.security_groups'])
|
|
@helpers.skipIfNoService(['security.security_groups'])
|
|
|
def test_azure_security_group_rule_get_notExist(self):
|
|
def test_azure_security_group_rule_get_notExist(self):
|
|
|
- list = self.security_groups.list()
|
|
|
|
|
|
|
+ list = self.provider.security.security_groups.list()
|
|
|
cb = list.data[0]
|
|
cb = list.data[0]
|
|
|
rule = cb.get_rule('*', '25', '1', '1')
|
|
rule = cb.get_rule('*', '25', '1', '1')
|
|
|
print("Get Rule - " + str(rule))
|
|
print("Get Rule - " + str(rule))
|
|
@@ -118,7 +115,7 @@ class AzureSecurityServiceTestCase(ProviderTestBase):
|
|
|
|
|
|
|
|
@helpers.skipIfNoService(['security.security_groups'])
|
|
@helpers.skipIfNoService(['security.security_groups'])
|
|
|
def test_azure_security_group_to_json(self):
|
|
def test_azure_security_group_to_json(self):
|
|
|
- list = self.security_groups.list()
|
|
|
|
|
|
|
+ list = self.provider.security.security_groups.list()
|
|
|
cb = list.data[0]
|
|
cb = list.data[0]
|
|
|
rule = cb.to_json()
|
|
rule = cb.to_json()
|
|
|
print("Get Rule - " + str(rule))
|
|
print("Get Rule - " + str(rule))
|
|
@@ -126,7 +123,7 @@ class AzureSecurityServiceTestCase(ProviderTestBase):
|
|
|
|
|
|
|
|
@helpers.skipIfNoService(['security.security_groups'])
|
|
@helpers.skipIfNoService(['security.security_groups'])
|
|
|
def test_azure_security_group_rule_to_json(self):
|
|
def test_azure_security_group_rule_to_json(self):
|
|
|
- list = self.security_groups.list()
|
|
|
|
|
|
|
+ list = self.provider.security.security_groups.list()
|
|
|
cb = list.data[0]
|
|
cb = list.data[0]
|
|
|
rules = cb.rules
|
|
rules = cb.rules
|
|
|
rule = rules[0]
|
|
rule = rules[0]
|