-
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.
RESOURCE-141 Support azure power bi datasets (#536)
* support azure power bi dataset(s) Signed-off-by: Sathish <sbabu@progress.com> * unit test azure power bi dataset(s) Signed-off-by: Sathish <sbabu@progress.com> * integral test azure power bi dataset(s) Signed-off-by: Sathish <sbabu@progress.com> * document azure power bi dataset(s) Signed-off-by: Sathish <sbabu@progress.com> * update doc with azure power bi dataset(s) Signed-off-by: Sathish <sbabu@progress.com> * Docs edits Signed-off-by: Ian Maddaus <ian.maddaus@progress.com> Co-authored-by: Ian Maddaus <ian.maddaus@progress.com>
- Loading branch information
1 parent
94b6001
commit 42b9c00
Showing
9 changed files
with
314 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
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,94 @@ | ||
--- | ||
title: About the azure_power_bi_dataset Resource | ||
platform: azure | ||
--- | ||
|
||
# azure_power_bi_dataset | ||
|
||
Use the `azure_power_bi_dataset` InSpec audit resource to test the properties related to Azure Power BI dataset. | ||
|
||
## Azure REST API version, Endpoint, and HTTP Client Parameters | ||
|
||
This resource interacts with API versions supported by the resource provider. The `api_version` is defined as a resource parameter. | ||
If not provided, the latest version is used. For more information, refer to [`azure_generic_resource`](azure_generic_resource.md). | ||
|
||
Unless defined, `azure_cloud` global endpoint and default values for the HTTP client are used. For more information, refer to the resource pack [README](../../README.md). | ||
|
||
## Availability | ||
|
||
### Installation | ||
|
||
This resource is available in the [InSpec Azure resource pack](https://github.com/inspec/inspec-azure). For an example, `inspec.yml` file and how to set up your Azure credentials, refer to resource pack [README](../../README.md#Service-Principal). | ||
|
||
## Syntax | ||
|
||
```ruby | ||
describe azure_power_bi_dataset(name: 'DATASET_ID') do | ||
it { should exist } | ||
end | ||
``` | ||
|
||
```ruby | ||
describe azure_power_bi_dataset(group_id: 'GROUP_ID', name: 'DATASET_ID') do | ||
it { should exist } | ||
end | ||
``` | ||
|
||
## Parameters | ||
|
||
`name` _(required)_ | ||
|
||
The dataset ID. | ||
|
||
`group_id` _(optional)_ | ||
|
||
The workspace ID. | ||
|
||
## Properties | ||
|
||
| Property | Description | | ||
|----------------------------|------------------------------------------------------------------| | ||
| name | The dataset name. | | ||
| addRowsAPIEnabled | Whether the dataset allows adding new rows. | | ||
| configuredBy | The dataset owner. | | ||
| isRefreshable | Can this dataset be refreshed. | | ||
| isEffectiveIdentityRequired| Whether the dataset requires an effective identity. This indicates that you must send an effective identity using the GenerateToken API.| | ||
| isEffectiveIdentityRolesRequired | Whether RLS is defined inside the PBIX file. This indicates that you must specify a role.| | ||
| isOnPremGatewayRequired | dataset requires an On-premises Data Gateway. | | ||
|
||
|
||
For properties applicable to all resources, such as `type`, `name`, `id`, and `properties`, refer to [`azure_generic_resource`](azure_generic_resource.md#properties). | ||
|
||
Also, refer to [Azure documentation](https://docs.microsoft.com/en-us/rest/api/power-bi/datasets/get-dataset) for other properties available. | ||
|
||
## Examples | ||
|
||
### Test that the Power BI dataset requires an on-prem gateway | ||
|
||
```ruby | ||
describe azure_power_bi_dataset(name: 'DATASET_ID') do | ||
it { should exist } | ||
its('IsOnPremGatewayRequired') { should eq true } | ||
end | ||
``` | ||
|
||
## Matchers | ||
|
||
This InSpec audit resource has the following special matchers. For a full list of available matchers, please visit our [Universal Matchers page](/inspec/matchers/). | ||
|
||
### exists | ||
|
||
```ruby | ||
# If the Power BI dataset is found, it will exist | ||
describe azure_power_bi_dataset(name: 'DATASET_ID') do | ||
it { should exist } | ||
end | ||
# if the Power BI dataset is not found, it will not exist | ||
describe azure_power_bi_dataset(name: 'DATASET_ID') do | ||
it { should_not exist } | ||
end | ||
``` | ||
|
||
## Azure Permissions | ||
|
||
Your [Service Principal](https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-service-principal-portal) must be set up with a `Dataset.Read.All` role on the Azure Power BI dataset you wish to test. |
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,84 @@ | ||
--- | ||
title: About the azure_power_bi_datasets Resource | ||
platform: azure | ||
--- | ||
|
||
# azure_power_bi_datasets | ||
|
||
Use the `azure_power_bi_datasets` InSpec audit resource to test the properties of all Azure Power BI datasets. | ||
|
||
## Azure REST API version, Endpoint, and HTTP Client Parameters | ||
|
||
This resource interacts with API versions supported by the resource provider. The `api_version` is defined as a resource parameter. | ||
If not provided, the latest version is used. For more information, refer to [`azure_generic_resource`](azure_generic_resource.md). | ||
|
||
Unless defined, `azure_cloud` global endpoint and default values for the HTTP client is used. For more information, refer to the resource pack [README](../../README.md). | ||
|
||
## Availability | ||
|
||
### Installation | ||
|
||
This resource is available in the [InSpec Azure resource pack](https://github.com/inspec/inspec-azure). For an example, `inspec.yml` file and how to set up your Azure credentials, refer to resource pack [README](../../README.md#Service-Principal). | ||
|
||
## Syntax | ||
|
||
An `azure_power_bi_datasets` resource block returns all Azure Power BI datasets. | ||
|
||
```ruby | ||
describe azure_power_bi_datasets do | ||
#... | ||
end | ||
``` | ||
|
||
## Parameters | ||
|
||
`group_id` _(optional)_ | ||
|
||
The workspace ID. | ||
|
||
## Properties | ||
|
||
|Property | Description | Filter Criteria<superscript>*</superscript> | | ||
|---------------------------|------------------------------------------------------------------------|------------------| | ||
| ids | List of all Power BI dataset IDs. | `id` | | ||
| names | List of all the Power BI dataset names. | `name` | | ||
| addRowsAPIEnableds | List of boolean flags which describes whether the dataset allows adding new rows.| `addRowsAPIEnabled`| | ||
| isRefreshables | List of boolean flags that represent refreshable parameter of datasets. | `isRefreshable` | | ||
| isEffectiveIdentityRequireds | List of boolean flags that represent effective identity. | `isEffectiveIdentityRequired` | | ||
| isEffectiveIdentityRolesRequireds | List of boolean flags that describes whether RLS is defined inside the PBIX file. | `isEffectiveIdentityRolesRequired` | | ||
| isOnPremGatewayRequireds | List of boolean flags that describes whether dataset requires an On-premises Data Gateway.| `isOnPremGatewayRequired` | | ||
|
||
<superscript>*</superscript> For information on how to use filter criteria on plural resources refer to [FilterTable usage](https://github.com/inspec/inspec/blob/master/dev-docs/filtertable-usage.md). | ||
|
||
Also, refer to [Azure documentation](https://docs.microsoft.com/en-us/rest/api/power-bi/datasets/get-datasets) for other properties available. | ||
|
||
## Examples | ||
|
||
### Test to ensure Power BI dataset is refreshable | ||
|
||
```ruby | ||
describe azure_power_bi_datasets.where(isRefreshable: true) 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 Power BI datasets are present | ||
describe azure_power_bi_datasets do | ||
it { should_not exist } | ||
end | ||
# Should exist if the filter returns at least one Power BI datasets | ||
describe azure_power_bi_datasets do | ||
it { should exist } | ||
end | ||
``` | ||
|
||
## Azure Permissions | ||
|
||
Your [Service Principal](https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-service-principal-portal) must be set up with a `Dataset.Read.All` role on the Azure Power BI dataset you wish to test. |
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,38 @@ | ||
require 'azure_generic_resource' | ||
|
||
class AzurePowerBIDataset < AzureGenericResource | ||
name 'azure_power_bi_dataset' | ||
desc 'Retrieves and verifies the settings of an Azure Power BI Dataset.' | ||
example <<-EXAMPLE | ||
describe azure_power_bi_dataset(group_id: '0f084df7-c13d-451b-af5f-ed0c466403b2', name: 'cfafbeb1-8037-4d0c-896e-a46fb27ff229') do | ||
it { should exist } | ||
end | ||
EXAMPLE | ||
|
||
AUDIENCE = 'https://analysis.windows.net/powerbi/api'.freeze | ||
|
||
def initialize(opts = {}) | ||
raise ArgumentError, 'Parameters must be provided in an Hash object.' unless opts.is_a?(Hash) | ||
|
||
Validators.validate_parameters(resource_name: @__resource_name__, allow: %i(group_id), | ||
opts: opts) | ||
|
||
opts[:resource_uri] = ['https://api.powerbi.com/v1.0/myorg'].tap do |array| | ||
if opts[:group_id].present? | ||
array << 'groups' | ||
array << opts.delete(:group_id) | ||
end | ||
array << 'datasets' | ||
array << opts[:name] | ||
end.join('/') | ||
opts[:audience] = AUDIENCE | ||
opts[:add_subscription_id] = false | ||
opts[:is_uri_a_url] = true | ||
opts[:api_version] = 'v1.0' | ||
super | ||
end | ||
|
||
def to_s | ||
super(AzurePowerBIDataset) | ||
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,39 @@ | ||
require 'azure_generic_resources' | ||
|
||
class AzurePowerBIDatasets < AzureGenericResources | ||
name 'azure_power_bi_datasets' | ||
desc 'Retrieves and verifies the settings of all Azure Power BI Datasets.' | ||
example <<-EXAMPLE | ||
describe azure_power_bi_datasets do | ||
it { should exist } | ||
end | ||
EXAMPLE | ||
|
||
AUDIENCE = 'https://analysis.windows.net/powerbi/api'.freeze | ||
|
||
def initialize(opts = {}) | ||
raise ArgumentError, 'Parameters must be provided in an Hash object.' unless opts.is_a?(Hash) | ||
Validators.validate_parameters(resource_name: @__resource_name__, allow: %i(group_id), | ||
opts: opts) | ||
|
||
opts[:resource_uri] = ['https://api.powerbi.com/v1.0/myorg'].tap do |array| | ||
if opts[:group_id].present? | ||
array << 'groups' | ||
array << opts.delete(:group_id) | ||
end | ||
array << 'datasets' | ||
end.join('/') | ||
opts[:audience] = AUDIENCE | ||
opts[:add_subscription_id] = false | ||
opts[:is_uri_a_url] = true | ||
opts[:api_version] = 'v1.0' | ||
super | ||
return if failed_resource? | ||
|
||
populate_filter_table_from_response | ||
end | ||
|
||
def to_s | ||
super(AzurePowerBIDatasets) | ||
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,9 @@ | ||
control 'verify the settings of an Azure Power BI Dataset' do | ||
describe azure_power_bi_dataset(dataset_id: 'cfafbeb1-8037-4d0c-896e-a46fb27ff229') do | ||
it { should exist } | ||
its('name') { should eq 'SalesMarketing' } | ||
its('addRowsAPIEnabled') { should eq false } | ||
its('isRefreshable') { should eq true } | ||
its('isEffectiveIdentityRequired') { should eq true } | ||
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,9 @@ | ||
control 'verify the settings of all Azure Power BI Datasets' do | ||
describe azure_power_bi_datasets do | ||
it { should exist } | ||
its('names') { should include 'SalesMarketing' } | ||
its('addRowsAPIEnableds') { should include false } | ||
its('isRefreshables') { should include true } | ||
its('isEffectiveIdentityRequireds') { should include true } | ||
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,17 @@ | ||
require_relative 'helper' | ||
require 'azure_power_bi_dataset' | ||
|
||
class AzurePowerBIDatasetConstructorTest < Minitest::Test | ||
def test_empty_param_not_ok | ||
assert_raises(ArgumentError) { AzurePowerBIDataset.new } | ||
end | ||
|
||
# resource_provider should not be allowed. | ||
def test_resource_provider_not_ok | ||
assert_raises(ArgumentError) { AzurePowerBIDataset.new(resource_provider: 'some_type') } | ||
end | ||
|
||
def test_resource_group_name_alone_ok | ||
assert_raises(ArgumentError) { AzurePowerBIDataset.new(name: 'my-name', resource_group: 'test') } | ||
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,22 @@ | ||
require_relative 'helper' | ||
require 'azure_power_bi_datasets' | ||
|
||
class AzurePowerBIDatasetsConstructorTest < Minitest::Test | ||
# resource_type should not be allowed. | ||
|
||
def test_resource_type_not_ok | ||
assert_raises(ArgumentError) { AzurePowerBIDatasets.new(resource_provider: 'some_type') } | ||
end | ||
|
||
def tag_value_not_ok | ||
assert_raises(ArgumentError) { AzurePowerBIDatasets.new(tag_value: 'some_tag_value') } | ||
end | ||
|
||
def tag_name_not_ok | ||
assert_raises(ArgumentError) { AzurePowerBIDatasets.new(tag_name: 'some_tag_name') } | ||
end | ||
|
||
def test_name_not_ok | ||
assert_raises(ArgumentError) { AzurePowerBIDatasets.new(name: 'some_name') } | ||
end | ||
end |