Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions test/module/Entra/Common-Parameter.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# ------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
# ------------------------------------------------------------------------------
BeforeAll{
if($null -eq (Get-Module -Name Microsoft.Graph.Entra)){
Import-Module Microsoft.Graph.Entra
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,26 @@ Describe "Get-EntraCustomSecurityAttributeDefinition" {
}
It "Should contain 'User-Agent' header" {
$userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraCustomSecurityAttributeDefinition"

Get-EntraCustomSecurityAttributeDefinition -Id Engineering_Project | Out-Null
$result = Get-EntraCustomSecurityAttributeDefinition -Id 'Engineering_Project'
$result | Should -Not -BeNullOrEmpty
$userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraCustomSecurityAttributeDefinition"
Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 -ParameterFilter {
$Headers.'User-Agent' | Should -Be $userAgentHeaderValue
$true
}
}
}
It "Should execute successfully without throwing an error" {
# Disable confirmation prompts
$originalDebugPreference = $DebugPreference
$DebugPreference = 'Continue'

try {
# Act & Assert: Ensure the function doesn't throw an exception
{ Get-EntraCustomSecurityAttributeDefinition -Id 'Engineering_Project' -Debug } | Should -Not -Throw
} finally {
# Restore original confirmation preference
$DebugPreference = $originalDebugPreference
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,26 @@ Describe "Get-EntraCustomSecurityAttributeDefinitionAllowedValue" {
}
It "Should contain 'User-Agent' header" {
$userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraCustomSecurityAttributeDefinitionAllowedValue"

Get-EntraCustomSecurityAttributeDefinitionAllowedValue -CustomSecurityAttributeDefinitionId 'Engineering_Project' | Out-Null
$result = Get-EntraCustomSecurityAttributeDefinitionAllowedValue -CustomSecurityAttributeDefinitionId 'Engineering_Project' -Id 'Apline'
$result | Should -Not -BeNullOrEmpty
$userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraCustomSecurityAttributeDefinitionAllowedValue"
Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 -ParameterFilter {
$Headers.'User-Agent' | Should -Be $userAgentHeaderValue
$true
}
}
}
It "Should execute successfully without throwing an error" {
# Disable confirmation prompts
$originalDebugPreference = $DebugPreference
$DebugPreference = 'Continue'

try {
# Act & Assert: Ensure the function doesn't throw an exception
{ Get-EntraCustomSecurityAttributeDefinitionAllowedValue -CustomSecurityAttributeDefinitionId 'Engineering_Project' -Id 'Apline' -Debug } | Should -Not -Throw
} finally {
# Restore original confirmation preference
$DebugPreference = $originalDebugPreference
}
}
}
}
13 changes: 13 additions & 0 deletions test/module/Entra/Get-EntraFeatureRolloutPolicy.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,18 @@ Describe "Get-EntraFeatureRolloutPolicy" {
$true
}
}
It "Should execute successfully without throwing an error" {
# Disable confirmation prompts
$originalDebugPreference = $DebugPreference
$DebugPreference = 'Continue'

try {
# Act & Assert: Ensure the function doesn't throw an exception
{ Get-EntraFeatureRolloutPolicy -Debug } | Should -Not -Throw
} finally {
# Restore original confirmation preference
$DebugPreference = $originalDebugPreference
}
}
}
}
7 changes: 6 additions & 1 deletion test/module/Entra/Get-EntraObjectSetting.Tests.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# ------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
# ------------------------------------------------------------------------------
BeforeAll {
if ((Get-Module -Name Microsoft.Graph.Entra) -eq $null) {
Import-Module Microsoft.Graph.Entra
Expand Down Expand Up @@ -56,7 +59,9 @@ Describe "Get-EntraObjectSetting" {
}
It "Should contain 'User-Agent' header" {
$userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraObjectSetting"
Get-EntraObjectSetting -TargetType "Groups" -TargetObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc" | Out-Null
$result = Get-EntraObjectSetting -TargetType "Groups" -TargetObjectId "bbbbbbbb-1111-2222-3333-cccccccccccc"
$result | Should -Not -BeNullOrEmpty
$userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraObjectSetting"
Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 -ParameterFilter {
$Headers.'User-Agent' | Should -Be $userAgentHeaderValue
$true
Expand Down
17 changes: 15 additions & 2 deletions test/module/Entra/Get-EntraPolicy.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,26 @@ Describe "Get-EntraPolicy" {
}
It "Should contain 'User-Agent' header" {
$userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraPolicy"

$result = Get-EntraPolicy -Id "bbbbbbbb-1111-2222-3333-cccccccccccc"
$result | Should -Not -BeNullOrEmpty
$userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraPolicy"
Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 -ParameterFilter {
$Headers.'User-Agent' | Should -Be $userAgentHeaderValue
$true
}
}
}
It "Should execute successfully without throwing an error " {
# Disable confirmation prompts
$originalDebugPreference = $DebugPreference
$DebugPreference = 'Continue'

try {
# Act & Assert: Ensure the function doesn't throw an exception
{ Get-EntraPolicy -Id "bbbbbbbb-1111-2222-3333-cccccccccccc" -Debug } | Should -Not -Throw
} finally {
# Restore original confirmation preference
$DebugPreference = $originalDebugPreference
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,27 @@ Describe "Get-EntraServicePrincipalAppRoleAssignedTo" {
}

It "Should contain 'User-Agent' header" {
Mock -CommandName Get-MgServicePrincipalAppRoleAssignment -MockWith {$args} -ModuleName Microsoft.Graph.Entra

$userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraServicePrincipalAppRoleAssignedTo"

$result = Get-EntraServicePrincipalAppRoleAssignedTo -ObjectId "4d8fcb23-adc7-4d47-9328-2420eb1075ef"
$params = Get-Parameters -data $result
$params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue
}
$result | Should -Not -BeNullOrEmpty
$userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraServicePrincipalAppRoleAssignedTo"
Should -Invoke -CommandName Get-MgServicePrincipalAppRoleAssignment -ModuleName Microsoft.Graph.Entra -Times 1 -ParameterFilter {
$Headers.'User-Agent' | Should -Be $userAgentHeaderValue
$true
}
}
It "Should execute successfully without throwing an error " {
# Disable confirmation prompts
$originalDebugPreference = $DebugPreference
$DebugPreference = 'Continue'

try {
# Act & Assert: Ensure the function doesn't throw an exception
{ Get-EntraServicePrincipalAppRoleAssignedTo -ObjectId "4d8fcb23-adc7-4d47-9328-2420eb1075ef" -Debug } | Should -Not -Throw
} finally {
# Restore original confirmation preference
$DebugPreference = $originalDebugPreference
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,27 @@ Describe "Get-EntraServiceAppRoleAssigned" {
}

It "Should contain 'User-Agent' header" {
Mock -CommandName Get-MgServicePrincipalAppRoleAssignedTo -MockWith {$args} -ModuleName Microsoft.Graph.Entra

$userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraServicePrincipalAppRoleAssignment"

$result = Get-EntraServicePrincipalAppRoleAssignment -ObjectId "021510b7-e753-40aa-b668-29753295ca34"
$params = Get-Parameters -data $result
$params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue
}
$result | Should -Not -BeNullOrEmpty
$userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraServicePrincipalAppRoleAssignment"
Should -Invoke -CommandName Get-MgServicePrincipalAppRoleAssignedTo -ModuleName Microsoft.Graph.Entra -Times 1 -ParameterFilter {
$Headers.'User-Agent' | Should -Be $userAgentHeaderValue
$true
}
}
It "Should execute successfully without throwing an error " {
# Disable confirmation prompts
$originalDebugPreference = $DebugPreference
$DebugPreference = 'Continue'

try {
# Act & Assert: Ensure the function doesn't throw an exception
{ Get-EntraServicePrincipalAppRoleAssignment -ObjectId "021510b7-e753-40aa-b668-29753295ca34" -Debug } | Should -Not -Throw
} finally {
# Restore original confirmation preference
$DebugPreference = $originalDebugPreference
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,19 @@ Describe "Get-EntraServicePrincipalKeyCredential" {
$Headers.'User-Agent' | Should -Be $userAgentHeaderValue
$true
}
}
}
It "Should execute successfully without throwing an error " {
# Disable confirmation prompts
$originalDebugPreference = $DebugPreference
$DebugPreference = 'Continue'

try {
# Act & Assert: Ensure the function doesn't throw an exception
{ Get-EntraServicePrincipalKeyCredential -ObjectId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -Debug } | Should -Not -Throw
} finally {
# Restore original confirmation preference
$DebugPreference = $originalDebugPreference
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,18 @@ Describe "Get-EntraServicePrincipalPasswordCredential" {
$true
}
}
It "Should execute successfully without throwing an error " {
# Disable confirmation prompts
$originalDebugPreference = $DebugPreference
$DebugPreference = 'Continue'

try {
# Act & Assert: Ensure the function doesn't throw an exception
{ Get-EntraServicePrincipalPasswordCredential -ObjectId "00aa00aa-bb11-cc22-dd33-44ee44ee44ee" -Debug } | Should -Not -Throw
} finally {
# Restore original confirmation preference
$DebugPreference = $originalDebugPreference
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# ------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
# ------------------------------------------------------------------------------
BeforeAll {
if ((Get-Module -Name Microsoft.Graph.Entra) -eq $null) {
Import-Module Microsoft.Graph.Entra
Expand Down Expand Up @@ -75,17 +78,16 @@ Describe "New-EntraCustomSecurityAttributeDefinition" {
It "Should fail when usePreDefinedValuesOnly is invalid" {
{ New-EntraCustomSecurityAttributeDefinition -attributeSet "Engineering" -description "Active projects for user" -isCollection $true -isSearchable $true -name "Project1234" -status "Available" -type "String" -usePreDefinedValuesOnly "" } | Should -Throw "Cannot process argument transformation on parameter 'usePreDefinedValuesOnly'*"
}


It "Should contain 'User-Agent' header" {
$userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion New-EntraCustomSecurityAttributeDefinition"

New-EntraCustomSecurityAttributeDefinition -attributeSet "Engineering" -description "Active projects for user" -isCollection $true -isSearchable $true -name "Project1234" -status "Available" -type "String" -usePreDefinedValuesOnly $true | Out-Null
$result = New-EntraCustomSecurityAttributeDefinition -attributeSet "Engineering" -description "Active projects for user" -isCollection $true -isSearchable $true -name "Project1234" -status "Available" -type "String" -usePreDefinedValuesOnly $true
$result | Should -Not -BeNullOrEmpty
$userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion New-EntraCustomSecurityAttributeDefinition"
Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 -ParameterFilter {
$Headers.'User-Agent' | Should -Be $userAgentHeaderValue
$true
}
}
}
It "Should execute successfully without throwing an error " {
# Disable confirmation prompts
$originalDebugPreference = $DebugPreference
Expand Down
20 changes: 17 additions & 3 deletions test/module/Entra/New-EntraFeatureRolloutPolicy.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,26 @@ Describe "New-EntraFeatureRolloutPolicy" {
}
It "Should contain 'User-Agent' header" {
$userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion New-EntraFeatureRolloutPolicy"

New-EntraFeatureRolloutPolicy -Feature 'PasswordHashSync' -DisplayName 'FeatureRolloutPolicy1' -Description 'FeatureRolloutPolicy1' -IsEnabled $false | Out-Null
$result = New-EntraFeatureRolloutPolicy -Feature 'PasswordHashSync' -DisplayName 'FeatureRolloutPolicy1' -Description 'FeatureRolloutPolicy1' -IsEnabled $false
$result | Should -Not -BeNullOrEmpty
$userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion New-EntraFeatureRolloutPolicy"
Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 -ParameterFilter {
$Headers.'User-Agent' | Should -Be $userAgentHeaderValue
$true
}
}
}
It "Should execute successfully without throwing an error " {
# Disable confirmation prompts
$originalDebugPreference = $DebugPreference
$DebugPreference = 'Continue'

try {
# Act & Assert: Ensure the function doesn't throw an exception
{ New-EntraFeatureRolloutPolicy -Feature 'PasswordHashSync' -DisplayName 'FeatureRolloutPolicy1' -Description 'FeatureRolloutPolicy1' -IsEnabled $false -Debug } | Should -Not -Throw
} finally {
# Restore original confirmation preference
$DebugPreference = $originalDebugPreference
}
}
}
}
18 changes: 16 additions & 2 deletions test/module/Entra/New-EntraOauth2PermissionGrant.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,26 @@ Describe "New-EntraOauth2PermissionGrant" {
}
It "Should contain 'User-Agent' header" {
$userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion New-EntraOauth2PermissionGrant"

New-EntraOauth2PermissionGrant -ClientId "bbbbbbbb-1111-2222-3333-cccccccccccc" -ConsentType "AllPrincipals" -ResourceId "bbbbbbbb-1111-2222-3333-rrrrrrrrrrrr" | Out-Null
$result = New-EntraOauth2PermissionGrant -ClientId "bbbbbbbb-1111-2222-3333-cccccccccccc" -ConsentType "AllPrincipals" -ResourceId "bbbbbbbb-1111-2222-3333-rrrrrrrrrrrr" -Scope "DelegatedPermissionGrant.ReadWrite.All"
$result | Should -Not -BeNullOrEmpty
$userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion New-EntraOauth2PermissionGrant"
Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 -ParameterFilter {
$Headers.'User-Agent' | Should -Be $userAgentHeaderValue
$true
}
}
It "Should execute successfully without throwing an error " {
# Disable confirmation prompts
$originalDebugPreference = $DebugPreference
$DebugPreference = 'Continue'

try {
# Act & Assert: Ensure the function doesn't throw an exception
{ New-EntraOauth2PermissionGrant -ClientId "bbbbbbbb-1111-2222-3333-cccccccccccc" -ConsentType "AllPrincipals" -ResourceId "bbbbbbbb-1111-2222-3333-rrrrrrrrrrrr" -Scope "DelegatedPermissionGrant.ReadWrite.All" -Debug } | Should -Not -Throw
} finally {
# Restore original confirmation preference
$DebugPreference = $originalDebugPreference
}
}
}
}
Loading