Skip to content

Commit

Permalink
feat: Added tests to the network resources
Browse files Browse the repository at this point in the history
  • Loading branch information
1101-1 committed Oct 26, 2023
1 parent 5517c0d commit 09815e6
Show file tree
Hide file tree
Showing 39 changed files with 3,601 additions and 2 deletions.
4 changes: 2 additions & 2 deletions plugins/azure/test/collector_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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) == 62
assert len(collector.graph.edges) == 80
assert len(collector.graph.nodes) == 454
assert len(collector.graph.edges) == 472
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
{
"value": [
{
"name": "Policy1",
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/ApplicationGatewayWebApplicationFirewallPolicies/Policy1",
"type": "Microsoft.Network/applicationgatewaywebapplicationfirewallpolicies",
"tags": {
"key1": "value1",
"key2": "value2"
},
"location": "WestUs",
"properties": {
"resourceState": "Enabled",
"provisioningState": "Succeeded",
"policySettings": {
"state": "Enabled",
"mode": "Prevention",
"requestBodyEnforcement": true,
"maxRequestBodySizeInKb": 2000,
"requestBodyInspectLimitInKB": 2000,
"fileUploadEnforcement": true,
"fileUploadLimitInMb": 4000,
"requestBodyCheck": true,
"customBlockResponseStatusCode": 405,
"customBlockResponseBody": "SGVsbG8=",
"logScrubbing": {
"state": "Enabled",
"scrubbingRules": [
{
"state": "Enabled",
"matchVariable": "RequestArgNames",
"selectorMatchOperator": "Equals",
"selector": "test"
},
{
"state": "Enabled",
"matchVariable": "RequestIPAddress",
"selectorMatchOperator": "EqualsAny",
"selector": "*"
}
]
}
},
"customRules": [
{
"name": "Rule1",
"priority": 1,
"state": "Enabled",
"ruleType": "MatchRule",
"matchConditions": [
{
"matchVariables": [
{
"variableName": "RemoteAddr",
"selector": null
}
],
"operator": "IPMatch",
"negationConditon": false,
"matchValues": [
"192.168.1.0/24",
"10.0.0.0/24"
],
"transforms": []
}
],
"action": "Block"
},
{
"name": "Rule2",
"priority": 2,
"state": "Enabled",
"ruleType": "MatchRule",
"matchConditions": [
{
"matchVariables": [
{
"variableName": "RemoteAddr",
"selector": null
}
],
"operator": "IPMatch",
"negationConditon": false,
"matchValues": [
"192.168.1.0/24"
]
},
{
"matchVariables": [
{
"variableName": "RequestHeader",
"selector": "UserAgent"
}
],
"operator": "Contains",
"negationConditon": false,
"matchValues": [
"Windows"
]
}
],
"action": "Block"
},
{
"name": "RateLimitRule3",
"priority": 3,
"rateLimitDuration": "OneMin",
"rateLimitThreshold": 10,
"ruleType": "RateLimitRule",
"matchConditions": [
{
"matchVariables": [
{
"variableName": "RemoteAddr",
"selector": null
}
],
"operator": "IPMatch",
"negationConditon": true,
"matchValues": [
"192.168.1.0/24",
"10.0.0.0/24"
]
}
],
"groupByUserSession": [
{
"groupByVariables": [
{
"variableName": "ClientAddr"
}
]
}
],
"action": "Block"
}
],
"managedRules": {
"managedRuleSets": [
{
"ruleSetType": "OWASP",
"ruleSetVersion": "3.2"
}
]
}
}
}
]
}
52 changes: 52 additions & 0 deletions plugins/azure/test/files/network/ExpressRoutePorts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"value": [
{
"name": "portName",
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/expressRoutePorts/portName",
"type": "Microsoft.Network/expressRoutePorts",
"location": "westus",
"properties": {
"provisioningState": "Succeeded",
"peeringLocation": "peeringLocationName",
"bandwidthInGbps": 100,
"provisionedBandwidthInGbps": 0,
"mtu": "1500",
"encapsulation": "QinQ",
"billingType": "UnlimitedData",
"etherType": "0x8100",
"allocationDate": "Friday, July 1, 2018",
"links": [
{
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/expressRoutePorts/portName/links/link1",
"name": "link1",
"properties": {
"provisioningState": "Succeeded",
"routerName": "router1",
"interfaceName": "Ethernet 0/0",
"patchPanelId": "patchPanelId1",
"rackId": "rackId1",
"coloLocation": "coloLocation1",
"connectorType": "LC",
"adminState": "Disabled"
}
},
{
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/expressRoutePorts/portName/links/link2",
"name": "link2",
"properties": {
"provisioningState": "Succeeded",
"routerName": "router2",
"interfaceName": "Ethernet 0/0",
"patchPanelId": "patchPanelId2",
"rackId": "rackId2",
"coloLocation": "coloLocation2",
"connectorType": "LC",
"adminState": "Disabled"
}
}
],
"circuits": []
}
}
]
}
16 changes: 16 additions & 0 deletions plugins/azure/test/files/network/ExpressRoutePortsLocations.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"value": [
{
"name": "locationName",
"id": "/subscriptions/subid/providers/Microsoft.Network/expressRoutePortsLocations/locationName",
"type": "Microsoft.Network/expressRoutePortsLocations",
"location": "westus",
"properties": {
"provisioningState": "Succeeded",
"address": "123 Main Street, City, State, Zip",
"contact": "[email protected]",
"availableBandwidths": []
}
}
]
}
32 changes: 32 additions & 0 deletions plugins/azure/test/files/network/IpAllocations.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"value": [
{
"name": "test-ipallocation1",
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/IpAllocations/test-ipallocation1",
"type": "Microsoft.Network/IpAllocations",
"location": "centraluseuap",
"properties": {
"type": "Hypernet",
"prefix": "3.2.5.0/24",
"ipamAllocationId": "916d3b28-663f-448b-9abc-1bea9d5fed8f",
"allocationTags": {
"VNetID": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/HypernetVnet1"
}
}
},
{
"name": "test-ipallocation2",
"id": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/IpAllocations/test-ipallocation2",
"type": "Microsoft.Network/IpAllocations",
"location": "centraluseuap",
"properties": {
"type": "Hypernet",
"prefix": "3.2.6.0/24",
"ipamAllocationId": "57dc7256-2ff7-43f2-b9c8-85a70b5c6408",
"allocationTags": {
"VNetID": "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/HypernetVnet2"
}
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"value": [
{
"name": "OWASP_3.0",
"id": "/subscriptions//resourceGroups//providers/Microsoft.Network/applicationGatewayAvailableWafRuleSets/",
"type": "Microsoft.Network/applicationGatewayAvailableWafRuleSets",
"properties": {
"provisioningState": "Succeeded",
"ruleSetType": "OWASP",
"ruleSetVersion": "3.0",
"ruleGroups": [
{
"ruleGroupName": "General",
"description": "",
"rules": [
{
"ruleId": 200004,
"ruleIdString": "200004",
"description": "Possible Multipart Unmatched Boundary."
}
]
}
]
}
}
]
}
Loading

0 comments on commit 09815e6

Please sign in to comment.