-
Notifications
You must be signed in to change notification settings - Fork 36
added integration test #738
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 3 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
afde25b
added integration test
20ca4e7
updated integration test
271907c
updated 3 test and added 1 test
52bcd1d
Merge branch 'main' of https://github.com/microsoftgraph/entra-powers…
c49260e
integrated EntraMSGroup, EntraMSGroupLifecyclePolicy into EntraMSLife…
3a3abcc
updated test
7fb4fd0
Merge branch 'main' of https://github.com/microsoftgraph/entra-powers…
f098a8d
Removed EntraGroup, Added EntraGroupOwner and EntraGroupAppRoleAssign…
7cb6fe0
Merge branch 'main' of https://github.com/microsoftgraph/entra-powers…
96759e2
updated test
f0b32fa
updated test
268c120
updated test
c6ba464
Updated EntraGroupAppRoleAssignment test
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| Describe "The EntraGroup command executing unmocked" { | ||
|
|
||
| Context "When getting user and group" { | ||
| BeforeAll { | ||
| $testReportPath = join-path $psscriptroot "\env.ps1" | ||
| Import-Module -Name $testReportPath | ||
| $appId = $env:TEST_APPID | ||
| $tenantId = $env:TEST_TENANTID | ||
| $cert = $env:CERTIFICATETHUMBPRINT | ||
| Connect-Entra -TenantId $tenantId -AppId $appId -CertificateThumbprint $cert | ||
|
|
||
| $thisTestInstanceId = New-Guid | Select-Object -expandproperty guid | ||
| $testName = 'Demo Name' + $thisTestInstanceId | ||
|
|
||
| #create test group | ||
| $global:newGroup = New-EntraGroup -DisplayName $testName -MailEnabled $false -SecurityEnabled $true -MailNickName "NotSet" | ||
| } | ||
|
|
||
| It "should successfully get a specific group by using an Id" { | ||
| $group = Get-EntraGroup -ObjectId $newGroup.Id | ||
| $group.Id | Should -Be $newGroup.Id | ||
| $group.DisplayName | Should -Be $testName | ||
| } | ||
|
|
||
| It "should successfully update a group display name" { | ||
| Set-EntraGroup -ObjectId $newGroup.Id -DisplayName "Demo Name 2" | ||
| $result = Get-EntraGroup -ObjectId $newGroup.Id | ||
| $result.Id | Should -Contain $newGroup.Id | ||
| } | ||
|
|
||
| AfterAll { | ||
| Remove-EntraGroup -ObjectId $newGroup.Id | Out-Null | ||
| } | ||
| } | ||
| } |
38 changes: 38 additions & 0 deletions
38
test/module/Entra/Integration/EntraMSApplication.Tests.ps1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| Describe "The EntraMSApplication command executing unmocked" { | ||
|
|
||
| Context "When getting application" { | ||
| BeforeAll { | ||
| $testReportPath = join-path $psscriptroot "\env.ps1" | ||
| Import-Module -Name $testReportPath | ||
| $appId = $env:TEST_APPID | ||
| $tenantId = $env:TEST_TENANTID | ||
| $cert = $env:CERTIFICATETHUMBPRINT | ||
| Connect-Entra -TenantId $tenantId -AppId $appId -CertificateThumbprint $cert | ||
|
|
||
| $thisTestInstanceId = New-Guid | Select-Object -expandproperty guid | ||
| $testApplicationName = 'Demo Name' + $thisTestInstanceId | ||
|
|
||
| # Create an application | ||
| $global:newMSApplication = New-EntraMSApplication -DisplayName $testApplicationName | ||
| } | ||
|
|
||
| It "should successfully get an application by display name" { | ||
| $application = Get-EntraMSApplication -Filter "DisplayName eq '$($newMSApplication.DisplayName)'" | ||
| $application.ObjectId | Should -Be $newMSApplication.Id | ||
| $application.AppId | Should -Be $newMSApplication.AppId | ||
| $application.DisplayName | Should -Be $newMSApplication.DisplayName | ||
| } | ||
|
|
||
| It "should successfully update a application display name" { | ||
| Set-EntraMSApplication -ObjectId $newMSApplication.ObjectId -DisplayName "Update Application Name" | ||
| $result = Get-EntraMSApplication -Filter "AppId eq '$($newMSApplication.AppId)'" | ||
| $result.ObjectId | Should -Be $newMSApplication.Id | ||
| $result.AppId | Should -Be $newMSApplication.AppId | ||
| $result.DisplayName | Should -Be "Update Application Name" | ||
| } | ||
|
|
||
| AfterAll { | ||
| Remove-EntraMSApplication -ObjectId $newMSApplication.ObjectId | Out-Null | ||
| } | ||
| } | ||
| } |
50 changes: 50 additions & 0 deletions
50
test/module/Entra/Integration/EntraMSApplicationExtensionProperty.Tests.ps1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| Describe "The EntraMSApplicationExtensionProperty command executing unmocked" { | ||
|
|
||
| Context "When getting ApplicationExtensionProperty" { | ||
| BeforeAll { | ||
| $testReportPath = Join-Path $PSScriptRoot "\env.ps1" | ||
| Import-Module -Name $testReportPath | ||
|
|
||
| $appId = $env:TEST_APPID | ||
| $tenantId = $env:TEST_TENANTID | ||
| $cert = $env:CERTIFICATETHUMBPRINT | ||
|
|
||
| # Validate required environment variables | ||
| if (-not $appId -or -not $tenantId -or -not $cert) { | ||
| throw "Required environment variables are not set." | ||
| } | ||
|
|
||
| # Connect to Entra service | ||
| Connect-Entra -TenantId $tenantId -AppId $appId -CertificateThumbprint $cert | ||
|
|
||
| # Create an application | ||
| $thisTestInstanceId = New-Guid | Select-Object -expandproperty guid | ||
| $testApplicationName = 'Test Demo Name' + $thisTestInstanceId | ||
| $global:newMSApplication = New-EntraMSApplication -DisplayName $testApplicationName | ||
| Write-Host "Id :$($newMSApplication.Id)" | ||
| Write-Host "AppId :$($newMSApplication.AppId)" | ||
|
|
||
| # Create an extension property | ||
| $global:newMSApplicationExtensionProperty = New-EntraMSApplicationExtensionProperty -ObjectId $newMSApplication.Id -DataType "string" -Name "NewAttribute" -TargetObjects "Application" | ||
| Write-Host "ObjectId :$($newMSApplicationExtensionProperty.ObjectId)" | ||
| Write-Host "Name :$($newMSApplicationExtensionProperty.Name)" | ||
| } | ||
|
|
||
| It "should successfully get application extension property" { | ||
| # Get application extension property using object id | ||
| $applicationExtensionProperty = Get-EntraMSApplicationExtensionProperty -ObjectId $newMSApplicationExtensionProperty.ObjectId | ||
| $applicationExtensionProperty.ObjectId | Should -Be $newMSApplicationExtensionProperty.ObjectId | ||
| $applicationExtensionProperty.Name | Should -Be $newMSApplicationExtensionProperty.Name | ||
| Write-Host $applicationExtensionProperty | ||
| } | ||
|
|
||
| AfterAll { | ||
| if ($newMSGroup) { | ||
snehalkotwal marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Remove-EntraMSApplication -ObjectId $newMSApplication.ObjectId | Out-Null | ||
| } | ||
| if ($testGroupPolicy) { | ||
snehalkotwal marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| # Remove-EntraMSApplicationExtensionProperty -ObjectId $newMSApplicationExtensionProperty.ObjectId -ExtensionPropertyId "344ed560-f8e7-410e-ab9f-c79df5c36" | Out-Null | ||
| } | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| Describe "The EntraMSGroup command executing unmocked" { | ||
|
|
||
| Context "When getting user and group" { | ||
| BeforeAll { | ||
| $testReportPath = join-path $psscriptroot "\env.ps1" | ||
| Import-Module -Name $testReportPath | ||
| $appId = $env:TEST_APPID | ||
| $tenantId = $env:TEST_TENANTID | ||
| $cert = $env:CERTIFICATETHUMBPRINT | ||
| Connect-Entra -TenantId $tenantId -AppId $appId -CertificateThumbprint $cert | ||
|
|
||
| $thisTestInstanceId = New-Guid | Select-Object -expandproperty guid | ||
| $testName = 'Demo Help Group' + $thisTestInstanceId | ||
| $testNickname = "helpDeskAdminGroup" | ||
|
|
||
| #Create a group with Description parameter. | ||
| $global:newMSGroup = New-EntraMSGroup -DisplayName $testName -MailEnabled $False -MailNickname $testNickname -SecurityEnabled $True | ||
| } | ||
|
|
||
| It "should successfully get a specific group by using an Id" { | ||
| $group = Get-EntraMSGroup -Id $newMSGroup.Id | ||
| $group.ObjectId | Should -Be $newMSGroup.Id | ||
| $group.DisplayName | Should -Be $testName | ||
| } | ||
|
|
||
| It "should successfully update a group display name" { | ||
| Set-EntraMSGroup -Id $newMSGroup.Id -DisplayName "Update Help Group Name" | ||
| $result = Get-EntraGroup -ObjectId $newMSGroup.Id | ||
| $result.Id | Should -Contain $newMSGroup.Id | ||
| } | ||
|
|
||
| AfterAll { | ||
| Remove-EntraMSGroup -Id $newMSGroup.Id | Out-Null | ||
| } | ||
| } | ||
| } |
46 changes: 46 additions & 0 deletions
46
test/module/Entra/Integration/EntraMSGroupLifecyclePolicy.Tests.ps1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| Describe "The EntraMSGroupLifecyclePolicy command executing unmocked" { | ||
|
|
||
| Context "When getting groupLifecyclePolicy" { | ||
| BeforeAll { | ||
| $testReportPath = join-path $psscriptroot "\env.ps1" | ||
| Import-Module -Name $testReportPath | ||
| $appId = $env:TEST_APPID | ||
| $tenantId = $env:TEST_TENANTID | ||
| $cert = $env:CERTIFICATETHUMBPRINT | ||
| Connect-Entra -TenantId $tenantId -AppId $appId -CertificateThumbprint $cert | ||
|
|
||
| $global:testGroupPolicy = New-EntraMSGroupLifecyclePolicy -GroupLifetimeInDays 99 -ManagedGroupTypes "Selected" -AlternateNotificationEmails "[email protected]" | ||
| } | ||
|
|
||
| It "should successfully retrieve properties of an groupLifecyclePolicy" { | ||
| $groupLifecyclePolicy = Get-EntraMSGroupLifecyclePolicy -Id $testGroupPolicy.Id | ||
|
|
||
| # Ensure that the retrieved group lifecycle policy matches the expected one | ||
| $groupLifecyclePolicy.Id | Should -Be $testGroupPolicy.Id | ||
| $groupLifecyclePolicy.GroupLifetimeInDays | Should -Be 99 | ||
| $groupLifecyclePolicy.ManagedGroupTypes | Should -Contain "Selected" | ||
| $groupLifecyclePolicy.AlternateNotificationEmails | Should -Contain "[email protected]" | ||
| } | ||
|
|
||
| It "should successfully update group lifecycle policy" { | ||
| $updatedGroupLifecyclePolicy = Set-EntraMSGroupLifecyclePolicy -Id $testGroupPolicy.Id -GroupLifetimeInDays 200 -AlternateNotificationEmails "[email protected]" -ManagedGroupTypes "All" | ||
|
|
||
| # Ensure that the retrieved group lifecycle policy matches the expected one | ||
| $updatedGroupLifecyclePolicy.Id | Should -Be $testGroupPolicy.Id | ||
| $updatedGroupLifecyclePolicy.GroupLifetimeInDays | Should -Be 200 | ||
| $updatedGroupLifecyclePolicy.ManagedGroupTypes | Should -Contain "All" | ||
| $updatedGroupLifecyclePolicy.AlternateNotificationEmails | Should -Contain "[email protected]" | ||
| } | ||
|
|
||
| # It "should throw an exception if a nonexistent ID parameter is specified" { | ||
| # $Id = (New-Guid).Guid | ||
| # Get-EntraMSGroupLifecyclePolicy -Id $Id -ErrorAction ignore | ||
| # $errorMessage = $Error[0].Exception.Message | ||
| # $errorMessage | Should -match "([\da-fA-F]{8}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{12})" | ||
| # } | ||
|
|
||
| AfterAll { | ||
| Remove-EntraMSGroupLifecyclePolicy -Id $testGroupPolicy.Id | Out-Null | ||
| } | ||
| } | ||
| } |
69 changes: 69 additions & 0 deletions
69
test/module/Entra/Integration/EntraMSLifecyclePolicyGroup.Tests.ps1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| Describe "The EntraMSLifecyclePolicyGroup command executing unmocked" { | ||
|
|
||
| Context "When getting LifecyclePolicyGroup" { | ||
| BeforeAll { | ||
| $testReportPath = Join-Path $PSScriptRoot "\env.ps1" | ||
| Import-Module -Name $testReportPath | ||
|
|
||
| $appId = $env:TEST_APPID | ||
| $tenantId = $env:TEST_TENANTID | ||
| $cert = $env:CERTIFICATETHUMBPRINT | ||
|
|
||
| # Validate required environment variables | ||
| if (-not $appId -or -not $tenantId -or -not $cert) { | ||
| throw "Required environment variables are not set." | ||
| } | ||
|
|
||
| # Connect to Entra service | ||
| Connect-Entra -TenantId $tenantId -AppId $appId -CertificateThumbprint $cert | ||
|
|
||
| # Create a group with Description parameter. | ||
| $thisTestInstanceId = New-Guid | Select-Object -ExpandProperty Guid | ||
| $testName = 'Demo Help Group' + $thisTestInstanceId | ||
| $testNickname = "testhelpDeskAdminGroup" | ||
| $global:newMSGroup = New-EntraMSGroup -DisplayName $testName -MailEnabled $false -MailNickname $testNickname -SecurityEnabled $true -GroupTypes "unified" | ||
| Write-Host "Group Id:$($newMSGroup.Id)" | ||
| # Validate group creation | ||
| if (-not $newMSGroup) { | ||
| throw "Failed to create a new group." | ||
| } | ||
| Start-Sleep -Seconds 10 | ||
|
|
||
| # Create a lifecycle policy | ||
| $global:testGroupPolicy = New-EntraMSGroupLifecyclePolicy -GroupLifetimeInDays 99 -ManagedGroupTypes "Selected" -AlternateNotificationEmails "[email protected]" | ||
| Write-Host "Policy Id:$($testGroupPolicy.Id)" | ||
| # Validate policy creation | ||
| if (-not $testGroupPolicy) { | ||
| throw "Failed to create a new group lifecycle policy." | ||
| } | ||
| Start-Sleep -Seconds 10 | ||
| } | ||
|
|
||
| It "should successfully retrieve details of a LifecyclePolicyGroup" { | ||
| # Associate the group with the lifecycle policy | ||
| $testLifePolicyGroup = Add-EntraMSLifecyclePolicyGroup -Id $testGroupPolicy.Id -GroupId $newMSGroup.Id | ||
| Write-Host "Lifecycle Policy Group Id:$($testLifePolicyGroup.Id)" | ||
| $testLifePolicyGroup.ObjectId | Should -BeNullOrEmpty | ||
|
|
||
| # Get lifecycle policy group using group id | ||
| $lifecyclePolicyGroup = Get-EntraMSLifecyclePolicyGroup -Id $newMSGroup.Id | ||
| $lifecyclePolicyGroup.ObjectId | Should -Be $testGroupPolicy.Id | ||
| $lifecyclePolicyGroup.GroupLifetimeInDays | Should -Be 99 | ||
| $lifecyclePolicyGroup.ManagedGroupTypes | Should -Contain "Selected" | ||
| $lifecyclePolicyGroup.AlternateNotificationEmails | Should -Contain "[email protected]" | ||
| Write-Host $lifecyclePolicyGroup | ||
| } | ||
|
|
||
| AfterAll { | ||
| if ($newMSGroup) { | ||
| Remove-EntraMSGroup -Id $newMSGroup.Id | Out-Null | ||
| } | ||
| if ($testGroupPolicy) { | ||
| Remove-EntraMSGroupLifecyclePolicy -Id $testGroupPolicy.Id | Out-Null | ||
| } | ||
| if ($testLifePolicyGroup) { | ||
| Remove-EntraMSLifecyclePolicyGroup -Id $testLifePolicyGroup.Id -GroupId $newMSGroup.Id | Out-Null | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| $env:TEST_APPID = "8886ad7b-1795-4542-9808-c85859d97f23" | ||
| $env:TEST_TENANTID = "d5aec55f-2d12-4442-8d2f-ccca95d4390e" | ||
| $env:CERTIFICATETHUMBPRINT = "6CAEA8F6CEF8C5F8642F1F9AABE0237DB3D0C424" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.