mirror of
https://github.com/NexusOne23/noid-privacy.git
synced 2026-02-07 04:01:52 +01:00
Fix: Use direct env check for -Skip (Pester evaluates before BeforeAll)
This commit is contained in:
parent
745d808771
commit
75c6c76ba2
8 changed files with 22 additions and 30 deletions
|
|
@ -2,7 +2,6 @@ Describe "ASR Integration Tests" {
|
|||
BeforeAll {
|
||||
$script:ModulePath = Join-Path $PSScriptRoot "..\..\Modules\ASR"
|
||||
$script:ManifestPath = Join-Path $script:ModulePath "ASR.psd1"
|
||||
$script:IsCI = $env:GITHUB_ACTIONS -eq 'true' -or $env:CI -eq 'true'
|
||||
}
|
||||
|
||||
Context "Module Structure" {
|
||||
|
|
@ -21,7 +20,7 @@ Describe "ASR Integration Tests" {
|
|||
}
|
||||
|
||||
Context "DryRun Execution" {
|
||||
It "Should run in DryRun mode without errors" -Skip:$script:IsCI {
|
||||
It "Should run in DryRun mode without errors" -Skip:($env:GITHUB_ACTIONS -eq 'true') {
|
||||
# Skip on CI - requires Windows Defender and admin rights
|
||||
{ Invoke-ASRRules -DryRun -ErrorAction Stop } | Should -Not -Throw
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ Describe "AdvancedSecurity Integration Tests" {
|
|||
BeforeAll {
|
||||
$script:ModulePath = Join-Path $PSScriptRoot "..\..\Modules\AdvancedSecurity"
|
||||
$script:ManifestPath = Join-Path $script:ModulePath "AdvancedSecurity.psd1"
|
||||
$script:IsCI = $env:GITHUB_ACTIONS -eq 'true' -or $env:CI -eq 'true'
|
||||
}
|
||||
|
||||
Context "Module Structure" {
|
||||
|
|
@ -48,24 +47,24 @@ Describe "AdvancedSecurity Integration Tests" {
|
|||
}
|
||||
|
||||
Context "DryRun Execution" {
|
||||
It "Should run Invoke-AdvancedSecurity in DryRun mode without errors" -Skip:$script:IsCI {
|
||||
It "Should run Invoke-AdvancedSecurity in DryRun mode without errors" -Skip:($env:GITHUB_ACTIONS -eq 'true') {
|
||||
# Skip on CI - requires admin rights and registry access
|
||||
{ Invoke-AdvancedSecurity -DryRun -ErrorAction Stop } | Should -Not -Throw
|
||||
}
|
||||
|
||||
It "Should run with Balanced profile in DryRun mode" -Skip:$script:IsCI {
|
||||
It "Should run with Balanced profile in DryRun mode" -Skip:($env:GITHUB_ACTIONS -eq 'true') {
|
||||
{ Invoke-AdvancedSecurity -SecurityProfile "Balanced" -DryRun -ErrorAction Stop } | Should -Not -Throw
|
||||
}
|
||||
|
||||
It "Should run with Enterprise profile in DryRun mode" -Skip:$script:IsCI {
|
||||
It "Should run with Enterprise profile in DryRun mode" -Skip:($env:GITHUB_ACTIONS -eq 'true') {
|
||||
{ Invoke-AdvancedSecurity -SecurityProfile "Enterprise" -DryRun -ErrorAction Stop } | Should -Not -Throw
|
||||
}
|
||||
|
||||
It "Should run with Maximum profile in DryRun mode" -Skip:$script:IsCI {
|
||||
It "Should run with Maximum profile in DryRun mode" -Skip:($env:GITHUB_ACTIONS -eq 'true') {
|
||||
{ Invoke-AdvancedSecurity -SecurityProfile "Maximum" -DryRun -ErrorAction Stop } | Should -Not -Throw
|
||||
}
|
||||
|
||||
It "Should run Test-AdvancedSecurity without errors" -Skip:$script:IsCI {
|
||||
It "Should run Test-AdvancedSecurity without errors" -Skip:($env:GITHUB_ACTIONS -eq 'true') {
|
||||
{ Test-AdvancedSecurity -ErrorAction Stop } | Should -Not -Throw
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ Describe "AntiAI Integration Tests" {
|
|||
$script:ModulePath = Join-Path $PSScriptRoot "..\..\Modules\AntiAI"
|
||||
$script:ManifestPath = Join-Path $script:ModulePath "AntiAI.psd1"
|
||||
$script:ComplianceScript = Join-Path $script:ModulePath "Private\Test-AntiAICompliance.ps1"
|
||||
$script:IsCI = $env:GITHUB_ACTIONS -eq 'true' -or $env:CI -eq 'true'
|
||||
}
|
||||
|
||||
Context "Module Structure" {
|
||||
|
|
@ -26,14 +25,14 @@ Describe "AntiAI Integration Tests" {
|
|||
}
|
||||
|
||||
Context "DryRun Execution" {
|
||||
It "Should run in DryRun mode without errors" -Skip:$script:IsCI {
|
||||
It "Should run in DryRun mode without errors" -Skip:($env:GITHUB_ACTIONS -eq 'true') {
|
||||
# Skip on CI - requires admin rights and registry access
|
||||
{ Invoke-AntiAI -DryRun -ErrorAction Stop } | Should -Not -Throw
|
||||
}
|
||||
}
|
||||
|
||||
Context "Compliance Check" {
|
||||
It "Should run compliance test without errors" -Skip:$script:IsCI {
|
||||
It "Should run compliance test without errors" -Skip:($env:GITHUB_ACTIONS -eq 'true') {
|
||||
# Skip on CI - requires admin rights and registry access
|
||||
{ & $script:ComplianceScript -ErrorAction Stop } | Should -Not -Throw
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ Describe "DNS Integration Tests" {
|
|||
BeforeAll {
|
||||
$script:ModulePath = Join-Path $PSScriptRoot "..\..\Modules\DNS"
|
||||
$script:ManifestPath = Join-Path $script:ModulePath "DNS.psd1"
|
||||
$script:IsCI = $env:GITHUB_ACTIONS -eq 'true' -or $env:CI -eq 'true'
|
||||
}
|
||||
|
||||
Context "Module Structure" {
|
||||
|
|
@ -26,7 +25,7 @@ Describe "DNS Integration Tests" {
|
|||
}
|
||||
|
||||
Context "DryRun Execution" {
|
||||
It "Should run in DryRun mode with provider specified without errors" -Skip:$script:IsCI {
|
||||
It "Should run in DryRun mode with provider specified without errors" -Skip:($env:GITHUB_ACTIONS -eq 'true') {
|
||||
# Skip on CI - requires network adapters and admin rights
|
||||
{ Invoke-DNSConfiguration -Provider "Quad9" -DryRun -ErrorAction Stop } | Should -Not -Throw
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ Describe "EdgeHardening Integration Tests" {
|
|||
BeforeAll {
|
||||
$script:ModulePath = Join-Path $PSScriptRoot "..\..\Modules\EdgeHardening"
|
||||
$script:ManifestPath = Join-Path $script:ModulePath "EdgeHardening.psd1"
|
||||
$script:IsCI = $env:GITHUB_ACTIONS -eq 'true' -or $env:CI -eq 'true'
|
||||
}
|
||||
|
||||
Context "Module Structure" {
|
||||
|
|
@ -38,12 +37,12 @@ Describe "EdgeHardening Integration Tests" {
|
|||
}
|
||||
|
||||
Context "DryRun Execution" {
|
||||
It "Should run Invoke-EdgeHardening in DryRun mode without errors" -Skip:$script:IsCI {
|
||||
It "Should run Invoke-EdgeHardening in DryRun mode without errors" -Skip:($env:GITHUB_ACTIONS -eq 'true') {
|
||||
# Skip on CI - requires admin rights and registry access
|
||||
{ Invoke-EdgeHardening -DryRun -ErrorAction Stop } | Should -Not -Throw
|
||||
}
|
||||
|
||||
It "Should run Test-EdgeHardening without errors" -Skip:$script:IsCI {
|
||||
It "Should run Test-EdgeHardening without errors" -Skip:($env:GITHUB_ACTIONS -eq 'true') {
|
||||
{ Test-EdgeHardening -ErrorAction Stop } | Should -Not -Throw
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ Describe "Privacy Integration Tests" {
|
|||
BeforeAll {
|
||||
$script:ModulePath = Join-Path $PSScriptRoot "..\..\Modules\Privacy"
|
||||
$script:ManifestPath = Join-Path $script:ModulePath "Privacy.psd1"
|
||||
$script:IsCI = $env:GITHUB_ACTIONS -eq 'true' -or $env:CI -eq 'true'
|
||||
}
|
||||
|
||||
Context "Module Structure" {
|
||||
|
|
@ -21,7 +20,7 @@ Describe "Privacy Integration Tests" {
|
|||
}
|
||||
|
||||
Context "DryRun Execution" {
|
||||
It "Should run in DryRun mode with MSRecommended mode without errors" -Skip:$script:IsCI {
|
||||
It "Should run in DryRun mode with MSRecommended mode without errors" -Skip:($env:GITHUB_ACTIONS -eq 'true') {
|
||||
# Skip on CI - requires admin rights and registry access
|
||||
{ Invoke-PrivacyHardening -Mode "MSRecommended" -DryRun -ErrorAction Stop } | Should -Not -Throw
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ Describe "SecurityBaseline Integration Tests" {
|
|||
BeforeAll {
|
||||
$script:ModulePath = Join-Path $PSScriptRoot "..\..\Modules\SecurityBaseline"
|
||||
$script:ManifestPath = Join-Path $script:ModulePath "SecurityBaseline.psd1"
|
||||
$script:IsCI = $env:GITHUB_ACTIONS -eq 'true' -or $env:CI -eq 'true'
|
||||
}
|
||||
|
||||
Context "Module Structure" {
|
||||
|
|
@ -26,7 +25,7 @@ Describe "SecurityBaseline Integration Tests" {
|
|||
}
|
||||
|
||||
Context "DryRun Execution" {
|
||||
It "Should run in DryRun mode without errors" -Skip:$script:IsCI {
|
||||
It "Should run in DryRun mode without errors" -Skip:($env:GITHUB_ACTIONS -eq 'true') {
|
||||
# Skip on CI - requires admin rights and registry access
|
||||
{ Invoke-SecurityBaseline -DryRun -ErrorAction Stop } | Should -Not -Throw
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,35 +96,34 @@ Describe "ModuleTemplate Module" {
|
|||
if (Get-Command Initialize-Logger -ErrorAction SilentlyContinue) {
|
||||
Initialize-Logger -EnableConsole $false
|
||||
}
|
||||
$script:IsCI = $env:GITHUB_ACTIONS -eq 'true' -or $env:CI -eq 'true'
|
||||
}
|
||||
|
||||
It "Should execute without errors in DryRun mode" -Skip:$script:IsCI {
|
||||
It "Should execute without errors in DryRun mode" -Skip:($env:GITHUB_ACTIONS -eq 'true') {
|
||||
# Skip on CI - requires initialized environment
|
||||
{ Invoke-ModuleTemplate -DryRun } | Should -Not -Throw
|
||||
}
|
||||
|
||||
It "Should return a PSCustomObject" -Skip:$script:IsCI {
|
||||
It "Should return a PSCustomObject" -Skip:($env:GITHUB_ACTIONS -eq 'true') {
|
||||
$result = Invoke-ModuleTemplate -DryRun
|
||||
$result | Should -BeOfType [PSCustomObject]
|
||||
}
|
||||
|
||||
It "Should have ModuleName property" -Skip:$script:IsCI {
|
||||
It "Should have ModuleName property" -Skip:($env:GITHUB_ACTIONS -eq 'true') {
|
||||
$result = Invoke-ModuleTemplate -DryRun
|
||||
$result.ModuleName | Should -Be "ModuleTemplate"
|
||||
}
|
||||
|
||||
It "Should have Success property" -Skip:$script:IsCI {
|
||||
It "Should have Success property" -Skip:($env:GITHUB_ACTIONS -eq 'true') {
|
||||
$result = Invoke-ModuleTemplate -DryRun
|
||||
$result.PSObject.Properties.Name | Should -Contain 'Success'
|
||||
}
|
||||
|
||||
It "Should have ChangesApplied property" -Skip:$script:IsCI {
|
||||
It "Should have ChangesApplied property" -Skip:($env:GITHUB_ACTIONS -eq 'true') {
|
||||
$result = Invoke-ModuleTemplate -DryRun
|
||||
$result.PSObject.Properties.Name | Should -Contain 'ChangesApplied'
|
||||
}
|
||||
|
||||
It "Should not apply changes in DryRun mode" -Skip:$script:IsCI {
|
||||
It "Should not apply changes in DryRun mode" -Skip:($env:GITHUB_ACTIONS -eq 'true') {
|
||||
$result = Invoke-ModuleTemplate -DryRun
|
||||
$result.ChangesApplied | Should -Be 0
|
||||
}
|
||||
|
|
@ -132,7 +131,7 @@ Describe "ModuleTemplate Module" {
|
|||
|
||||
Context "Return Object Structure" {
|
||||
|
||||
It "Should return object with all required properties" -Skip:$script:IsCI {
|
||||
It "Should return object with all required properties" -Skip:($env:GITHUB_ACTIONS -eq 'true') {
|
||||
$result = Invoke-ModuleTemplate -DryRun
|
||||
|
||||
$requiredProperties = @(
|
||||
|
|
@ -150,12 +149,12 @@ Describe "ModuleTemplate Module" {
|
|||
}
|
||||
}
|
||||
|
||||
It "Errors should be an array" -Skip:$script:IsCI {
|
||||
It "Errors should be an array" -Skip:($env:GITHUB_ACTIONS -eq 'true') {
|
||||
$result = Invoke-ModuleTemplate -DryRun
|
||||
$result.Errors | Should -BeOfType [System.Object[]]
|
||||
}
|
||||
|
||||
It "Warnings should be an array" -Skip:$script:IsCI {
|
||||
It "Warnings should be an array" -Skip:($env:GITHUB_ACTIONS -eq 'true') {
|
||||
$result = Invoke-ModuleTemplate -DryRun
|
||||
$result.Warnings | Should -BeOfType [System.Object[]]
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue