diff --git a/CHANGELOG.md b/CHANGELOG.md index f1e8f7c02fb..47ada1a9b48 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ +# Change log ## Unreleased +- Added default baseline to module. [#126](https://github.com/BernieWhite/PSRule.Rules.Azure/issues/126) + ## v0.4.0-B190902 (pre-release) - Added rule to verify connectivity of VNET peers. [#120](https://github.com/BernieWhite/PSRule.Rules.Azure/issues/120) diff --git a/pipeline.build.ps1 b/pipeline.build.ps1 index 8c9203eaffc..ffe5575965b 100644 --- a/pipeline.build.ps1 +++ b/pipeline.build.ps1 @@ -63,7 +63,7 @@ function CopyModuleFiles { process { $sourcePath = Resolve-Path -Path $Path; - Get-ChildItem -Path $sourcePath -Recurse -File -Include *.ps1,*.psm1,*.psd1,*.ps1xml | Where-Object -FilterScript { + Get-ChildItem -Path $sourcePath -Recurse -File -Include *.ps1,*.psm1,*.psd1,*.ps1xml,*.yaml | Where-Object -FilterScript { ($_.FullName -notmatch '(\.(cs|csproj)|(\\|\/)(obj|bin))') } | ForEach-Object -Process { $filePath = $_.FullName.Replace($sourcePath, $destinationPath); @@ -108,6 +108,9 @@ task VersionModule ModuleDependencies, { } }; Update-ModuleManifest -Path $manifestPath -RequiredModules $requiredModules; + $manifestContent = Get-Content -Path $manifestPath -Raw; + $manifestContent = $manifestContent -replace 'PSRule = ''System.Collections.Hashtable''', 'PSRule = @{ Baseline = ''Azure.SubscriptionDefault'' }'; + $manifestContent | Set-Content -Path $manifestPath; } # Synopsis: Publish to PowerShell Gallery diff --git a/src/PSRule.Rules.Azure/PSRule.Rules.Azure.psd1 b/src/PSRule.Rules.Azure/PSRule.Rules.Azure.psd1 index 8b1e0a0e9b3..8631ce8462c 100644 --- a/src/PSRule.Rules.Azure/PSRule.Rules.Azure.psd1 +++ b/src/PSRule.Rules.Azure/PSRule.Rules.Azure.psd1 @@ -112,7 +112,7 @@ PrivateData = @{ ReleaseNotes = 'https://github.com/BernieWhite/PSRule.Rules.Azure/blob/master/CHANGELOG.md' } # End of PSData hashtable PSRule = @{ - Baseline = 'DefaultBaseline' + Baseline = 'Azure.SubscriptionDefault' } } # End of PrivateData hashtable diff --git a/src/PSRule.Rules.Azure/rules/Baseline.Rule.yaml b/src/PSRule.Rules.Azure/rules/Baseline.Rule.yaml index f4f83089333..3bd040b2168 100644 --- a/src/PSRule.Rules.Azure/rules/Baseline.Rule.yaml +++ b/src/PSRule.Rules.Azure/rules/Baseline.Rule.yaml @@ -1,8 +1,9 @@ --- +# Synopsis: Default baseline for Azure rules kind: Baseline metadata: - name: DefaultBaseline + name: Azure.SubscriptionDefault spec: binding: targetType: diff --git a/tests/PSRule.Rules.Azure.Tests/Azure.Baseline.Tests.ps1 b/tests/PSRule.Rules.Azure.Tests/Azure.Baseline.Tests.ps1 new file mode 100644 index 00000000000..33562de1d10 --- /dev/null +++ b/tests/PSRule.Rules.Azure.Tests/Azure.Baseline.Tests.ps1 @@ -0,0 +1,33 @@ +# +# Unit tests for baselines +# + +[CmdletBinding()] +param ( + +) + +# Setup error handling +$ErrorActionPreference = 'Stop'; +Set-StrictMode -Version latest; + +if ($Env:SYSTEM_DEBUG -eq 'true') { + $VerbosePreference = 'Continue'; +} + +# Setup tests paths +$rootPath = $PWD; +Import-Module (Join-Path -Path $rootPath -ChildPath out/modules/PSRule.Rules.Azure) -Force; +$here = (Resolve-Path $PSScriptRoot).Path; + +Describe 'Baselines' -Tag Baseline { + $dataPath = Join-Path -Path $here -ChildPath 'Resources.Resource.json'; + + Context 'Binding' { + $result = Invoke-PSRule -Module PSRule.Rules.Azure -Outcome All -InputPath $dataPath -WarningAction Ignore -ErrorAction Stop; + + It 'TargetType' { + $result.TargetType | Should -Not -BeIn 'System.Management.Automation.PSCustomObject'; + } + } +}