-
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 #637 from inspec/support-azure-cache-skus
RESOURCE-104 Support azure cache skus
- Loading branch information
Showing
5 changed files
with
146 additions
and
3 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
85 changes: 85 additions & 0 deletions
85
docs-chef-io/content/inspec/resources/azure_hpc_cache_skus.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,85 @@ | ||
+++ | ||
title = "azure_hpc_cache_skus Resource" | ||
platform = "azure" | ||
draft = false | ||
gh_repo = "inspec-azure" | ||
|
||
[menu.inspec] | ||
title = "azure_hpc_cache_skus" | ||
identifier = "inspec/resources/azure/azure_hpc_cache_skus Resource" | ||
parent = "inspec/resources/azure" | ||
+++ | ||
|
||
Use the `azure_hpc_cache_skus` InSpec audit resource to test the properties related to all Azure HPC Cache SKUs. | ||
|
||
## Azure REST API Version, Endpoint, and HTTP Client Parameters | ||
|
||
{{% inspec_azure_common_parameters %}} | ||
|
||
## Installation | ||
|
||
{{% inspec_azure_install %}} | ||
|
||
## Syntax | ||
|
||
An `azure_hpc_cache_skus` resource block returns all Azure HPC Cache SKUs. | ||
|
||
```ruby | ||
describe azure_hpc_cache_skus do | ||
#... | ||
end | ||
``` | ||
|
||
## Parameters | ||
|
||
## Properties | ||
|
||
`resourceTypes` | ||
: A resource types list of the SKU applies to. **Field**: `resourceType` | ||
|
||
`names` | ||
: A list of SKU names. **Field**: `name` | ||
|
||
`sizes` | ||
: A list of the SKU sizes. **Field**: `size` | ||
|
||
`tiers` | ||
: A tiers list of VM in a scale set. **Field**: `tier` | ||
|
||
`kind` | ||
: The supported kind list of resources. **Field**: `kind` | ||
|
||
{{% inspec_filter_table %}} | ||
|
||
## Examples | ||
|
||
### Ensure that there are Standard tier HPC Cache SKUs | ||
|
||
```ruby | ||
describe azure_hpc_cache_skus.where(tier: 'STANDARD') do | ||
it { should exist } | ||
end | ||
``` | ||
|
||
## Matchers | ||
|
||
This InSpec audit resource has the following special matchers. For a full list of available matchers, please visit our [Universal Matchers page](https://www.inspec.io/docs/reference/matchers/). | ||
|
||
### exists | ||
|
||
```ruby | ||
# Should not exist if no HPC Cache SKUs are present | ||
|
||
describe azure_hpc_cache_skus do | ||
it { should_not exist } | ||
end | ||
# Should exist if the filter returns at least one HPC Cache SKUs | ||
|
||
describe azure_hpc_cache_skus 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,25 @@ | ||
require 'azure_generic_resources' | ||
|
||
class AzureHPCCacheSKUs < AzureGenericResources | ||
name 'azure_hpc_cache_skus' | ||
desc 'Verifies settings for a collection of Azure HPC Storage SKUs' | ||
example <<-EXAMPLE | ||
describe azure_hpc_cache_skus 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.StorageCache/skus', opts) | ||
super(opts, true) | ||
return if failed_resource? | ||
|
||
populate_filter_table_from_response | ||
end | ||
|
||
def to_s | ||
super(AzureHPCCacheSKUs) | ||
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,10 @@ | ||
describe azure_hpc_cache_skus do | ||
it { should exist } | ||
its('tier') { should eq 'Standard' } | ||
its('size') { should eq 'A0' } | ||
end | ||
|
||
describe azure_hpc_cache_skus.where(tier: 'Standard') do | ||
it { should exist } | ||
its('size') { should eq 'A0' } | ||
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,21 @@ | ||
require_relative 'helper' | ||
require 'azure_hpc_cache_skus' | ||
|
||
class AzureHPCCacheSKUsConstructorTest < Minitest::Test | ||
# resource_type should not be allowed. | ||
def test_resource_type_not_ok | ||
assert_raises(ArgumentError) { AzureHPCCacheSKUs.new(resource_provider: 'some_type') } | ||
end | ||
|
||
def tag_value_not_ok | ||
assert_raises(ArgumentError) { AzureHPCCacheSKUs.new(tag_value: 'some_tag_value') } | ||
end | ||
|
||
def tag_name_not_ok | ||
assert_raises(ArgumentError) { AzureHPCCacheSKUs.new(tag_name: 'some_tag_name') } | ||
end | ||
|
||
def test_name_not_ok | ||
assert_raises(ArgumentError) { AzureHPCCacheSKUs.new(name: 'some_name') } | ||
end | ||
end |