From d5c64910abf6a1213796718e70d7b1a56f0cc68b Mon Sep 17 00:00:00 2001 From: DrIOS <58635327+DrIOSX@users.noreply.github.com> Date: Tue, 28 May 2024 11:15:22 -0500 Subject: [PATCH] fix: 7.2.1 aligned with test-template --- source/tests/Test-ModernAuthSharePoint.ps1 | 26 ++++++++++++++++------ 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/source/tests/Test-ModernAuthSharePoint.ps1 b/source/tests/Test-ModernAuthSharePoint.ps1 index 0677c3a..7f9f60e 100644 --- a/source/tests/Test-ModernAuthSharePoint.ps1 +++ b/source/tests/Test-ModernAuthSharePoint.ps1 @@ -1,13 +1,14 @@ function Test-ModernAuthSharePoint { [CmdletBinding()] param ( + # Aligned # Define your parameters here ) begin { - # Initialization code - - $auditResult = [CISAuditResult]::new() + # Dot source the class script if necessary + #. .\source\Classes\CISAuditResult.ps1 + # Initialization code, if needed } process { @@ -15,7 +16,18 @@ function Test-ModernAuthSharePoint { $SPOTenant = Get-SPOTenant | Select-Object -Property LegacyAuthProtocolsEnabled $modernAuthForSPRequired = -not $SPOTenant.LegacyAuthProtocolsEnabled - # Populate the auditResult object with the required properties + # Prepare failure reasons and details based on compliance + $failureReasons = if (-not $modernAuthForSPRequired) { + "Legacy authentication protocols are enabled" + } + else { + "N/A" + } + + $details = "LegacyAuthProtocolsEnabled: $($SPOTenant.LegacyAuthProtocolsEnabled)" + + # Create and populate the CISAuditResult object + $auditResult = [CISAuditResult]::new() $auditResult.CISControlVer = "v8" $auditResult.CISControl = "3.10" $auditResult.CISDescription = "Encrypt Sensitive Data in Transit" @@ -27,13 +39,13 @@ function Test-ModernAuthSharePoint { $auditResult.IG3 = $true $auditResult.RecDescription = "Modern Authentication for SharePoint Applications" $auditResult.Result = $modernAuthForSPRequired - $auditResult.Details = "LegacyAuthProtocolsEnabled: $($SPOTenant.LegacyAuthProtocolsEnabled)" - $auditResult.FailureReason = if (-not $modernAuthForSPRequired) { "Legacy authentication protocols are enabled" } else { "N/A" } + $auditResult.Details = $details + $auditResult.FailureReason = $failureReasons $auditResult.Status = if ($modernAuthForSPRequired) { "Pass" } else { "Fail" } } end { - # Return auditResult + # Return the audit result return $auditResult } }