Skip to content

PolicyInsights RP GA version of cmdlets #6375

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
Jun 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
937c683
Fix bug in help text for To parameter
bulentelmaci May 24, 2018
bfa6d75
Merge branch 'preview' of https://github.com/Azure/azure-powershell i…
bulentelmaci May 24, 2018
a709a17
Upgrade PolicyInsights package to latest; test changes (needs new rec…
bulentelmaci May 24, 2018
58e63dd
Version change; release notes and change log
bulentelmaci May 24, 2018
943c40e
Merge branch 'preview' of https://github.com/Azure/azure-powershell i…
bulentelmaci May 31, 2018
34b9da7
Update assembly and help versions as well
bulentelmaci May 31, 2018
9042bf8
Update test project; update test scripts to get hardcoded resource na…
bulentelmaci May 31, 2018
99e52ce
Minor fix
bulentelmaci Jun 1, 2018
b86e238
Add format for PolicyDefinitionReferenceId
bulentelmaci Jun 1, 2018
65c7cd2
Regenerate MDs using platyPS
bulentelmaci Jun 1, 2018
a45a85d
Fix common function
bulentelmaci Jun 2, 2018
0e964ee
More test validation fixes
bulentelmaci Jun 2, 2018
73ede6d
Recorded new tests with some changed resource names; minor fixes to v…
bulentelmaci Jun 2, 2018
14f673c
Recorded tests again with changes to resource names for policy defini…
bulentelmaci Jun 4, 2018
1c93e69
Remove version number from changelog
bulentelmaci Jun 5, 2018
c11b547
Remove references/packages that come from common dependencies; add us…
bulentelmaci Jun 5, 2018
fb747c4
Merge branch 'preview' into preview
MiYanni Jun 6, 2018
7c1345f
Merge branch 'preview' of https://github.com/Azure/azure-powershell i…
bulentelmaci Jun 6, 2018
5280973
Merge branch 'preview' of https://github.com/bulentelmaci/azure-power…
bulentelmaci Jun 6, 2018
c7e05a4
Fix the dependency version and metadata for netcore
bulentelmaci Jun 6, 2018
325c523
Change package version in netcore test project as well; add policy in…
bulentelmaci Jun 6, 2018
1f7606b
Merge branch 'preview' of https://github.com/Azure/azure-powershell i…
bulentelmaci Jun 6, 2018
34eb29a
Use string.IsNullOrEmpty instead
bulentelmaci Jun 6, 2018
d120a3d
Merge branch 'preview' into preview
bulentelmaci Jun 7, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ PrivateData = @{
# IconUri = ''

# ReleaseNotes of this module
# ReleaseNotes = ''
ReleaseNotes = '* Public release of Policy Insights cmdlets'

# Prerelease string of this module
Prerelease = 'preview'
# Prerelease = ''

# Flag to indicate whether the module requires explicit user acceptance for install/update/save
# RequireLicenseAcceptance = $false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# RootModule = ''

# Version number of this module.
ModuleVersion = '0.9.1'
ModuleVersion = '1.0.0'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down Expand Up @@ -110,10 +110,10 @@ PrivateData = @{
# IconUri = ''

# ReleaseNotes of this module
ReleaseNotes = '* Set minimum dependency of module to PowerShell 5.0'
ReleaseNotes = '* Public release of Policy Insights cmdlets'

# Prerelease string of this module
Prerelease = 'preview'
# Prerelease = ''

# Flag to indicate whether the module requires explicit user acceptance for install/update
# RequireLicenseAcceptance = $false
Expand Down
3 changes: 3 additions & 0 deletions src/ResourceManager/PolicyInsights/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
- Additional information about change #1
-->
## Current Release
* Public release of Policy Insights cmdlets
- Use API version 2018-04-04
- Add PolicyDefinitionReferenceId to the results of Get-AzureRmPolicyStateSummary

## Version 0.9.1-preview
* Set minimum dependency of module to PowerShell 5.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Management.PolicyInsights" Version="0.9.0-preview" />
<PackageReference Include="Microsoft.Azure.Management.PolicyInsights" Version="1.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,9 @@
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Azure.Management.PolicyInsights, Version=0.9.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Reference Include="Microsoft.Azure.Management.PolicyInsights, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.PolicyInsights.0.9.0-preview\lib\net452\Microsoft.Azure.Management.PolicyInsights.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Rest.ClientRuntime, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.2.3.10\lib\net452\Microsoft.Rest.ClientRuntime.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Rest.ClientRuntime.Azure, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.3.3.10\lib\net452\Microsoft.Rest.ClientRuntime.Azure.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.PolicyInsights.1.0.0\lib\net452\Microsoft.Azure.Management.PolicyInsights.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Threading.Tasks, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
Expand All @@ -67,10 +59,6 @@
<HintPath>..\..\..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Resources.2.20.0-preview\lib\net40\Microsoft.Azure.ResourceManager.dll</HintPath>
<Private>True</Private>
Expand Down Expand Up @@ -189,7 +177,9 @@
</ItemGroup>
<ItemGroup>
<None Include="MSSharedLibKey.snk" />
<None Include="packages.config" />
<None Include="packages.config">
<SubType>Designer</SubType>
</None>
<None Include="ScenarioTests\Common.ps1">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
[assembly: CLSCompliant(false)]
[assembly: Guid("840516AC-34D7-4F12-925B-37509D240277")]

[assembly: AssemblyVersion("0.9.0")]
[assembly: AssemblyFileVersion("0.9.0")]
[assembly: AssemblyVersion("1.0.0")]
[assembly: AssemblyFileVersion("1.0.0")]

[assembly: CollectionBehavior(DisableTestParallelization = true)]
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,114 @@
# limitations under the License.
# ----------------------------------------------------------------------------------

<#
.SYNOPSIS
Gets test management group name
#>
function Get-TestManagementGroupName
{
"azgovtest4"
}

<#
.SYNOPSIS
Gets test resource group group name
#>
function Get-TestResourceGroupName
{
"bulenttestrg"
}

<#
.SYNOPSIS
Gets test resource id
#>
function Get-TestResourceId
{
"/subscriptions/d0610b27-9663-4c05-89f8-5b4be01e86a5/resourcegroups/govintpolicyrp/providers/microsoft.network/trafficmanagerprofiles/gov-int-policy-rp"
}

<#
.SYNOPSIS
Gets test policy set definition name
#>
function Get-TestPolicySetDefinitionName
{
"12b58873-e0f8-4b95-936c-86cbe7c9d697"
}

<#
.SYNOPSIS
Gets test policy definition name
#>
function Get-TestPolicyDefinitionName
{
"24813039-7534-408a-9842-eb99f45721b1"
}

<#
.SYNOPSIS
Gets test policy assignment name
#>
function Get-TestPolicyAssignmentName
{
"45ab2ab7898d45ebb3087573"
}

<#
.SYNOPSIS
Gets test resource group group name for resource group level policy assignment (for event tests)
#>
function Get-TestResourceGroupNameForPolicyAssignmentEvents
{
"jilimpolicytest2"
}

<#
.SYNOPSIS
Gets test policy assignment name (resource group level) (for event tests)
#>
function Get-TestPolicyAssignmentNameResourceGroupLevelEvents
{
"e9860612d8ec4a469f59af06"
}

<#
.SYNOPSIS
Gets test resource group group name for resource group level policy assignment (for state tests)
#>
function Get-TestResourceGroupNameForPolicyAssignmentStates
{
"bulenttestrg"
}

<#
.SYNOPSIS
Gets test policy assignment name (resource group level) (for state tests)
#>
function Get-TestPolicyAssignmentNameResourceGroupLevelStates
{
"f4d1645d-9180-4968-99df-17234d0f7019"
}

<#
.SYNOPSIS
Gets test query interval start
#>
function Get-TestQueryIntervalStart
{
"2018-03-31 00:00:00Z"
}

<#
.SYNOPSIS
Gets test query interval end
#>
function Get-TestQueryIntervalEnd
{
"2018-05-30 00:00:00Z"
}

<#
.SYNOPSIS
Validates a list of policy events
Expand All @@ -20,7 +128,8 @@ function Validate-PolicyEvents
{
param([System.Collections.Generic.List`1[[Microsoft.Azure.Commands.PolicyInsights.Models.PolicyEvent]]]$policyEvents, [int]$count)

Assert-AreEqual $count $policyEvents.Count
Assert-True { $count -ge $policyEvents.Count }
Assert-True { $policyEvents.Count -gt 0 }
Foreach($policyEvent in $policyEvents)
{
Validate-PolicyEvent $policyEvent
Expand Down Expand Up @@ -56,7 +165,8 @@ function Validate-PolicyStates
{
param([System.Collections.Generic.List`1[[Microsoft.Azure.Commands.PolicyInsights.Models.PolicyState]]]$policyStates, [int]$count)

Assert-AreEqual $count $policyStates.Count
Assert-True { $count -ge $policyStates.Count }
Assert-True { $policyStates.Count -gt 0 }
Foreach($policyState in $policyStates)
{
Validate-PolicyState $policyState
Expand Down Expand Up @@ -97,7 +207,8 @@ function Validate-PolicyStateSummary
Assert-NotNull $policyStateSummary.Results.NonCompliantPolicies

Assert-NotNull $policyStateSummary.PolicyAssignments
Assert-AreEqual $policyStateSummary.PolicyAssignments.Count $policyStateSummary.Results.NonCompliantPolicies
Assert-True { $policyStateSummary.PolicyAssignments.Count -le $policyStateSummary.Results.NonCompliantPolicies }
Assert-True { $policyStateSummary.PolicyAssignments.Count -gt 0 }

Foreach($policyAssignmentSummary in $policyStateSummary.PolicyAssignments)
{
Expand All @@ -110,7 +221,8 @@ function Validate-PolicyStateSummary
Assert-NotNull $policyAssignmentSummary.Results.NonCompliantPolicies

Assert-NotNull $policyAssignmentSummary.PolicyDefinitions
Assert-AreEqual $policyAssignmentSummary.PolicyDefinitions.Count $policyAssignmentSummary.Results.NonCompliantPolicies
Assert-True { $policyAssignmentSummary.PolicyDefinitions.Count -eq $policyAssignmentSummary.Results.NonCompliantPolicies }
Assert-True { $policyAssignmentSummary.PolicyDefinitions.Count -gt 0 }

if ($policyAssignmentSummary.Results.NonCompliantPolicies -gt 1)
{
Expand Down Expand Up @@ -139,6 +251,5 @@ function Assert-NotNullOrEmpty
{
param([string]$value)

Assert-NotNull $value
Assert-AreNotEqual $value ""
Assert-False { [string]::IsNullOrEmpty($value) }
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ Get policy events at management group scope
#>
function Get-AzureRmPolicyEvent-ManagementGroupScope
{
$policyEvents = Get-AzureRmPolicyEvent -ManagementGroupName "AzGovTest1" -Top 5
Validate-PolicyEvents $policyEvents 5
$managementGroupName = Get-TestManagementGroupName
$from = Get-TestQueryIntervalStart

$policyEvents = Get-AzureRmPolicyEvent -ManagementGroupName $managementGroupName -Top 10 -From $from
Validate-PolicyEvents $policyEvents 10
}

<#
Expand All @@ -28,8 +31,10 @@ Get policy events at subscription scope
#>
function Get-AzureRmPolicyEvent-SubscriptionScope
{
$policyEvents = Get-AzureRmPolicyEvent -Top 5
Validate-PolicyEvents $policyEvents 5
$from = Get-TestQueryIntervalStart

$policyEvents = Get-AzureRmPolicyEvent -Top 10 -From $from
Validate-PolicyEvents $policyEvents 10
}

<#
Expand All @@ -38,8 +43,11 @@ Get policy events at resource group scope
#>
function Get-AzureRmPolicyEvent-ResourceGroupScope
{
$policyEvents = Get-AzureRmPolicyEvent -ResourceGroupName defaultresourcegroup-eus -Top 5
Validate-PolicyEvents $policyEvents 5
$resourceGroupName = Get-TestResourceGroupName
$from = Get-TestQueryIntervalStart

$policyEvents = Get-AzureRmPolicyEvent -ResourceGroupName $resourceGroupName -Top 10 -From $from
Validate-PolicyEvents $policyEvents 10
}

<#
Expand All @@ -48,8 +56,11 @@ Get policy events at resource scope
#>
function Get-AzureRmPolicyEvent-ResourceScope
{
$policyEvents = Get-AzureRmPolicyEvent -ResourceId "/subscriptions/d0610b27-9663-4c05-89f8-5b4be01e86a5/resourcegroups/defaultresourcegroup-eus/providers/microsoft.operationalinsights/workspaces/defaultworkspace-d0610b27-9663-4c05-89f8-5b4be01e86a5-eus/linkedServices/Security"
Validate-PolicyEvents $policyEvents 7
$resourceId = Get-TestResourceId
$from = Get-TestQueryIntervalStart

$policyEvents = Get-AzureRmPolicyEvent -ResourceId $resourceId -Top 10 -From $from
Validate-PolicyEvents $policyEvents 10
}

<#
Expand All @@ -58,8 +69,10 @@ Get policy events at policy set definition scope
#>
function Get-AzureRmPolicyEvent-PolicySetDefinitionScope
{
$policyEvents = Get-AzureRmPolicyEvent -PolicySetDefinitionName a03db67e-a286-43c3-9098-b2da83d361ad -Top 5
Validate-PolicyEvents $policyEvents 5
$policySetDefinitionName = Get-TestPolicySetDefinitionName

$policyEvents = Get-AzureRmPolicyEvent -PolicySetDefinitionName $policySetDefinitionName -Top 10
Validate-PolicyEvents $policyEvents 10
}

<#
Expand All @@ -68,8 +81,10 @@ Get policy events at policy definition scope
#>
function Get-AzureRmPolicyEvent-PolicyDefinitionScope
{
$policyEvents = Get-AzureRmPolicyEvent -PolicyDefinitionName c8b79b49-a579-4045-984e-1b249ab8b474 -Top 5
Validate-PolicyEvents $policyEvents 5
$policyDefinitionName = Get-TestPolicyDefinitionName

$policyEvents = Get-AzureRmPolicyEvent -PolicyDefinitionName $policyDefinitionName -Top 10
Validate-PolicyEvents $policyEvents 10
}

<#
Expand All @@ -78,8 +93,10 @@ Get policy events at subscription level policy assignment scope
#>
function Get-AzureRmPolicyEvent-SubscriptionLevelPolicyAssignmentScope
{
$policyEvents = Get-AzureRmPolicyEvent -PolicyAssignmentName e46af646ebdb461dba708e01 -Top 5
Validate-PolicyEvents $policyEvents 5
$policyAssignmentName = Get-TestPolicyAssignmentName

$policyEvents = Get-AzureRmPolicyEvent -PolicyAssignmentName $policyAssignmentName -Top 10
Validate-PolicyEvents $policyEvents 10
}

<#
Expand All @@ -88,6 +105,9 @@ Get policy events at resource group level policy assignment scope
#>
function Get-AzureRmPolicyEvent-ResourceGroupLevelPolicyAssignmentScope
{
$policyEvents = Get-AzureRmPolicyEvent -ResourceGroupName cheggpolicy -PolicyAssignmentName d620f2d1462b4426a6b499fc -Top 1
Validate-PolicyEvents $policyEvents 1
$resourceGroupName = Get-TestResourceGroupNameForPolicyAssignmentEvents
$policyAssignmentName = Get-TestPolicyAssignmentNameResourceGroupLevelEvents

$policyEvents = Get-AzureRmPolicyEvent -ResourceGroupName $resourceGroupName -PolicyAssignmentName $policyAssignmentName -Top 10
Validate-PolicyEvents $policyEvents 10
}
Loading