Skip to content

Commit

Permalink
Merge pull request #4073 from NikCharlebois/Integration-Tests
Browse files Browse the repository at this point in the history
Integration tests
  • Loading branch information
NikCharlebois authored Dec 20, 2023
2 parents cafbca2 + f82e5d5 commit 2fbf8da
Show file tree
Hide file tree
Showing 30 changed files with 310 additions and 457 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

# UNRELEASED

* AADEntitlementManagementAccessPackage
* Retrieve catalog by name instead of id.
* IntuneDeviceAndAppManagementAssignmentFilter
* Add support for remaining platforms supported by this policy
FIXES [#4065](https://github.com/microsoft/Microsoft365DSC/issues/4065)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -551,12 +551,19 @@ function Set-TargetResource
Write-Verbose -Message "Creating an Azure AD Administrative Unit with DisplayName {$DisplayName}"

#region resource generator code
$policy = New-MgBetaDirectoryAdministrativeUnit -BodyParameter $CreateParameters
Write-Verbose -Message "Creating new Administrative Unit with: $(Convert-M365DscHashtableToString -Hashtable $CreateParameters)"

$jsonParams = ConvertTo-Json $CreateParameters

# TODO - Replace by cmdlet call which has an issue in 2.11.1
$url = $Global:MSCloudLoginConnectionProfile.MicrosoftGraph.ResourceUrl + 'beta/administrativeUnits'
$policy = Invoke-MgGraphRequest -Method POST -Uri $url -Body $jsonParams

if ($MembershipType -ne 'Dynamic')
{
foreach ($member in $memberSpecification)
{
Write-Verbose -Message "Adding new dynamic member {$($member.Id)}"
$memberBodyParam = @{
'@odata.id' = "https://graph.microsoft.com/v1.0/$($member.Type)/$($member.Id)"
}
Expand Down Expand Up @@ -993,8 +1000,8 @@ function Export-TargetResource
Add-M365DSCTelemetryEvent -Data $data
#endregion




try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ function Set-TargetResource
}
#region resource generator code
$UpdateParameters.Add("@odata.type", "#microsoft.graph.AuthenticationMethodsPolicy")
Write-Verbose -Message "Updating AuthenticationMethodPolicy with: `r`n$(Convert-M365DscHashtableToString -Hashtable $UpdateParameters)"
Update-MgBetaPolicyAuthenticationMethodPolicy -BodyParameter $UpdateParameters
#endregion
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,14 @@ function Get-TargetResource
$complexCompanionAppAllowedState = @{}
$complexExcludeTarget = @{}
if ($getValue.additionalProperties.featureSettings.companionAppAllowedState.excludeTarget.id -notmatch 'all_users|00000000-0000-0000-0000-000000000000')
{
$myExcludeTargetsDisplayName = Get-MgGroup -GroupId $getValue.additionalProperties.featureSettings.companionAppAllowedState.excludeTarget.id
$complexExcludeTarget.Add('Id', $myExcludeTargetsDisplayName.DisplayName)
}
else
{
$complexExcludeTarget.Add('Id', $getValue.additionalProperties.featureSettings.companionAppAllowedState.excludeTarget.id)
}
{
$myExcludeTargetsDisplayName = Get-MgGroup -GroupId $getValue.additionalProperties.featureSettings.companionAppAllowedState.excludeTarget.id
$complexExcludeTarget.Add('Id', $myExcludeTargetsDisplayName.DisplayName)
}
else
{
$complexExcludeTarget.Add('Id', 'all_users')
}
if ($null -ne $getValue.additionalProperties.featureSettings.companionAppAllowedState.excludeTarget.targetType)
{
$complexExcludeTarget.Add('TargetType', $getValue.additionalProperties.featureSettings.companionAppAllowedState.excludeTarget.targetType.toString())
Expand All @@ -118,14 +118,14 @@ function Get-TargetResource
$complexCompanionAppAllowedState.Add('ExcludeTarget', $complexExcludeTarget)
$complexIncludeTarget = @{}
if ($getValue.additionalProperties.featureSettings.companionAppAllowedState.includeTarget.id -notmatch 'all_users|00000000-0000-0000-0000-000000000000')
{
$myIncludeTargetsDisplayName = Get-MgGroup -GroupId $getValue.additionalProperties.featureSettings.companionAppAllowedState.includeTarget.id
$complexIncludeTarget.Add('Id', $myIncludeTargetsDisplayName.DisplayName)
}
else
{
$complexIncludeTarget.Add('Id', $getValue.additionalProperties.featureSettings.companionAppAllowedState.includeTarget.id)
}
{
$myIncludeTargetsDisplayName = Get-MgGroup -GroupId $getValue.additionalProperties.featureSettings.companionAppAllowedState.includeTarget.id
$complexIncludeTarget.Add('Id', $myIncludeTargetsDisplayName.DisplayName)
}
else
{
$complexIncludeTarget.Add('Id', 'all_users')
}
if ($null -ne $getValue.additionalProperties.featureSettings.companionAppAllowedState.includeTarget.targetType)
{
$complexIncludeTarget.Add('TargetType', $getValue.additionalProperties.featureSettings.companionAppAllowedState.includeTarget.targetType.toString())
Expand All @@ -145,16 +145,17 @@ function Get-TargetResource
}
$complexFeatureSettings.Add('CompanionAppAllowedState', $complexCompanionAppAllowedState)
$complexDisplayAppInformationRequiredState = @{}

$complexExcludeTarget = @{}
if ($getValue.additionalProperties.featureSettings.displayAppInformationRequiredState.excludeTarget.id -notmatch 'all_users|00000000-0000-0000-0000-000000000000')
{
$myExcludeTargetsDisplayName = Get-MgGroup -GroupId $getValue.additionalProperties.featureSettings.displayAppInformationRequiredState.excludeTarget.id
$complexExcludeTarget.Add('Id', $myExcludeTargetsDisplayName.DisplayName)
}
else
{
$complexExcludeTarget.Add('Id', $getValue.additionalProperties.featureSettings.displayAppInformationRequiredState.excludeTarget.id)
}
{
$myExcludeTargetsDisplayName = Get-MgGroup -GroupId $getValue.additionalProperties.featureSettings.displayAppInformationRequiredState.excludeTarget.id
$complexExcludeTarget.Add('Id', $myExcludeTargetsDisplayName.DisplayName)
}
else
{
$complexExcludeTarget.Add('Id', 'all_users')
}
if ($null -ne $getValue.additionalProperties.featureSettings.displayAppInformationRequiredState.excludeTarget.targetType)
{
$complexExcludeTarget.Add('TargetType', $getValue.additionalProperties.featureSettings.displayAppInformationRequiredState.excludeTarget.targetType.toString())
Expand All @@ -166,14 +167,14 @@ function Get-TargetResource
$complexDisplayAppInformationRequiredState.Add('ExcludeTarget', $complexExcludeTarget)
$complexIncludeTarget = @{}
if ($getValue.additionalProperties.featureSettings.displayAppInformationRequiredState.includeTarget.id -notmatch 'all_users|00000000-0000-0000-0000-000000000000')
{
$myIncludeTargetsDisplayName = Get-MgGroup -GroupId $getValue.additionalProperties.featureSettings.displayAppInformationRequiredState.includeTarget.id
$complexIncludeTarget.Add('Id', $myIncludeTargetsDisplayName.DisplayName)
}
else
{
$complexIncludeTarget.Add('Id', $getValue.additionalProperties.featureSettings.displayAppInformationRequiredState.includeTarget.id)
}
{
$myIncludeTargetsDisplayName = Get-MgGroup -GroupId $getValue.additionalProperties.featureSettings.displayAppInformationRequiredState.includeTarget.id
$complexIncludeTarget.Add('Id', $myIncludeTargetsDisplayName.DisplayName)
}
else
{
$complexIncludeTarget.Add('Id', 'all_users')
}
if ($null -ne $getValue.additionalProperties.featureSettings.displayAppInformationRequiredState.includeTarget.targetType)
{
$complexIncludeTarget.Add('TargetType', $getValue.additionalProperties.featureSettings.displayAppInformationRequiredState.includeTarget.targetType.toString())
Expand All @@ -195,14 +196,14 @@ function Get-TargetResource
$complexDisplayLocationInformationRequiredState = @{}
$complexExcludeTarget = @{}
if ($getValue.additionalProperties.featureSettings.displayLocationInformationRequiredState.excludeTarget.id -notmatch 'all_users|00000000-0000-0000-0000-000000000000')
{
$myExcludeTargetsDisplayName = Get-MgGroup -GroupId $getValue.additionalProperties.featureSettings.displayLocationInformationRequiredState.excludeTarget.id
$complexExcludeTarget.Add('Id', $myExcludeTargetsDisplayName.DisplayName)
}
else
{
$complexExcludeTarget.Add('Id', $getValue.additionalProperties.featureSettings.displayLocationInformationRequiredState.excludeTarget.id)
}
{
$myExcludeTargetsDisplayName = Get-MgGroup -GroupId $getValue.additionalProperties.featureSettings.displayLocationInformationRequiredState.excludeTarget.id
$complexExcludeTarget.Add('Id', $myExcludeTargetsDisplayName.DisplayName)
}
else
{
$complexExcludeTarget.Add('Id', 'all_users')
}
if ($null -ne $getValue.additionalProperties.featureSettings.displayLocationInformationRequiredState.excludeTarget.targetType)
{
$complexExcludeTarget.Add('TargetType', $getValue.additionalProperties.featureSettings.displayLocationInformationRequiredState.excludeTarget.targetType.toString())
Expand All @@ -214,14 +215,14 @@ function Get-TargetResource
$complexDisplayLocationInformationRequiredState.Add('ExcludeTarget', $complexExcludeTarget)
$complexIncludeTarget = @{}
if ($getValue.additionalProperties.featureSettings.displayLocationInformationRequiredState.includeTarget.id -notmatch 'all_users|00000000-0000-0000-0000-000000000000')
{
$myIncludeTargetsDisplayName = Get-MgGroup -GroupId $getValue.additionalProperties.featureSettings.displayLocationInformationRequiredState.includeTarget.id
$complexIncludeTarget.Add('Id', $myIncludeTargetsDisplayName.DisplayName)
}
else
{
$complexIncludeTarget.Add('Id', $getValue.additionalProperties.featureSettings.displayLocationInformationRequiredState.includeTarget.id)
}
{
$myIncludeTargetsDisplayName = Get-MgGroup -GroupId $getValue.additionalProperties.featureSettings.displayLocationInformationRequiredState.includeTarget.id
$complexIncludeTarget.Add('Id', $myIncludeTargetsDisplayName.DisplayName)
}
else
{
$complexIncludeTarget.Add('Id', 'all_users')
}
if ($null -ne $getValue.additionalProperties.featureSettings.displayLocationInformationRequiredState.includeTarget.targetType)
{
$complexIncludeTarget.Add('TargetType', $getValue.additionalProperties.featureSettings.displayLocationInformationRequiredState.includeTarget.targetType.toString())
Expand Down Expand Up @@ -249,7 +250,7 @@ function Get-TargetResource
{
$myExcludeTargetsDisplayName = Get-MgGroup -GroupId $currentExcludeTargets.id -ErrorAction SilentlyContinue

if ($null -ne $myIncludeTargetsDisplayName)
if ($null -ne $myExcludeTargetsDisplayName)
{
$myExcludeTargets.Add('Id', $myExcludeTargetsDisplayName.DisplayName)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ function Get-TargetResource
}
}

$catalog = Get-MgBetaEntitlementManagementAccessPackageCatalog -AccessPackageCatalog $getValue.CatalogId

$getIncompatibleAccessPackages = @()
[Array]$query = Get-MgBetaEntitlementManagementAccessPackageIncompatibleAccessPackage -AccessPackageId $getValue.id
if ($query.count -gt 0)
Expand All @@ -165,7 +167,7 @@ function Get-TargetResource

$results = @{
Id = $getValue.Id
CatalogId = $getValue.CatalogId
CatalogId = $catalog.DisplayName
Description = $getValue.Description
DisplayName = $getValue.DisplayName
IsHidden = $getValue.IsHidden
Expand Down Expand Up @@ -313,6 +315,16 @@ function Set-TargetResource
#region basic information
$CreateParameters = ([Hashtable]$PSBoundParameters).clone()

$ObjectGuid = [System.Guid]::empty
if (-not [System.Guid]::TryParse($CreateParameters.CatalogId, [System.Management.Automation.PSReference]$ObjectGuid))
{
$catalogInstance = Get-MgBetaEntitlementManagementAccessPackageCatalog -Filter "DisplayName eq '$($CreateParameters.CatalogId)'"
if ($catalogInstance)
{
$CreateParameters.CatalogId = $catalogInstance.Id
}
}

$CreateParameters.Remove('Id') | Out-Null
$CreateParameters.Remove('Verbose') | Out-Null
$CreateParameters.Remove('AccessPackageResourceRoleScopes') | Out-Null
Expand Down Expand Up @@ -419,6 +431,16 @@ function Set-TargetResource
#region basic information
$UpdateParameters = ([Hashtable]$PSBoundParameters).clone()

$ObjectGuid = [System.Guid]::empty
if (-not [System.Guid]::TryParse($CreateParameters.CatalogId, [System.Management.Automation.PSReference]$ObjectGuid))
{
$catalogInstance = Get-MgBetaEntitlementManagementAccessPackageCatalog -Filter "DisplayName eq '$($UpdateParameters.CatalogId)'"
if ($catalogInstance)
{
$UpdateParameters.CatalogId = $catalogInstance.Id
}
}

$UpdateParameters.Remove('Id') | Out-Null
$UpdateParameters.Remove('Verbose') | Out-Null
$UpdateParameters.Remove('AccessPackageResourceRoleScopes') | Out-Null
Expand Down Expand Up @@ -755,7 +777,7 @@ function Test-TargetResource
Add-M365DSCTelemetryEvent -Data $data
#endregion

Write-Verbose -Message "Testing configuration of {$Id}"
Write-Verbose -Message "Testing configuration of {$DisplayName}"

$CurrentValues = Get-TargetResource @PSBoundParameters
$ValuesToCheck = ([Hashtable]$PSBoundParameters).clone()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Configuration Example
AADAdministrativeUnit 'TestUnit'
{
DisplayName = 'Test-Unit'
Description = 'Test Description'
MembershipRule = "(user.country -eq `"Canada`")"
MembershipRuleProcessingState = 'On'
MembershipType = 'Dynamic'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,69 +17,66 @@ Configuration Example
{
AADAuthenticationMethodPolicyAuthenticator "AADAuthenticationMethodPolicyAuthenticator-MicrosoftAuthenticator"
{
Credential = $Credscredential;
Ensure = "Present";
ExcludeTargets = @(
MSFT_AADAuthenticationMethodPolicyAuthenticatorExcludeTarget{
Id = 'fakegroup1'
Id = 'Legal Team'
TargetType = 'group'
}
MSFT_AADAuthenticationMethodPolicyAuthenticatorExcludeTarget{
Id = 'Paralegals'
TargetType = 'group'
}
);
FeatureSettings = MSFT_MicrosoftGraphmicrosoftAuthenticatorFeatureSettings{
DisplayLocationInformationRequiredState = MSFT_MicrosoftGraphAuthenticationMethodFeatureConfiguration{
ExcludeTarget = MSFT_AADAuthenticationMethodPolicyAuthenticatorFeatureTarget{
Id = '00000000-0000-0000-0000-000000000000'
Id = 'all_users'
TargetType = 'group'
}
IncludeTarget = MSFT_AADAuthenticationMethodPolicyAuthenticatorFeatureTarget{
Id = 'fakegroup2'
Id = 'all_users'
TargetType = 'group'
}
State = 'enabled'
State = 'default'
}
NumberMatchingRequiredState = MSFT_MicrosoftGraphAuthenticationMethodFeatureConfiguration{
CompanionAppAllowedState = MSFT_MicrosoftGraphAuthenticationMethodFeatureConfiguration{
ExcludeTarget = MSFT_AADAuthenticationMethodPolicyAuthenticatorFeatureTarget{
Id = '00000000-0000-0000-0000-000000000000'
Id = 'all_users'
TargetType = 'group'
}
IncludeTarget = MSFT_AADAuthenticationMethodPolicyAuthenticatorFeatureTarget{
Id = 'fakegroup3'
Id = 'all_users'
TargetType = 'group'
}
State = 'enabled'
State = 'default'
}
CompanionAppAllowedState = MSFT_MicrosoftGraphAuthenticationMethodFeatureConfiguration{
DisplayAppInformationRequiredState = MSFT_MicrosoftGraphAuthenticationMethodFeatureConfiguration{
ExcludeTarget = MSFT_AADAuthenticationMethodPolicyAuthenticatorFeatureTarget{
Id = '00000000-0000-0000-0000-000000000000'
Id = 'all_users'
TargetType = 'group'
}
IncludeTarget = MSFT_AADAuthenticationMethodPolicyAuthenticatorFeatureTarget{
Id = 'fakegroup4'
Id = 'all_users'
TargetType = 'group'
}
State = 'enabled'
State = 'default'
}
DisplayAppInformationRequiredState = MSFT_MicrosoftGraphAuthenticationMethodFeatureConfiguration{
ExcludeTarget = MSFT_AADAuthenticationMethodPolicyAuthenticatorFeatureTarget{
Id = '00000000-0000-0000-0000-000000000000'
TargetType = 'group'
}
IncludeTarget = MSFT_AADAuthenticationMethodPolicyAuthenticatorFeatureTarget{
Id = 'fakegroup5'
TargetType = 'group'
}
State = 'enabled'
}
};
};
Id = "MicrosoftAuthenticator";
IncludeTargets = @(
MSFT_AADAuthenticationMethodPolicyAuthenticatorIncludeTarget{
Id = 'fakegroup6'
Id = 'Finance Team'
TargetType = 'group'
}
MSFT_AADAuthenticationMethodPolicyAuthenticatorIncludeTarget{
Id = 'Northwind Traders'
TargetType = 'group'
}
);
IsSoftwareOathEnabled = $False;
State = "enabled";
Credential = $credsCredential;
}
}
}
Loading

0 comments on commit 2fbf8da

Please sign in to comment.