diff --git a/source/Private/Get-CISAadOutput.ps1 b/source/Private/Get-CISAadOutput.ps1 new file mode 100644 index 0000000..4acf52f --- /dev/null +++ b/source/Private/Get-CISAadOutput.ps1 @@ -0,0 +1,41 @@ +<# + .SYNOPSIS + This is a sample Private function only visible within the module. + .DESCRIPTION + This sample function is not exported to the module and only return the data passed as parameter. + .EXAMPLE + $null = Get-Get-CISAadOutput -PrivateData 'NOTHING TO SEE HERE' + .PARAMETER PrivateData + The PrivateData parameter is what will be returned without transformation. +#> +function Get-CISAadOutput { + [cmdletBinding()] + [OutputType([string])] + param( + [Parameter(Mandatory = $true)] + [String] + $Rec + ) + begin { + # Begin Block # + <# + # Tests + 1.2.2 + # Test number + $testNumbers ="1.2.2" + #> + } + process { + switch ($Rec) { + '1.2.2' { + # Test-BlockSharedMailboxSignIn.ps1 + $users = Get-AzureADUser + } + default { throw "No match found for test: $Rec" } + } + } + end { + Write-Verbose "Retuning data for Rec: $Rec" + return $users + } +} # end function Get-CISAadOutput diff --git a/source/tests/Test-BlockSharedMailboxSignIn.ps1 b/source/tests/Test-BlockSharedMailboxSignIn.ps1 index 9025358..cfda390 100644 --- a/source/tests/Test-BlockSharedMailboxSignIn.ps1 +++ b/source/tests/Test-BlockSharedMailboxSignIn.ps1 @@ -31,9 +31,10 @@ function Test-BlockSharedMailboxSignIn { try { # Step: Retrieve shared mailbox details $MBX = Get-CISExoOutput -Rec $recnum - + $objectids = $MBX.ExternalDirectoryObjectId + $users = Get-CISAadOutput -Rec $recnum # Step: Retrieve details of shared mailboxes from Azure AD (Condition B: Pass/Fail) - $sharedMailboxDetails = $MBX | ForEach-Object { Get-AzureADUser -ObjectId $_.ExternalDirectoryObjectId } + $sharedMailboxDetails = $users | Where-Object {$_.objectid -in $objectids} # Step: Identify enabled mailboxes (Condition B: Pass/Fail) $enabledMailboxes = $sharedMailboxDetails | Where-Object { $_.AccountEnabled } | ForEach-Object { $_.DisplayName } diff --git a/tests/Unit/Private/Get-CISAadOutput.tests.ps1 b/tests/Unit/Private/Get-CISAadOutput.tests.ps1 new file mode 100644 index 0000000..4a2aa69 --- /dev/null +++ b/tests/Unit/Private/Get-CISAadOutput.tests.ps1 @@ -0,0 +1,27 @@ +$ProjectPath = "$PSScriptRoot\..\..\.." | Convert-Path +$ProjectName = ((Get-ChildItem -Path $ProjectPath\*\*.psd1).Where{ + ($_.Directory.Name -match 'source|src' -or $_.Directory.Name -eq $_.BaseName) -and + $(try { Test-ModuleManifest $_.FullName -ErrorAction Stop } catch { $false } ) + }).BaseName + + +Import-Module $ProjectName + +InModuleScope $ProjectName { + Describe Get-PrivateFunction { + Context 'Default' { + BeforeEach { + $return = Get-PrivateFunction -PrivateData 'string' + } + + It 'Returns a single object' { + ($return | Measure-Object).Count | Should -Be 1 + } + + It 'Returns a string based on the parameter PrivateData' { + $return | Should -Be 'string' + } + } + } +} +