change: Get-Action Testing-Refactor export
This commit is contained in:
33
source/Private/Get-AuditMailboxDetail.ps1
Normal file
33
source/Private/Get-AuditMailboxDetail.ps1
Normal file
@@ -0,0 +1,33 @@
|
||||
function Get-AuditMailboxDetail {
|
||||
[cmdletBinding()]
|
||||
param (
|
||||
[Parameter(Mandatory = $true)]
|
||||
[String]$Details,
|
||||
[Parameter(Mandatory = $true)]
|
||||
[String]$Version
|
||||
)
|
||||
process {
|
||||
switch ($Version) {
|
||||
"6.1.2" { [string]$VersionText = "No M365 E3 licenses found."}
|
||||
"6.1.3" { [string]$VersionText = "No M365 E5 licenses found."}
|
||||
}
|
||||
if ($details -ne $VersionText ) {
|
||||
$csv = $details | ConvertFrom-Csv -Delimiter '|'
|
||||
}
|
||||
else {
|
||||
$csv = $null
|
||||
}
|
||||
if ($null -ne $csv) {
|
||||
foreach ($row in $csv) {
|
||||
$row.AdminActionsMissing = (Get-Action -AbbreviatedActions $row.AdminActionsMissing.Split(',') -ReverseActionType Admin -Version $Version) -join ','
|
||||
$row.DelegateActionsMissing = (Get-Action -AbbreviatedActions $row.DelegateActionsMissing.Split(',') -ReverseActionType Delegate -Version $Version ) -join ','
|
||||
$row.OwnerActionsMissing = (Get-Action -AbbreviatedActions $row.OwnerActionsMissing.Split(',') -ReverseActionType Owner -Version $Version ) -join ','
|
||||
}
|
||||
$newObjectDetails = $csv
|
||||
}
|
||||
else {
|
||||
$newObjectDetails = $details
|
||||
}
|
||||
return $newObjectDetails
|
||||
}
|
||||
}
|
@@ -109,44 +109,12 @@ function Export-M365SecurityAuditTable {
|
||||
switch ($test) {
|
||||
"6.1.2" {
|
||||
$details = $auditResult.Details
|
||||
if ($details -ne "No M365 E3 licenses found.") {
|
||||
$csv = $details | ConvertFrom-Csv -Delimiter '|'
|
||||
}
|
||||
else {
|
||||
$csv = $null
|
||||
}
|
||||
if ($null -ne $csv) {
|
||||
foreach ($row in $csv) {
|
||||
$row.AdminActionsMissing = (Get-Action -AbbreviatedActions $row.AdminActionsMissing.Split(',') -ReverseActionType Admin -Version '6.1.2') -join ','
|
||||
$row.DelegateActionsMissing = (Get-Action -AbbreviatedActions $row.DelegateActionsMissing.Split(',') -ReverseActionType Delegate -Version '6.1.2' ) -join ','
|
||||
$row.OwnerActionsMissing = (Get-Action -AbbreviatedActions $row.OwnerActionsMissing.Split(',') -ReverseActionType Owner -Version '6.1.2' ) -join ','
|
||||
}
|
||||
$newObjectDetails = $csv
|
||||
}
|
||||
else {
|
||||
$newObjectDetails = $details
|
||||
}
|
||||
$newObjectDetails = Get-AuditMailboxDetail -Details $details -Version '6.1.2'
|
||||
$results += [PSCustomObject]@{ TestNumber = $test; Details = $newObjectDetails }
|
||||
}
|
||||
"6.1.3" {
|
||||
$details = $auditResult.Details
|
||||
if ($details -ne "No M365 E5 licenses found.") {
|
||||
$csv = $details | ConvertFrom-Csv -Delimiter '|'
|
||||
}
|
||||
else {
|
||||
$csv = $null
|
||||
}
|
||||
if ($null -ne $csv) {
|
||||
foreach ($row in $csv) {
|
||||
$row.AdminActionsMissing = (Get-Action -AbbreviatedActions $row.AdminActionsMissing.Split(',') -ReverseActionType Admin -Version '6.1.3') -join ','
|
||||
$row.DelegateActionsMissing = (Get-Action -AbbreviatedActions $row.DelegateActionsMissing.Split(',') -ReverseActionType Delegate -Version '6.1.3') -join ','
|
||||
$row.OwnerActionsMissing = (Get-Action -AbbreviatedActions $row.OwnerActionsMissing.Split(',') -ReverseActionType Owner -Version '6.1.3') -join ','
|
||||
}
|
||||
$newObjectDetails = $csv
|
||||
}
|
||||
else {
|
||||
$newObjectDetails = $details
|
||||
}
|
||||
$newObjectDetails = Get-AuditMailboxDetail -Details $details -Version '6.1.3'
|
||||
$results += [PSCustomObject]@{ TestNumber = $test; Details = $newObjectDetails }
|
||||
}
|
||||
Default {
|
||||
|
27
tests/Unit/Private/Get-AuditMailboxDetail.tests.ps1
Normal file
27
tests/Unit/Private/Get-AuditMailboxDetail.tests.ps1
Normal file
@@ -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'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user