Skip to content

Commit

Permalink
Merge pull request #3849 from pkernevez/fix-CSComplianceRecordingPoli…
Browse files Browse the repository at this point in the history
…cies

Use sub call to retreive Applications
  • Loading branch information
NikCharlebois authored Nov 1, 2023
2 parents 8ef59b2 + f513c81 commit 8577551
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 11 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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' {
Expand All @@ -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
Expand All @@ -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' {
Expand All @@ -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
Expand All @@ -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' {
Expand Down Expand Up @@ -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' {
Expand Down
13 changes: 13 additions & 0 deletions Tests/Unit/Stubs/Microsoft365.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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()]
Expand Down

0 comments on commit 8577551

Please sign in to comment.