Skip to content
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

Enhancement to Unit-Test-Policies workflow #1402

Merged
merged 6 commits into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
26 changes: 25 additions & 1 deletion .github/actions-pester/Test-ModifiedPolicies.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,29 @@ Describe 'UnitTest-ModifiedPolicies' {
$PolicyMetadataVersion = $PolicyJson.properties.metadata.version
$PolicyJson = Get-Content -Path $_ -Raw | ConvertFrom-Json
Write-Warning "$($PolicyFile) - The current metadata version for the policy in the PR branch is : $($PolicyMetadataVersion)"
$PolicyMetadataVersion | Should -BeGreaterThan $PreviousPolicyDefinitionsFileVersion
if (!$PreviousPolicyDefinitionsFileVersion.EndsWith("deprecated")) {
$PolicyMetadataVersion | Should -BeGreaterThan $PreviousPolicyDefinitionsFileVersion
}
}
}

It "Check deprecated policy contains all required metadata" {
$ModifiedAddedFiles | ForEach-Object {
$PolicyJson = Get-Content -Path $_ -Raw | ConvertFrom-Json
$PolicyFile = Split-Path $_ -Leaf
$PolicyMetadataVersion = $PolicyJson.properties.metadata.version
Write-Warning "$($PolicyFile) - This is the policy metadata version: $($PolicyMetadataVersion)"
if ($PolicyMetadataVersion.EndsWith("deprecated")) {
Write-Warning "$($PolicyFile) - Should have the deprecated metadata flag set to true"
$PolicyMetadataDeprecated = $PolicyJson.properties.metadata.deprecated
$PolicyMetadataDeprecated | Should -BeTrue
Write-Warning "$($PolicyFile) - Should have the supersededBy metadata value set"
$PolicyMetadataSuperseded = $PolicyJson.properties.metadata.supersededBy
$PolicyMetadataSuperseded | Should -Not -BeNullOrEmpty
Write-Warning "$($PolicyFile) - [Deprecated] should be in the display name"
$PolicyPropertiesDisplayName = $PolicyJson.properties.displayName
$PolicyPropertiesDisplayName | Should -Match "[DEPRECATED]"
}
}
}

Expand Down Expand Up @@ -86,7 +108,9 @@ Describe 'UnitTest-ModifiedPolicies' {
$PolicyJson.properties.metadata.alzCloudEnvironments | Should -BeIn $AlzEnvironments
}
}

}

Context "Validate policy parameters" {
It 'Check for policy parameters have default values' {
$ModifiedAddedFiles | ForEach-Object {
Expand Down
Loading