-
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 #516 from inspec/support-power-bi-dashboard-tiles
RESOURCE-143 Support power bi dashboard tiles
- Loading branch information
Showing
10 changed files
with
367 additions
and
7 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
104 changes: 104 additions & 0 deletions
104
docs-chef-io/content/inspec/resources/azure_power_bi_dashboard_tile.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,104 @@ | ||
+++ | ||
title = "azure_power_bi_dashboard_tile Resource" | ||
platform = "azure" | ||
draft = false | ||
gh_repo = "inspec-azure" | ||
|
||
[menu.inspec] | ||
title = "azure_power_bi_dashboard_tile" | ||
identifier = "inspec/resources/azure/azure_power_bi_dashboard_tile Resource" | ||
parent = "inspec/resources/azure" | ||
+++ | ||
|
||
Use the `azure_power_bi_dashboard_tile` InSpec audit resource to test the properties related to Azure Power BI dashboard tile. | ||
|
||
## Azure REST API Version, Endpoint, and HTTP Client Parameters | ||
|
||
{{% inspec_azure_common_parameters %}} | ||
|
||
## Installation | ||
|
||
{{% inspec_azure_install %}} | ||
|
||
## Syntax | ||
|
||
```ruby | ||
describe azure_power_bi_dashboard_tile(group_id: 'GROUP_ID', dashboard_id: 'dashboard_ID', title_id: 'TITLE_ID') do | ||
it { should exist } | ||
end | ||
``` | ||
|
||
## Parameters | ||
|
||
`dashboard_id` _(required)_ | ||
|
||
: The dashboard ID. | ||
|
||
`tile_id` _(required)_ | ||
|
||
: The tile ID. | ||
|
||
`group_id` _(optional)_ | ||
|
||
: The workspace ID. | ||
|
||
## Properties | ||
|
||
`id` | ||
: Power BI dashboard tile ID. | ||
|
||
`title` | ||
: The dashboard display name. | ||
|
||
`embedUrl` | ||
: The tile embed url. | ||
|
||
`rowSpan` | ||
: number of rows a tile should span. | ||
|
||
`colSpan` | ||
: number of columns a tile should span. | ||
|
||
`reportId` | ||
: The report ID, which is available only for tiles created from a report. | ||
|
||
`datasetId` | ||
: The dataset ID, which is available only for tiles created from a report or using a dataset, such as Q&A tiles. | ||
|
||
For properties applicable to all resources, such as `type`, `name`, `id`, and `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/power-bi/dashboards/get-tile) for other properties available. | ||
|
||
## Examples | ||
|
||
**Test that the Power BI dashboard tile is on left corner.** | ||
|
||
```ruby | ||
describe azure_power_bi_dashboard_tile(group_id: 'GROUP_ID', dashboard_id: 'dashboard_ID', title_id: 'TITLE_ID') do | ||
its('rowSpan') { should eq 0 } | ||
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 | ||
# Use should to test for an Azure Power BI dashboard tile that should be in the resource group | ||
|
||
describe azure_power_bi_dashboard_tile(group_id: 'GROUP_ID', dashboard_id: 'dashboard_ID', title_id: 'TITLE_ID') do | ||
it { should exist } | ||
end | ||
|
||
# Use should_not to test for an Azure Power BI dashboard tile that should not be in the resource group | ||
|
||
describe azure_power_bi_dashboard_tile(group_id: 'GROUP_ID', dashboard_id: 'dashboard_ID', title_id: 'TITLE_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 `dashboard.Read.All` role on the Azure Power BI Workspace you wish to test. |
130 changes: 130 additions & 0 deletions
130
docs-chef-io/content/inspec/resources/azure_power_bi_dashboard_tiles.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,130 @@ | ||
+++ | ||
title = "azure_power_bi_dashboard_tiles Resource" | ||
platform = "azure" | ||
draft = false | ||
gh_repo = "inspec-azure" | ||
|
||
[menu.inspec] | ||
title = "azure_power_bi_dashboard_tiles" | ||
identifier = "inspec/resources/azure/azure_power_bi_dashboard_tiles Resource" | ||
parent = "inspec/resources/azure" | ||
+++ | ||
|
||
Use the `azure_power_bi_dashboard_tiles` InSpec audit resource to test the properties related to all Azure Power BI dashboard tiles within a project. | ||
|
||
## Azure REST API Version, Endpoint, and HTTP Client Parameters | ||
|
||
{{% inspec_azure_common_parameters %}} | ||
|
||
## Installation | ||
|
||
{{% inspec_azure_install %}} | ||
|
||
## Syntax | ||
|
||
An `azure_power_bi_dashboard_tiles` resource block returns all Azure Power BI dashboard tiles within dashboard and a group. | ||
|
||
```ruby | ||
describe azure_power_bi_dashboard_tiles(dashboard_id: 'dashboard_ID') do | ||
#... | ||
end | ||
``` | ||
|
||
```ruby | ||
describe azure_power_bi_dashboard_tiles(group_id: 'GROUP_ID') do | ||
#... | ||
end | ||
``` | ||
|
||
## Parameters | ||
|
||
`group_id` _(required)_ | ||
: The workspace ID. | ||
|
||
`dashboard_id` _(optional)_ | ||
: The dashboard ID. | ||
|
||
## Properties | ||
|
||
`ids` | ||
: List of all dashboard IDs. | ||
|
||
: **Field**: `id` | ||
|
||
`titles` | ||
: List of all the titles. | ||
|
||
: **Field**: `title` | ||
|
||
`embedUrls` | ||
: List of all dashboard embed urls. | ||
|
||
: **Field**: `embedUrl` | ||
|
||
`rowSpans` | ||
: List of all row spans. | ||
|
||
: **Field**: `rowSpan` | ||
|
||
`colSpans` | ||
: List of all col spans. | ||
|
||
: **Field**: `colSpan` | ||
|
||
`reportIds` | ||
: List of all report IDs. | ||
|
||
: **Field**: `reportId` | ||
|
||
`datasetIds` | ||
: List of all dataset IDs. | ||
|
||
: **Field**: `datasetId` | ||
|
||
|
||
{{% inspec_filter_table %}} | ||
Also, refer to [Azure documentation](https://docs.microsoft.com/en-us/rest/api/power-bi/dashboards/get-dashboards) for other properties available. | ||
|
||
## Examples | ||
|
||
**Loop through Power BI dashboard tiles by their IDs.** | ||
|
||
```ruby | ||
azure_power_bi_dashboard_tiles.ids.each do |id| | ||
describe azure_power_bi_dashboard_tile(dashboard_id: id) do | ||
it { should exist } | ||
end | ||
end | ||
``` | ||
|
||
**Test to ensure all Power BI dashboard tiles that are in top left corner.** | ||
|
||
```ruby | ||
describe azure_power_bi_dashboard_tiles.where(rowSpan: 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 | ||
# Use should to test for an Azure Power BI dashboard tile that should be in the resource group. | ||
|
||
describe azure_power_bi_dashboard_tiles do | ||
it { should_not exist } | ||
end | ||
|
||
# Use should_not to test for an Azure Power BI dashboard tile that should not be in the resource group | ||
|
||
describe azure_power_bi_dashboard_tiles 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 `dashboard.Read.All` role on the Azure Power BI Workspace 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
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_resource' | ||
|
||
class AzurePowerBIDashboardTile < AzureGenericResource | ||
name 'azure_power_bi_dashboard_tile' | ||
desc 'Retrieves and verifies the settings of a Azure Power BI Dashboard tile' | ||
example <<-EXAMPLE | ||
describe azure_power_bi_dashboard_tile(tile_id: '3262-4671-bdc8', dashboard_id: 'b84b01c6-3262-4671-bdc8-ff99becf2a0b', group_id: '95a4871a-33a4-4f35-9eea-8ff006b4840b') do | ||
it { should exist } | ||
end | ||
EXAMPLE | ||
|
||
attr_reader :table | ||
|
||
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__, required: %i(tiles_id dashboard_id), | ||
allow: %i(group_id), | ||
opts: opts) | ||
|
||
opts[:name] = opts.delete(:dashboard_id) | ||
opts[:resource_uri] = ['https://api.powerbi.com/v1.0/myorg'].tap do |arr| | ||
arr << "groups/#{opts.delete(:group_id)}" if opts[:group_id].present? | ||
arr << "dashboards/#{opts[:name]}" | ||
arr << "tiles/#{opts[:tiles_id]}" | ||
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(AzurePowerBIDashboardTile) | ||
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,35 @@ | ||
require 'azure_generic_resources' | ||
|
||
class AzurePowerBIDashboardTiles < AzureGenericResources | ||
name 'azure_power_bi_dashboard_tiles' | ||
desc 'Retrieves and verifies the settings of all Azure Power BI Dashboard Tiles' | ||
example <<-EXAMPLE | ||
describe azure_power_bi_dashboard_tiles(dashboard_id: 'b84b01c6-3262-4671-bdc8-ff99becf2a0b', group_id: '95a4871a-33a4-4f35-9eea-8ff006b4840b') 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) | ||
|
||
opts[:resource_uri] = ['https://api.powerbi.com/v1.0/myorg'].tap do |arr| | ||
arr << "groups/#{opts.delete(:group_id)}" if opts[:group_id].present? | ||
arr << "dashboards/#{opts[:name]}" | ||
arr << 'tiles' | ||
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(AzurePowerBIDashboardTiles) | ||
end | ||
end |
8 changes: 8 additions & 0 deletions
8
test/integration/verify/controls/azure_power_bi_dashboard_tile.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,8 @@ | ||
group_id = input(:inspec_powerbi_workspace_id, value: '') | ||
dashboard_id = 'b84b01c6-3262-4671-bdc8-ff99becf2a0b' | ||
tile_id = '3262-4671-bdc8-' | ||
control 'Verify settings of a Power BI Dashboard tile' do | ||
describe azure_power_bi_dashboard_tile(group_id: group_id, dashboard_id: dashboard_id, tile_id: tile_id) do | ||
it { should exist } | ||
end | ||
end |
6 changes: 6 additions & 0 deletions
6
test/integration/verify/controls/azure_power_bi_dashboard_tiles.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,6 @@ | ||
group_id = input(:inspec_powerbi_workspace_id, value: '') | ||
control 'verify settings of all Power BI Dashboard Tiles in a group' do | ||
describe azure_power_bi_dashboards(group_id: group_id, dashboard_id: 'b84b01c6-3262-4671-bdc8-ff99becf2a0b') do | ||
it { should exist } | ||
end | ||
end |
Oops, something went wrong.