diff --git a/src/network-manager/azext_network_manager/tests/latest/test_network_scenario.py b/src/network-manager/azext_network_manager/tests/latest/test_network_scenario.py index 512dc2a1292..86eb18396d0 100644 --- a/src/network-manager/azext_network_manager/tests/latest/test_network_scenario.py +++ b/src/network-manager/azext_network_manager/tests/latest/test_network_scenario.py @@ -53,8 +53,7 @@ def test_network_manager_crud(self, resource_group): self.cmd('network manager delete --resource-group {rg} --name {name} --yes') @ResourceGroupPreparer(name_prefix='test_network_manager_group', location='eastus2euap') - @VirtualNetworkPreparer() - def test_network_manager_group_crud(self, virtual_network, resource_group): + def test_network_manager_group_crud(self, resource_group): self.kwargs.update({ 'name': 'TestNetworkGroup', @@ -62,8 +61,7 @@ def test_network_manager_group_crud(self, virtual_network, resource_group): 'description': '"A sample group"', 'display_name': 'MyNetworkGroup', 'member_type': 'Microsoft.Network/virtualNetworks', - 'sub': '/subscriptions/{}'.format(self.get_subscription_id()), - 'virtual_network': virtual_network + 'sub': '/subscriptions/{}'.format(self.get_subscription_id()) }) self.cmd('network manager create --name {manager_name} --description "My Test Network Manager" --display-name "TestNetworkManager" ' @@ -74,14 +72,44 @@ def test_network_manager_group_crud(self, virtual_network, resource_group): '--resource-group {rg}') self.cmd('network manager group create --name {name} --network-manager-name {manager_name} --description {description} ' - '--conditional-membership "" --display-name {display_name} --member-type "{member_type}" -g {rg} ' - '--group-members resource-id="{sub}/resourceGroups/{rg}/providers/Microsoft.Network/virtualnetworks/{virtual_network}" ') + '--display-name {display_name} --member-type "{member_type}" -g {rg} ') self.cmd('network manager group update -g {rg} --name {name} --network-manager-name {manager_name} --description "Desc changed."') self.cmd('network manager group show -g {rg} --name {name} --network-manager-name {manager_name}') self.cmd('network manager group list -g {rg} --network-manager-name {manager_name}') self.cmd('network manager group delete -g {rg} --name {name} --network-manager-name {manager_name} --yes') + @ResourceGroupPreparer(name_prefix='test_network_manager_static_member', location='eastus2euap') + @VirtualNetworkPreparer() + def test_network_manager_static_member_crud(self, virtual_network, resource_group): + self.kwargs.update({ + 'name': 'TestStaticMember', + 'group_name': 'TestNetworkGroup', + 'manager_name': 'TestNetworkManager', + 'description': '"A sample group"', + 'display_name': 'MyNetworkGroup', + 'member_type': 'Microsoft.Network/virtualNetworks', + 'sub': '/subscriptions/{}'.format(self.get_subscription_id()), + 'virtual_network': virtual_network + }) + self.cmd('network manager create --name {manager_name} --description "My Test Network Manager" --display-name "TestNetworkManager" ' + '--scope-accesses "Connectivity" ' + '--network-manager-scopes ' + ' subscriptions={sub} ' + '-l eastus2euap ' + '--resource-group {rg}') + + self.cmd('network manager group create --name {group_name} --network-manager-name {manager_name} --description {description} ' + '--display-name {display_name} --member-type "{member_type}" -g {rg} ') + + self.cmd('network manager group static-member create --name {name} --network-group-name {group_name} --network-manager-name {manager_name} ' + '--resource-id="{sub}/resourceGroups/{rg}/providers/Microsoft.Network/virtualnetworks/{virtual_network}" -g {rg} ') + + self.cmd('network manager group static-member update -g {rg} --name {name} --network-group-name {group_name} --network-manager-name {manager_name} --description "Desc changed."') + self.cmd('network manager group static-member show -g {rg} --name {name} --network-group-name {group_name} --network-manager-name {manager_name}') + self.cmd('network manager group static-member list -g {rg} --network-group-name {group_name} --network-manager-name {manager_name}') + self.cmd('network manager group static-member delete -g {rg} --name {name} --network-group-name {group_name} --network-manager-name {manager_name} --yes') + @ResourceGroupPreparer(name_prefix='test_network_manager_security_user_config', location='eastus2euap') def test_network_manager_security_user_config_crud(self, resource_group): @@ -167,8 +195,10 @@ def test_network_manager_admin_rule_crud(self, virtual_network, resource_group): '--resource-group {rg}') self.cmd('network manager group create --name {group_name} --network-manager-name {manager_name} --description {description} ' - '--conditional-membership "" --display-name ASampleGroup --member-type "Microsoft.Network/virtualNetworks" -g {rg} ' - '--group-members resource-id="{sub}/resourceGroups/{rg}/providers/Microsoft.Network/virtualnetworks/{virtual_network}" ') + ' --display-name ASampleGroup --member-type "Microsoft.Network/virtualNetworks" -g {rg} ') + + self.cmd('network manager group static-member create --name {name} --network-group-name {group_name} --network-manager-name {manager_name} ' + '--resource-id="{sub}/resourceGroups/{rg}/providers/Microsoft.Network/virtualnetworks/{virtual_network}" -g {rg} ') self.cmd('network manager security-admin-config create --configuration-name {config_name} --network-manager-name {manager_name} -g {rg} ' '--description {description} --delete-existing-ns-gs true --display-name MyTestConfig') @@ -209,8 +239,10 @@ def test_network_manager_admin_rule_collection_crud(self, virtual_network, resou '--resource-group {rg}') self.cmd('network manager group create --name {group_name} --network-manager-name {manager_name} --description {description} ' - '--conditional-membership "" --display-name ASampleGroup --member-type "Microsoft.Network/virtualNetworks" -g {rg} ' - '--group-members resource-id="{sub}/resourceGroups/{rg}/providers/Microsoft.Network/virtualnetworks/{virtual_network}" ') + '--display-name ASampleGroup --member-type "Microsoft.Network/virtualNetworks" -g {rg} ') + + self.cmd('network manager group static-member create --name {name} --network-group-name {group_name} --network-manager-name {manager_name} ' + '--resource-id="{sub}/resourceGroups/{rg}/providers/Microsoft.Network/virtualnetworks/{virtual_network}" -g {rg} ') self.cmd('network manager security-admin-config create --configuration-name {config_name} --network-manager-name {manager_name} -g {rg} ' '--description {description} --delete-existing-ns-gs true --display-name MyTestConfig') @@ -253,8 +285,10 @@ def test_network_manager_user_rule_crud(self, virtual_network, resource_group): '--resource-group {rg}') self.cmd('network manager group create --name {group_name} --network-manager-name {manager_name} --description {description} ' - '--conditional-membership "" --display-name ASampleGroup --member-type "Microsoft.Network/virtualNetworks" -g {rg} ' - '--group-members resource-id="{sub}/resourceGroups/{rg}/providers/Microsoft.Network/virtualnetworks/{virtual_network}" ') + '--display-name ASampleGroup --member-type "Microsoft.Network/virtualNetworks" -g {rg} ') + + self.cmd('network manager group static-member create --name {name} --network-group-name {group_name} --network-manager-name {manager_name} ' + '--resource-id="{sub}/resourceGroups/{rg}/providers/Microsoft.Network/virtualnetworks/{virtual_network}" -g {rg} ') self.cmd('network manager security-user-config create --configuration-name {config_name} --network-manager-name {manager_name} -g {rg} ' '--description {description} --delete-existing-ns-gs true --display-name MyTestConfig') @@ -293,8 +327,10 @@ def test_network_manager_user_rule_collection_crud(self, virtual_network, resour '--resource-group {rg}') self.cmd('network manager group create --name {group_name} --network-manager-name {manager_name} --description {description} ' - '--conditional-membership "" --display-name ASampleGroup --member-type "Microsoft.Network/virtualNetworks" -g {rg} ' - '--group-members resource-id="{sub}/resourceGroups/{rg}/providers/Microsoft.Network/virtualnetworks/{virtual_network}" ') + '--display-name ASampleGroup --member-type "Microsoft.Network/virtualNetworks" -g {rg} ') + + self.cmd('network manager group static-member create --name {name} --network-group-name {group_name} --network-manager-name {manager_name} ' + '--resource-id="{sub}/resourceGroups/{rg}/providers/Microsoft.Network/virtualnetworks/{virtual_network}" -g {rg} ') self.cmd('network manager security-user-config create --configuration-name {config_name} --network-manager-name {manager_name} -g {rg} ' '--description {description} --delete-existing-ns-gs true --display-name MyTestConfig') @@ -331,8 +367,10 @@ def test_network_manager_connect_config_crud(self, virtual_network, resource_gro '--resource-group {rg}') self.cmd('network manager group create --name {group_name} --network-manager-name {manager_name} --description {description} ' - '--conditional-membership "" --display-name ASampleGroup --member-type "Microsoft.Network/virtualNetworks" -g {rg} ' - '--group-members resource-id="{sub}/resourceGroups/{rg}/providers/Microsoft.Network/virtualnetworks/{virtual_network}" ') + '--display-name ASampleGroup --member-type "Microsoft.Network/virtualNetworks" -g {rg} ') + + self.cmd('network manager group static-member create --name {name} --network-group-name {group_name} --network-manager-name {manager_name} ' + '--resource-id="{sub}/resourceGroups/{rg}/providers/Microsoft.Network/virtualnetworks/{virtual_network}" -g {rg} ') self.cmd('network manager connect-config create --configuration-name {config_name} --network-manager-name {manager_name} -g {rg} ' '--applies-to-groups group-connectivity="None" network-group-id={sub}/resourceGroups/{rg}/providers/Microsoft.Network/networkManagers/{manager_name}/networkGroups/{group_name} ' @@ -365,8 +403,10 @@ def test_network_manager_list_queries(self, virtual_network, resource_group): '--resource-group {rg}') self.cmd('network manager group create --name {group_name} --network-manager-name {manager_name} --description {description} ' - '--conditional-membership "" --display-name ASampleGroup --member-type "Microsoft.Network/virtualNetworks" -g {rg} ' - '--group-members resource-id="{sub}/resourceGroups/{rg}/providers/Microsoft.Network/virtualnetworks/{virtual_network}" ') + '--display-name ASampleGroup --member-type "Microsoft.Network/virtualNetworks" -g {rg} ') + + self.cmd('network manager group static-member create --name {name} --network-group-name {group_name} --network-manager-name {manager_name} ' + '--resource-id="{sub}/resourceGroups/{rg}/providers/Microsoft.Network/virtualnetworks/{virtual_network}" -g {rg} ') self.cmd('network manager list-deploy-status --network-manager-name {manager_name} --deployment-types "Connectivity" --regions "eastus2euap" --resource-group {rg}') self.cmd('network manager group list-effect-vnet --network-group-name {group_name} --network-manager-name {manager_name} --resource-group {rg}') @@ -377,3 +417,95 @@ def test_network_manager_list_queries(self, virtual_network, resource_group): self.cmd('network manager list-active-security-admin-rule --network-manager-name {manager_name} -g {rg} --regions eastus2euap') # Internal Server Error # self.cmd('network manager list-active-security-user-rule --network-manager-name {manager_name} -g {rg} --region eastus2euap') + + + @ResourceGroupPreparer(name_prefix='test_network_manager_scope_connection_crud', location='eastus2euap') + def test_network_manager_scope_connection(self, resource_group): + + self.kwargs.update({ + 'connection_name': 'myTestScopeConnection', + 'manager_name': 'TestNetworkManager', + }) + + self.cmd('network manager create --name {manager_name} --description "My Test Network Manager" --display-name "TestNetworkManager" ' + '--scope-accesses "SecurityAdmin" "Connectivity" ' + '--network-manager-scopes ' + ' subscriptions={sub} ' + '-l eastus2euap ' + '--resource-group {rg}') + + self.cmd('network manager scope-connection create --resource-group {rg} --network-manager-name {manager_name} --name {connection_name} ' + '--description "My Test Network Manager Scope Connection"' + '--tenant-id "testTenantId"' + '--resource-id "testResourceId"') + + self.cmd('network manager scope-connection show -g {rg} --network-manager-name {manager_name} --name {connection_name} ') + + self.cmd('network manager scope-connection update --g {rg} --network-manager-name {manager_name} --name {connection_name} ' + '--description "My Test Network Manager Scope Connection Updated Description"') + + self.cmd('network manager scope-connection list -g {rg} --network-manager-name {manager_name} ') + + self.cmd('network manager scope-connection delete -g {rg} --network-manager-name {manager_name} --name {connection_name} ') + + @ResourceGroupPreparer(name_prefix='test_network_manager_connection_crud', location='eastus2euap') + def test_network_manager_scope_connection(self, resource_group): + + self.kwargs.update({ + 'subId': self.get_subscription_id(), + 'sub': '/subscriptions/{}'.format(self.get_subscription_id()), + 'manager_id': '/subscriptions/{}/resourceGroups/{rg}/providers/Microsoft.Network/networkManagers/{connection_name}'.format(self.get_subscription_id()), + 'manager_name': 'TestNetworkManager', + 'connection_name': 'myTestNetworkManagerConnection' + }) + + self.cmd('network manager create --name {manager_name} --description "My Test Network Manager" --display-name "TestNetworkManager" ' + '--scope-accesses "SecurityAdmin" "Connectivity" ' + '--network-manager-scopes ' + ' subscriptions={sub} ' + '-l eastus2euap ' + '--resource-group {rg}') + + self.cmd('network manager connection create --subscriptionId {subId} --connection-name {connection_name} ' + '--description "My Test Network Manager Connection"' + '--network-manager-id {manager_id}') + + self.cmd('network manager connection show --subscriptionId {subId} --connection-name {connection_name} ') + + self.cmd('network manager scope-connection update --subscriptionId {subId} --connection-name {connection_name} ' + '--description "My Test Network Manager Connection Updated Description"') + + self.cmd('network manager scope-connection list --subscriptionId {subId} ') + + self.cmd('network manager scope-connection delete --subscriptionId {subId} --connection-name {connection_name} ') + + @ResourceGroupPreparer(name_prefix='test_network_manager_connection_crud', location='eastus2euap') + def test_network_manager_scope_connection(self, resource_group): + + self.kwargs.update({ + 'sub': '/subscriptions/{}'.format(self.get_subscription_id()), + 'manager_id': '/subscriptions/{}/resourceGroups/{rg}/providers/Microsoft.Network/networkManagers/{connection_name}'.format(self.get_subscription_id()), + 'manager_name': 'TestNetworkManager', + 'connection_name': 'myTestNetworkManagerConnection', + 'mgId': 'testManagementGroupId' + }) + + self.cmd('network manager create --name {manager_name} --description "My Test Network Manager" --display-name "TestNetworkManager" ' + '--scope-accesses "SecurityAdmin" "Connectivity" ' + '--network-manager-scopes ' + ' subscriptions={sub} ' + '-l eastus2euap ' + '--resource-group {rg}') + + self.cmd('network manager connection create --management-group-id {mgId} --connection-name {connection_name} ' + '--description "My Test Network Manager Connection"' + '--network-manager-id {manager_id}') + + self.cmd('network manager connection show --management-group-id {mgId} --connection-name {connection_name} ') + + self.cmd('network manager scope-connection update --management-group-id {mgId} --connection-name {connection_name} ' + '--description "My Test Network Manager Connection Updated Description"') + + self.cmd('network manager scope-connection list --management-group-id {mgId} ') + + self.cmd('network manager scope-connection delete --management-group-id {mgId} --connection-name {connection_name} ') \ No newline at end of file