Skip to content

Commit

Permalink
Merge pull request #4175 from NikCharlebois/Integration-Tests
Browse files Browse the repository at this point in the history
GCCHigh Error Handling
  • Loading branch information
NikCharlebois authored Jan 17, 2024
2 parents fd8d7fc + e756603 commit f775e75
Show file tree
Hide file tree
Showing 79 changed files with 214 additions and 168 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
* Ignore Permissions in tests if not passed. Preventing null comparison errors.
* AADAttributeSet
* Removed the ability to specify a value of Absent for the Ensure property.
* AADAUthenticationMethodPolicy
* AADAuthenticationMethodPolicy
* Removed the ability to specify a value of Absent for the Ensure property.
* AADAUthenticationMethodPolicyX509
* AADAuthenticationMethodPolicyX509
* Fix the way we returned an empty rule set from the Get method. This caused
the Test-TargetResource method to return true even when instances matched.
* AADRoleSetting
* Removed the ability to specify a value of Absent for the Ensure property.
* DEPENDENCIES
* Updated Microsoft.PowerApps.Administration.PowerShell to version 2.0.178.
* Updated MSCloudLoginAssistant to version 1.1.5.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ function Get-TargetResource
$EligibleAssignmentAssigneeNotificationOnlyCritical,

[Parameter()]
[ValidateSet('Present', 'Absent')]
[ValidateSet('Present')]
[System.String]
$Ensure = 'Present',

Expand Down Expand Up @@ -213,7 +213,6 @@ function Get-TargetResource
#endregion

$nullReturn = $PSBoundParameters
$nullReturn.Ensure = 'Absent'

$RoleDefintion = $null
if ($null -ne $Script:exportedInstances -and $Script:ExportMode)
Expand Down Expand Up @@ -559,7 +558,7 @@ function Set-TargetResource
$EligibleAssignmentAssigneeNotificationOnlyCritical,

[Parameter()]
[ValidateSet('Present', 'Absent')]
[ValidateSet('Present')]
[System.String]
$Ensure = 'Present',

Expand Down Expand Up @@ -1271,7 +1270,7 @@ function Test-TargetResource
$EligibleAssignmentAssigneeNotificationOnlyCritical,

[Parameter()]
[ValidateSet('Present', 'Absent')]
[ValidateSet('Present')]
[System.String]
$Ensure = 'Present',

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class MSFT_AADRoleSetting : OMI_BaseResource
[Write, Description("Send notifications when eligible members activate this role: Notification to activated user (requestor), default recipient (True/False)")] Boolean EligibleAssignmentAssigneeNotificationDefaultRecipient;
[Write, Description("Send notifications when eligible members activate this role: Notification to activated user (requestor), additional recipient (UPN)")] String EligibleAssignmentAssigneeNotificationAdditionalRecipient[];
[Write, Description("Send notifications when eligible members activate this role: Notification to activated user (requestor), only critical Email (True/False)")] Boolean EligibleAssignmentAssigneeNotificationOnlyCritical;
[Write, Description("Specify if the Azure AD role setting should exist or not."), ValueMap{"Present","Absent"}, Values{"Present","Absent"}] String Ensure;
[Write, Description("Specify if the Azure AD role setting should exist or not."), ValueMap{"Present"}, Values{"Present"}] String Ensure;
[Write, Description("Credentials for the Microsoft Graph delegated permissions."), EmbeddedInstance("MSFT_Credential")] string Credential;
[Write, Description("Id of the Azure Active Directory application to authenticate with.")] String ApplicationId;
[Write, Description("Id of the Azure Active Directory tenant used for authentication.")] String TenantId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,11 @@ function Test-TargetResource
Write-Verbose -Message "Current Values: $(Convert-M365DscHashtableToString -Hashtable $CurrentValues)"
Write-Verbose -Message "Target Values: $(Convert-M365DscHashtableToString -Hashtable $PSBoundParameters)"

if ($Ensure -eq 'Absent' -and $CurrentValues.Ensure -eq 'Absent')
{
return $true
}

$ValuesToCheck = $PSBoundParameters
$TestResult = Test-M365DSCParameterState -CurrentValues $CurrentValues `
-Source $($MyInvocation.MyCommand.Source) `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ function Export-TargetResource
if ($ReportSubmissionRule.Length -eq 0)
{
Write-Host $Global:M365DSCEmojiGreenCheckMark
return
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,8 @@ function Export-TargetResource
catch
{
if ($_.Exception -like '*401*' -or $_.ErrorDetails.Message -like "*`"ErrorCode`":`"Forbidden`"*" -or `
$_.Exception -like "*Unable to perform redirect as Location Header is not set in response*")
$_.Exception -like "*Unable to perform redirect as Location Header is not set in response*" -or `
$_.Exception -like "*Request not applicable to target tenant*")
{
Write-Host "`r`n $($Global:M365DSCEmojiYellowCircle) The current tenant is not registered for Intune."
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,8 @@ function Export-TargetResource
catch
{
if ($_.Exception -like '*401*' -or $_.ErrorDetails.Message -like "*`"ErrorCode`":`"Forbidden`"*" -or `
$_.Exception -like "*Unable to perform redirect as Location Header is not set in response*")
$_.Exception -like "*Unable to perform redirect as Location Header is not set in response*" -or `
$_.Exception -like "*Request not applicable to target tenant*")
{
Write-Host "`r`n $($Global:M365DSCEmojiYellowCircle) The current tenant is not registered for Intune."
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,8 @@ function Export-TargetResource
catch
{
if ($_.Exception -like '*401*' -or $_.ErrorDetails.Message -like "*`"ErrorCode`":`"Forbidden`"*" -or `
$_.Exception -like "*Unable to perform redirect as Location Header is not set in response*")
$_.Exception -like "*Unable to perform redirect as Location Header is not set in response*" -or `
$_.Exception -like "*Request not applicable to target tenant*")
{
Write-Host "`r`n $($Global:M365DSCEmojiYellowCircle) The current tenant is not registered for Intune."
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,8 @@ function Export-TargetResource
catch
{
if ($_.Exception -like '*401*' -or $_.ErrorDetails.Message -like "*`"ErrorCode`":`"Forbidden`"*" -or `
$_.Exception -like "*Unable to perform redirect as Location Header is not set in response*")
$_.Exception -like "*Unable to perform redirect as Location Header is not set in response*" -or `
$_.Exception -like "*Request not applicable to target tenant*")
{
Write-Host "`r`n $($Global:M365DSCEmojiYellowCircle) The current tenant is not registered for Intune."
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1498,7 +1498,8 @@ function Export-TargetResource
}
catch
{
if ($_.Exception -like '*401*' -or $_.ErrorDetails.Message -like "*`"ErrorCode`":`"Forbidden`"*")
if ($_.Exception -like '*401*' -or $_.ErrorDetails.Message -like "*`"ErrorCode`":`"Forbidden`"*" -or `
$_.Exception -like "*Request not applicable to target tenant*")
{
Write-Host "`r`n $($Global:M365DSCEmojiYellowCircle) The current tenant is not registered for Intune."
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,8 @@ function Export-TargetResource
}
catch
{
if ($_.Exception -like '*401*' -or $_.ErrorDetails.Message -like "*`"ErrorCode`":`"Forbidden`"*")
if ($_.Exception -like '*401*' -or $_.ErrorDetails.Message -like "*`"ErrorCode`":`"Forbidden`"*" -or `
$_.Exception -like "*Request not applicable to target tenant*")
{
Write-Host "`r`n $($Global:M365DSCEmojiYellowCircle) The current tenant is not registered for Intune."
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1125,7 +1125,8 @@ function Export-TargetResource
}
catch
{
if ($_.Exception -like '*401*' -or $_.ErrorDetails.Message -like "*`"ErrorCode`":`"Forbidden`"*")
if ($_.Exception -like '*401*' -or $_.ErrorDetails.Message -like "*`"ErrorCode`":`"Forbidden`"*" -or `
$_.Exception -like "*Request not applicable to target tenant*")
{
Write-Host "`r`n $($Global:M365DSCEmojiYellowCircle) The current tenant is not registered for Intune."
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1189,7 +1189,8 @@ function Export-TargetResource
}
catch
{
if ($_.Exception -like '*401*' -or $_.ErrorDetails.Message -like "*`"ErrorCode`":`"Forbidden`"*")
if ($_.Exception -like '*401*' -or $_.ErrorDetails.Message -like "*`"ErrorCode`":`"Forbidden`"*" -or `
$_.Exception -like "*Request not applicable to target tenant*")
{
Write-Host "`r`n $($Global:M365DSCEmojiYellowCircle) The current tenant is not registered for Intune."
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,8 @@ function Export-TargetResource
catch
{
if ($_.Exception -like '*401*' -or $_.ErrorDetails.Message -like "*`"ErrorCode`":`"Forbidden`"*" -or `
$_.Exception -like "*Unable to perform redirect as Location Header is not set in response*")
$_.Exception -like "*Unable to perform redirect as Location Header is not set in response*" -or `
$_.Exception -like "*Request not applicable to target tenant*")
{
Write-Host "`r`n $($Global:M365DSCEmojiYellowCircle) The current tenant is not registered for Intune."
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,8 @@ function Export-TargetResource
catch
{
if ($_.Exception -like '*401*' -or $_.ErrorDetails.Message -like "*`"ErrorCode`":`"Forbidden`"*" -or `
$_.Exception -like "*Unable to perform redirect as Location Header is not set in response*")
$_.Exception -like "*Unable to perform redirect as Location Header is not set in response*" -or `
$_.Exception -like "*Request not applicable to target tenant*")
{
Write-Host "`r`n $($Global:M365DSCEmojiYellowCircle) The current tenant is not registered for Intune."
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,8 @@ function Export-TargetResource
}
catch
{
if ($_.Exception -like '*401*' -or $_.ErrorDetails.Message -like "*`"ErrorCode`":`"Forbidden`"*")
if ($_.Exception -like '*401*' -or $_.ErrorDetails.Message -like "*`"ErrorCode`":`"Forbidden`"*" -or `
$_.Exception -like "*Request not applicable to target tenant*")
{
Write-Host "`r`n $($Global:M365DSCEmojiYellowCircle) The current tenant is not registered for Intune."
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,8 @@ function Export-TargetResource
}
catch
{
if ($_.Exception -like '*401*' -or $_.ErrorDetails.Message -like "*`"ErrorCode`":`"Forbidden`"*")
if ($_.Exception -like '*401*' -or $_.ErrorDetails.Message -like "*`"ErrorCode`":`"Forbidden`"*" -or `
$_.Exception -like "*Request not applicable to target tenant*")
{
Write-Host "`r`n $($Global:M365DSCEmojiYellowCircle) The current tenant is not registered for Intune."
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,9 @@ function Export-TargetResource
catch
{
if ($_.Exception -like "*401*" -or $_.ErrorDetails.Message -like "*`"ErrorCode`":`"Forbidden`"*" -or
$_.Exception -like "* Unauthorized*")
$_.Exception -like "* Unauthorized*" -or `
$_.Exception -like "*Request not applicable to target tenant*" -or `
$_.Exception -like "*BadRequest*")
{
Write-Host "`r`n $($Global:M365DSCEmojiYellowCircle) The current tenant is not registered for Intune."
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,8 @@ function Export-TargetResource
}
catch
{
if ($_.Exception -like '*401*' -or $_.ErrorDetails.Message -like "*`"ErrorCode`":`"Forbidden`"*")
if ($_.Exception -like '*401*' -or $_.ErrorDetails.Message -like "*`"ErrorCode`":`"Forbidden`"*" -or `
$_.Exception -like "*Request not applicable to target tenant*")
{
Write-Host "`r`n $($Global:M365DSCEmojiYellowCircle) The current tenant is not registered for Intune."
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,8 @@ function Export-TargetResource
}
catch
{
if ($_.Exception -like '*401*' -or $_.ErrorDetails.Message -like "*`"ErrorCode`":`"Forbidden`"*")
if ($_.Exception -like '*401*' -or $_.ErrorDetails.Message -like "*`"ErrorCode`":`"Forbidden`"*" -or `
$_.Exception -like "*Request not applicable to target tenant*")
{
Write-Host "`r`n $($Global:M365DSCEmojiYellowCircle) The current tenant is not registered for Intune."
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,8 @@ function Export-TargetResource
}
catch
{
if ($_.Exception -like '*401*' -or $_.ErrorDetails.Message -like "*`"ErrorCode`":`"Forbidden`"*")
if ($_.Exception -like '*401*' -or $_.ErrorDetails.Message -like "*`"ErrorCode`":`"Forbidden`"*" -or `
$_.Exception -like "*Request not applicable to target tenant*")
{
Write-Host "`r`n $($Global:M365DSCEmojiYellowCircle) The current tenant is not registered for Intune."
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,8 @@ function Export-TargetResource
}
catch
{
if ($_.Exception -like '*401*' -or $_.ErrorDetails.Message -like "*`"ErrorCode`":`"Forbidden`"*")
if ($_.Exception -like '*401*' -or $_.ErrorDetails.Message -like "*`"ErrorCode`":`"Forbidden`"*" -or `
$_.Exception -like "*Request not applicable to target tenant*")
{
Write-Host "`r`n $($Global:M365DSCEmojiYellowCircle) The current tenant is not registered for Intune."
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,8 @@ function Export-TargetResource
}
catch
{
if ($_.Exception -like '*401*' -or $_.ErrorDetails.Message -like "*`"ErrorCode`":`"Forbidden`"*")
if ($_.Exception -like '*401*' -or $_.ErrorDetails.Message -like "*`"ErrorCode`":`"Forbidden`"*" -or `
$_.Exception -like "*Request not applicable to target tenant*")
{
Write-Host "`r`n $($Global:M365DSCEmojiYellowCircle) The current tenant is not registered for Intune."
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,8 @@ function Export-TargetResource
}
catch
{
if ($_.Exception -like '*401*' -or $_.ErrorDetails.Message -like "*`"ErrorCode`":`"Forbidden`"*")
if ($_.Exception -like '*401*' -or $_.ErrorDetails.Message -like "*`"ErrorCode`":`"Forbidden`"*" -or `
$_.Exception -like "*Request not applicable to target tenant*")
{
Write-Host "`r`n $($Global:M365DSCEmojiYellowCircle) The current tenant is not registered for Intune."
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,8 @@ function Export-TargetResource
catch
{
if ($_.Exception -like '*401*' -or $_.ErrorDetails.Message -like "*`"ErrorCode`":`"Forbidden`"*" -or `
$_.Exception -like "*Unable to perform redirect as Location Header is not set in response*")
$_.Exception -like "*Unable to perform redirect as Location Header is not set in response*" -or `
$_.Exception -like "*Request not applicable to target tenant*")
{
Write-Host "`r`n $($Global:M365DSCEmojiYellowCircle) The current tenant is not registered for Intune."
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,8 @@ function Export-TargetResource
}
catch
{
if ($_.Exception -like '*401*' -or $_.ErrorDetails.Message -like "*`"ErrorCode`":`"Forbidden`"*")
if ($_.Exception -like '*401*' -or $_.ErrorDetails.Message -like "*`"ErrorCode`":`"Forbidden`"*" -or `
$_.Exception -like "*Request not applicable to target tenant*")
{
Write-Host "`r`n $($Global:M365DSCEmojiYellowCircle) The current tenant is not registered for Intune."
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,8 @@ function Export-TargetResource
}
catch
{
if ($_.Exception -like '*401*' -or $_.ErrorDetails.Message -like "*`"ErrorCode`":`"Forbidden`"*")
if ($_.Exception -like '*401*' -or $_.ErrorDetails.Message -like "*`"ErrorCode`":`"Forbidden`"*" -or `
$_.Exception -like "*Request not applicable to target tenant*")
{
Write-Host "`r`n $($Global:M365DSCEmojiYellowCircle) The current tenant is not registered for Intune."
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,8 @@ function Export-TargetResource
}
catch
{
if ($_.Exception -like '*401*' -or $_.ErrorDetails.Message -like "*`"ErrorCode`":`"Forbidden`"*")
if ($_.Exception -like '*401*' -or $_.ErrorDetails.Message -like "*`"ErrorCode`":`"Forbidden`"*" -or `
$_.Exception -like "*Request not applicable to target tenant*")
{
Write-Host "`r`n $($Global:M365DSCEmojiYellowCircle) The current tenant is not registered for Intune."
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,8 @@ function Export-TargetResource
}
catch
{
if ($_.Exception -like '*401*' -or $_.ErrorDetails.Message -like "*`"ErrorCode`":`"Forbidden`"*")
if ($_.Exception -like '*401*' -or $_.ErrorDetails.Message -like "*`"ErrorCode`":`"Forbidden`"*" -or `
$_.Exception -like "*Request not applicable to target tenant*")
{
Write-Host "`r`n $($Global:M365DSCEmojiYellowCircle) The current tenant is not registered for Intune."
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,8 @@ function Export-TargetResource
}
catch
{
if ($_.Exception -like '*401*' -or $_.ErrorDetails.Message -like "*`"ErrorCode`":`"Forbidden`"*")
if ($_.Exception -like '*401*' -or $_.ErrorDetails.Message -like "*`"ErrorCode`":`"Forbidden`"*" -or `
$_.Exception -like "*Request not applicable to target tenant*")
{
Write-Host "`r`n $($Global:M365DSCEmojiYellowCircle) The current tenant is not registered for Intune."
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6076,7 +6076,8 @@ function Export-TargetResource
}
catch
{
if ($_.Exception -like '*401*' -or $_.ErrorDetails.Message -like "*`"ErrorCode`":`"Forbidden`"*")
if ($_.Exception -like '*401*' -or $_.ErrorDetails.Message -like "*`"ErrorCode`":`"Forbidden`"*" -or `
$_.Exception -like "*Request not applicable to target tenant*")
{
Write-Host "`r`n $($Global:M365DSCEmojiYellowCircle) The current tenant is not registered for Intune."
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,8 @@ function Export-TargetResource
}
catch
{
if ($_.Exception -like '*401*' -or $_.ErrorDetails.Message -like "*`"ErrorCode`":`"Forbidden`"*")
if ($_.Exception -like '*401*' -or $_.ErrorDetails.Message -like "*`"ErrorCode`":`"Forbidden`"*" -or `
$_.Exception -like "*Request not applicable to target tenant*")
{
Write-Host "`r`n $($Global:M365DSCEmojiYellowCircle) The current tenant is not registered for Intune."
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,8 @@ function Export-TargetResource
}
catch
{
if ($_.Exception -like '*401*' -or $_.ErrorDetails.Message -like "*`"ErrorCode`":`"Forbidden`"*")
if ($_.Exception -like '*401*' -or $_.ErrorDetails.Message -like "*`"ErrorCode`":`"Forbidden`"*" -or `
$_.Exception -like "*Request not applicable to target tenant*")
{
Write-Host "`r`n $($Global:M365DSCEmojiYellowCircle) The current tenant is not registered for Intune."
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,8 @@ function Export-TargetResource
}
catch
{
if ($_.Exception -like '*401*' -or $_.ErrorDetails.Message -like "*`"ErrorCode`":`"Forbidden`"*")
if ($_.Exception -like '*401*' -or $_.ErrorDetails.Message -like "*`"ErrorCode`":`"Forbidden`"*" -or `
$_.Exception -like "*Request not applicable to target tenant*")
{
Write-Host "`r`n $($Global:M365DSCEmojiYellowCircle) The current tenant is not registered for Intune."
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,8 @@ function Export-TargetResource
}
catch
{
if ($_.Exception -like '*401*' -or $_.ErrorDetails.Message -like "*`"ErrorCode`":`"Forbidden`"*")
if ($_.Exception -like '*401*' -or $_.ErrorDetails.Message -like "*`"ErrorCode`":`"Forbidden`"*" -or `
$_.Exception -like "*Request not applicable to target tenant*")
{
Write-Host "`r`n $($Global:M365DSCEmojiYellowCircle) The current tenant is not registered for Intune."
}
Expand Down
Loading

0 comments on commit f775e75

Please sign in to comment.