From 159e8cf070a557997e85fba4d33927687df67e38 Mon Sep 17 00:00:00 2001 From: Kirill Date: Fri, 24 Nov 2023 20:25:13 +0400 Subject: [PATCH] feat: Added a new tests for collected resources --- .../resoto_plugin_azure/resource/compute.py | 5 - plugins/azure/test/collector_test.py | 4 +- plugins/azure/test/conftest.py | 1 - .../test/files/network/loadBalancers.json | 20 ++ .../azure/test/files/network/natGateways.json | 61 ++++- .../test/files/network/networkInterfaces.json | 86 ++++++- .../files/network/networkSecurityGroups.json | 221 +++++++++++++++++- .../files/network/privateLinkServices.json | 133 ++++++++++- .../test/files/network/publicIPAddresses.json | 70 +++++- .../files/network/virtualNetworkTaps.json | 45 +++- plugins/azure/test/network_test.py | 99 +++++--- 11 files changed, 694 insertions(+), 51 deletions(-) diff --git a/plugins/azure/resoto_plugin_azure/resource/compute.py b/plugins/azure/resoto_plugin_azure/resource/compute.py index 96f57f017b..dc2e2fcd3d 100644 --- a/plugins/azure/resoto_plugin_azure/resource/compute.py +++ b/plugins/azure/resoto_plugin_azure/resource/compute.py @@ -1101,11 +1101,6 @@ def connect_in_graph(self, builder: GraphBuilder, source: Json) -> None: if vmss_id := vmss.id: builder.add_edge(self, clazz=AzureVirtualMachineScaleSet, id=vmss_id) - # if vms := self.virtual_machines_status: - # for vm in vms: - # if vm_id := vm.id: - # builder.add_edge(self, clazz=AzureVirtualMachine, id=vm_id) - @define(eq=False, slots=False) class AzureResourceSkuCapacity: diff --git a/plugins/azure/test/collector_test.py b/plugins/azure/test/collector_test.py index 0701512089..6f2058b023 100644 --- a/plugins/azure/test/collector_test.py +++ b/plugins/azure/test/collector_test.py @@ -15,5 +15,5 @@ def test_collect( ) -> None: collector = AzureSubscriptionCollector(config, Cloud(id="azure"), azure_subscription, credentials, core_feedback) collector.collect() - assert len(collector.graph.nodes) == 454 - assert len(collector.graph.edges) == 472 + assert len(collector.graph.nodes) == 467 + assert len(collector.graph.edges) == 493 diff --git a/plugins/azure/test/conftest.py b/plugins/azure/test/conftest.py index 93d4682137..36c6e562df 100644 --- a/plugins/azure/test/conftest.py +++ b/plugins/azure/test/conftest.py @@ -134,7 +134,6 @@ def roundtrip_check( # since we can not compare objects, we use the json representation to see that no information is lost again_js = again.to_json() assert js_repr == again_js, f"Left: {js_repr}\nRight: {again_js}" - print(resources) return resources diff --git a/plugins/azure/test/files/network/loadBalancers.json b/plugins/azure/test/files/network/loadBalancers.json index 32e6b49d8e..1fb94a6a4f 100644 --- a/plugins/azure/test/files/network/loadBalancers.json +++ b/plugins/azure/test/files/network/loadBalancers.json @@ -47,6 +47,26 @@ "type": "Microsoft.Network/loadBalancers/backendAddressPools", "properties": { "provisioningState": "Succeeded", + "virtualNetwork": { + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet1" + }, + "loadBalancingRules": [ + { + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/loadBalancingRules/rulelb" + } + ] + } + }, + { + "name": "telb", + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/backendAddressPools/telb", + "etag": "W/\"00000000-0000-0000-0000-00000000\"", + "type": "Microsoft.Network/loadBalancers/backendAddressPools", + "properties": { + "provisioningState": "Succeeded", + "virtualNetwork": { + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet2" + }, "loadBalancingRules": [ { "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/loadBalancingRules/rulelb" diff --git a/plugins/azure/test/files/network/natGateways.json b/plugins/azure/test/files/network/natGateways.json index d17ed79daf..7d42b1ce03 100644 --- a/plugins/azure/test/files/network/natGateways.json +++ b/plugins/azure/test/files/network/natGateways.json @@ -1 +1,60 @@ -{ "value": []} +{ + "value": [ + { + "name": "test-natGateway", + "sku": { + "name": "Standard" + }, + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/natGateways/test-natGateway", + "location": "westus", + "properties": { + "idleTimeoutInMinutes": 5, + "provisioningState": "Succeeded", + "publicIpAddresses": [ + { + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/PublicIpAddress1" + } + ], + "publicIpPrefixes": [ + { + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/publicIPPrefixes/PublicIpPrefix1" + } + ], + "subnets": [ + { + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/subnet1" + } + ] + }, + "type": "Microsoft.Network/natGateways" + }, + { + "name": "test-natGateway2", + "sku": { + "name": "Standard" + }, + "id": "/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/natGatewayes/test-natGateway2", + "location": "westus", + "properties": { + "idleTimeoutInMinutes": 5, + "provisioningState": "Succeeded", + "publicIpAddresses": [ + { + "id": "/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/publicIPAddresses/PublicIpAddress1" + } + ], + "publicIpPrefixes": [ + { + "id": "/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/publicIPPrefixes/PublicIpPrefix1" + } + ], + "subnets": [ + { + "id": "/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/subnet1" + } + ] + }, + "type": "Microsoft.Network/natGateways" + } + ] + } \ No newline at end of file diff --git a/plugins/azure/test/files/network/networkInterfaces.json b/plugins/azure/test/files/network/networkInterfaces.json index d17ed79daf..5339e189d1 100644 --- a/plugins/azure/test/files/network/networkInterfaces.json +++ b/plugins/azure/test/files/network/networkInterfaces.json @@ -1 +1,85 @@ -{ "value": []} +{ + "value": [ + { + "name": "test-nic", + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/networkInterfaces/test-nic", + "location": "eastus", + "properties": { + "provisioningState": "Succeeded", + "ipConfigurations": [ + { + "name": "ipconfig1", + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/networkInterfaces/test-nic/ipConfigurations/ipconfig1", + "properties": { + "provisioningState": "Succeeded", + "privateIPAddress": "172.20.2.4", + "privateIPAllocationMethod": "Dynamic", + "publicIPAddress": { + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/test-ip" + }, + "subnet": { + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/rg1-vnet/subnets/default" + }, + "primary": true, + "privateIPAddressVersion": "IPv4" + } + } + ], + "dnsSettings": { + "dnsServers": [], + "appliedDnsServers": [], + "internalDomainNameSuffix": "test.bx.internal.cloudapp.net" + }, + "macAddress": "00-0D-3A-1B-C7-21", + "enableAcceleratedNetworking": true, + "disableTcpStateTracking": true, + "enableIPForwarding": false, + "vnetEncryptionSupported": false, + "networkSecurityGroup": { + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/networkSecurityGroups/nsg" + }, + "primary": true, + "virtualMachine": { + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Compute/virtualMachines/vm1" + } + }, + "type": "Microsoft.Network/networkInterfaces" + }, + { + "name": "test-nic2", + "id": "/subscriptions/subid/resourceGroups/rgnew/providers/Microsoft.Network/networkInterfaces/test-nic2", + "location": "eastus", + "properties": { + "provisioningState": "Succeeded", + "ipConfigurations": [ + { + "name": "ipconfig1", + "id": "/subscriptions/subid/resourceGroups/rgnew/providers/Microsoft.Network/networkInterfaces/test-nic2/ipConfigurations/ipconfig1", + "properties": { + "provisioningState": "Succeeded", + "privateIPAddress": "172.20.2.4", + "privateIPAllocationMethod": "Dynamic", + "publicIPAddress": { + "id": "/subscriptions/subid/resourceGroups/rgnew/providers/Microsoft.Network/publicIPAddresses/test-ip2" + }, + "subnet": { + "id": "/subscriptions/subid/resourceGroups/rgnew/providers/Microsoft.Network/virtualNetworks/rgnew-vnet2/subnets/default" + }, + "primary": true, + "privateIPAddressVersion": "IPv4" + } + } + ], + "dnsSettings": { + "dnsServers": [], + "appliedDnsServers": [] + }, + "enableAcceleratedNetworking": true, + "disableTcpStateTracking": true, + "enableIPForwarding": false, + "vnetEncryptionSupported": false + }, + "type": "Microsoft.Network/networkInterfaces" + } + ] + } \ No newline at end of file diff --git a/plugins/azure/test/files/network/networkSecurityGroups.json b/plugins/azure/test/files/network/networkSecurityGroups.json index d17ed79daf..795d33bd98 100644 --- a/plugins/azure/test/files/network/networkSecurityGroups.json +++ b/plugins/azure/test/files/network/networkSecurityGroups.json @@ -1 +1,220 @@ -{ "value": []} +{ + "value": [ + { + "name": "nsg1", + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/networkSecurityGroups/nsg1", + "type": "Microsoft.Network/networkSecurityGroups", + "location": "westus", + "properties": { + "provisioningState": "Succeeded", + "securityRules": [], + "defaultSecurityRules": [ + { + "name": "AllowVnetInBound", + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/networkSecurityGroups/nsg1/defaultSecurityRules/AllowVnetInBound", + "properties": { + "provisioningState": "Succeeded", + "description": "Allow inbound traffic from all VMs in VNET", + "protocol": "*", + "sourcePortRange": "*", + "destinationPortRange": "*", + "sourceAddressPrefix": "VirtualNetwork", + "destinationAddressPrefix": "VirtualNetwork", + "access": "Allow", + "priority": 65000, + "direction": "Inbound" + } + }, + { + "name": "AllowAzureLoadBalancerInBound", + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/networkSecurityGroups/nsg1/defaultSecurityRules/AllowAzureLoadBalancerInBound", + "properties": { + "provisioningState": "Succeeded", + "description": "Allow inbound traffic from azure load balancer", + "protocol": "*", + "sourcePortRange": "*", + "destinationPortRange": "*", + "sourceAddressPrefix": "AzureLoadBalancer", + "destinationAddressPrefix": "*", + "access": "Allow", + "priority": 65001, + "direction": "Inbound" + } + }, + { + "name": "DenyAllInBound", + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/networkSecurityGroups/nsg1/defaultSecurityRules/DenyAllInBound", + "properties": { + "provisioningState": "Succeeded", + "description": "Deny all inbound traffic", + "protocol": "*", + "sourcePortRange": "*", + "destinationPortRange": "*", + "sourceAddressPrefix": "*", + "destinationAddressPrefix": "*", + "access": "Deny", + "priority": 65500, + "direction": "Inbound" + } + }, + { + "name": "AllowVnetOutBound", + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/networkSecurityGroups/nsg1/defaultSecurityRules/AllowVnetOutBound", + "properties": { + "provisioningState": "Succeeded", + "description": "Allow outbound traffic from all VMs to all VMs in VNET", + "protocol": "*", + "sourcePortRange": "*", + "destinationPortRange": "*", + "sourceAddressPrefix": "VirtualNetwork", + "destinationAddressPrefix": "VirtualNetwork", + "access": "Allow", + "priority": 65000, + "direction": "Outbound" + } + }, + { + "name": "AllowInternetOutBound", + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/networkSecurityGroups/nsg1/defaultSecurityRules/AllowInternetOutBound", + "properties": { + "provisioningState": "Succeeded", + "description": "Allow outbound traffic from all VMs to Internet", + "protocol": "*", + "sourcePortRange": "*", + "destinationPortRange": "*", + "sourceAddressPrefix": "*", + "destinationAddressPrefix": "Internet", + "access": "Allow", + "priority": 65001, + "direction": "Outbound" + } + }, + { + "name": "DenyAllOutBound", + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/networkSecurityGroups/nsg1/defaultSecurityRules/DenyAllOutBound", + "properties": { + "provisioningState": "Succeeded", + "description": "Deny all outbound traffic", + "protocol": "*", + "sourcePortRange": "*", + "destinationPortRange": "*", + "sourceAddressPrefix": "*", + "destinationAddressPrefix": "*", + "access": "Deny", + "priority": 65500, + "direction": "Outbound" + } + } + ] + } + }, + { + "name": "nsg3", + "id": "/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/networkSecurityGroups/nsg3", + "type": "Microsoft.Network/networkSecurityGroups", + "location": "westus", + "properties": { + "provisioningState": "Succeeded", + "securityRules": [], + "defaultSecurityRules": [ + { + "name": "AllowVnetInBound", + "id": "/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/networkSecurityGroups/nsg3/defaultSecurityRules/AllowVnetInBound", + "properties": { + "provisioningState": "Succeeded", + "description": "Allow inbound traffic from all VMs in VNET", + "protocol": "*", + "sourcePortRange": "*", + "destinationPortRange": "*", + "sourceAddressPrefix": "VirtualNetwork", + "destinationAddressPrefix": "VirtualNetwork", + "access": "Allow", + "priority": 65000, + "direction": "Inbound" + } + }, + { + "name": "AllowAzureLoadBalancerInBound", + "id": "/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/networkSecurityGroups/nsg3/defaultSecurityRules/AllowAzureLoadBalancerInBound", + "properties": { + "provisioningState": "Succeeded", + "description": "Allow inbound traffic from azure load balancer", + "protocol": "*", + "sourcePortRange": "*", + "destinationPortRange": "*", + "sourceAddressPrefix": "AzureLoadBalancer", + "destinationAddressPrefix": "*", + "access": "Allow", + "priority": 65001, + "direction": "Inbound" + } + }, + { + "name": "DenyAllInBound", + "id": "/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/networkSecurityGroups/nsg3/defaultSecurityRules/DenyAllInBound", + "properties": { + "provisioningState": "Succeeded", + "description": "Deny all inbound traffic", + "protocol": "*", + "sourcePortRange": "*", + "destinationPortRange": "*", + "sourceAddressPrefix": "*", + "destinationAddressPrefix": "*", + "access": "Deny", + "priority": 65500, + "direction": "Inbound" + } + }, + { + "name": "AllowVnetOutBound", + "id": "/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/networkSecurityGroups/nsg3/defaultSecurityRules/AllowVnetOutBound", + "properties": { + "provisioningState": "Succeeded", + "description": "Allow outbound traffic from all VMs to all VMs in VNET", + "protocol": "*", + "sourcePortRange": "*", + "destinationPortRange": "*", + "sourceAddressPrefix": "VirtualNetwork", + "destinationAddressPrefix": "VirtualNetwork", + "access": "Allow", + "priority": 65000, + "direction": "Outbound" + } + }, + { + "name": "AllowInternetOutBound", + "id": "/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/networkSecurityGroups/nsg3/defaultSecurityRules/AllowInternetOutBound", + "properties": { + "provisioningState": "Succeeded", + "description": "Allow outbound traffic from all VMs to Internet", + "protocol": "*", + "sourcePortRange": "*", + "destinationPortRange": "*", + "sourceAddressPrefix": "*", + "destinationAddressPrefix": "Internet", + "access": "Allow", + "priority": 65001, + "direction": "Outbound" + } + }, + { + "name": "DenyAllOutBound", + "id": "/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/networkSecurityGroups/nsg3/defaultSecurityRules/DenyAllOutBound", + "properties": { + "provisioningState": "Succeeded", + "description": "Deny all outbound traffic", + "protocol": "*", + "sourcePortRange": "*", + "destinationPortRange": "*", + "sourceAddressPrefix": "*", + "destinationAddressPrefix": "*", + "access": "Deny", + "priority": 65500, + "direction": "Outbound" + } + } + ] + } + } + ] + } \ No newline at end of file diff --git a/plugins/azure/test/files/network/privateLinkServices.json b/plugins/azure/test/files/network/privateLinkServices.json index d17ed79daf..77fe64a620 100644 --- a/plugins/azure/test/files/network/privateLinkServices.json +++ b/plugins/azure/test/files/network/privateLinkServices.json @@ -1 +1,132 @@ -{ "value": []} +{ + "value": [ + { + "name": "testPls1", + "id": "/subscriptions/subId/resourceGroups/rg1/providers/Microsoft.Network/privateLinkServices/testPls1", + "type": "Microsoft.Network/privateLinkServices", + "location": "eastus", + "properties": { + "provisioningState": "Succeeded", + "visibility": { + "subscriptions": [ + "subscription1", + "subscription2", + "subscription3" + ] + }, + "autoApproval": { + "subscriptions": [ + "subscription1", + "subscription2" + ] + }, + "fqdns": [ + "fqdn1", + "fqdn2", + "fqdn3" + ], + "alias": "ContosoService.{guid}.azure.privatelinkservice", + "loadBalancerFrontendIpConfigurations": [ + { + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/fe-lb1" + } + ], + "ipConfigurations": [ + { + "name": "fe-lb1", + "properties": { + "privateIPAddress": "10.0.1.4", + "privateIPAllocationMethod": "Static", + "privateIPAddressVersion": "IPv4", + "subnet": { + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnetlb/subnets/subnetlb1" + } + } + } + ], + "privateEndpointConnections": [ + { + "name": "pec1", + "properties": { + "privateEndpoint": { + "id": "/subscriptions/subId/resourceGroups/rg1/providers/Microsoft.Network/privateEndpoints/testPe1" + }, + "privateLinkServiceConnectionState": { + "status": "Approved", + "description": "approved it for some reason." + } + } + } + ], + "networkInterfaces": [ + { + "id": "/subscriptions/subId/resourceGroups/rg1/provders/Microsoft.Network/networkInterfaces/testPls1.nic.abcd1234" + } + ] + } + }, + { + "name": "testPls2", + "id": "/subscriptions/subId/resourceGroups/rg2/providers/Microsoft.Network/privateLinkServices/testPls2", + "type": "Microsoft.Network/privateLinkServices", + "location": "eastus", + "properties": { + "provisioningState": "Succeeded", + "visibility": { + "subscriptions": [ + "subscription1", + "subscription2" + ] + }, + "autoApproval": { + "subscriptions": [ + "subscription1", + "subscription2" + ] + }, + "fqdns": [ + "fqdn1", + "fqdn2" + ], + "alias": "ContosoService.{guid}.azure.privatelinkservice", + "loadBalancerFrontendIpConfigurations": [ + { + "id": "/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/fe-lb2" + } + ], + "ipConfigurations": [ + { + "name": "fe-lb2", + "properties": { + "privateIPAddress": "10.0.1.5", + "privateIPAllocationMethod": "Static", + "privateIPAddressVersion": "IPv4", + "subnet": { + "id": "/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/virtualNetworks/vnetlb/subnets/subnetlb2" + } + } + } + ], + "privateEndpointConnections": [ + { + "name": "pec1", + "properties": { + "privateEndpoint": { + "id": "/subscriptions/subId/resourceGroups/rg2/providers/Microsoft.Network/privateEndpoints/testPe2" + }, + "privateLinkServiceConnectionState": { + "status": "Approved", + "description": "approved it for some reason." + } + } + } + ], + "networkInterfaces": [ + { + "id": "/subscriptions/subId/resourceGroups/rg2/provders/Microsoft.Network/networkInterfaces/testPls2.nic.efgh5678" + } + ] + } + } + ] + } \ No newline at end of file diff --git a/plugins/azure/test/files/network/publicIPAddresses.json b/plugins/azure/test/files/network/publicIPAddresses.json index d17ed79daf..0d7ca46657 100644 --- a/plugins/azure/test/files/network/publicIPAddresses.json +++ b/plugins/azure/test/files/network/publicIPAddresses.json @@ -1 +1,69 @@ -{ "value": []} +{ + "value": [ + { + "name": "testDNS-ip", + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/testDNS-ip", + "location": "westus", + "properties": { + "provisioningState": "Succeeded", + "publicIPAddressVersion": "IPv4", + "publicIPAllocationMethod": "Dynamic", + "idleTimeoutInMinutes": 4, + "ipConfiguration": { + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/networkInterfaces/testDNS649/ipConfigurations/ipconfig1" + }, + "ddosSettings": { + "protectionMode": "VirtualNetworkInherited" + } + }, + "type": "Microsoft.Network/publicIPAddresses" + }, + { + "name": "ip01", + "id": "/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/publicIPAddresses/ip01", + "location": "westus", + "properties": { + "provisioningState": "Succeeded", + "ipAddress": "40.85.154.247", + "publicIPAddressVersion": "IPv4", + "publicIPAllocationMethod": "Dynamic", + "idleTimeoutInMinutes": 4, + "dnsSettings": { + "domainNameLabel": "testlbl", + "fqdn": "testlbl.westus.cloudapp.azure.com" + }, + "ipConfiguration": { + "id": "/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/loadBalancers/testLb/frontendIPConfigurations/LoadBalancerFrontEnd" + }, + "ddosSettings": { + "protectionMode": "VirtualNetworkInherited" + } + }, + "type": "Microsoft.Network/publicIPAddresses" + }, + { + "name": "ip02", + "id": "/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/publicIPAddresses/ip02", + "location": "westus", + "properties": { + "provisioningState": "Succeeded", + "ipAddress": "40.85.154.248", + "publicIPAddressVersion": "IPv4", + "publicIPAllocationMethod": "Dynamic", + "idleTimeoutInMinutes": 4, + "dnsSettings": { + "domainNameLabel": "testlbl", + "domainNameLabelScope": "TenantReuse", + "fqdn": "testlbl.hxdwgjcdfgbhgebs.eastus.sysgen.cloudapp.azure.com" + }, + "ipConfiguration": { + "id": "/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/loadBalancers/testLb/frontendIPConfigurations/LoadBalancerFrontEnd" + }, + "ddosSettings": { + "protectionMode": "VirtualNetworkInherited" + } + }, + "type": "Microsoft.Network/publicIPAddresses" + } + ] + } \ No newline at end of file diff --git a/plugins/azure/test/files/network/virtualNetworkTaps.json b/plugins/azure/test/files/network/virtualNetworkTaps.json index d17ed79daf..b17c6b7515 100644 --- a/plugins/azure/test/files/network/virtualNetworkTaps.json +++ b/plugins/azure/test/files/network/virtualNetworkTaps.json @@ -1 +1,44 @@ -{ "value": []} +{ + "value": [ + { + "name": "testvtap", + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworkTaps/testvtap", + "etag": "etag", + "type": "Microsoft.Network/virtualNetworkTaps", + "location": "centraluseuap", + "properties": { + "destinationNetworkInterfaceIPConfiguration": { + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/networkInterfaces/testNetworkInterface/ipConfigurations/testIPConfig1" + }, + "destinationPort": 4789, + "provisioningState": "Succeded", + "resourceGuid": "6A7C139D-8B8D-499B-B7CB-4F3F02A8A44F", + "networkInterfaceTapConfigurations": [ + { + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/networkInterfaces/testNetworkInterface2/tapConfigurations/testtapConfiguration" + } + ] + } + }, + { + "name": "testvtap2", + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworkTaps/testvtap2", + "etag": "etag", + "type": "Microsoft.Network/virtualNetworkTaps", + "location": "centraluseuap", + "properties": { + "destinationNetworkInterfaceIPConfiguration": { + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/networkInterfaces/testNetworkInterface/ipConfigurations/testIPConfig1" + }, + "destinationPort": 4789, + "provisioningState": "Succeded", + "resourceGuid": "6A7C139D-8B8D-499B-B7CB-4F3F02A8A44F", + "networkInterfaceTapConfigurations": [ + { + "id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/networkInterfaces/testNetworkInterface3/tapConfigurations/testtapConfiguration" + } + ] + } + } + ] + } \ No newline at end of file diff --git a/plugins/azure/test/network_test.py b/plugins/azure/test/network_test.py index ea43264d72..391268f4ee 100644 --- a/plugins/azure/test/network_test.py +++ b/plugins/azure/test/network_test.py @@ -3,181 +3,206 @@ from resoto_plugin_azure.resource.network import * -def test_azure_application_gateway_available_waf_rule_set(builder: GraphBuilder) -> None: +def test_application_gateway_available_waf_rule_set(builder: GraphBuilder) -> None: collected = roundtrip_check(AzureApplicationGatewayFirewallRuleSet, builder) assert len(collected) == 1 -def test_azure_application_gateway(builder: GraphBuilder) -> None: +def test_application_gateway(builder: GraphBuilder) -> None: collected = roundtrip_check(AzureApplicationGateway, builder) assert len(collected) == 1 -def test_azure_application_gateway_web_application_firewall_policy(builder: GraphBuilder) -> None: +def test_application_gateway_web_application_firewall_policy(builder: GraphBuilder) -> None: collected = roundtrip_check(AzureWebApplicationFirewallPolicy, builder) assert len(collected) == 1 -def test_azure_auto_approved_private_link_service(builder: GraphBuilder) -> None: +def test_auto_approved_private_link_service(builder: GraphBuilder) -> None: collected = roundtrip_check(AzureAutoApprovedPrivateLinkService, builder) assert len(collected) == 3 -def test_azure_available_service_alias(builder: GraphBuilder) -> None: +def test_available_service_alias(builder: GraphBuilder) -> None: collected = roundtrip_check(AzureAvailableServiceAlias, builder) assert len(collected) == 2 -def test_azure_azure_firewall_fqdn_tag(builder: GraphBuilder) -> None: +def test_azure_firewall_fqdn_tag(builder: GraphBuilder) -> None: collected = roundtrip_check(AzureFirewallFqdnTag, builder) assert len(collected) == 1 -def test_azure_azure_firewall(builder: GraphBuilder) -> None: +def test_azure_firewall(builder: GraphBuilder) -> None: collected = roundtrip_check(AzureFirewall, builder) assert len(collected) == 1 -def test_azure_azure_web_category(builder: GraphBuilder) -> None: +def test_azure_web_category(builder: GraphBuilder) -> None: collected = roundtrip_check(AzureWebCategory, builder) assert len(collected) == 1 -def test_azure_bastion_host(builder: GraphBuilder) -> None: +def test_bastion_host(builder: GraphBuilder) -> None: collected = roundtrip_check(AzureBastionHost, builder) assert len(collected) == 2 -def test_azure_custom_ip_prefix(builder: GraphBuilder) -> None: +def test_custom_ip_prefix(builder: GraphBuilder) -> None: collected = roundtrip_check(AzureCustomIpPrefix, builder) assert len(collected) == 12 -def test_azure_ddos_protection_plan(builder: GraphBuilder) -> None: +def test_ddos_protection_plan(builder: GraphBuilder) -> None: collected = roundtrip_check(AzureDdosProtectionPlan, builder) assert len(collected) == 2 -def test_azure_dscp_configuration(builder: GraphBuilder) -> None: +def test_dscp_configuration(builder: GraphBuilder) -> None: collected = roundtrip_check(AzureDscpConfiguration, builder) assert len(collected) == 2 -def test_azure_express_route_circuit(builder: GraphBuilder) -> None: +def test_express_route_circuit(builder: GraphBuilder) -> None: collected = roundtrip_check(AzureExpressRouteCircuit, builder) assert len(collected) == 2 -def test_azure_express_route_gateway(builder: GraphBuilder) -> None: +def test_express_route_gateway(builder: GraphBuilder) -> None: collected = roundtrip_check(AzureExpressRouteGateway, builder) assert len(collected) == 1 -def test_azure_express_route_port(builder: GraphBuilder) -> None: +def test_express_route_port(builder: GraphBuilder) -> None: collected = roundtrip_check(AzureExpressRoutePort, builder) assert len(collected) == 1 -def test_azure_express_route_port_location(builder: GraphBuilder) -> None: +def test_express_route_port_location(builder: GraphBuilder) -> None: collected = roundtrip_check(AzureExpressRoutePortsLocation, builder) assert len(collected) == 1 -def test_azure_firewall_policy(builder: GraphBuilder) -> None: +def test_firewall_policy(builder: GraphBuilder) -> None: collected = roundtrip_check(AzureFirewallPolicy, builder) assert len(collected) == 1 -def test_azure_ip_allocation(builder: GraphBuilder) -> None: +def test_ip_allocation(builder: GraphBuilder) -> None: collected = roundtrip_check(AzureIpAllocation, builder) assert len(collected) == 2 -def test_azure_ip_group(builder: GraphBuilder) -> None: +def test_ip_group(builder: GraphBuilder) -> None: collected = roundtrip_check(AzureIpGroup, builder) assert len(collected) == 2 -def test_azure_load_balancer(builder: GraphBuilder) -> None: +def test_load_balancer(builder: GraphBuilder) -> None: collected = roundtrip_check(AzureLoadBalancer, builder) assert len(collected) == 2 -def test_azure_network_profile(builder: GraphBuilder) -> None: +def test_network_profile(builder: GraphBuilder) -> None: collected = roundtrip_check(AzureNetworkProfile, builder) assert len(collected) == 2 -def test_azure_network_virtual_appliance(builder: GraphBuilder) -> None: +def test_network_virtual_appliance(builder: GraphBuilder) -> None: collected = roundtrip_check(AzureNetworkVirtualAppliance, builder) assert len(collected) == 1 -def test_azure_network_virtual_appliance_sku(builder: GraphBuilder) -> None: +def test_network_virtual_appliance_sku(builder: GraphBuilder) -> None: collected = roundtrip_check(AzureNetworkVirtualApplianceSku, builder) assert len(collected) == 1 -def test_azure_network_watcher(builder: GraphBuilder) -> None: +def test_network_watcher(builder: GraphBuilder) -> None: collected = roundtrip_check(AzureNetworkWatcher, builder) assert len(collected) == 2 -def test_azure_p2s_vpn_gateway(builder: GraphBuilder) -> None: +def test_p2s_vpn_gateway(builder: GraphBuilder) -> None: collected = roundtrip_check(AzureP2SVpnGateway, builder) assert len(collected) == 2 -def test_azure_public_ip_prefix(builder: GraphBuilder) -> None: +def test_public_ip_prefix(builder: GraphBuilder) -> None: collected = roundtrip_check(AzurePublicIPPrefix, builder) assert len(collected) == 3 -def test_azure_route_filter(builder: GraphBuilder) -> None: +def test_route_filter(builder: GraphBuilder) -> None: collected = roundtrip_check(AzureRouteFilter, builder) assert len(collected) == 1 -def test_azure_security_partner_provider(builder: GraphBuilder) -> None: +def test_security_partner_provider(builder: GraphBuilder) -> None: collected = roundtrip_check(AzureSecurityPartnerProvider, builder) assert len(collected) == 1 -def test_azure_usage(builder: GraphBuilder) -> None: +def test_usage(builder: GraphBuilder) -> None: collected = roundtrip_check(AzureUsage, builder) assert len(collected) == 25 -def test_azure_virtual_hub(builder: GraphBuilder) -> None: +def test_virtual_hub(builder: GraphBuilder) -> None: collected = roundtrip_check(AzureVirtualHub, builder) assert len(collected) == 2 -def test_azure_virtual_network(builder: GraphBuilder) -> None: +def test_virtual_network(builder: GraphBuilder) -> None: collected = roundtrip_check(AzureVirtualNetwork, builder) assert len(collected) == 2 -def test_azure_virtual_router(builder: GraphBuilder) -> None: +def test_virtual_router(builder: GraphBuilder) -> None: collected = roundtrip_check(AzureVirtualRouter, builder) assert len(collected) == 1 -def test_azure_virtual_wan(builder: GraphBuilder) -> None: +def test_virtual_wan(builder: GraphBuilder) -> None: collected = roundtrip_check(AzureVirtualWAN, builder) assert len(collected) == 2 -def test_azure_vpn_gateway(builder: GraphBuilder) -> None: +def test_vpn_gateway(builder: GraphBuilder) -> None: collected = roundtrip_check(AzureVpnGateway, builder) assert len(collected) == 2 -def test_azure_vpn_server_configuration(builder: GraphBuilder) -> None: +def test_vpn_server_configuration(builder: GraphBuilder) -> None: collected = roundtrip_check(AzureVpnServerConfiguration, builder) assert len(collected) == 2 -def test_azure_vpn_site(builder: GraphBuilder) -> None: - collected = roundtrip_check(AzureVpnSite, builder) +def test_nat_gateway(builder: GraphBuilder) -> None: + collected = roundtrip_check(AzureNatGateway, builder) + assert len(collected) == 2 + + +def test_network_interface(builder: GraphBuilder) -> None: + collected = roundtrip_check(AzureNetworkInterface, builder) + assert len(collected) == 2 + + +def test_network_security_group(builder: GraphBuilder) -> None: + collected = roundtrip_check(AzureNetworkSecurityGroup, builder) + assert len(collected) == 2 + + +def test_private_link_service(builder: GraphBuilder) -> None: + collected = roundtrip_check(AzurePrivateLinkService, builder) + assert len(collected) == 2 + + +def test_public_ip_address(builder: GraphBuilder) -> None: + collected = roundtrip_check(AzurePublicIPAddress, builder) + assert len(collected) == 3 + + +def test_virtual_network_tap(builder: GraphBuilder) -> None: + collected = roundtrip_check(AzureVirtualNetworkTap, builder) assert len(collected) == 2