|
| 1 | +Describe "Test-Assessment-35005" { |
| 2 | + BeforeAll { |
| 3 | + $here = $PSScriptRoot |
| 4 | + $srcRoot = Join-Path $here "../../src/powershell" |
| 5 | + |
| 6 | + # Mock external module dependencies if they are not present |
| 7 | + if (-not (Get-Command Write-PSFMessage -ErrorAction SilentlyContinue)) { |
| 8 | + function Write-PSFMessage {} |
| 9 | + } |
| 10 | + if (-not (Get-Command Get-SPOTenant -ErrorAction SilentlyContinue)) { |
| 11 | + function Get-SPOTenant {} |
| 12 | + } |
| 13 | + |
| 14 | + # Load the class |
| 15 | + $classPath = Join-Path $srcRoot "classes/ZtTest.ps1" |
| 16 | + if (-not ("ZtTest" -as [type])) { |
| 17 | + . $classPath |
| 18 | + } |
| 19 | + |
| 20 | + # Load the SUT |
| 21 | + $sut = Join-Path $srcRoot "tests/Test-Assessment.35005.ps1" |
| 22 | + . $sut |
| 23 | + |
| 24 | + # Setup output file |
| 25 | + $script:outputFile = Join-Path $here "../TestResults/Report-Test-Assessment.35005.md" |
| 26 | + $outputDir = Split-Path $script:outputFile |
| 27 | + if (-not (Test-Path $outputDir)) { New-Item -ItemType Directory -Path $outputDir | Out-Null } |
| 28 | + "# Test Results for 35005`n" | Set-Content $script:outputFile |
| 29 | + } |
| 30 | + |
| 31 | + # Mock common module functions |
| 32 | + BeforeEach { |
| 33 | + Mock Write-PSFMessage {} |
| 34 | + Mock Write-ZtProgress {} |
| 35 | + } |
| 36 | + |
| 37 | + Context "When querying SharePoint tenant settings fails" { |
| 38 | + It "Should return Investigate status" { |
| 39 | + Mock Get-SPOTenant { throw "Connection error" } |
| 40 | + Mock Add-ZtTestResultDetail { |
| 41 | + param($TestId, $Title, $Status, $Result) |
| 42 | + "## Scenario: Error querying settings`n`n$Result`n" | Add-Content $script:outputFile |
| 43 | + } |
| 44 | + |
| 45 | + Test-Assessment-35005 |
| 46 | + |
| 47 | + Should -Invoke Add-ZtTestResultDetail -ParameterFilter { |
| 48 | + $Status -eq $false -and $Result -match "Unable to query SharePoint Tenant Settings" |
| 49 | + } |
| 50 | + } |
| 51 | + } |
| 52 | + |
| 53 | + Context "When EnableAIPIntegration is disabled" { |
| 54 | + It "Should fail" { |
| 55 | + Mock Get-SPOTenant { |
| 56 | + return [PSCustomObject]@{ |
| 57 | + EnableAIPIntegration = $false |
| 58 | + } |
| 59 | + } |
| 60 | + Mock Add-ZtTestResultDetail { |
| 61 | + param($TestId, $Title, $Status, $Result) |
| 62 | + "## Scenario: EnableAIPIntegration disabled`n`n$Result`n" | Add-Content $script:outputFile |
| 63 | + } |
| 64 | + |
| 65 | + Test-Assessment-35005 |
| 66 | + |
| 67 | + Should -Invoke Add-ZtTestResultDetail -ParameterFilter { |
| 68 | + $Status -eq $false -and |
| 69 | + $Result -match "Sensitivity labels are NOT enabled" -and |
| 70 | + $Result -match "EnableAIPIntegration: False" |
| 71 | + } |
| 72 | + } |
| 73 | + } |
| 74 | + |
| 75 | + Context "When EnableAIPIntegration is enabled" { |
| 76 | + It "Should pass" { |
| 77 | + Mock Get-SPOTenant { |
| 78 | + return [PSCustomObject]@{ |
| 79 | + EnableAIPIntegration = $true |
| 80 | + } |
| 81 | + } |
| 82 | + Mock Add-ZtTestResultDetail { |
| 83 | + param($TestId, $Title, $Status, $Result) |
| 84 | + "## Scenario: EnableAIPIntegration enabled`n`n$Result`n" | Add-Content $script:outputFile |
| 85 | + } |
| 86 | + |
| 87 | + Test-Assessment-35005 |
| 88 | + |
| 89 | + Should -Invoke Add-ZtTestResultDetail -ParameterFilter { |
| 90 | + $Status -eq $true -and |
| 91 | + $Result -match "Sensitivity labels are enabled" -and |
| 92 | + $Result -match "EnableAIPIntegration: True" |
| 93 | + } |
| 94 | + } |
| 95 | + } |
| 96 | +} |
0 commit comments