diff --git a/CHANGELOG.md b/CHANGELOG.md index 8fd27d9706..10d14646be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,9 @@ * SPOSharingSettings * Fixes parameter validation of ExternalUserExpireInDays and ExternalUserExpirationRequired. FIXES [#3856](https://github.com/microsoft/Microsoft365DSC/issues/3856) +* TeamsComplianceRecordingPolicy + * Fix an issue where the Compliance Application ID wasn't properly retrieved. + FIXES [#3848](https://github.com/microsoft/Microsoft365DSC/issues/3848) # 1.23.1025.1 diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsComplianceRecordingPolicy/MSFT_TeamsComplianceRecordingPolicy.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsComplianceRecordingPolicy/MSFT_TeamsComplianceRecordingPolicy.psm1 index feffced474..14e0c8c493 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsComplianceRecordingPolicy/MSFT_TeamsComplianceRecordingPolicy.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_TeamsComplianceRecordingPolicy/MSFT_TeamsComplianceRecordingPolicy.psm1 @@ -74,11 +74,20 @@ function Get-TargetResource { return $nullResult } + $recordingApplications = [Array](Get-CsTeamsComplianceRecordingApplication -Filter "$($instance.Identity)/*") + if ($null -eq $recordingApplications) + { + $recordingApplications = @() + } + $recordApplicationIds = @() + foreach ($app in $recordingApplications) { + $recordApplicationIds += @{Id=$app.Id} + } Write-Verbose -Message "Found an instance with Identity {$Identity}" $results = @{ Identity = $instance.Identity - ComplianceRecordingApplications = [Array]$instance.ComplianceRecordingApplications.Id + ComplianceRecordingApplications = $recordApplicationIds Description = $instance.Description DisableComplianceRecordingAudioNotificationForCalls = $instance.DisableComplianceRecordingAudioNotificationForCalls Enabled = $instance.Enabled diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.TeamsComplianceRecordingPolicy.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.TeamsComplianceRecordingPolicy.Tests.ps1 index a0d97fe0c9..6ea4b41bd0 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.TeamsComplianceRecordingPolicy.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.TeamsComplianceRecordingPolicy.Tests.ps1 @@ -63,7 +63,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { Description = 'FakeStringValue' Enabled = $True DisableComplianceRecordingAudioNotificationForCalls = $True - ComplianceRecordingApplications = 'FakeStringValue' + ComplianceRecordingApplications = @(@{Id="123456"}) Identity = 'FakeStringValue' Ensure = 'Present' Credential = $Credential @@ -95,7 +95,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { Description = 'FakeStringValue' Enabled = $True DisableComplianceRecordingAudioNotificationForCalls = $True - ComplianceRecordingApplications = 'FakeStringValue' + ComplianceRecordingApplications = @(@{Id='123456'}) Identity = 'FakeStringValue' Ensure = 'Absent' Credential = $Credential @@ -107,15 +107,27 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { Description = 'FakeStringValue' Enabled = $True DisableComplianceRecordingAudioNotificationForCalls = $True - ComplianceRecordingApplications = @{Id='FakeStringValue'} + ComplianceRecordingApplications = "Microsoft.Teams.Policy.Aministration.Cmdlets.Core.CompianceRecordingApplication" Identity = 'FakeStringValue' - } } + Mock -CommandName Get-CsTeamsComplianceRecordingApplication -MockWith { + return @{ + Identity = 'FakeStringValue/123456' + Id = '123456' + } + } + } It 'Should return Values from the Get method' { - (Get-TargetResource @testParams).Ensure | Should -Be 'Present' + $Result = (Get-TargetResource @testParams) + $Result.Ensure | Should -Be 'Present' + $Result.ComplianceRecordingApplications.Length | Should -Be 1 + $Result.ComplianceRecordingApplications[0].Id | Should -Be '123456' + Should -Invoke -CommandName Get-CsTeamsComplianceRecordingPolicy -Exactly 1 + Should -Invoke -CommandName Get-CsTeamsComplianceRecordingApplication -ParameterFilter {$Filter -eq 'FakeStringValue/*'} -Exactly 1 + } It 'Should return true from the Test method' { @@ -135,7 +147,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { Description = 'FakeStringValue' Enabled = $True DisableComplianceRecordingAudioNotificationForCalls = $True - ComplianceRecordingApplications = 'FakeStringValue' + ComplianceRecordingApplications = @(@{Id='123456'}) Identity = 'FakeStringValue' Ensure = 'Present' Credential = $Credential @@ -147,11 +159,17 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { Description = 'FakeStringValue' Enabled = $True DisableComplianceRecordingAudioNotificationForCalls = $True - ComplianceRecordingApplications = @{Id='FakeStringValue'} + ComplianceRecordingApplications = "Microsoft.Teams.Policy.Aministration.Cmdlets.Core.CompianceRecordingApplication" Identity = 'FakeStringValue' } } + Mock -CommandName Get-CsTeamsComplianceRecordingApplication -MockWith { + return @{ + Identity = 'FakeStringValue/123456' + Id = '123456' + } + } } It 'Should return true from the Test method' { @@ -166,7 +184,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { Description = 'FakeStringValue' Enabled = $True DisableComplianceRecordingAudioNotificationForCalls = $True - ComplianceRecordingApplications = 'FakeStringValue' + ComplianceRecordingApplications = @{Id='123456'} Identity = 'FakeStringValue' Ensure = 'Present' Credential = $Credential @@ -178,10 +196,17 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { Description = 'FakeStringValueDrift' #Drift Enabled = $False DisableComplianceRecordingAudioNotificationForCalls = $False - ComplianceRecordingApplications = @{Id='FakeStringValueDrift'} #Drift + ComplianceRecordingApplications = "Microsoft.Teams.Policy.Aministration.Cmdlets.Core.CompianceRecordingApplication" Identity = 'FakeStringValue' } } + + Mock -CommandName Get-CsTeamsComplianceRecordingApplication -MockWith { + return @{ + Identity = 'FakeStringValue/123456Drift' + Id = '123456Drift' #Drift + } + } } It 'Should return Values from the Get method' { @@ -212,11 +237,18 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { Description = 'FakeStringValue' Enabled = $True DisableComplianceRecordingAudioNotificationForCalls = $True - ComplianceRecordingApplications = @{Id='FakeStringValue'} + ComplianceRecordingApplications = "Microsoft.Teams.Policy.Aministration.Cmdlets.Core.CompianceRecordingApplication" Identity = 'FakeStringValue' } } + Mock -CommandName Get-CsTeamsComplianceRecordingApplication -MockWith { + return @{ + Identity = 'FakeStringValue/123456' + Id = '123456' + } + } + } It 'Should Reverse Engineer resource from the Export method' { diff --git a/Tests/Unit/Stubs/Microsoft365.psm1 b/Tests/Unit/Stubs/Microsoft365.psm1 index 6c9faaecea..db2d079c8b 100644 --- a/Tests/Unit/Stubs/Microsoft365.psm1 +++ b/Tests/Unit/Stubs/Microsoft365.psm1 @@ -70486,6 +70486,19 @@ function Get-CsTeamsComplianceRecordingPolicy $Identity ) } +function Get-CsTeamsComplianceRecordingApplication +{ + [CmdletBinding()] + param( + [Parameter()] + [System.String] + $Filter, + + [Parameter()] + [System.String] + $Identity + ) +} function Get-CsTeamsEmergencyCallingPolicy { [CmdletBinding()]