-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #582 from inspec/support-azure-service-fabric-mesh…
…-nws RESOURCE-115 Support azure service fabric mesh network
- v1.118.43
- v1.118.42
- v1.118.41
- v1.118.40
- v1.118.39
- v1.118.38
- v1.118.37
- v1.118.36
- v1.118.35
- v1.118.34
- v1.118.33
- v1.118.32
- v1.118.31
- v1.118.30
- v1.118.29
- v1.118.28
- v1.118.27
- v1.118.26
- v1.118.25
- v1.118.24
- v1.118.23
- v1.118.22
- v1.118.21
- v1.118.20
- v1.118.19
- v1.118.18
- v1.118.17
- v1.118.16
- v1.118.15
- v1.118.14
- v1.118.13
- v1.118.12
- v1.118.11
- v1.118.10
- v1.118.9
- v1.118.8
- v1.118.7
- v1.118.6
- v1.118.5
- v1.118.4
- v1.118.3
- v1.118.2
- v1.118.1
- v1.118.0
- v1.117.0
- v1.116.0
- v1.115.1
- v1.115.0
- v1.114.4
- v1.114.3
- v1.114.2
- v1.114.1
- v1.114.0
- v1.113.0
Showing
9 changed files
with
349 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
114 changes: 114 additions & 0 deletions
114
docs-chef-io/content/inspec/resources/azure_service_fabric_mesh_network.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
+++ | ||
title = "azure_service_fabric_mesh_network Resource" | ||
platform = "azure" | ||
draft = false | ||
gh_repo = "inspec-azure" | ||
|
||
[menu.inspec] | ||
title = "azure_service_fabric_mesh_network" | ||
identifier = "inspec/resources/azure/azure_service_fabric_mesh_network Resource" | ||
parent = "inspec/resources/azure" | ||
+++ | ||
|
||
Use the `azure_service_fabric_mesh_network` InSpec audit resource to test properties of an Azure Service Fabric Mesh network. | ||
|
||
## Azure REST API Version, Endpoint, and HTTP Client Parameters | ||
|
||
{{% inspec_azure_common_parameters %}} | ||
|
||
## Installation | ||
|
||
{{% inspec_azure_install %}} | ||
|
||
## Syntax | ||
|
||
`name`, `resource_group` is a required parameter. | ||
|
||
```ruby | ||
describe azure_service_fabric_mesh_network(resource_group: 'RESOURCE_GROUP', name: 'SERVICE_FABRIC_MESH_NETWORK_NAME') do | ||
it { should exist } | ||
its('type') { should eq 'Microsoft.ServiceFabricMesh/networks' } | ||
its('location') { should eq 'eastus' } | ||
end | ||
``` | ||
|
||
```ruby | ||
describe azure_service_fabric_mesh_network(resource_group: 'RESOURCE_GROUP', name: 'SERVICE_FABRIC_MESH_NETWORK_NAME') do | ||
it { should exist } | ||
end | ||
``` | ||
|
||
## Parameters | ||
|
||
`name` | ||
: Name of the Azure Service Fabric Mesh networks to test. | ||
|
||
`resource_group` | ||
: Azure resource group that the targeted resource resides in. `MyResourceGroup`. | ||
|
||
The parameter set should be provided for a valid query: | ||
- `resource_group` and `name` | ||
|
||
## Properties | ||
|
||
`id` | ||
: Resource Id. | ||
|
||
`name` | ||
: Resource name. | ||
|
||
`type` | ||
: Resource type. `Microsoft.ServiceFabricMesh/networks`. | ||
|
||
`location` | ||
: The Geo-location where the resource lives. | ||
|
||
`properties` | ||
: The properties of the Service Fabric Mesh network. | ||
|
||
`properties.addressPrefix` | ||
: the address prefix for this network. | ||
|
||
`properties.provisioningState` | ||
: State of the resource. | ||
|
||
`properties.ingressConfig.qosLevel` | ||
: The QoS tier for ingress. | ||
|
||
|
||
For properties applicable to all resources, such as `type`, `name`, `id`, `properties`, refer to [`azure_generic_resource`]({{< relref "azure_generic_resource.md#properties" >}}). | ||
|
||
Also, refer to [Azure documentation](https://docs.microsoft.com/en-us/rest/api/servicefabric/sfmeshrp-api-network_get) for other properties available. | ||
|
||
## Examples | ||
|
||
**Test that the Service Fabric Mesh network is provisioned successfully.** | ||
|
||
```ruby | ||
describe azure_service_fabric_mesh_network(resource_group: 'RESOURCE_GROUP', name: 'SERVICE_FABRIC_MESH_NETWORK_NAME') do | ||
its('properties.provisioningState') { should eq 'Succeeded' } | ||
end | ||
``` | ||
|
||
## Matchers | ||
|
||
{{% inspec_matchers_link %}} | ||
|
||
### exists | ||
|
||
```ruby | ||
# If a Service Fabric Mesh network is found it will exist | ||
|
||
describe azure_service_fabric_mesh_network(resource_group: 'RESOURCE_GROUP', name: 'SERVICE_FABRIC_MESH_NETWORK_NAME') do | ||
it { should exist } | ||
end | ||
# if Service Fabric Mesh network is not found it will not exist | ||
|
||
describe azure_service_fabric_mesh_network(resource_group: 'RESOURCE_GROUP', name: 'SERVICE_FABRIC_MESH_NETWORK_NAME') do | ||
it { should_not exist } | ||
end | ||
``` | ||
|
||
## Azure Permissions | ||
|
||
{{% azure_permissions_service_principal role="reader" %}} |
118 changes: 118 additions & 0 deletions
118
docs-chef-io/content/inspec/resources/azure_service_fabric_mesh_networks.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
+++ | ||
title = "azure_service_fabric_mesh_networks Resource" | ||
platform = "azure" | ||
draft = false | ||
gh_repo = "inspec-azure" | ||
|
||
[menu.inspec] | ||
title = "azure_service_fabric_mesh_networks" | ||
identifier = "inspec/resources/azure/azure_service_fabric_mesh_networks Resource" | ||
parent = "inspec/resources/azure" | ||
+++ | ||
|
||
Use the `azure_service_fabric_mesh_networks` InSpec audit resource to test properties of all Azure Service Fabric Mesh networks. | ||
|
||
## Azure REST API Version, Endpoint, and HTTP Client Parameters | ||
|
||
{{% inspec_azure_common_parameters %}} | ||
|
||
## Installation | ||
|
||
{{% inspec_azure_install %}} | ||
|
||
## Syntax | ||
|
||
An `azure_service_fabric_mesh_networks` resource block returns all Azure Service Fabric Mesh networks. | ||
|
||
```ruby | ||
describe azure_service_fabric_mesh_networks do | ||
#... | ||
end | ||
``` | ||
|
||
## Parameters | ||
|
||
`resource_group` _(optional)_ | ||
: Azure resource group that the targeted resource resides in. | ||
|
||
## Properties | ||
|
||
`ids` | ||
: A list of resource IDs. | ||
|
||
: **Field**: `id` | ||
|
||
`names` | ||
: A list of resource Names. | ||
|
||
: **Field**: `name` | ||
|
||
`types` | ||
: A list of the resource types. | ||
|
||
: **Field**: `type` | ||
|
||
`properties` | ||
: A list of Properties for all the Service Fabric Mesh networks. | ||
|
||
: **Field**: `properties` | ||
|
||
`locations` | ||
: A list of the Geo-locations. | ||
|
||
: **Field**: `location` | ||
|
||
`provisioningStates` | ||
: A list of provisioning states of the Service Fabric Mesh networks. | ||
|
||
: **Field**: `provisioningState` | ||
|
||
`addressPrefixes` | ||
: A list of address prefixes. | ||
|
||
: **Field**: `addressPrefix` | ||
|
||
{{% inspec_filter_table %}} | ||
|
||
## Examples | ||
|
||
**Loop through Service Fabric Mesh networks by their names.** | ||
|
||
```ruby | ||
azure_service_fabric_mesh_networks(resource_group: 'RESOURCE_GROUP').names.each do |name| | ||
describe azure_service_fabric_mesh_network(resource_group: 'RESOURCE_GROUP', name: name) do | ||
it { should exist } | ||
end | ||
end | ||
``` | ||
|
||
**Test that there are Service Fabric Mesh networks that are successfully provisioned.** | ||
|
||
```ruby | ||
describe azure_service_fabric_mesh_networks(resource_group: 'RESOURCE_GROUP').where(provisioningState: 'Succeeded') do | ||
it { should exist } | ||
end | ||
``` | ||
|
||
## Matchers | ||
|
||
{{% inspec_matchers_link %}} | ||
|
||
### exists | ||
|
||
```ruby | ||
# Should not exist if no Service Fabric Mesh networks are present | ||
|
||
describe azure_service_fabric_mesh_networks(resource_group: 'RESOURCE_GROUP') do | ||
it { should_not exist } | ||
end | ||
# Should exist if the filter returns at least one Service Fabric Mesh networks | ||
|
||
describe azure_service_fabric_mesh_networks(resource_group: 'RESOURCE_GROUP') do | ||
it { should exist } | ||
end | ||
``` | ||
|
||
## Azure Permissions | ||
|
||
{{% azure_permissions_service_principal role="reader" %}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
require 'azure_generic_resource' | ||
|
||
class AzureServiceFabricMeshNetwork < AzureGenericResource | ||
name 'azure_service_fabric_mesh_network' | ||
desc 'Retrieves and verifies the settings of an Azure Service Fabric Mesh Network.' | ||
example <<-EXAMPLE | ||
describe azure_service_fabric_mesh_network(resource_group: 'inspec-rg', name: 'fabric-vol') do | ||
it { should exist } | ||
end | ||
EXAMPLE | ||
|
||
def initialize(opts = {}) | ||
raise ArgumentError, 'Parameters must be provided in an Hash object.' unless opts.is_a?(Hash) | ||
|
||
opts[:resource_provider] = specific_resource_constraint('Microsoft.ServiceFabricMesh/networks', opts) | ||
super(opts, true) | ||
end | ||
|
||
def to_s | ||
super(AzureServiceFabricMeshNetwork) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
require 'azure_generic_resources' | ||
|
||
class AzureServiceFabricMeshNetworks < AzureGenericResources | ||
name 'azure_service_fabric_mesh_networks' | ||
desc 'Verifies settings for a collection of Azure Service Fabric Mesh Networks' | ||
example <<-EXAMPLE | ||
describe azure_service_fabric_mesh_networks do | ||
it { should exist } | ||
end | ||
EXAMPLE | ||
|
||
def initialize(opts = {}) | ||
raise ArgumentError, 'Parameters must be provided in an Hash object.' unless opts.is_a?(Hash) | ||
|
||
opts[:resource_provider] = specific_resource_constraint('Microsoft.ServiceFabricMesh/networks', opts) | ||
super(opts, true) | ||
return if failed_resource? | ||
|
||
populate_filter_table_from_response | ||
end | ||
|
||
def to_s | ||
super(AzureServiceFabricMeshNetworks) | ||
end | ||
|
||
private | ||
|
||
def populate_table | ||
@resources.each do |resource| | ||
@table << resource.merge(resource[:properties]).merge(resource[:properties][:ingressConfig]) | ||
end | ||
end | ||
end |
11 changes: 11 additions & 0 deletions
11
test/integration/verify/controls/azure_service_fabric_mesh_network.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
location = input(:location, value: '') | ||
rg = input(:resource_group, value: '') | ||
|
||
skip_control 'Test the properties of a Azure Service Fabric Mesh Network' do | ||
describe azure_service_fabric_mesh_networks(resource_group: rg, name: 'mesh-fabric-name') do | ||
it { should exist } | ||
its('location') { should eq location.downcase.gsub("\s", '') } | ||
its('addressPrefix') { should eq '10.0.0.4/22' } | ||
its('provisioningState') { should eq 'Succeeded' } | ||
end | ||
end |
11 changes: 11 additions & 0 deletions
11
test/integration/verify/controls/azure_service_fabric_mesh_networks.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
location = input(:location, value: '') | ||
|
||
skip_control 'Testthe properties of all Azure Service Fabric Mesh Networks' do | ||
describe azure_service_fabric_mesh_networks do | ||
it { should exist } | ||
its('names') { should include 'inspec-fb-mesh-vol' } | ||
its('locations') { should include location.downcase.gsub("\s", '') } | ||
its('addressPrefixes') { should include '10.0.0.4/22' } | ||
its('provisioningStates') { should include 'Succeeded' } | ||
end | ||
end |
17 changes: 17 additions & 0 deletions
17
test/unit/resources/azure_service_fabric_mesh_network_test.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
require_relative 'helper' | ||
require 'azure_service_fabric_mesh_network' | ||
|
||
class AzureServiceFabricMeshNetworkConstructorTest < Minitest::Test | ||
def test_empty_param_not_ok | ||
assert_raises(ArgumentError) { AzureServiceFabricMeshNetwork.new } | ||
end | ||
|
||
# resource_provider should not be allowed. | ||
def test_resource_provider_not_ok | ||
assert_raises(ArgumentError) { AzureServiceFabricMeshNetwork.new(resource_provider: 'some_type') } | ||
end | ||
|
||
def test_resource_group_name_alone_not_ok | ||
assert_raises(ArgumentError) { AzureServiceFabricMeshNetwork.new(resource_group: 'test') } | ||
end | ||
end |
21 changes: 21 additions & 0 deletions
21
test/unit/resources/azure_service_fabric_mesh_networks_test.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
require_relative 'helper' | ||
require 'azure_service_fabric_mesh_networks' | ||
|
||
class AzureServiceFabricMeshNetworksConstructorTest < Minitest::Test | ||
# resource_type should not be allowed. | ||
def test_resource_type_not_ok | ||
assert_raises(ArgumentError) { AzureServiceFabricMeshNetworks.new(resource_provider: 'some_type') } | ||
end | ||
|
||
def tag_value_not_ok | ||
assert_raises(ArgumentError) { AzureServiceFabricMeshNetworks.new(tag_value: 'some_tag_value') } | ||
end | ||
|
||
def tag_name_not_ok | ||
assert_raises(ArgumentError) { AzureServiceFabricMeshNetworks.new(tag_name: 'some_tag_name') } | ||
end | ||
|
||
def test_name_not_ok | ||
assert_raises(ArgumentError) { AzureServiceFabricMeshNetworks.new(name: 'some_name') } | ||
end | ||
end |