From 0bc3e8fcec23ee73d23fb27ae828c51b09a3fafa Mon Sep 17 00:00:00 2001 From: Nik Charlebois Date: Fri, 16 Jul 2021 07:45:21 -0400 Subject: [PATCH 1/3] Fixed Integration Tests --- CHANGELOG.md | 9 +++++++++ .../DSCResources/MSFT_AADMSGroup/MSFT_AADMSGroup.psm1 | 4 +++- .../DSCResources/MSFT_SPOSite/MSFT_SPOSite.psm1 | 6 +----- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c88ad8b329..f361994b32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Change log for Microsoft365DSC +# 1.21.721.1 + +* AADMSGroup + * Fixed an issue where the Visibility parameter was never properly returned + which always threw a detected drift when used. +* SPOSite + * Fixed the StorageQuotaWarningLevel value returned by the Get-TargetResource + function. + # 1.21.714.1 * EXOHostedContentFilterPolicy diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_AADMSGroup/MSFT_AADMSGroup.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_AADMSGroup/MSFT_AADMSGroup.psm1 index 117efed96e..b1234a2c4c 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_AADMSGroup/MSFT_AADMSGroup.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_AADMSGroup/MSFT_AADMSGroup.psm1 @@ -111,7 +111,8 @@ function Get-TargetResource { Write-Verbose -Message "Id was NOT specified" ## Can retreive multiple AAD Groups since displayname is not unique - $Group = Get-AzureADGroup -Filter "DisplayName eq '$DisplayName'" -ErrorAction Stop + ## Get-AzureADMSGroup is required for the visibility param to be returned. Get-AzureADGroup won't work. + $Group = Get-AzureADMSGroup -Filter "DisplayName eq '$DisplayName'" -ErrorAction Stop if ($Group.Length -gt 1) { throw "Duplicate AzureAD Groups named $DisplayName exist in tenant" @@ -420,6 +421,7 @@ function Test-TargetResource $ValuesToCheck = $PSBoundParameters $ValuesToCheck.Remove('GlobalAdminAccount') | Out-Null $ValuesToCheck.Remove('Id') | Out-Null + $ValuesToCheck.Remove('GroupTypes') | Out-Null $TestResult = Test-M365DSCParameterState -CurrentValues $CurrentValues ` -Source $($MyInvocation.MyCommand.Source) ` diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_SPOSite/MSFT_SPOSite.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_SPOSite/MSFT_SPOSite.psm1 index 6df2b3b679..50e09854e7 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_SPOSite/MSFT_SPOSite.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_SPOSite/MSFT_SPOSite.psm1 @@ -230,10 +230,6 @@ function Get-TargetResource } } } - if ($site.StorageQuotaWarningLevel -gt 0) - { - $quotaWarning = $site.StorageQuotaWarningLevel / 100 - } return @{ Url = $Url Title = $site.Title @@ -245,7 +241,7 @@ function Get-TargetResource LogoFilePath = $LogoFilePath SharingCapability = $site.SharingCapability StorageMaximumLevel = $site.StorageQuota - StorageWarningLevel = $quotaWarning + StorageWarningLevel = $site.StorageQuotaWarningLevel AllowSelfServiceUpgrade = $site.AllowSelfServiceUpgrade Owner = $siteOwnerEmail CommentsOnSitePagesDisabled = $site.CommentsOnSitePagesDisabled From 620256562cc3107039c26a4b4670414337f55171 Mon Sep 17 00:00:00 2001 From: Nik Charlebois Date: Fri, 16 Jul 2021 07:57:55 -0400 Subject: [PATCH 2/3] Update Microsoft365DSC.SPOSite.Tests.ps1 --- Tests/Unit/Microsoft365DSC/Microsoft365DSC.SPOSite.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.SPOSite.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.SPOSite.Tests.ps1 index dbf3b798a2..e8be7e650f 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.SPOSite.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.SPOSite.Tests.ps1 @@ -208,7 +208,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { RestrictedToRegion = "Unknown"; SocialBarOnSitePagesDisabled = $False; StorageQuota = 26214400; - StorageQuotaWarningLevel = 2557440000; + StorageQuotaWarningLevel = 25574400; Title = "CommNik"; Template = "STS#3"; HubSiteId = "fcc3c848-6d2f-4821-a56c-980eea7990c5" From c00d153f5bc45b6fdb479a339179cee9a5e22675 Mon Sep 17 00:00:00 2001 From: Nik Charlebois Date: Fri, 16 Jul 2021 08:20:49 -0400 Subject: [PATCH 3/3] Fixed Unit Tests --- .../MSFT_AADMSGroup/MSFT_AADMSGroup.psm1 | 4 ++-- .../Microsoft365DSC.AADMSGroup.Tests.ps1 | 23 ++++++++----------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_AADMSGroup/MSFT_AADMSGroup.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_AADMSGroup/MSFT_AADMSGroup.psm1 index b1234a2c4c..78c1e8e1c8 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_AADMSGroup/MSFT_AADMSGroup.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_AADMSGroup/MSFT_AADMSGroup.psm1 @@ -95,12 +95,12 @@ function Get-TargetResource Write-Verbose -Message "GroupID was specified" try { - $Group = Get-AzureADGroup -ObjectId $Id -ErrorAction Stop + $Group = Get-AzureADMSGroup -ObjectId $Id -ErrorAction Stop } catch { Write-Verbose -Message "Couldn't get group by ID, trying by name" - $Group = Get-AzureADGroup -Filter "DisplayName eq '$DisplayName'" -ErrorAction Stop + $Group = Get-AzureADMSGroup -Filter "DisplayName eq '$DisplayName'" -ErrorAction Stop if ($Group.Length -gt 1) { throw "Duplicate AzureAD Groups named $DisplayName exist in tenant" diff --git a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADMSGroup.Tests.ps1 b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADMSGroup.Tests.ps1 index 5f267728d5..2297bcb8ff 100644 --- a/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADMSGroup.Tests.ps1 +++ b/Tests/Unit/Microsoft365DSC/Microsoft365DSC.AADMSGroup.Tests.ps1 @@ -71,13 +71,13 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { return "Credential" } - Mock -CommandName Get-AzureADGroup -MockWith { + Mock -CommandName Get-AzureADMSGroup -MockWith { return $null } } It "Should return Values from the Get method" { (Get-TargetResource @testParams).Ensure | Should -Be 'Absent' - Should -Invoke -CommandName "Get-AzureADGroup" -Exactly 1 + Should -Invoke -CommandName "Get-AzureADMSGroup" -Exactly 1 } It 'Should return false from the Test method' { Test-TargetResource @testParams | Should -Be $false @@ -106,7 +106,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { return "Credential" } - Mock -CommandName Get-AzureADGroup -MockWith { + Mock -CommandName Get-AzureADMSGroup -MockWith { return @{DisplayName = "DSCGroup" ID = "12345-12345-12345-12345" } } @@ -114,7 +114,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { It "Should return Values from the Get method" { (Get-TargetResource @testParams).Ensure | Should -Be 'Present' - Should -Invoke -CommandName "Get-AzureADGroup" -Exactly 1 + Should -Invoke -CommandName "Get-AzureADMSGroup" -Exactly 1 } It 'Should return true from the Test method' { @@ -145,7 +145,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { return "Credential" } - Mock -CommandName Get-AzureADGroup -MockWith { + Mock -CommandName Get-AzureADMSGroup -MockWith { return @{ DisplayName = "DSCGroup" ID = "12345-12345-12345-12345" @@ -162,7 +162,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { It "Should return Values from the Get method" { Get-TargetResource @testParams - Should -Invoke -CommandName "Get-AzureADGroup" -Exactly 1 + Should -Invoke -CommandName "Get-AzureADMSGroup" -Exactly 1 } It 'Should return true from the Test method' { @@ -188,7 +188,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { return "Credential" } - Mock -CommandName Get-AzureADGroup -MockWith { + Mock -CommandName Get-AzureADMSGroup -MockWith { return @{ DisplayName = "DSCGroup" Description = "Microsoft DSC" #Drift @@ -199,16 +199,11 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { Visibility = "Private" } } - - Mock -CommandName Get-AzureADGroup -MockWith { - return @{DisplayName = "DSCGroup" - ID = "12345-12345-12345-12345" } - } } It "Should return Values from the Get method" { Get-TargetResource @testParams - Should -Invoke -CommandName "Get-AzureADGroup" -Exactly 1 + Should -Invoke -CommandName "Get-AzureADMSGroup" -Exactly 1 } It 'Should return false from the Test method' { @@ -231,7 +226,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture { return "Credential" } - Mock -CommandName Get-AzureADGroup -MockWith { + Mock -CommandName Get-AzureADMSGroup -MockWith { return @{ DisplayName = "Test Team" ID = "12345-12345-12345-12345"