From 19f4a4cc4b4d683985b28701d7347797c57de818 Mon Sep 17 00:00:00 2001 From: "Ashwini Karke (Perennial Systems Inc)" Date: Mon, 25 Mar 2024 17:01:19 +0530 Subject: [PATCH 01/40] Mock Get-AzureADApplication --- .../Entra/Mock-Get-EntraApplication.Tests.ps1 | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 test/module/Entra/Mock-Get-EntraApplication.Tests.ps1 diff --git a/test/module/Entra/Mock-Get-EntraApplication.Tests.ps1 b/test/module/Entra/Mock-Get-EntraApplication.Tests.ps1 new file mode 100644 index 000000000..43ca2a34e --- /dev/null +++ b/test/module/Entra/Mock-Get-EntraApplication.Tests.ps1 @@ -0,0 +1,73 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ + Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force + } + $scriptblock = { + param($args) + Write-Host "Mocking Get-MgApplication with parameters: $($args | ConvertTo-Json -Depth 3)" + return @( + [PSCustomObject]@{ + "AppId" = "5f783237-3457-45d8-93e7-a0edb1cfbfd1" + "DeletedDateTime" = $null + "Id" = "111cc9b5-fce9-485e-9566-c68debafac5f" + "DisplayName" = "Mock-App" + "Info" = @{LogoUrl=""; MarketingUrl=""; PrivacyStatementUrl=""; SupportUrl=""; TermsOfServiceUrl=""} + "IsDeviceOnlyAuthSupported" = $True + "IsFallbackPublicClient" = $true + "KeyCredentials" = @{CustomKeyIdentifier = @(211, 174, 247);DisplayName =""; Key="";KeyId="d903c7a3-75ea-4772-8935-5c0cf82068a7";Type="Symmetric";Usage="Sign"} + "OptionalClaims" = @{AccessToken=""; IdToken=""; Saml2Token=""} + "ParentalControlSettings" = @{CountriesBlockedForMinors=$null; LegalAgeGroupRule="Allow"} + "PasswordCredentials" = @{} + "PublicClient" = @{RedirectUris=$null} + "PublisherDomain" = "M365x99297270.onmicrosoft.com" + "SignInAudience" = "AzureADandPersonalMicrosoftAccount" + "Web" = @{HomePageUrl="https://localhost/demoapp"; ImplicitGrantSettings=""; LogoutUrl="";} + } + ) + } + Mock -CommandName Get-MgApplication -MockWith $scriptBlock -ModuleName Microsoft.Graph.Entra + } + + Describe "Get-EntraApplication" { + Context "Test for Get-EntraApplication" { + It "Should return specific application" { + $result = Get-EntraApplication -ObjectId "111cc9b5-fce9-485e-9566-c68debafac5f" + $result | Should -Not -BeNullOrEmpty + $result.Id | should -Be @('111cc9b5-fce9-485e-9566-c68debafac5f') + + Should -Invoke -CommandName Get-MgApplication -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when ObjectId is empty" { + { Get-EntraApplication -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + } + It "Should return all applications" { + $result = Get-EntraApplication -All $true + $result | Should -Not -BeNullOrEmpty + + Should -Invoke -CommandName Get-MgApplication -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when All is empty" { + { Get-EntraApplication -All } | Should -Throw "Missing an argument for parameter 'All'*" + } + It "Should return specific application by searchstring" { + $result = Get-EntraApplication -SearchString 'Mock-App' + $result | Should -Not -BeNullOrEmpty + $result.DisplayName | should -Be 'Mock-App' + + Should -Invoke -CommandName Get-MgApplication -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should return specific application by filter" { + $result = Get-EntraApplication -Filter "DisplayName -eq 'Mock-App'" + $result | Should -Not -BeNullOrEmpty + $result.DisplayName | should -Be 'Mock-App' + + Should -Invoke -CommandName Get-MgApplication -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should return top application" { + $result = Get-EntraApplication -Top 1 + $result | Should -Not -BeNullOrEmpty + + Should -Invoke -CommandName Get-MgApplication -ModuleName Microsoft.Graph.Entra -Times 1 + } + } + } \ No newline at end of file From fd77011581fe445eeeec033256ee3d7d26325ccc Mon Sep 17 00:00:00 2001 From: "Ashwini Karke (Perennial Systems Inc)" Date: Mon, 25 Mar 2024 17:01:19 +0530 Subject: [PATCH 02/40] Mock Get-AzureADApplication --- .../Entra/Mock-Get-EntraApplication.Tests.ps1 | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 test/module/Entra/Mock-Get-EntraApplication.Tests.ps1 diff --git a/test/module/Entra/Mock-Get-EntraApplication.Tests.ps1 b/test/module/Entra/Mock-Get-EntraApplication.Tests.ps1 new file mode 100644 index 000000000..43ca2a34e --- /dev/null +++ b/test/module/Entra/Mock-Get-EntraApplication.Tests.ps1 @@ -0,0 +1,73 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ + Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force + } + $scriptblock = { + param($args) + Write-Host "Mocking Get-MgApplication with parameters: $($args | ConvertTo-Json -Depth 3)" + return @( + [PSCustomObject]@{ + "AppId" = "5f783237-3457-45d8-93e7-a0edb1cfbfd1" + "DeletedDateTime" = $null + "Id" = "111cc9b5-fce9-485e-9566-c68debafac5f" + "DisplayName" = "Mock-App" + "Info" = @{LogoUrl=""; MarketingUrl=""; PrivacyStatementUrl=""; SupportUrl=""; TermsOfServiceUrl=""} + "IsDeviceOnlyAuthSupported" = $True + "IsFallbackPublicClient" = $true + "KeyCredentials" = @{CustomKeyIdentifier = @(211, 174, 247);DisplayName =""; Key="";KeyId="d903c7a3-75ea-4772-8935-5c0cf82068a7";Type="Symmetric";Usage="Sign"} + "OptionalClaims" = @{AccessToken=""; IdToken=""; Saml2Token=""} + "ParentalControlSettings" = @{CountriesBlockedForMinors=$null; LegalAgeGroupRule="Allow"} + "PasswordCredentials" = @{} + "PublicClient" = @{RedirectUris=$null} + "PublisherDomain" = "M365x99297270.onmicrosoft.com" + "SignInAudience" = "AzureADandPersonalMicrosoftAccount" + "Web" = @{HomePageUrl="https://localhost/demoapp"; ImplicitGrantSettings=""; LogoutUrl="";} + } + ) + } + Mock -CommandName Get-MgApplication -MockWith $scriptBlock -ModuleName Microsoft.Graph.Entra + } + + Describe "Get-EntraApplication" { + Context "Test for Get-EntraApplication" { + It "Should return specific application" { + $result = Get-EntraApplication -ObjectId "111cc9b5-fce9-485e-9566-c68debafac5f" + $result | Should -Not -BeNullOrEmpty + $result.Id | should -Be @('111cc9b5-fce9-485e-9566-c68debafac5f') + + Should -Invoke -CommandName Get-MgApplication -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when ObjectId is empty" { + { Get-EntraApplication -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + } + It "Should return all applications" { + $result = Get-EntraApplication -All $true + $result | Should -Not -BeNullOrEmpty + + Should -Invoke -CommandName Get-MgApplication -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when All is empty" { + { Get-EntraApplication -All } | Should -Throw "Missing an argument for parameter 'All'*" + } + It "Should return specific application by searchstring" { + $result = Get-EntraApplication -SearchString 'Mock-App' + $result | Should -Not -BeNullOrEmpty + $result.DisplayName | should -Be 'Mock-App' + + Should -Invoke -CommandName Get-MgApplication -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should return specific application by filter" { + $result = Get-EntraApplication -Filter "DisplayName -eq 'Mock-App'" + $result | Should -Not -BeNullOrEmpty + $result.DisplayName | should -Be 'Mock-App' + + Should -Invoke -CommandName Get-MgApplication -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should return top application" { + $result = Get-EntraApplication -Top 1 + $result | Should -Not -BeNullOrEmpty + + Should -Invoke -CommandName Get-MgApplication -ModuleName Microsoft.Graph.Entra -Times 1 + } + } + } \ No newline at end of file From 572a5d62fcd000cd4393809331375c6c80b2d1f9 Mon Sep 17 00:00:00 2001 From: "Ashwini Karke (Perennial Systems Inc)" Date: Mon, 1 Apr 2024 18:22:46 +0530 Subject: [PATCH 03/40] testcases --- .../Entra/Mock-Get-EntraApplication.Tests.ps1 | 9 +++- .../Mock-Get-EntraDirectoryRole.Tests.ps1 | 47 +++++++++++++++++++ .../Entra/Mock-New-EntraGroup.Tests.ps1 | 38 +++++++++++++++ 3 files changed, 92 insertions(+), 2 deletions(-) create mode 100644 test/module/Entra/Mock-Get-EntraDirectoryRole.Tests.ps1 create mode 100644 test/module/Entra/Mock-New-EntraGroup.Tests.ps1 diff --git a/test/module/Entra/Mock-Get-EntraApplication.Tests.ps1 b/test/module/Entra/Mock-Get-EntraApplication.Tests.ps1 index 43ca2a34e..9be95706f 100644 --- a/test/module/Entra/Mock-Get-EntraApplication.Tests.ps1 +++ b/test/module/Entra/Mock-Get-EntraApplication.Tests.ps1 @@ -1,6 +1,7 @@ BeforeAll { if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ - Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force + # Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force + Import-Module Microsoft.Graph.Entra } $scriptblock = { param($args) @@ -68,6 +69,10 @@ BeforeAll { $result | Should -Not -BeNullOrEmpty Should -Invoke -CommandName Get-MgApplication -ModuleName Microsoft.Graph.Entra -Times 1 - } + } + It "Result should Contain ObjectId" { + $result = Get-EntraApplication -ObjectId "111cc9b5-fce9-485e-9566-c68debafac5f" + $result.ObjectId | should -Be "111cc9b5-fce9-485e-9566-c68debafac5f" + } } } \ No newline at end of file diff --git a/test/module/Entra/Mock-Get-EntraDirectoryRole.Tests.ps1 b/test/module/Entra/Mock-Get-EntraDirectoryRole.Tests.ps1 new file mode 100644 index 000000000..fcf4d4a73 --- /dev/null +++ b/test/module/Entra/Mock-Get-EntraDirectoryRole.Tests.ps1 @@ -0,0 +1,47 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ + Import-Module Microsoft.Graph.Entra + } + $scriptblock = { + param($args) + Write-Host "Mocking Get-EntraDirectoryRole with parameters: $($args | ConvertTo-Json -Depth 3)" + return @( + [PSCustomObject]@{ + "DeletedDateTime" = $null + "Description" = "Read custom security attribute keys and values for supported Microsoft Entra objects." + "DisplayName" = "Attribute Assignment Reader" + "Id" = "dc587a80-d49c-4700-a73b-57227856fc32" + "RoleTemplateId" = "ffd52fa5-98dc-465c-991d-fc073eb59f8f" + "Members" = $null + "ScopedMembers" = $null + } + ) + } + Mock -CommandName Get-MgDirectoryRole -MockWith $scriptBlock -ModuleName Microsoft.Graph.Entra + } + + Describe "Get-EntraDirectoryRole" { + Context "Test for Get-EntraDirectoryRole" { + It "Should return specific application" { + $result = Get-EntraDirectoryRole -ObjectId "dc587a80-d49c-4700-a73b-57227856fc32" + $result | Should -Not -BeNullOrEmpty + $result.Id | should -Be "dc587a80-d49c-4700-a73b-57227856fc32" + + Should -Invoke -CommandName Get-MgDirectoryRole -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when ObjectId is empty" { + { Get-EntraDirectoryRole -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + } + It "Should return specific application by filter" { + $result = Get-EntraDirectoryRole -Filter "DisplayName -eq 'Attribute Assignment Reader'" + $result | Should -Not -BeNullOrEmpty + $result.DisplayName | should -Be 'Attribute Assignment Reader' + + Should -Invoke -CommandName Get-MgDirectoryRole -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Result should Contain ObjectId" { + $result = Get-EntraDirectoryRole -ObjectId "dc587a80-d49c-4700-a73b-57227856fc32" + $result.ObjectId | should -Be "dc587a80-d49c-4700-a73b-57227856fc32" + } + } + } \ No newline at end of file diff --git a/test/module/Entra/Mock-New-EntraGroup.Tests.ps1 b/test/module/Entra/Mock-New-EntraGroup.Tests.ps1 new file mode 100644 index 000000000..e4763bbd5 --- /dev/null +++ b/test/module/Entra/Mock-New-EntraGroup.Tests.ps1 @@ -0,0 +1,38 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ + Import-Module Microsoft.Graph.Entra + } + $scriptblock = { + param($args) + Write-Host "Mocking New-EntraGroup with parameters: $($args | ConvertTo-Json -Depth 3)" + return @( + [PSCustomObject]@{ + "DisplayName" = "demo" + "Id" = "056b2531-005e-4f3e-be78-01a71ea30a04" + "MailEnabled" = "False" + "Description" = "test" + "MailNickname" = "demoNickname" + "SecurityEnabled" = "True" + } + ) + } + Mock -CommandName New-MgGroup -MockWith $scriptBlock -ModuleName Microsoft.Graph.Entra + } + + Describe "New-EntraGroup" { + Context "Test for New-EntraGroup" { + It "Should return specific application" { + $result = New-EntraGroup -DisplayName "demo" -MailEnabled $false -SecurityEnabled $true -MailNickName "demoNickname" -Description "test" + $result | Should -Not -BeNullOrEmpty + $result.DisplayName | should -Be "demo" + $result.MailEnabled | should -Be "False" + $result.SecurityEnabled | should -Be "True" + $result.Description | should -Be "test" + + Should -Invoke -CommandName New-MgGroup -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when Description is empty" { + { New-EntraGroup -DisplayName "" -MailEnabled -SecurityEnabled -MailNickName "" -Description "" } | Should -Throw "Missing an argument for parameter*" + } + } + } \ No newline at end of file From 664bfb8ebbf9ab56ecd813000a063132f2210a92 Mon Sep 17 00:00:00 2001 From: "Ashwini Karke (Perennial Systems Inc)" Date: Tue, 2 Apr 2024 17:33:14 +0530 Subject: [PATCH 04/40] test-Get-AzureADApplication --- coverage.xml | 7121 +++++++++++++++++ .../Entra/Mock-Get-EntraApplication.Tests.ps1 | 4 +- .../Mock-Get-EntraDirectoryRole.Tests.ps1 | 4 +- .../Entra/Mock-Get-EntraGroup.Tests.ps1 | 68 + .../Entra/Mock-New-EntraGroup.Tests.ps1 | 4 +- .../Entra/Mock-Remove-EntraGroup.Tests.ps1 | 25 + .../Entra/Mock-Set-EntraGroup.Tests.ps1 | 25 + 7 files changed, 7245 insertions(+), 6 deletions(-) create mode 100644 coverage.xml create mode 100644 test/module/Entra/Mock-Get-EntraGroup.Tests.ps1 create mode 100644 test/module/Entra/Mock-Remove-EntraGroup.Tests.ps1 create mode 100644 test/module/Entra/Mock-Set-EntraGroup.Tests.ps1 diff --git a/coverage.xml b/coverage.xml new file mode 100644 index 000000000..9c9d48fa1 --- /dev/null +++ b/coverage.xml @@ -0,0 +1,7121 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/module/Entra/Mock-Get-EntraApplication.Tests.ps1 b/test/module/Entra/Mock-Get-EntraApplication.Tests.ps1 index 9be95706f..8a0753fec 100644 --- a/test/module/Entra/Mock-Get-EntraApplication.Tests.ps1 +++ b/test/module/Entra/Mock-Get-EntraApplication.Tests.ps1 @@ -25,8 +25,8 @@ BeforeAll { "Web" = @{HomePageUrl="https://localhost/demoapp"; ImplicitGrantSettings=""; LogoutUrl="";} } ) - } - Mock -CommandName Get-MgApplication -MockWith $scriptBlock -ModuleName Microsoft.Graph.Entra + } + Mock -CommandName Get-MgApplication -MockWith $scriptBlock -ModuleName Microsoft.Graph.Entra } Describe "Get-EntraApplication" { diff --git a/test/module/Entra/Mock-Get-EntraDirectoryRole.Tests.ps1 b/test/module/Entra/Mock-Get-EntraDirectoryRole.Tests.ps1 index fcf4d4a73..779dca760 100644 --- a/test/module/Entra/Mock-Get-EntraDirectoryRole.Tests.ps1 +++ b/test/module/Entra/Mock-Get-EntraDirectoryRole.Tests.ps1 @@ -22,7 +22,7 @@ BeforeAll { Describe "Get-EntraDirectoryRole" { Context "Test for Get-EntraDirectoryRole" { - It "Should return specific application" { + It "Should return specific role" { $result = Get-EntraDirectoryRole -ObjectId "dc587a80-d49c-4700-a73b-57227856fc32" $result | Should -Not -BeNullOrEmpty $result.Id | should -Be "dc587a80-d49c-4700-a73b-57227856fc32" @@ -32,7 +32,7 @@ BeforeAll { It "Should fail when ObjectId is empty" { { Get-EntraDirectoryRole -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." } - It "Should return specific application by filter" { + It "Should return specific role by filter" { $result = Get-EntraDirectoryRole -Filter "DisplayName -eq 'Attribute Assignment Reader'" $result | Should -Not -BeNullOrEmpty $result.DisplayName | should -Be 'Attribute Assignment Reader' diff --git a/test/module/Entra/Mock-Get-EntraGroup.Tests.ps1 b/test/module/Entra/Mock-Get-EntraGroup.Tests.ps1 new file mode 100644 index 000000000..94640a546 --- /dev/null +++ b/test/module/Entra/Mock-Get-EntraGroup.Tests.ps1 @@ -0,0 +1,68 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ + Import-Module Microsoft.Graph.Entra + } + $scriptblock = { + param($args) + Write-Host "Mocking Get-EntraGroup with parameters: $($args | ConvertTo-Json -Depth 3)" + return @( + [PSCustomObject]@{ + "DisplayName" = "demo" + "Id" = "056b2531-005e-4f3e-be78-01a71ea30a04" + "MailEnabled" = "False" + "Description" = "test" + "MailNickname" = "demoNickname" + "SecurityEnabled" = "True" + } + ) + } + Mock -CommandName Get-MgGroup -MockWith $scriptBlock -ModuleName Microsoft.Graph.Entra +} + + Describe "Get-EntraGroup" { + Context "Test for Get-EntraGroup" { + It "Should return specific group" { + $result = Get-EntraGroup -ObjectId "056b2531-005e-4f3e-be78-01a71ea30a04" + $result | Should -Not -BeNullOrEmpty + $result.Id | should -Be '056b2531-005e-4f3e-be78-01a71ea30a04' + + Should -Invoke -CommandName Get-MgGroup -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when ObjectId is empty" { + { Get-EntraGroup -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + } + It "Should return all group" { + $result = Get-EntraGroup -All $true + $result | Should -Not -BeNullOrEmpty + + Should -Invoke -CommandName Get-MgGroup -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when All is empty" { + { Get-EntraGroup -All } | Should -Throw "Missing an argument for parameter 'All'*" + } + It "Should return specific group by searchstring" { + $result = Get-EntraGroup -SearchString 'demo' + $result | Should -Not -BeNullOrEmpty + $result.DisplayName | should -Be 'demo' + + Should -Invoke -CommandName Get-MgGroup -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should return specific group by filter" { + $result = Get-EntraGroup -Filter "DisplayName -eq 'demo'" + $result | Should -Not -BeNullOrEmpty + $result.DisplayName | should -Be 'demo' + + Should -Invoke -CommandName Get-MgGroup -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should return top group" { + $result = Get-EntraGroup -Top 1 + $result | Should -Not -BeNullOrEmpty + + Should -Invoke -CommandName Get-MgGroup -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Result should Contain ObjectId" { + $result = Get-EntraGroup -ObjectId "056b2531-005e-4f3e-be78-01a71ea30a04" + $result.ObjectId | should -Be "056b2531-005e-4f3e-be78-01a71ea30a04" + } + } + } \ No newline at end of file diff --git a/test/module/Entra/Mock-New-EntraGroup.Tests.ps1 b/test/module/Entra/Mock-New-EntraGroup.Tests.ps1 index e4763bbd5..a02deec85 100644 --- a/test/module/Entra/Mock-New-EntraGroup.Tests.ps1 +++ b/test/module/Entra/Mock-New-EntraGroup.Tests.ps1 @@ -21,7 +21,7 @@ BeforeAll { Describe "New-EntraGroup" { Context "Test for New-EntraGroup" { - It "Should return specific application" { + It "Should return created Group" { $result = New-EntraGroup -DisplayName "demo" -MailEnabled $false -SecurityEnabled $true -MailNickName "demoNickname" -Description "test" $result | Should -Not -BeNullOrEmpty $result.DisplayName | should -Be "demo" @@ -31,7 +31,7 @@ BeforeAll { Should -Invoke -CommandName New-MgGroup -ModuleName Microsoft.Graph.Entra -Times 1 } - It "Should fail when Description is empty" { + It "Should fail when parameters are empty" { { New-EntraGroup -DisplayName "" -MailEnabled -SecurityEnabled -MailNickName "" -Description "" } | Should -Throw "Missing an argument for parameter*" } } diff --git a/test/module/Entra/Mock-Remove-EntraGroup.Tests.ps1 b/test/module/Entra/Mock-Remove-EntraGroup.Tests.ps1 new file mode 100644 index 000000000..617bffd2e --- /dev/null +++ b/test/module/Entra/Mock-Remove-EntraGroup.Tests.ps1 @@ -0,0 +1,25 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ + Import-Module Microsoft.Graph.Entra + } + $scriptblock = { + param($args) + Write-Host "Mocking Remove-EntraGroup with parameters: $($args | ConvertTo-Json -Depth 3)" + return @() + } + Mock -CommandName Remove-MgGroup -MockWith $scriptBlock -ModuleName Microsoft.Graph.Entra + } + + Describe "Remove-EntraGroup" { + Context "Test for Remove-EntraGroup" { + It "Should return empty object" { + $result = Remove-EntraGroup -ObjectId 056b2531-005e-4f3e-be78-01a71ea30a04 + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName Remove-MgGroup -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when ObjectId is empty" { + { Set-EntraGroup -ObjectId "" } + } + } + } \ No newline at end of file diff --git a/test/module/Entra/Mock-Set-EntraGroup.Tests.ps1 b/test/module/Entra/Mock-Set-EntraGroup.Tests.ps1 new file mode 100644 index 000000000..e8d3779ac --- /dev/null +++ b/test/module/Entra/Mock-Set-EntraGroup.Tests.ps1 @@ -0,0 +1,25 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ + Import-Module Microsoft.Graph.Entra + } + $scriptblock = { + param($args) + Write-Host "Mocking Set-EntraGroup with parameters: $($args | ConvertTo-Json -Depth 3)" + return @() + } + Mock -CommandName Update-MgGroup -MockWith $scriptBlock -ModuleName Microsoft.Graph.Entra + } + + Describe "Set-EntraGroup" { + Context "Test for Set-EntraGroup" { + It "Should return empty object" { + $result = Set-EntraGroup -ObjectId 056b2531-005e-4f3e-be78-01a71ea30a04 -DisplayName "demo" -MailEnabled $false -SecurityEnabled $true -MailNickName "demoNickname" -Description "test" + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName Update-MgGroup -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when ObjectId is empty" { + { Set-EntraGroup -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + } + } + } \ No newline at end of file From 4c8b1dca2212257fdd3e478d1aace74231e5dce5 Mon Sep 17 00:00:00 2001 From: "Ashwini Karke (Perennial Systems Inc)" Date: Tue, 2 Apr 2024 18:03:34 +0530 Subject: [PATCH 05/40] test-Get-AzureADApplication --- coverage.xml | 7121 -------------------------------------------------- 1 file changed, 7121 deletions(-) delete mode 100644 coverage.xml diff --git a/coverage.xml b/coverage.xml deleted file mode 100644 index 9c9d48fa1..000000000 --- a/coverage.xml +++ /dev/null @@ -1,7121 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - From 1a8ff733a4da0feb85eef86f9d106f9e46726e19 Mon Sep 17 00:00:00 2001 From: v-uansari Date: Wed, 3 Apr 2024 17:10:14 +0530 Subject: [PATCH 06/40] added single test file for mock tests --- .gitignore | 2 ++ reportgenerator/ReportUnit.exe | Bin 0 -> 205312 bytes test/module/Entra/Entra.Tests.ps1 | 33 ++++++++++++++++++ .../Entra/Mock-Get-EntraApplication.Tests.ps1 | 5 ++- .../Mock-Get-EntraDirectoryRole.Tests.ps1 | 4 +-- .../Entra/Mock-Get-EntraGroup.Tests.ps1 | 4 +-- .../Entra/Mock-New-EntraGroup.Tests.ps1 | 4 +-- .../Entra/Mock-Remove-EntraGroup.Tests.ps1 | 4 +-- .../Entra/Mock-Set-EntraGroup.Tests.ps1 | 6 ++-- test/module/EntraBeta/EntraBeta.Tests.ps1 | 33 ++++++++++++++++++ 10 files changed, 81 insertions(+), 14 deletions(-) create mode 100644 reportgenerator/ReportUnit.exe create mode 100644 test/module/Entra/Entra.Tests.ps1 create mode 100644 test/module/EntraBeta/EntraBeta.Tests.ps1 diff --git a/.gitignore b/.gitignore index 746d6cb42..568f33205 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ /bin /.vscode /samples/test.ps1 +coverage.xml +/testreport diff --git a/reportgenerator/ReportUnit.exe b/reportgenerator/ReportUnit.exe new file mode 100644 index 0000000000000000000000000000000000000000..bfb952c08b91a5eba25585bc8f3b11c805530645 GIT binary patch literal 205312 zcmeFa31C#$bvJ%zB#riEB#>C_AdE4xHg*gcV?ZpH4H$z=yn{dk$QBy;jf5c>0%;aI zjh#AMvp9+EB>mDhU6Zug+Qe;>rc2ti$=9Yya(sUNb7MY&Z~j{+?&QuXBsa|YScCac_2=e( zB)0W)a|aF$XWGZS^g(a%aQptj(b4pH`@U4WH!<2iJlekT=3VWF(?hA=`udtHZPhzA z8M8H3W@de0&TiM*vnC#^jnx`61CUi|>^;}O-wyveLc31=afKTZ0zbdaDWoHw|H{m| zR~geJ|NUT1u+w;@nW zyz7Wp{3C2}Q(=xCF=pVCaT7!MQEiRMQ~uYosND1+H_9hHIAb+swUwLLu^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kzKhntv+3p2^)8 zzxlzr>Ddd<>sQ7n6(!G2OwZQqqxT*v!q&h4yDzJq3GZHxKYiKj0<@N8^Iz2KNxkYN z_YeNdG;`Vdx@KeMb2sZPcQ;*Jxc(3I?w_6M&&DG9v)`QS&;HUL<57KgTz~ImH#OUF zC)DNMR1C!|$PX4`Den7soBrzm&|hDpPk;S@FZFMeesj%+Yv;qYJBqAk7miyZ&L_6w z-&ev@HtRuHX?bAF!G#;Lf3@kKO3*5T&g%5ZiI8I@%#1BP5BIRGf&CoUw58-bJCkkK zvjnz}LVP!+@OEKdL*EmYw+mS5|4jC(p7;J*XD+!fAKrUR$@RlhEAjbKo?73N93U^m zW&jah#zpu)t5-tY2yv@^Ms+9CmHhjA$|_Y<9Y*B`Pd112S&M76?3Y=si@?6ts9BIA z*1vBBoL>|4l;slp0*T|0Ph`4U<19axlL7Zup>R(zGFhaEiPq24|M7tH;&Wxpm+^iw zJabkYn6J-knki_a7ybR!zxnrLA3T5bu=ccJ8TTF;J-oM8pPHDyH#zm-)ZW{-E{>es zTbp}4K6P*W;q+Af)ZQ2MxxF8p-nMmYd~UA(=9*sUdvbXkVd}{K3eeSW_;n16!s?`=6yL7KU^?35}ivmPg zyuGz48Rt`bue>-rGxKnAVjR;pIzBVA_mH*lc=pNM<4aTbr#pn_=-%+0`kt##JegIW zjnBF=TmR7$!CAj|eRlHckn&k8|n{F?H!-H zH1%})v-<4b+LOt%6BG40q4ECs!?}86P@$1SEueAG4;5e^JG6iV-7t2@DWnfjdj Date: Wed, 3 Apr 2024 17:12:15 +0530 Subject: [PATCH 07/40] update file --- test/module/Entra/Mock-Remove-EntraGroup.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/module/Entra/Mock-Remove-EntraGroup.Tests.ps1 b/test/module/Entra/Mock-Remove-EntraGroup.Tests.ps1 index a009b6058..5b530d075 100644 --- a/test/module/Entra/Mock-Remove-EntraGroup.Tests.ps1 +++ b/test/module/Entra/Mock-Remove-EntraGroup.Tests.ps1 @@ -19,7 +19,7 @@ BeforeAll { Should -Invoke -CommandName Remove-MgGroup -ModuleName Microsoft.Graph.Entra -Times 1 } It "Should fail when ObjectId is empty" { - { Set-EntraGroup -ObjectId "" } + { Remove-EntraGroup -ObjectId "" } } } } \ No newline at end of file From 57193f4d6deba0ddb50b8bfb771e3809d0e7d3e1 Mon Sep 17 00:00:00 2001 From: "Ashwini Karke (Perennial Systems Inc)" Date: Thu, 4 Apr 2024 17:19:10 +0530 Subject: [PATCH 08/40] Added validation for transformed parameters --- .../Entra/Mock-Get-EntraApplication.Tests.ps1 | 35 ++++++++++++++++++- .../Mock-Get-EntraDirectoryRole.Tests.ps1 | 18 +++++++++- .../Entra/Mock-Get-EntraGroup.Tests.ps1 | 32 +++++++++++++++++ .../Entra/Mock-Remove-EntraGroup.Tests.ps1 | 18 +++++++++- .../Entra/Mock-Set-EntraGroup.Tests.ps1 | 18 +++++++++- 5 files changed, 117 insertions(+), 4 deletions(-) diff --git a/test/module/Entra/Mock-Get-EntraApplication.Tests.ps1 b/test/module/Entra/Mock-Get-EntraApplication.Tests.ps1 index 2986d613d..dc4e7dd8c 100644 --- a/test/module/Entra/Mock-Get-EntraApplication.Tests.ps1 +++ b/test/module/Entra/Mock-Get-EntraApplication.Tests.ps1 @@ -72,6 +72,39 @@ BeforeAll { It "Result should Contain ObjectId" { $result = Get-EntraApplication -ObjectId "111cc9b5-fce9-485e-9566-c68debafac5f" $result.ObjectId | should -Be "111cc9b5-fce9-485e-9566-c68debafac5f" - } + } + It "Should contain ApplicationId in parameters when passed ObjectId to it" { + $scriptblock = { + param($args) + return $args + } + Mock -CommandName Get-MgApplication -MockWith $scriptBlock -ModuleName Microsoft.Graph.Entra + + $result = Get-EntraApplication -ObjectId "111cc9b5-fce9-485e-9566-c68debafac5f" + $params = @{} + $params = @{} + for ($i = 0; $i -lt $result.Length; $i += 2) { + $key = $result[$i] -replace '-', '' -replace ':', '' + $value = $result[$i + 1] + $params[$key] = $value + } + $params.GroupId | Should -Be "111cc9b5-fce9-485e-9566-c68debafac5f" + } + It "Should contain Filter in parameters when passed SearchString to it" { + $scriptblock = { + param($args) + return $args + } + Mock -CommandName Get-MgApplication -MockWith $scriptBlock -ModuleName Microsoft.Graph.Entra + + $result = Get-EntraApplication -SearchString 'Mock-App' + $params = @{} + for ($i = 0; $i -lt $result.Length; $i += 2) { + $key = $result[$i] -replace '-', '' -replace ':', '' + $value = $result[$i + 1] + $params[$key] = $value + } + $params.Filter | Should -Match "Mock-App" + } } } \ No newline at end of file diff --git a/test/module/Entra/Mock-Get-EntraDirectoryRole.Tests.ps1 b/test/module/Entra/Mock-Get-EntraDirectoryRole.Tests.ps1 index 0532e874b..042507818 100644 --- a/test/module/Entra/Mock-Get-EntraDirectoryRole.Tests.ps1 +++ b/test/module/Entra/Mock-Get-EntraDirectoryRole.Tests.ps1 @@ -42,6 +42,22 @@ BeforeAll { It "Result should Contain ObjectId" { $result = Get-EntraDirectoryRole -ObjectId "dc587a80-d49c-4700-a73b-57227856fc32" $result.ObjectId | should -Be "dc587a80-d49c-4700-a73b-57227856fc32" - } + } + It "Should contain DirectoryRoleId in parameters when passed ObjectId to it" { + $scriptblock = { + param($args) + return $args + } + Mock -CommandName Get-MgDirectoryRole -MockWith $scriptBlock -ModuleName Microsoft.Graph.Entra + + $result = Get-EntraDirectoryRole -ObjectId "dc587a80-d49c-4700-a73b-57227856fc32" + $params = @{} + for ($i = 0; $i -lt $result.Length; $i += 2) { + $key = $result[$i] -replace '-', '' -replace ':', '' + $value = $result[$i + 1] + $params[$key] = $value + } + $params.DirectoryRoleId | Should -Be "dc587a80-d49c-4700-a73b-57227856fc32" + } } } \ No newline at end of file diff --git a/test/module/Entra/Mock-Get-EntraGroup.Tests.ps1 b/test/module/Entra/Mock-Get-EntraGroup.Tests.ps1 index 6a80149dd..a2ded25e7 100644 --- a/test/module/Entra/Mock-Get-EntraGroup.Tests.ps1 +++ b/test/module/Entra/Mock-Get-EntraGroup.Tests.ps1 @@ -63,6 +63,38 @@ BeforeAll { It "Result should Contain ObjectId" { $result = Get-EntraGroup -ObjectId "056b2531-005e-4f3e-be78-01a71ea30a04" $result.ObjectId | should -Be "056b2531-005e-4f3e-be78-01a71ea30a04" + } + It "Should contain GroupId in parameters when passed ObjectId to it" { + $scriptblock = { + param($args) + return $args + } + Mock -CommandName Get-MgGroup -MockWith $scriptBlock -ModuleName Microsoft.Graph.Entra + + $result = Get-EntraGroup -ObjectId "056b2531-005e-4f3e-be78-01a71ea30a04" + $params = @{} + for ($i = 0; $i -lt $result.Length; $i += 2) { + $key = $result[$i] -replace '-', '' -replace ':', '' + $value = $result[$i + 1] + $params[$key] = $value + } + $params.GroupId | Should -Be "056b2531-005e-4f3e-be78-01a71ea30a04" + } + It "Should contain Filter in parameters when passed SearchString to it" { + $scriptblock = { + param($args) + return $args + } + Mock -CommandName Get-MgGroup -MockWith $scriptBlock -ModuleName Microsoft.Graph.Entra + + $result = Get-EntraGroup -SearchString 'demo' + $params = @{} + for ($i = 0; $i -lt $result.Length; $i += 2) { + $key = $result[$i] -replace '-', '' -replace ':', '' + $value = $result[$i + 1] + $params[$key] = $value + } + $params.Filter | Should -Match "demo" } } } \ No newline at end of file diff --git a/test/module/Entra/Mock-Remove-EntraGroup.Tests.ps1 b/test/module/Entra/Mock-Remove-EntraGroup.Tests.ps1 index 5b530d075..67c534a72 100644 --- a/test/module/Entra/Mock-Remove-EntraGroup.Tests.ps1 +++ b/test/module/Entra/Mock-Remove-EntraGroup.Tests.ps1 @@ -20,6 +20,22 @@ BeforeAll { } It "Should fail when ObjectId is empty" { { Remove-EntraGroup -ObjectId "" } - } + } + It "Should contain GroupId in parameters when passed ObjectId to it" { + $scriptblock = { + param($args) + return $args + } + Mock -CommandName Remove-MgGroup -MockWith $scriptBlock -ModuleName Microsoft.Graph.Entra + + $result = Remove-EntraGroup -ObjectId 056b2531-005e-4f3e-be78-01a71ea30a04 + $params = @{} + for ($i = 0; $i -lt $result.Length; $i += 2) { + $key = $result[$i] -replace '-', '' -replace ':', '' + $value = $result[$i + 1] + $params[$key] = $value + } + $params.GroupId | Should -Be "056b2531-005e-4f3e-be78-01a71ea30a04" + } } } \ No newline at end of file diff --git a/test/module/Entra/Mock-Set-EntraGroup.Tests.ps1 b/test/module/Entra/Mock-Set-EntraGroup.Tests.ps1 index 362cdac7d..2e8ba7910 100644 --- a/test/module/Entra/Mock-Set-EntraGroup.Tests.ps1 +++ b/test/module/Entra/Mock-Set-EntraGroup.Tests.ps1 @@ -20,6 +20,22 @@ BeforeAll { } It "Should fail when ObjectId is empty" { { Set-EntraGroup -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." - } + } + It "Should contain GroupId in parameters when passed ObjectId to it" { + $scriptblock = { + param($args) + return $args + } + Mock -CommandName Update-MgGroup -MockWith $scriptBlock -ModuleName Microsoft.Graph.Entra + + $result = Set-EntraGroup -ObjectId 056b2531-005e-4f3e-be78-01a71ea30a04 + $params = @{} + for ($i = 0; $i -lt $result.Length; $i += 2) { + $key = $result[$i] -replace '-', '' -replace ':', '' + $value = $result[$i + 1] + $params[$key] = $value + } + $params.GroupId | Should -Be "056b2531-005e-4f3e-be78-01a71ea30a04" + } } } \ No newline at end of file From 413ea967839dac3681ea2279f6c7171fe0f1eaeb Mon Sep 17 00:00:00 2001 From: "Ashwini Karke (Perennial Systems Inc)" Date: Fri, 5 Apr 2024 13:10:12 +0530 Subject: [PATCH 09/40] test-Get-AzureADApplication --- test/module/Entra/Mock-Get-EntraApplication.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/module/Entra/Mock-Get-EntraApplication.Tests.ps1 b/test/module/Entra/Mock-Get-EntraApplication.Tests.ps1 index dc4e7dd8c..13109b381 100644 --- a/test/module/Entra/Mock-Get-EntraApplication.Tests.ps1 +++ b/test/module/Entra/Mock-Get-EntraApplication.Tests.ps1 @@ -88,7 +88,7 @@ BeforeAll { $value = $result[$i + 1] $params[$key] = $value } - $params.GroupId | Should -Be "111cc9b5-fce9-485e-9566-c68debafac5f" + $params.ApplicationId | Should -Be "111cc9b5-fce9-485e-9566-c68debafac5f" } It "Should contain Filter in parameters when passed SearchString to it" { $scriptblock = { From ac5e2d0d2dd38e0665f7ee63926c6285ca1bcffa Mon Sep 17 00:00:00 2001 From: v-uansari Date: Fri, 5 Apr 2024 16:58:39 +0530 Subject: [PATCH 10/40] crud operation for entraApplication --- .../Entra/Mock-New-EntraApplication.Tests.ps1 | 47 +++++++++++++++++++ .../Mock-Remove-EntraApplication.Tests.ps1 | 41 ++++++++++++++++ .../Entra/Mock-Set-EntraApplication.Tests.ps1 | 41 ++++++++++++++++ 3 files changed, 129 insertions(+) create mode 100644 test/module/Entra/Mock-New-EntraApplication.Tests.ps1 create mode 100644 test/module/Entra/Mock-Remove-EntraApplication.Tests.ps1 create mode 100644 test/module/Entra/Mock-Set-EntraApplication.Tests.ps1 diff --git a/test/module/Entra/Mock-New-EntraApplication.Tests.ps1 b/test/module/Entra/Mock-New-EntraApplication.Tests.ps1 new file mode 100644 index 000000000..43fb3cadd --- /dev/null +++ b/test/module/Entra/Mock-New-EntraApplication.Tests.ps1 @@ -0,0 +1,47 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ + #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force + Import-Module Microsoft.Graph.Entra + } + $scriptblock = { + # Write-Host "Mocking New-MgApplication with parameters: $($args | ConvertTo-Json -Depth 3)" + return @( + [PSCustomObject]@{ + "AppId" = "5f783237-3457-45d8-93e7-a0edb1cfbfd1" + "DeletedDateTime" = $null + "Id" = "111cc9b5-fce9-485e-9566-c68debafac5f" + "DisplayName" = "Mock-App" + "Info" = @{LogoUrl=""; MarketingUrl=""; PrivacyStatementUrl=""; SupportUrl=""; TermsOfServiceUrl=""} + "IsDeviceOnlyAuthSupported" = $True + "IsFallbackPublicClient" = $true + "KeyCredentials" = @{CustomKeyIdentifier = @(211, 174, 247);DisplayName =""; Key="";KeyId="d903c7a3-75ea-4772-8935-5c0cf82068a7";Type="Symmetric";Usage="Sign"} + "OptionalClaims" = @{AccessToken=""; IdToken=""; Saml2Token=""} + "ParentalControlSettings" = @{CountriesBlockedForMinors=$null; LegalAgeGroupRule="Allow"} + "PasswordCredentials" = @{} + "PublicClient" = @{RedirectUris=$null} + "PublisherDomain" = "M365x99297270.onmicrosoft.com" + "SignInAudience" = "AzureADandPersonalMicrosoftAccount" + "Web" = @{HomePageUrl="https://localhost/demoapp"; ImplicitGrantSettings=""; LogoutUrl="";} + } + ) + } + Mock -CommandName New-MgApplication -MockWith $scriptBlock -ModuleName Microsoft.Graph.Entra +} + +Describe "New-EntraApplication"{ + Context "Test for New-EntraApplication" { + It "Should return created Application"{ + $result = New-EntraApplication -DisplayName "Mock-App" + $result | Should -Not -BeNullOrEmpty + $result.DisplayName | should -Be "Mock-App" + $result.IsDeviceOnlyAuthSupported | should -Be "True" + $result.IsFallbackPublicClient | should -Be "True" + $result.SignInAudience | should -Be "AzureADandPersonalMicrosoftAccount" + + Should -Invoke -CommandName New-MgApplication -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when DisplayName is empty" { + { New-EntraApplication -DisplayName "" } | Should -Throw "Cannot bind argument to parameter 'DisplayName' because it is an empty string." + } + } +} \ No newline at end of file diff --git a/test/module/Entra/Mock-Remove-EntraApplication.Tests.ps1 b/test/module/Entra/Mock-Remove-EntraApplication.Tests.ps1 new file mode 100644 index 000000000..ee5f3ceb0 --- /dev/null +++ b/test/module/Entra/Mock-Remove-EntraApplication.Tests.ps1 @@ -0,0 +1,41 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ + #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force + Import-Module Microsoft.Graph.Entra + } + $scriptblock = { + #Write-Host "Mocking Remove-MgApplication with parameters: $($args | ConvertTo-Json -Depth 3)" + return @() + } + Mock -CommandName Remove-MgApplication -MockWith $scriptBlock -ModuleName Microsoft.Graph.Entra +} + +Describe "Remove-EntraApplication" { + Context "Test for Remove-EntraApplication" { + It "Should return empty object" { + $result = Remove-EntraApplication -ObjectId 056b2531-005e-4f3e-be78-01a71ea30a04 + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName Remove-MgApplication -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when ObjectId is empty" { + { Remove-EntraApplication -ObjectId "" } + } + It "Should contain ApplicationId in parameters when passed ObjectId to it" { + $scriptblock = { + param($args) + return $args + } + Mock -CommandName Remove-MgApplication -MockWith $scriptBlock -ModuleName Microsoft.Graph.Entra + + $result = Remove-EntraApplication -ObjectId 056b2531-005e-4f3e-be78-01a71ea30a04 + $params = @{} + for ($i = 0; $i -lt $result.Length; $i += 2) { + $key = $result[$i] -replace '-', '' -replace ':', '' + $value = $result[$i + 1] + $params[$key] = $value + } + $params.ApplicationId | Should -Be "056b2531-005e-4f3e-be78-01a71ea30a04" + } + } +} \ No newline at end of file diff --git a/test/module/Entra/Mock-Set-EntraApplication.Tests.ps1 b/test/module/Entra/Mock-Set-EntraApplication.Tests.ps1 new file mode 100644 index 000000000..6f7e19053 --- /dev/null +++ b/test/module/Entra/Mock-Set-EntraApplication.Tests.ps1 @@ -0,0 +1,41 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ + #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force + Import-Module Microsoft.Graph.Entra + } + $scriptblock = { + # Write-Host "Mocking Update-MgApplication with parameters: $($args | ConvertTo-Json -Depth 3)" + return @() + } + Mock -CommandName Update-MgApplication -MockWith $scriptBlock -ModuleName Microsoft.Graph.Entra +} + +Describe "Set-EntraApplication"{ + Context "Test for Set-EntraApplication" { + It "Should return empty object"{ + $result = Set-EntraApplication -ObjectId 056b2531-005e-4f3e-be78-01a71ea30a04 -DisplayName "Mock-App" + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName Update-MgApplication -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when ObjectId is empty" { + { Set-EntraApplication -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + } + It "Should contain ApplicationId in parameters when passed ObjectId to it" { + $scriptblock = { + param($args) + return $args + } + Mock -CommandName Update-MgApplication -MockWith $scriptBlock -ModuleName Microsoft.Graph.Entra + + $result = Set-EntraApplication -ObjectId 056b2531-005e-4f3e-be78-01a71ea30a04 + $params = @{} + for ($i = 0; $i -lt $result.Length; $i += 2) { + $key = $result[$i] -replace '-', '' -replace ':', '' + $value = $result[$i + 1] + $params[$key] = $value + } + $params.ApplicationId | Should -Be "056b2531-005e-4f3e-be78-01a71ea30a04" + } + } +} \ No newline at end of file From 1038850e59704592d4fa775932f64e4aa65b2706 Mon Sep 17 00:00:00 2001 From: v-uansari Date: Mon, 8 Apr 2024 13:30:06 +0530 Subject: [PATCH 11/40] updated mock tests --- test/module/Common-Functions.ps1 | 19 ++++++ test/module/Entra/Entra.Tests.ps1 | 13 +--- .../Entra/Mock-Get-EntraApplication.Tests.ps1 | 47 ++++++++------- .../Mock-Get-EntraDirectoryRole.Tests.ps1 | 46 +++++++++------ .../Entra/Mock-Get-EntraGroup.Tests.ps1 | 59 +++++++++++-------- .../Entra/Mock-New-EntraApplication.Tests.ps1 | 20 ++++++- .../Entra/Mock-New-EntraGroup.Tests.ps1 | 43 ++++++++++---- .../Mock-Remove-EntraApplication.Tests.ps1 | 33 +++++++---- .../Entra/Mock-Remove-EntraGroup.Tests.ps1 | 41 +++++++------ .../Entra/Mock-Set-EntraApplication.Tests.ps1 | 36 ++++++----- .../Entra/Mock-Set-EntraGroup.Tests.ps1 | 38 +++++++----- test/module/EntraBeta/EntraBeta.Tests.ps1 | 13 +--- 12 files changed, 245 insertions(+), 163 deletions(-) create mode 100644 test/module/Common-Functions.ps1 diff --git a/test/module/Common-Functions.ps1 b/test/module/Common-Functions.ps1 new file mode 100644 index 000000000..a899a6355 --- /dev/null +++ b/test/module/Common-Functions.ps1 @@ -0,0 +1,19 @@ +$psVersion = $global:PSVersionTable.PSVersion +$entraVersion = (Get-module Microsoft.Graph.Entra | select version).Version.ToString() + +function Get-Parameters{ + param( + $data + ) + + PROCESS{ + $params = @{} + for ($i = 0; $i -lt $data.Length; $i += 2) { + $key = $data[$i] -replace '-', '' -replace ':', '' + $value = $data[$i + 1] + $params[$key] = $value + } + + $params + } +} \ No newline at end of file diff --git a/test/module/Entra/Entra.Tests.ps1 b/test/module/Entra/Entra.Tests.ps1 index fd25a9472..e9c35bb7a 100644 --- a/test/module/Entra/Entra.Tests.ps1 +++ b/test/module/Entra/Entra.Tests.ps1 @@ -16,18 +16,7 @@ $config.CodeCoverage.CoveragePercentTarget = 100 $config.CodeCoverage.Path = @('.\bin\Microsoft.Graph.Entra.psm1') $config.TestResult.Enabled = $true $config.TestResult.OutputPath = $testOutputFile -#$config.Output.Verbosity = "Detailed" Invoke-Pester -Configuration $config -# $results = Invoke-Pester -Script $mockScripts -EnableExit -OutputFile $testOutputFile -OutputFormat NUnitXml -PassThru -CodeCoverage .\bin\Microsoft.Graph.Entra.psm1 - -.\reportgenerator\ReportUnit.exe "$testOutputFile" - -# $results.CodeCoverage.HitCommands | ConvertTo-Html | Out-File -FilePath "$PSScriptRoot\artifacts\HitCommands.html" -# if($results.CodeCoverage.MissedCommands -ne $null){ $results.CodeCoverage.MissedCommands | ConvertTo-Html | Out-File -FilePath "$PSScriptRoot\artifacts\MissedCommands.html"} -# $results.CodeCoverage.AnalyzedFiles | Out-File -FilePath "$PSScriptRoot\artifacts\AnalyzedFiles.txt" - -# $Percentage = ($results.CodeCoverage.NumberOfCommandsExecuted / $results.CodeCoverage.NumberOfCommandsAnalyzed)*100 -# $results.CodeCoverage | Add-Member Percentage ($Percentage | % { '{0:0.##}' -f $_ }) -# $results.CodeCoverage | ConvertTo-Html | Out-File -FilePath "$PSScriptRoot\artifacts\CoverageReport.html" \ No newline at end of file +.\reportgenerator\ReportUnit.exe "$testOutputFile" \ No newline at end of file diff --git a/test/module/Entra/Mock-Get-EntraApplication.Tests.ps1 b/test/module/Entra/Mock-Get-EntraApplication.Tests.ps1 index 13109b381..399bbee1a 100644 --- a/test/module/Entra/Mock-Get-EntraApplication.Tests.ps1 +++ b/test/module/Entra/Mock-Get-EntraApplication.Tests.ps1 @@ -1,8 +1,10 @@ BeforeAll { if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force - Import-Module Microsoft.Graph.Entra + Import-Module Microsoft.Graph.Entra } + Import-Module .\test\module\Common-Functions.ps1 -Force + $scriptblock = { # Write-Host "Mocking Get-MgApplication with parameters: $($args | ConvertTo-Json -Depth 3)" return @( @@ -25,10 +27,10 @@ BeforeAll { } ) } - Mock -CommandName Get-MgApplication -MockWith $scriptBlock -ModuleName Microsoft.Graph.Entra - } + Mock -CommandName Get-MgApplication -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra +} - Describe "Get-EntraApplication" { +Describe "Get-EntraApplication" { Context "Test for Get-EntraApplication" { It "Should return specific application" { $result = Get-EntraApplication -ObjectId "111cc9b5-fce9-485e-9566-c68debafac5f" @@ -78,16 +80,10 @@ BeforeAll { param($args) return $args } - Mock -CommandName Get-MgApplication -MockWith $scriptBlock -ModuleName Microsoft.Graph.Entra + Mock -CommandName Get-MgApplication -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra $result = Get-EntraApplication -ObjectId "111cc9b5-fce9-485e-9566-c68debafac5f" - $params = @{} - $params = @{} - for ($i = 0; $i -lt $result.Length; $i += 2) { - $key = $result[$i] -replace '-', '' -replace ':', '' - $value = $result[$i + 1] - $params[$key] = $value - } + $params = Get-Parameters -data $result $params.ApplicationId | Should -Be "111cc9b5-fce9-485e-9566-c68debafac5f" } It "Should contain Filter in parameters when passed SearchString to it" { @@ -95,16 +91,25 @@ BeforeAll { param($args) return $args } - Mock -CommandName Get-MgApplication -MockWith $scriptBlock -ModuleName Microsoft.Graph.Entra + Mock -CommandName Get-MgApplication -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra $result = Get-EntraApplication -SearchString 'Mock-App' - $params = @{} - for ($i = 0; $i -lt $result.Length; $i += 2) { - $key = $result[$i] -replace '-', '' -replace ':', '' - $value = $result[$i + 1] - $params[$key] = $value - } + $params = Get-Parameters -data $result $params.Filter | Should -Match "Mock-App" - } + } + It "Should contain 'User-Agent' header" { + $scriptblock = { + param($args) + return $args + } + + Mock -CommandName Get-MgApplication -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra + + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraApplication" + + $result = Get-EntraApplication -SearchString 'Mock-App' + $params = Get-Parameters -data $result + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } } - } \ No newline at end of file +} \ No newline at end of file diff --git a/test/module/Entra/Mock-Get-EntraDirectoryRole.Tests.ps1 b/test/module/Entra/Mock-Get-EntraDirectoryRole.Tests.ps1 index 042507818..804084eab 100644 --- a/test/module/Entra/Mock-Get-EntraDirectoryRole.Tests.ps1 +++ b/test/module/Entra/Mock-Get-EntraDirectoryRole.Tests.ps1 @@ -1,23 +1,26 @@ BeforeAll { if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force - Import-Module Microsoft.Graph.Entra + Import-Module Microsoft.Graph.Entra } + Import-Module .\test\module\Common-Functions.ps1 -Force + $scriptblock = { # Write-Host "Mocking Get-EntraDirectoryRole with parameters: $($args | ConvertTo-Json -Depth 3)" return @( [PSCustomObject]@{ - "DeletedDateTime" = $null - "Description" = "Read custom security attribute keys and values for supported Microsoft Entra objects." - "DisplayName" = "Attribute Assignment Reader" - "Id" = "dc587a80-d49c-4700-a73b-57227856fc32" - "RoleTemplateId" = "ffd52fa5-98dc-465c-991d-fc073eb59f8f" - "Members" = $null - "ScopedMembers" = $null + "DeletedDateTime" = $null + "Description" = "Read custom security attribute keys and values for supported Microsoft Entra objects." + "DisplayName" = "Attribute Assignment Reader" + "Id" = "dc587a80-d49c-4700-a73b-57227856fc32" + "RoleTemplateId" = "ffd52fa5-98dc-465c-991d-fc073eb59f8f" + "Members" = $null + "ScopedMembers" = $null } ) - } - Mock -CommandName Get-MgDirectoryRole -MockWith $scriptBlock -ModuleName Microsoft.Graph.Entra + } + + Mock -CommandName Get-MgDirectoryRole -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra } Describe "Get-EntraDirectoryRole" { @@ -48,16 +51,25 @@ BeforeAll { param($args) return $args } - Mock -CommandName Get-MgDirectoryRole -MockWith $scriptBlock -ModuleName Microsoft.Graph.Entra + Mock -CommandName Get-MgDirectoryRole -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra $result = Get-EntraDirectoryRole -ObjectId "dc587a80-d49c-4700-a73b-57227856fc32" - $params = @{} - for ($i = 0; $i -lt $result.Length; $i += 2) { - $key = $result[$i] -replace '-', '' -replace ':', '' - $value = $result[$i + 1] - $params[$key] = $value - } + $params = Get-Parameters -data $result $params.DirectoryRoleId | Should -Be "dc587a80-d49c-4700-a73b-57227856fc32" + } + It "Should contain 'User-Agent' header" { + $scriptblock = { + param($args) + return $args + } + + Mock -CommandName Get-MgDirectoryRole -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra + + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraDirectoryRole" + + $result = Get-EntraDirectoryRole -ObjectId "dc587a80-d49c-4700-a73b-57227856fc32" + $params = Get-Parameters -data $result + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue } } } \ No newline at end of file diff --git a/test/module/Entra/Mock-Get-EntraGroup.Tests.ps1 b/test/module/Entra/Mock-Get-EntraGroup.Tests.ps1 index a2ded25e7..a7db5da27 100644 --- a/test/module/Entra/Mock-Get-EntraGroup.Tests.ps1 +++ b/test/module/Entra/Mock-Get-EntraGroup.Tests.ps1 @@ -1,25 +1,28 @@ BeforeAll { if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force - Import-Module Microsoft.Graph.Entra + Import-Module Microsoft.Graph.Entra } + Import-Module .\test\module\Common-Functions.ps1 -Force + $scriptblock = { # Write-Host "Mocking Get-EntraGroup with parameters: $($args | ConvertTo-Json -Depth 3)" return @( [PSCustomObject]@{ - "DisplayName" = "demo" - "Id" = "056b2531-005e-4f3e-be78-01a71ea30a04" - "MailEnabled" = "False" - "Description" = "test" - "MailNickname" = "demoNickname" - "SecurityEnabled" = "True" + "DisplayName" = "demo" + "Id" = "056b2531-005e-4f3e-be78-01a71ea30a04" + "MailEnabled" = "False" + "Description" = "test" + "MailNickname" = "demoNickname" + "SecurityEnabled" = "True" } ) - } - Mock -CommandName Get-MgGroup -MockWith $scriptBlock -ModuleName Microsoft.Graph.Entra + } + + Mock -CommandName Get-MgGroup -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra } - Describe "Get-EntraGroup" { +Describe "Get-EntraGroup" { Context "Test for Get-EntraGroup" { It "Should return specific group" { $result = Get-EntraGroup -ObjectId "056b2531-005e-4f3e-be78-01a71ea30a04" @@ -69,15 +72,10 @@ BeforeAll { param($args) return $args } - Mock -CommandName Get-MgGroup -MockWith $scriptBlock -ModuleName Microsoft.Graph.Entra + Mock -CommandName Get-MgGroup -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra $result = Get-EntraGroup -ObjectId "056b2531-005e-4f3e-be78-01a71ea30a04" - $params = @{} - for ($i = 0; $i -lt $result.Length; $i += 2) { - $key = $result[$i] -replace '-', '' -replace ':', '' - $value = $result[$i + 1] - $params[$key] = $value - } + $params = Get-Parameters -data $result $params.GroupId | Should -Be "056b2531-005e-4f3e-be78-01a71ea30a04" } It "Should contain Filter in parameters when passed SearchString to it" { @@ -85,16 +83,25 @@ BeforeAll { param($args) return $args } - Mock -CommandName Get-MgGroup -MockWith $scriptBlock -ModuleName Microsoft.Graph.Entra + Mock -CommandName Get-MgGroup -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra $result = Get-EntraGroup -SearchString 'demo' - $params = @{} - for ($i = 0; $i -lt $result.Length; $i += 2) { - $key = $result[$i] -replace '-', '' -replace ':', '' - $value = $result[$i + 1] - $params[$key] = $value - } + $params = Get-Parameters -data $result $params.Filter | Should -Match "demo" - } + } + It "Should contain 'User-Agent' header" { + $scriptblock = { + param($args) + return $args + } + + Mock -CommandName Get-MgGroup -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra + + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraGroup" + + $result = Get-EntraGroup -SearchString 'demo' + $params = Get-Parameters -data $result + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } } - } \ No newline at end of file +} \ No newline at end of file diff --git a/test/module/Entra/Mock-New-EntraApplication.Tests.ps1 b/test/module/Entra/Mock-New-EntraApplication.Tests.ps1 index 43fb3cadd..b13d223ef 100644 --- a/test/module/Entra/Mock-New-EntraApplication.Tests.ps1 +++ b/test/module/Entra/Mock-New-EntraApplication.Tests.ps1 @@ -1,8 +1,10 @@ BeforeAll { if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force - Import-Module Microsoft.Graph.Entra + Import-Module Microsoft.Graph.Entra } + Import-Module .\test\module\Common-Functions.ps1 -Force + $scriptblock = { # Write-Host "Mocking New-MgApplication with parameters: $($args | ConvertTo-Json -Depth 3)" return @( @@ -25,7 +27,7 @@ BeforeAll { } ) } - Mock -CommandName New-MgApplication -MockWith $scriptBlock -ModuleName Microsoft.Graph.Entra + Mock -CommandName New-MgApplication -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra } Describe "New-EntraApplication"{ @@ -43,5 +45,19 @@ Describe "New-EntraApplication"{ It "Should fail when DisplayName is empty" { { New-EntraApplication -DisplayName "" } | Should -Throw "Cannot bind argument to parameter 'DisplayName' because it is an empty string." } + It "Should contain 'User-Agent' header" { + $scriptblock = { + param($args) + return $args + } + + Mock -CommandName New-MgApplication -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra + + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion New-EntraApplication" + + $result = New-EntraApplication -DisplayName "Mock-App" + $params = Get-Parameters -data $result + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } } } \ No newline at end of file diff --git a/test/module/Entra/Mock-New-EntraGroup.Tests.ps1 b/test/module/Entra/Mock-New-EntraGroup.Tests.ps1 index 21a39c9de..70674ffd2 100644 --- a/test/module/Entra/Mock-New-EntraGroup.Tests.ps1 +++ b/test/module/Entra/Mock-New-EntraGroup.Tests.ps1 @@ -1,25 +1,28 @@ BeforeAll { if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force - Import-Module Microsoft.Graph.Entra + Import-Module Microsoft.Graph.Entra } + Import-Module .\test\module\Common-Functions.ps1 -Force + $scriptblock = { #Write-Host "Mocking New-EntraGroup with parameters: $($args | ConvertTo-Json -Depth 3)" return @( [PSCustomObject]@{ - "DisplayName" = "demo" - "Id" = "056b2531-005e-4f3e-be78-01a71ea30a04" - "MailEnabled" = "False" - "Description" = "test" - "MailNickname" = "demoNickname" - "SecurityEnabled" = "True" + "DisplayName" = "demo" + "Id" = "056b2531-005e-4f3e-be78-01a71ea30a04" + "MailEnabled" = "False" + "Description" = "test" + "MailNickname" = "demoNickname" + "SecurityEnabled" = "True" } ) - } - Mock -CommandName New-MgGroup -MockWith $scriptBlock -ModuleName Microsoft.Graph.Entra - } + } + + Mock -CommandName New-MgGroup -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra +} - Describe "New-EntraGroup" { +Describe "New-EntraGroup" { Context "Test for New-EntraGroup" { It "Should return created Group" { $result = New-EntraGroup -DisplayName "demo" -MailEnabled $false -SecurityEnabled $true -MailNickName "demoNickname" -Description "test" @@ -33,6 +36,20 @@ BeforeAll { } It "Should fail when parameters are empty" { { New-EntraGroup -DisplayName "" -MailEnabled -SecurityEnabled -MailNickName "" -Description "" } | Should -Throw "Missing an argument for parameter*" - } + } + It "Should contain 'User-Agent' header" { + $scriptblock = { + param($args) + return $args + } + + Mock -CommandName New-MgGroup -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra + + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion New-EntraGroup" + + $result = New-EntraGroup -DisplayName "demo" -MailEnabled $false -SecurityEnabled $true -MailNickName "demoNickname" + $params = Get-Parameters -data $result + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } } - } \ No newline at end of file +} \ No newline at end of file diff --git a/test/module/Entra/Mock-Remove-EntraApplication.Tests.ps1 b/test/module/Entra/Mock-Remove-EntraApplication.Tests.ps1 index ee5f3ceb0..993d9eb39 100644 --- a/test/module/Entra/Mock-Remove-EntraApplication.Tests.ps1 +++ b/test/module/Entra/Mock-Remove-EntraApplication.Tests.ps1 @@ -3,11 +3,9 @@ BeforeAll { #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force Import-Module Microsoft.Graph.Entra } - $scriptblock = { - #Write-Host "Mocking Remove-MgApplication with parameters: $($args | ConvertTo-Json -Depth 3)" - return @() - } - Mock -CommandName Remove-MgApplication -MockWith $scriptBlock -ModuleName Microsoft.Graph.Entra + Import-Module .\test\module\Common-Functions.ps1 -Force + + Mock -CommandName Remove-MgApplication -MockWith {} -ModuleName Microsoft.Graph.Entra } Describe "Remove-EntraApplication" { @@ -26,16 +24,25 @@ Describe "Remove-EntraApplication" { param($args) return $args } - Mock -CommandName Remove-MgApplication -MockWith $scriptBlock -ModuleName Microsoft.Graph.Entra + Mock -CommandName Remove-MgApplication -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra $result = Remove-EntraApplication -ObjectId 056b2531-005e-4f3e-be78-01a71ea30a04 - $params = @{} - for ($i = 0; $i -lt $result.Length; $i += 2) { - $key = $result[$i] -replace '-', '' -replace ':', '' - $value = $result[$i + 1] - $params[$key] = $value - } + $params = Get-Parameters -data $result $params.ApplicationId | Should -Be "056b2531-005e-4f3e-be78-01a71ea30a04" - } + } + It "Should contain 'User-Agent' header" { + $scriptblock = { + param($args) + return $args + } + + Mock -CommandName Remove-MgApplication -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra + + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraApplication" + + $result = Remove-EntraApplication -ObjectId 056b2531-005e-4f3e-be78-01a71ea30a04 + $params = Get-Parameters -data $result + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } } } \ No newline at end of file diff --git a/test/module/Entra/Mock-Remove-EntraGroup.Tests.ps1 b/test/module/Entra/Mock-Remove-EntraGroup.Tests.ps1 index 67c534a72..a5bc0dbe9 100644 --- a/test/module/Entra/Mock-Remove-EntraGroup.Tests.ps1 +++ b/test/module/Entra/Mock-Remove-EntraGroup.Tests.ps1 @@ -1,16 +1,14 @@ BeforeAll { if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force - Import-Module Microsoft.Graph.Entra + Import-Module Microsoft.Graph.Entra } - $scriptblock = { - #Write-Host "Mocking Remove-EntraGroup with parameters: $($args | ConvertTo-Json -Depth 3)" - return @() - } - Mock -CommandName Remove-MgGroup -MockWith $scriptBlock -ModuleName Microsoft.Graph.Entra - } + Import-Module .\test\module\Common-Functions.ps1 -Force + + Mock -CommandName Remove-MgGroup -MockWith {} -ModuleName Microsoft.Graph.Entra +} - Describe "Remove-EntraGroup" { +Describe "Remove-EntraGroup" { Context "Test for Remove-EntraGroup" { It "Should return empty object" { $result = Remove-EntraGroup -ObjectId 056b2531-005e-4f3e-be78-01a71ea30a04 @@ -26,16 +24,25 @@ BeforeAll { param($args) return $args } - Mock -CommandName Remove-MgGroup -MockWith $scriptBlock -ModuleName Microsoft.Graph.Entra + Mock -CommandName Remove-MgGroup -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra $result = Remove-EntraGroup -ObjectId 056b2531-005e-4f3e-be78-01a71ea30a04 - $params = @{} - for ($i = 0; $i -lt $result.Length; $i += 2) { - $key = $result[$i] -replace '-', '' -replace ':', '' - $value = $result[$i + 1] - $params[$key] = $value - } + $params = Get-Parameters -data $result $params.GroupId | Should -Be "056b2531-005e-4f3e-be78-01a71ea30a04" - } + } + It "Should contain 'User-Agent' header" { + $scriptblock = { + param($args) + return $args + } + + Mock -CommandName Remove-MgGroup -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra + + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraGroup" + + $result = Remove-EntraGroup -ObjectId 056b2531-005e-4f3e-be78-01a71ea30a04 + $params = Get-Parameters -data $result + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } } - } \ No newline at end of file +} \ No newline at end of file diff --git a/test/module/Entra/Mock-Set-EntraApplication.Tests.ps1 b/test/module/Entra/Mock-Set-EntraApplication.Tests.ps1 index 6f7e19053..eec1e15db 100644 --- a/test/module/Entra/Mock-Set-EntraApplication.Tests.ps1 +++ b/test/module/Entra/Mock-Set-EntraApplication.Tests.ps1 @@ -1,13 +1,11 @@ BeforeAll { if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force - Import-Module Microsoft.Graph.Entra + Import-Module Microsoft.Graph.Entra } - $scriptblock = { - # Write-Host "Mocking Update-MgApplication with parameters: $($args | ConvertTo-Json -Depth 3)" - return @() - } - Mock -CommandName Update-MgApplication -MockWith $scriptBlock -ModuleName Microsoft.Graph.Entra + Import-Module .\test\module\Common-Functions.ps1 -Force + + Mock -CommandName Update-MgApplication -MockWith {} -ModuleName Microsoft.Graph.Entra } Describe "Set-EntraApplication"{ @@ -25,17 +23,27 @@ Describe "Set-EntraApplication"{ $scriptblock = { param($args) return $args - } - Mock -CommandName Update-MgApplication -MockWith $scriptBlock -ModuleName Microsoft.Graph.Entra + } + + Mock -CommandName Update-MgApplication -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra $result = Set-EntraApplication -ObjectId 056b2531-005e-4f3e-be78-01a71ea30a04 - $params = @{} - for ($i = 0; $i -lt $result.Length; $i += 2) { - $key = $result[$i] -replace '-', '' -replace ':', '' - $value = $result[$i + 1] - $params[$key] = $value - } + $params = Get-Parameters -data $result $params.ApplicationId | Should -Be "056b2531-005e-4f3e-be78-01a71ea30a04" } + It "Should contain 'User-Agent' header" { + $scriptblock = { + param($args) + return $args + } + + Mock -CommandName Update-MgApplication -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra + + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Set-EntraApplication" + + $result = Set-EntraApplication -ObjectId 056b2531-005e-4f3e-be78-01a71ea30a04 + $params = Get-Parameters -data $result + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } } } \ No newline at end of file diff --git a/test/module/Entra/Mock-Set-EntraGroup.Tests.ps1 b/test/module/Entra/Mock-Set-EntraGroup.Tests.ps1 index 2e8ba7910..f1d75b86e 100644 --- a/test/module/Entra/Mock-Set-EntraGroup.Tests.ps1 +++ b/test/module/Entra/Mock-Set-EntraGroup.Tests.ps1 @@ -1,16 +1,14 @@ BeforeAll { if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force - Import-Module Microsoft.Graph.Entra + Import-Module Microsoft.Graph.Entra } - $scriptblock = { - #Write-Host "Mocking Set-EntraGroup with parameters: $($args | ConvertTo-Json -Depth 3)" - return @() - } - Mock -CommandName Update-MgGroup -MockWith $scriptBlock -ModuleName Microsoft.Graph.Entra - } + Import-Module .\test\module\Common-Functions.ps1 -Force + + Mock -CommandName Update-MgGroup -MockWith {} -ModuleName Microsoft.Graph.Entra +} - Describe "Set-EntraGroup" { +Describe "Set-EntraGroup" { Context "Test for Set-EntraGroup" { It "Should return empty object" { $result = Set-EntraGroup -ObjectId 056b2531-005e-4f3e-be78-01a71ea30a04 -DisplayName "demo" -MailEnabled $false -SecurityEnabled $true -MailNickName "demoNickname" -Description "test" @@ -26,16 +24,24 @@ BeforeAll { param($args) return $args } - Mock -CommandName Update-MgGroup -MockWith $scriptBlock -ModuleName Microsoft.Graph.Entra + Mock -CommandName Update-MgGroup -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra $result = Set-EntraGroup -ObjectId 056b2531-005e-4f3e-be78-01a71ea30a04 - $params = @{} - for ($i = 0; $i -lt $result.Length; $i += 2) { - $key = $result[$i] -replace '-', '' -replace ':', '' - $value = $result[$i + 1] - $params[$key] = $value - } + $params = Get-Parameters -data $result $params.GroupId | Should -Be "056b2531-005e-4f3e-be78-01a71ea30a04" } + It "Should contain 'User-Agent' header" { + $scriptblock = { + param($args) + return $args + } + Mock -CommandName Update-MgGroup -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra + + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Set-EntraGroup" + + $result = Set-EntraGroup -ObjectId 056b2531-005e-4f3e-be78-01a71ea30a04 + $params = Get-Parameters -data $result + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } } - } \ No newline at end of file +} \ No newline at end of file diff --git a/test/module/EntraBeta/EntraBeta.Tests.ps1 b/test/module/EntraBeta/EntraBeta.Tests.ps1 index c62e122f4..063a3047c 100644 --- a/test/module/EntraBeta/EntraBeta.Tests.ps1 +++ b/test/module/EntraBeta/EntraBeta.Tests.ps1 @@ -16,18 +16,7 @@ $config.CodeCoverage.CoveragePercentTarget = 100 $config.CodeCoverage.Path = @('.\bin\Microsoft.Graph.Entra.Beta.psm1') $config.TestResult.Enabled = $true $config.TestResult.OutputPath = $testOutputFile -#$config.Output.Verbosity = "Detailed" Invoke-Pester -Configuration $config -# $results = Invoke-Pester -Script $mockScripts -EnableExit -OutputFile $testOutputFile -OutputFormat NUnitXml -PassThru -CodeCoverage .\bin\Microsoft.Graph.Entra.psm1 - -.\reportgenerator\ReportUnit.exe "$testOutputFile" - -# $results.CodeCoverage.HitCommands | ConvertTo-Html | Out-File -FilePath "$PSScriptRoot\artifacts\HitCommands.html" -# if($results.CodeCoverage.MissedCommands -ne $null){ $results.CodeCoverage.MissedCommands | ConvertTo-Html | Out-File -FilePath "$PSScriptRoot\artifacts\MissedCommands.html"} -# $results.CodeCoverage.AnalyzedFiles | Out-File -FilePath "$PSScriptRoot\artifacts\AnalyzedFiles.txt" - -# $Percentage = ($results.CodeCoverage.NumberOfCommandsExecuted / $results.CodeCoverage.NumberOfCommandsAnalyzed)*100 -# $results.CodeCoverage | Add-Member Percentage ($Percentage | % { '{0:0.##}' -f $_ }) -# $results.CodeCoverage | ConvertTo-Html | Out-File -FilePath "$PSScriptRoot\artifacts\CoverageReport.html" \ No newline at end of file +.\reportgenerator\ReportUnit.exe "$testOutputFile" \ No newline at end of file From a2a905011365ebefa994c465905d1d6b463eeca0 Mon Sep 17 00:00:00 2001 From: v-uansari Date: Mon, 8 Apr 2024 15:11:48 +0530 Subject: [PATCH 12/40] mock test updates --- test/module/Entra/Entra.Tests.ps1 | 2 ++ .../Entra/Mock-Get-EntraApplication.Tests.ps1 | 31 +++++++------------ .../Mock-Get-EntraDirectoryRole.Tests.ps1 | 22 ++++++------- .../Entra/Mock-Get-EntraGroup.Tests.ps1 | 24 +++++--------- .../Entra/Mock-New-EntraApplication.Tests.ps1 | 15 ++++----- .../Entra/Mock-New-EntraGroup.Tests.ps1 | 14 ++++----- .../Mock-Remove-EntraApplication.Tests.ps1 | 20 +++++------- .../Entra/Mock-Remove-EntraGroup.Tests.ps1 | 18 +++++------ .../Entra/Mock-Set-EntraApplication.Tests.ps1 | 19 +++++------- .../Entra/Mock-Set-EntraGroup.Tests.ps1 | 17 +++++----- 10 files changed, 75 insertions(+), 107 deletions(-) diff --git a/test/module/Entra/Entra.Tests.ps1 b/test/module/Entra/Entra.Tests.ps1 index e9c35bb7a..bdc1d3d90 100644 --- a/test/module/Entra/Entra.Tests.ps1 +++ b/test/module/Entra/Entra.Tests.ps1 @@ -1,4 +1,5 @@ Import-Module Pester +Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force $testOutputFile = ".\TestReport\Entra\TestResults.xml" @@ -16,6 +17,7 @@ $config.CodeCoverage.CoveragePercentTarget = 100 $config.CodeCoverage.Path = @('.\bin\Microsoft.Graph.Entra.psm1') $config.TestResult.Enabled = $true $config.TestResult.OutputPath = $testOutputFile +$config.Output.Verbosity = "Detailed" Invoke-Pester -Configuration $config diff --git a/test/module/Entra/Mock-Get-EntraApplication.Tests.ps1 b/test/module/Entra/Mock-Get-EntraApplication.Tests.ps1 index 399bbee1a..b27faa174 100644 --- a/test/module/Entra/Mock-Get-EntraApplication.Tests.ps1 +++ b/test/module/Entra/Mock-Get-EntraApplication.Tests.ps1 @@ -26,7 +26,13 @@ BeforeAll { "Web" = @{HomePageUrl="https://localhost/demoapp"; ImplicitGrantSettings=""; LogoutUrl="";} } ) - } + } + + $argsBlock = { + param($args) + return $args + } + Mock -CommandName Get-MgApplication -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra } @@ -75,35 +81,22 @@ Describe "Get-EntraApplication" { $result = Get-EntraApplication -ObjectId "111cc9b5-fce9-485e-9566-c68debafac5f" $result.ObjectId | should -Be "111cc9b5-fce9-485e-9566-c68debafac5f" } - It "Should contain ApplicationId in parameters when passed ObjectId to it" { - $scriptblock = { - param($args) - return $args - } - Mock -CommandName Get-MgApplication -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra + It "Should contain ApplicationId in parameters when passed ObjectId to it" { + Mock -CommandName Get-MgApplication -MockWith $argsBlock -ModuleName Microsoft.Graph.Entra $result = Get-EntraApplication -ObjectId "111cc9b5-fce9-485e-9566-c68debafac5f" $params = Get-Parameters -data $result $params.ApplicationId | Should -Be "111cc9b5-fce9-485e-9566-c68debafac5f" } - It "Should contain Filter in parameters when passed SearchString to it" { - $scriptblock = { - param($args) - return $args - } - Mock -CommandName Get-MgApplication -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra + It "Should contain Filter in parameters when passed SearchString to it" { + Mock -CommandName Get-MgApplication -MockWith $argsBlock -ModuleName Microsoft.Graph.Entra $result = Get-EntraApplication -SearchString 'Mock-App' $params = Get-Parameters -data $result $params.Filter | Should -Match "Mock-App" } It "Should contain 'User-Agent' header" { - $scriptblock = { - param($args) - return $args - } - - Mock -CommandName Get-MgApplication -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra + Mock -CommandName Get-MgApplication -MockWith $argsBlock -ModuleName Microsoft.Graph.Entra $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraApplication" diff --git a/test/module/Entra/Mock-Get-EntraDirectoryRole.Tests.ps1 b/test/module/Entra/Mock-Get-EntraDirectoryRole.Tests.ps1 index 804084eab..26b1d524b 100644 --- a/test/module/Entra/Mock-Get-EntraDirectoryRole.Tests.ps1 +++ b/test/module/Entra/Mock-Get-EntraDirectoryRole.Tests.ps1 @@ -18,7 +18,12 @@ BeforeAll { "ScopedMembers" = $null } ) - } + } + + $argsBlock = { + param($args) + return $args + } Mock -CommandName Get-MgDirectoryRole -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra } @@ -46,24 +51,15 @@ BeforeAll { $result = Get-EntraDirectoryRole -ObjectId "dc587a80-d49c-4700-a73b-57227856fc32" $result.ObjectId | should -Be "dc587a80-d49c-4700-a73b-57227856fc32" } - It "Should contain DirectoryRoleId in parameters when passed ObjectId to it" { - $scriptblock = { - param($args) - return $args - } - Mock -CommandName Get-MgDirectoryRole -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra + It "Should contain DirectoryRoleId in parameters when passed ObjectId to it" { + Mock -CommandName Get-MgDirectoryRole -MockWith $argsBlock -ModuleName Microsoft.Graph.Entra $result = Get-EntraDirectoryRole -ObjectId "dc587a80-d49c-4700-a73b-57227856fc32" $params = Get-Parameters -data $result $params.DirectoryRoleId | Should -Be "dc587a80-d49c-4700-a73b-57227856fc32" } It "Should contain 'User-Agent' header" { - $scriptblock = { - param($args) - return $args - } - - Mock -CommandName Get-MgDirectoryRole -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra + Mock -CommandName Get-MgDirectoryRole -MockWith $argsBlock -ModuleName Microsoft.Graph.Entra $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraDirectoryRole" diff --git a/test/module/Entra/Mock-Get-EntraGroup.Tests.ps1 b/test/module/Entra/Mock-Get-EntraGroup.Tests.ps1 index a7db5da27..380b06caa 100644 --- a/test/module/Entra/Mock-Get-EntraGroup.Tests.ps1 +++ b/test/module/Entra/Mock-Get-EntraGroup.Tests.ps1 @@ -19,6 +19,11 @@ BeforeAll { ) } + $argsBlock = { + param($args) + return $args + } + Mock -CommandName Get-MgGroup -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra } @@ -68,34 +73,21 @@ Describe "Get-EntraGroup" { $result.ObjectId | should -Be "056b2531-005e-4f3e-be78-01a71ea30a04" } It "Should contain GroupId in parameters when passed ObjectId to it" { - $scriptblock = { - param($args) - return $args - } - Mock -CommandName Get-MgGroup -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra + Mock -CommandName Get-MgGroup -MockWith $argsBlock -ModuleName Microsoft.Graph.Entra $result = Get-EntraGroup -ObjectId "056b2531-005e-4f3e-be78-01a71ea30a04" $params = Get-Parameters -data $result $params.GroupId | Should -Be "056b2531-005e-4f3e-be78-01a71ea30a04" } It "Should contain Filter in parameters when passed SearchString to it" { - $scriptblock = { - param($args) - return $args - } - Mock -CommandName Get-MgGroup -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra + Mock -CommandName Get-MgGroup -MockWith $argsBlock -ModuleName Microsoft.Graph.Entra $result = Get-EntraGroup -SearchString 'demo' $params = Get-Parameters -data $result $params.Filter | Should -Match "demo" } It "Should contain 'User-Agent' header" { - $scriptblock = { - param($args) - return $args - } - - Mock -CommandName Get-MgGroup -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra + Mock -CommandName Get-MgGroup -MockWith $argsBlock -ModuleName Microsoft.Graph.Entra $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraGroup" diff --git a/test/module/Entra/Mock-New-EntraApplication.Tests.ps1 b/test/module/Entra/Mock-New-EntraApplication.Tests.ps1 index b13d223ef..d1c2c3232 100644 --- a/test/module/Entra/Mock-New-EntraApplication.Tests.ps1 +++ b/test/module/Entra/Mock-New-EntraApplication.Tests.ps1 @@ -26,7 +26,13 @@ BeforeAll { "Web" = @{HomePageUrl="https://localhost/demoapp"; ImplicitGrantSettings=""; LogoutUrl="";} } ) - } + } + + $argsBlock = { + param($args) + return $args + } + Mock -CommandName New-MgApplication -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra } @@ -46,12 +52,7 @@ Describe "New-EntraApplication"{ { New-EntraApplication -DisplayName "" } | Should -Throw "Cannot bind argument to parameter 'DisplayName' because it is an empty string." } It "Should contain 'User-Agent' header" { - $scriptblock = { - param($args) - return $args - } - - Mock -CommandName New-MgApplication -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra + Mock -CommandName New-MgApplication -MockWith $argsBlock -ModuleName Microsoft.Graph.Entra $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion New-EntraApplication" diff --git a/test/module/Entra/Mock-New-EntraGroup.Tests.ps1 b/test/module/Entra/Mock-New-EntraGroup.Tests.ps1 index 70674ffd2..ec0352d93 100644 --- a/test/module/Entra/Mock-New-EntraGroup.Tests.ps1 +++ b/test/module/Entra/Mock-New-EntraGroup.Tests.ps1 @@ -17,7 +17,12 @@ BeforeAll { "SecurityEnabled" = "True" } ) - } + } + + $argsBlock = { + param($args) + return $args + } Mock -CommandName New-MgGroup -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra } @@ -38,12 +43,7 @@ Describe "New-EntraGroup" { { New-EntraGroup -DisplayName "" -MailEnabled -SecurityEnabled -MailNickName "" -Description "" } | Should -Throw "Missing an argument for parameter*" } It "Should contain 'User-Agent' header" { - $scriptblock = { - param($args) - return $args - } - - Mock -CommandName New-MgGroup -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra + Mock -CommandName New-MgGroup -MockWith $argsBlock -ModuleName Microsoft.Graph.Entra $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion New-EntraGroup" diff --git a/test/module/Entra/Mock-Remove-EntraApplication.Tests.ps1 b/test/module/Entra/Mock-Remove-EntraApplication.Tests.ps1 index 993d9eb39..fbdcae33e 100644 --- a/test/module/Entra/Mock-Remove-EntraApplication.Tests.ps1 +++ b/test/module/Entra/Mock-Remove-EntraApplication.Tests.ps1 @@ -3,7 +3,12 @@ BeforeAll { #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force Import-Module Microsoft.Graph.Entra } - Import-Module .\test\module\Common-Functions.ps1 -Force + Import-Module .\test\module\Common-Functions.ps1 -Force + + $argsBlock = { + param($args) + return $args + } Mock -CommandName Remove-MgApplication -MockWith {} -ModuleName Microsoft.Graph.Entra } @@ -20,23 +25,14 @@ Describe "Remove-EntraApplication" { { Remove-EntraApplication -ObjectId "" } } It "Should contain ApplicationId in parameters when passed ObjectId to it" { - $scriptblock = { - param($args) - return $args - } - Mock -CommandName Remove-MgApplication -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra + Mock -CommandName Remove-MgApplication -MockWith $argsBlock -ModuleName Microsoft.Graph.Entra $result = Remove-EntraApplication -ObjectId 056b2531-005e-4f3e-be78-01a71ea30a04 $params = Get-Parameters -data $result $params.ApplicationId | Should -Be "056b2531-005e-4f3e-be78-01a71ea30a04" } It "Should contain 'User-Agent' header" { - $scriptblock = { - param($args) - return $args - } - - Mock -CommandName Remove-MgApplication -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra + Mock -CommandName Remove-MgApplication -MockWith $argsBlock -ModuleName Microsoft.Graph.Entra $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraApplication" diff --git a/test/module/Entra/Mock-Remove-EntraGroup.Tests.ps1 b/test/module/Entra/Mock-Remove-EntraGroup.Tests.ps1 index a5bc0dbe9..648b63ff9 100644 --- a/test/module/Entra/Mock-Remove-EntraGroup.Tests.ps1 +++ b/test/module/Entra/Mock-Remove-EntraGroup.Tests.ps1 @@ -4,6 +4,11 @@ BeforeAll { Import-Module Microsoft.Graph.Entra } Import-Module .\test\module\Common-Functions.ps1 -Force + + $argsBlock = { + param($args) + return $args + } Mock -CommandName Remove-MgGroup -MockWith {} -ModuleName Microsoft.Graph.Entra } @@ -20,23 +25,14 @@ Describe "Remove-EntraGroup" { { Remove-EntraGroup -ObjectId "" } } It "Should contain GroupId in parameters when passed ObjectId to it" { - $scriptblock = { - param($args) - return $args - } - Mock -CommandName Remove-MgGroup -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra + Mock -CommandName Remove-MgGroup -MockWith $argsBlock -ModuleName Microsoft.Graph.Entra $result = Remove-EntraGroup -ObjectId 056b2531-005e-4f3e-be78-01a71ea30a04 $params = Get-Parameters -data $result $params.GroupId | Should -Be "056b2531-005e-4f3e-be78-01a71ea30a04" } It "Should contain 'User-Agent' header" { - $scriptblock = { - param($args) - return $args - } - - Mock -CommandName Remove-MgGroup -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra + Mock -CommandName Remove-MgGroup -MockWith $argsBlock -ModuleName Microsoft.Graph.Entra $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraGroup" diff --git a/test/module/Entra/Mock-Set-EntraApplication.Tests.ps1 b/test/module/Entra/Mock-Set-EntraApplication.Tests.ps1 index eec1e15db..7033219ac 100644 --- a/test/module/Entra/Mock-Set-EntraApplication.Tests.ps1 +++ b/test/module/Entra/Mock-Set-EntraApplication.Tests.ps1 @@ -4,6 +4,11 @@ BeforeAll { Import-Module Microsoft.Graph.Entra } Import-Module .\test\module\Common-Functions.ps1 -Force + + $argsBlock = { + param($args) + return $args + } Mock -CommandName Update-MgApplication -MockWith {} -ModuleName Microsoft.Graph.Entra } @@ -20,24 +25,14 @@ Describe "Set-EntraApplication"{ { Set-EntraApplication -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." } It "Should contain ApplicationId in parameters when passed ObjectId to it" { - $scriptblock = { - param($args) - return $args - } - - Mock -CommandName Update-MgApplication -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra + Mock -CommandName Update-MgApplication -MockWith $argsBlock -ModuleName Microsoft.Graph.Entra $result = Set-EntraApplication -ObjectId 056b2531-005e-4f3e-be78-01a71ea30a04 $params = Get-Parameters -data $result $params.ApplicationId | Should -Be "056b2531-005e-4f3e-be78-01a71ea30a04" } It "Should contain 'User-Agent' header" { - $scriptblock = { - param($args) - return $args - } - - Mock -CommandName Update-MgApplication -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra + Mock -CommandName Update-MgApplication -MockWith $argsBlock -ModuleName Microsoft.Graph.Entra $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Set-EntraApplication" diff --git a/test/module/Entra/Mock-Set-EntraGroup.Tests.ps1 b/test/module/Entra/Mock-Set-EntraGroup.Tests.ps1 index f1d75b86e..cd02acc17 100644 --- a/test/module/Entra/Mock-Set-EntraGroup.Tests.ps1 +++ b/test/module/Entra/Mock-Set-EntraGroup.Tests.ps1 @@ -4,6 +4,11 @@ BeforeAll { Import-Module Microsoft.Graph.Entra } Import-Module .\test\module\Common-Functions.ps1 -Force + + $argsBlock = { + param($args) + return $args + } Mock -CommandName Update-MgGroup -MockWith {} -ModuleName Microsoft.Graph.Entra } @@ -20,22 +25,14 @@ Describe "Set-EntraGroup" { { Set-EntraGroup -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." } It "Should contain GroupId in parameters when passed ObjectId to it" { - $scriptblock = { - param($args) - return $args - } - Mock -CommandName Update-MgGroup -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra + Mock -CommandName Update-MgGroup -MockWith $argsBlock -ModuleName Microsoft.Graph.Entra $result = Set-EntraGroup -ObjectId 056b2531-005e-4f3e-be78-01a71ea30a04 $params = Get-Parameters -data $result $params.GroupId | Should -Be "056b2531-005e-4f3e-be78-01a71ea30a04" } It "Should contain 'User-Agent' header" { - $scriptblock = { - param($args) - return $args - } - Mock -CommandName Update-MgGroup -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra + Mock -CommandName Update-MgGroup -MockWith $argsBlock -ModuleName Microsoft.Graph.Entra $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Set-EntraGroup" From 49a3c30e30bdb7cfdcbf15f2d38d2b12e5bd5856 Mon Sep 17 00:00:00 2001 From: v-uansari Date: Tue, 9 Apr 2024 12:58:54 +0530 Subject: [PATCH 13/40] mock tests update --- test/module/Entra/Entra.Tests.ps1 | 18 +-- .../Mock-Enable-EntraDirectoryRole.Tests.ps1 | 32 +++++ .../Entra/Mock-Get-EntraApplication.Tests.ps1 | 11 +- .../Entra/Mock-Get-EntraDevice.Tests.ps1 | 117 ++++++++++++++++++ .../Mock-Get-EntraDirectoryRole.Tests.ps1 | 9 +- .../Entra/Mock-Get-EntraGroup.Tests.ps1 | 11 +- .../Entra/Mock-New-EntraApplication.Tests.ps1 | 7 +- .../Entra/Mock-New-EntraGroup.Tests.ps1 | 7 +- .../Mock-Remove-EntraApplication.Tests.ps1 | 9 +- .../Entra/Mock-Remove-EntraGroup.Tests.ps1 | 9 +- .../Entra/Mock-Set-EntraApplication.Tests.ps1 | 9 +- .../Entra/Mock-Set-EntraGroup.Tests.ps1 | 9 +- test/module/EntraBeta/EntraBeta.Tests.ps1 | 18 ++- 13 files changed, 190 insertions(+), 76 deletions(-) create mode 100644 test/module/Entra/Mock-Enable-EntraDirectoryRole.Tests.ps1 create mode 100644 test/module/Entra/Mock-Get-EntraDevice.Tests.ps1 diff --git a/test/module/Entra/Entra.Tests.ps1 b/test/module/Entra/Entra.Tests.ps1 index bdc1d3d90..d50af2994 100644 --- a/test/module/Entra/Entra.Tests.ps1 +++ b/test/module/Entra/Entra.Tests.ps1 @@ -1,12 +1,16 @@ -Import-Module Pester -Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force +$modulePath = join-path $psscriptroot "..\..\..\bin\Microsoft.Graph.Entra.psm1" +$testReportPath = join-path $psscriptroot "..\..\..\TestReport\Entra" +$mockScriptsPath = join-path $psscriptroot "..\..\..\test\module\Entra\Mock-*.Tests.ps1" + -$testOutputFile = ".\TestReport\Entra\TestResults.xml" +Import-Module Pester +Import-Module $modulePath -Force +#Import-Module Microsoft.Graph.Entra -$reportFolder = ".\TestReport\Entra" -if (!(test-path -path $reportFolder)) {new-item -path $reportFolder -itemtype directory} +$testOutputFile = "$testReportPath\TestResults.xml" +if (!(test-path -path $testReportPath)) {new-item -path $testReportPath -itemtype directory} -$mockScripts = Get-ChildItem -Path ".\test\module\Entra\Mock-*.Tests.ps1" | ForEach-Object { $_.FullName } +$mockScripts = Get-ChildItem -Path $mockScriptsPath | ForEach-Object { $_.FullName } $config = New-PesterConfiguration $config.Run.Path = $mockScripts @@ -14,7 +18,7 @@ $config.Run.PassThru = $true $config.Run.Exit = $true $config.CodeCoverage.Enabled = $true $config.CodeCoverage.CoveragePercentTarget = 100 -$config.CodeCoverage.Path = @('.\bin\Microsoft.Graph.Entra.psm1') +$config.CodeCoverage.Path = $modulePath $config.TestResult.Enabled = $true $config.TestResult.OutputPath = $testOutputFile $config.Output.Verbosity = "Detailed" diff --git a/test/module/Entra/Mock-Enable-EntraDirectoryRole.Tests.ps1 b/test/module/Entra/Mock-Enable-EntraDirectoryRole.Tests.ps1 new file mode 100644 index 000000000..c1e958b6d --- /dev/null +++ b/test/module/Entra/Mock-Enable-EntraDirectoryRole.Tests.ps1 @@ -0,0 +1,32 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ + #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force + Import-Module Microsoft.Graph.Entra + } + Import-Module .\test\module\Common-Functions.ps1 -Force + + Mock -CommandName New-MgDirectoryRole -MockWith {} -ModuleName Microsoft.Graph.Entra +} + +Describe "Enable-EntraDirectoryRole" { + Context "Test for Enable-EntraDirectoryRole" { + It "Should return empty object" { + $result = Enable-EntraDirectoryRole -RoleTemplateId 056b2531-005e-4f3e-be78-01a71ea30a04 + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName New-MgDirectoryRole -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when RoleTemplateId is empty" { + { Enable-EntraDirectoryRole -RoleTemplateId "" } + } + It "Should contain 'User-Agent' header" { + Mock -CommandName New-MgDirectoryRole -MockWith { $args } -ModuleName Microsoft.Graph.Entra + + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Enable-EntraDirectoryRole" + + $result = Enable-EntraDirectoryRole -RoleTemplateId 056b2531-005e-4f3e-be78-01a71ea30a04 + $params = Get-Parameters -data $result + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } + } +} \ No newline at end of file diff --git a/test/module/Entra/Mock-Get-EntraApplication.Tests.ps1 b/test/module/Entra/Mock-Get-EntraApplication.Tests.ps1 index b27faa174..d48cc7500 100644 --- a/test/module/Entra/Mock-Get-EntraApplication.Tests.ps1 +++ b/test/module/Entra/Mock-Get-EntraApplication.Tests.ps1 @@ -26,11 +26,6 @@ BeforeAll { "Web" = @{HomePageUrl="https://localhost/demoapp"; ImplicitGrantSettings=""; LogoutUrl="";} } ) - } - - $argsBlock = { - param($args) - return $args } Mock -CommandName Get-MgApplication -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra @@ -82,21 +77,21 @@ Describe "Get-EntraApplication" { $result.ObjectId | should -Be "111cc9b5-fce9-485e-9566-c68debafac5f" } It "Should contain ApplicationId in parameters when passed ObjectId to it" { - Mock -CommandName Get-MgApplication -MockWith $argsBlock -ModuleName Microsoft.Graph.Entra + Mock -CommandName Get-MgApplication -MockWith {$args} -ModuleName Microsoft.Graph.Entra $result = Get-EntraApplication -ObjectId "111cc9b5-fce9-485e-9566-c68debafac5f" $params = Get-Parameters -data $result $params.ApplicationId | Should -Be "111cc9b5-fce9-485e-9566-c68debafac5f" } It "Should contain Filter in parameters when passed SearchString to it" { - Mock -CommandName Get-MgApplication -MockWith $argsBlock -ModuleName Microsoft.Graph.Entra + Mock -CommandName Get-MgApplication -MockWith {$args} -ModuleName Microsoft.Graph.Entra $result = Get-EntraApplication -SearchString 'Mock-App' $params = Get-Parameters -data $result $params.Filter | Should -Match "Mock-App" } It "Should contain 'User-Agent' header" { - Mock -CommandName Get-MgApplication -MockWith $argsBlock -ModuleName Microsoft.Graph.Entra + Mock -CommandName Get-MgApplication -MockWith {$args} -ModuleName Microsoft.Graph.Entra $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraApplication" diff --git a/test/module/Entra/Mock-Get-EntraDevice.Tests.ps1 b/test/module/Entra/Mock-Get-EntraDevice.Tests.ps1 new file mode 100644 index 000000000..3a34922f6 --- /dev/null +++ b/test/module/Entra/Mock-Get-EntraDevice.Tests.ps1 @@ -0,0 +1,117 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ + #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force + Import-Module Microsoft.Graph.Entra + } + Import-Module .\test\module\Common-Functions.ps1 -Force + + $scriptblock = { + # Write-Host "Mocking Get-MgDevice with parameters: $($args | ConvertTo-Json -Depth 3)" + return @( + [PSCustomObject]@{ + "ComplianceExpirationDateTime" = $null + "AccountEnabled" = $true + "ApproximateLastSignInDateTime" = $null + "DeletedDateTime" = $null + "DeviceCategory" = $null + "DeviceId" = "6e9d44e6-f191-4957-bb31-c52f33817204" + "DeviceMetadata" = "MetaData" + "DeviceOwnership" = $null + "DeviceVersion" = 2 + "DisplayName" = "Mock-Device" + "EnrollmentProfileName" = $null + "Extensions" = $null + "Id" = "74825acb-c984-4b54-ab65-d38347ea5e90" + "IsCompliant" = $False + "IsManaged" = $True + "MdmAppId" = $null + "MemberOf" = $null + "OnPremisesLastSyncDateTime" = $null + "OnPremisesSecurityIdentifier" = $null + "OnPremisesSyncEnabled" = $false + "OperatingSystem" = "WINDOWS" + "OperatingSystemVersion" = "10.0.22621.1700" + "ProfileType" = $null + "RegisteredOwners" = $null + "RegisteredUsers" = $null + "RegistrationDateTime" = $null + "TransitiveMemberOf" = $null + "TrustType" = $null + "PhysicalIds" = @{} + } + ) + } + + Mock -CommandName Get-MgDevice -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra +} + +Describe "Get-EntraDevice" { + Context "Test for Get-EntraDevice" { + It "Should return specific device" { + $result = Get-EntraDevice -ObjectId "74825acb-c984-4b54-ab65-d38347ea5e90" + $result | Should -Not -BeNullOrEmpty + $result.Id | should -Be @('74825acb-c984-4b54-ab65-d38347ea5e90') + + Should -Invoke -CommandName Get-MgDevice -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when ObjectId is empty" { + { Get-EntraDevice -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + } + It "Should return all devices" { + $result = Get-EntraDevice -All $true + $result | Should -Not -BeNullOrEmpty + + Should -Invoke -CommandName Get-MgDevice -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when All is empty" { + { Get-EntraDevice -All } | Should -Throw "Missing an argument for parameter 'All'*" + } + It "Should return specific device by searchstring" { + $result = Get-EntraDevice -SearchString 'Mock-Device' + $result | Should -Not -BeNullOrEmpty + $result.DisplayName | should -Be 'Mock-Device' + + Should -Invoke -CommandName Get-MgDevice -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should return specific device by filter" { + $result = Get-EntraDevice -Filter "DisplayName -eq 'Mock-Device'" + $result | Should -Not -BeNullOrEmpty + $result.DisplayName | should -Be 'Mock-Device' + + Should -Invoke -CommandName Get-MgDevice -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should return top device" { + $result = Get-EntraDevice -Top 1 + $result | Should -Not -BeNullOrEmpty + + Should -Invoke -CommandName Get-MgDevice -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Result should Contain ObjectId" { + $result = Get-EntraDevice -ObjectId "74825acb-c984-4b54-ab65-d38347ea5e90" + $result.ObjectId | should -Be "74825acb-c984-4b54-ab65-d38347ea5e90" + } + It "Should contain DeviceId in parameters when passed ObjectId to it" { + Mock -CommandName Get-MgDevice -MockWith {$args} -ModuleName Microsoft.Graph.Entra + + $result = Get-EntraDevice -ObjectId "74825acb-c984-4b54-ab65-d38347ea5e90" + $params = Get-Parameters -data $result + $params.DeviceId | Should -Be "74825acb-c984-4b54-ab65-d38347ea5e90" + } + It "Should contain Filter in parameters when passed SearchString to it" { + Mock -CommandName Get-MgDevice -MockWith {$args} -ModuleName Microsoft.Graph.Entra + + $result = Get-EntraDevice -SearchString 'Mock-Device' + $params = Get-Parameters -data $result + $params.Filter | Should -Match "Mock-Device" + } + It "Should contain 'User-Agent' header" { + Mock -CommandName Get-MgDevice -MockWith {$args} -ModuleName Microsoft.Graph.Entra + + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraDevice" + + $result = Get-EntraDevice -SearchString 'Mock-Device' + $params = Get-Parameters -data $result + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } + } +} \ No newline at end of file diff --git a/test/module/Entra/Mock-Get-EntraDirectoryRole.Tests.ps1 b/test/module/Entra/Mock-Get-EntraDirectoryRole.Tests.ps1 index 26b1d524b..72ac7159c 100644 --- a/test/module/Entra/Mock-Get-EntraDirectoryRole.Tests.ps1 +++ b/test/module/Entra/Mock-Get-EntraDirectoryRole.Tests.ps1 @@ -20,11 +20,6 @@ BeforeAll { ) } - $argsBlock = { - param($args) - return $args - } - Mock -CommandName Get-MgDirectoryRole -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra } @@ -52,14 +47,14 @@ BeforeAll { $result.ObjectId | should -Be "dc587a80-d49c-4700-a73b-57227856fc32" } It "Should contain DirectoryRoleId in parameters when passed ObjectId to it" { - Mock -CommandName Get-MgDirectoryRole -MockWith $argsBlock -ModuleName Microsoft.Graph.Entra + Mock -CommandName Get-MgDirectoryRole -MockWith {$args} -ModuleName Microsoft.Graph.Entra $result = Get-EntraDirectoryRole -ObjectId "dc587a80-d49c-4700-a73b-57227856fc32" $params = Get-Parameters -data $result $params.DirectoryRoleId | Should -Be "dc587a80-d49c-4700-a73b-57227856fc32" } It "Should contain 'User-Agent' header" { - Mock -CommandName Get-MgDirectoryRole -MockWith $argsBlock -ModuleName Microsoft.Graph.Entra + Mock -CommandName Get-MgDirectoryRole -MockWith {$args} -ModuleName Microsoft.Graph.Entra $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraDirectoryRole" diff --git a/test/module/Entra/Mock-Get-EntraGroup.Tests.ps1 b/test/module/Entra/Mock-Get-EntraGroup.Tests.ps1 index 380b06caa..f10c708c9 100644 --- a/test/module/Entra/Mock-Get-EntraGroup.Tests.ps1 +++ b/test/module/Entra/Mock-Get-EntraGroup.Tests.ps1 @@ -19,11 +19,6 @@ BeforeAll { ) } - $argsBlock = { - param($args) - return $args - } - Mock -CommandName Get-MgGroup -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra } @@ -73,21 +68,21 @@ Describe "Get-EntraGroup" { $result.ObjectId | should -Be "056b2531-005e-4f3e-be78-01a71ea30a04" } It "Should contain GroupId in parameters when passed ObjectId to it" { - Mock -CommandName Get-MgGroup -MockWith $argsBlock -ModuleName Microsoft.Graph.Entra + Mock -CommandName Get-MgGroup -MockWith {$args} -ModuleName Microsoft.Graph.Entra $result = Get-EntraGroup -ObjectId "056b2531-005e-4f3e-be78-01a71ea30a04" $params = Get-Parameters -data $result $params.GroupId | Should -Be "056b2531-005e-4f3e-be78-01a71ea30a04" } It "Should contain Filter in parameters when passed SearchString to it" { - Mock -CommandName Get-MgGroup -MockWith $argsBlock -ModuleName Microsoft.Graph.Entra + Mock -CommandName Get-MgGroup -MockWith {$args} -ModuleName Microsoft.Graph.Entra $result = Get-EntraGroup -SearchString 'demo' $params = Get-Parameters -data $result $params.Filter | Should -Match "demo" } It "Should contain 'User-Agent' header" { - Mock -CommandName Get-MgGroup -MockWith $argsBlock -ModuleName Microsoft.Graph.Entra + Mock -CommandName Get-MgGroup -MockWith {$args} -ModuleName Microsoft.Graph.Entra $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraGroup" diff --git a/test/module/Entra/Mock-New-EntraApplication.Tests.ps1 b/test/module/Entra/Mock-New-EntraApplication.Tests.ps1 index d1c2c3232..2619edbd1 100644 --- a/test/module/Entra/Mock-New-EntraApplication.Tests.ps1 +++ b/test/module/Entra/Mock-New-EntraApplication.Tests.ps1 @@ -27,11 +27,6 @@ BeforeAll { } ) } - - $argsBlock = { - param($args) - return $args - } Mock -CommandName New-MgApplication -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra } @@ -52,7 +47,7 @@ Describe "New-EntraApplication"{ { New-EntraApplication -DisplayName "" } | Should -Throw "Cannot bind argument to parameter 'DisplayName' because it is an empty string." } It "Should contain 'User-Agent' header" { - Mock -CommandName New-MgApplication -MockWith $argsBlock -ModuleName Microsoft.Graph.Entra + Mock -CommandName New-MgApplication -MockWith {$args} -ModuleName Microsoft.Graph.Entra $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion New-EntraApplication" diff --git a/test/module/Entra/Mock-New-EntraGroup.Tests.ps1 b/test/module/Entra/Mock-New-EntraGroup.Tests.ps1 index ec0352d93..e10f8645e 100644 --- a/test/module/Entra/Mock-New-EntraGroup.Tests.ps1 +++ b/test/module/Entra/Mock-New-EntraGroup.Tests.ps1 @@ -17,11 +17,6 @@ BeforeAll { "SecurityEnabled" = "True" } ) - } - - $argsBlock = { - param($args) - return $args } Mock -CommandName New-MgGroup -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra @@ -43,7 +38,7 @@ Describe "New-EntraGroup" { { New-EntraGroup -DisplayName "" -MailEnabled -SecurityEnabled -MailNickName "" -Description "" } | Should -Throw "Missing an argument for parameter*" } It "Should contain 'User-Agent' header" { - Mock -CommandName New-MgGroup -MockWith $argsBlock -ModuleName Microsoft.Graph.Entra + Mock -CommandName New-MgGroup -MockWith {$args} -ModuleName Microsoft.Graph.Entra $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion New-EntraGroup" diff --git a/test/module/Entra/Mock-Remove-EntraApplication.Tests.ps1 b/test/module/Entra/Mock-Remove-EntraApplication.Tests.ps1 index fbdcae33e..c31665a3a 100644 --- a/test/module/Entra/Mock-Remove-EntraApplication.Tests.ps1 +++ b/test/module/Entra/Mock-Remove-EntraApplication.Tests.ps1 @@ -5,11 +5,6 @@ BeforeAll { } Import-Module .\test\module\Common-Functions.ps1 -Force - $argsBlock = { - param($args) - return $args - } - Mock -CommandName Remove-MgApplication -MockWith {} -ModuleName Microsoft.Graph.Entra } @@ -25,14 +20,14 @@ Describe "Remove-EntraApplication" { { Remove-EntraApplication -ObjectId "" } } It "Should contain ApplicationId in parameters when passed ObjectId to it" { - Mock -CommandName Remove-MgApplication -MockWith $argsBlock -ModuleName Microsoft.Graph.Entra + Mock -CommandName Remove-MgApplication -MockWith {$args} -ModuleName Microsoft.Graph.Entra $result = Remove-EntraApplication -ObjectId 056b2531-005e-4f3e-be78-01a71ea30a04 $params = Get-Parameters -data $result $params.ApplicationId | Should -Be "056b2531-005e-4f3e-be78-01a71ea30a04" } It "Should contain 'User-Agent' header" { - Mock -CommandName Remove-MgApplication -MockWith $argsBlock -ModuleName Microsoft.Graph.Entra + Mock -CommandName Remove-MgApplication -MockWith {$args} -ModuleName Microsoft.Graph.Entra $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraApplication" diff --git a/test/module/Entra/Mock-Remove-EntraGroup.Tests.ps1 b/test/module/Entra/Mock-Remove-EntraGroup.Tests.ps1 index 648b63ff9..b7e51064c 100644 --- a/test/module/Entra/Mock-Remove-EntraGroup.Tests.ps1 +++ b/test/module/Entra/Mock-Remove-EntraGroup.Tests.ps1 @@ -5,11 +5,6 @@ BeforeAll { } Import-Module .\test\module\Common-Functions.ps1 -Force - $argsBlock = { - param($args) - return $args - } - Mock -CommandName Remove-MgGroup -MockWith {} -ModuleName Microsoft.Graph.Entra } @@ -25,14 +20,14 @@ Describe "Remove-EntraGroup" { { Remove-EntraGroup -ObjectId "" } } It "Should contain GroupId in parameters when passed ObjectId to it" { - Mock -CommandName Remove-MgGroup -MockWith $argsBlock -ModuleName Microsoft.Graph.Entra + Mock -CommandName Remove-MgGroup -MockWith {$args} -ModuleName Microsoft.Graph.Entra $result = Remove-EntraGroup -ObjectId 056b2531-005e-4f3e-be78-01a71ea30a04 $params = Get-Parameters -data $result $params.GroupId | Should -Be "056b2531-005e-4f3e-be78-01a71ea30a04" } It "Should contain 'User-Agent' header" { - Mock -CommandName Remove-MgGroup -MockWith $argsBlock -ModuleName Microsoft.Graph.Entra + Mock -CommandName Remove-MgGroup -MockWith {$args} -ModuleName Microsoft.Graph.Entra $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraGroup" diff --git a/test/module/Entra/Mock-Set-EntraApplication.Tests.ps1 b/test/module/Entra/Mock-Set-EntraApplication.Tests.ps1 index 7033219ac..d4167241a 100644 --- a/test/module/Entra/Mock-Set-EntraApplication.Tests.ps1 +++ b/test/module/Entra/Mock-Set-EntraApplication.Tests.ps1 @@ -5,11 +5,6 @@ BeforeAll { } Import-Module .\test\module\Common-Functions.ps1 -Force - $argsBlock = { - param($args) - return $args - } - Mock -CommandName Update-MgApplication -MockWith {} -ModuleName Microsoft.Graph.Entra } @@ -25,14 +20,14 @@ Describe "Set-EntraApplication"{ { Set-EntraApplication -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." } It "Should contain ApplicationId in parameters when passed ObjectId to it" { - Mock -CommandName Update-MgApplication -MockWith $argsBlock -ModuleName Microsoft.Graph.Entra + Mock -CommandName Update-MgApplication -MockWith {$args} -ModuleName Microsoft.Graph.Entra $result = Set-EntraApplication -ObjectId 056b2531-005e-4f3e-be78-01a71ea30a04 $params = Get-Parameters -data $result $params.ApplicationId | Should -Be "056b2531-005e-4f3e-be78-01a71ea30a04" } It "Should contain 'User-Agent' header" { - Mock -CommandName Update-MgApplication -MockWith $argsBlock -ModuleName Microsoft.Graph.Entra + Mock -CommandName Update-MgApplication -MockWith {$args} -ModuleName Microsoft.Graph.Entra $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Set-EntraApplication" diff --git a/test/module/Entra/Mock-Set-EntraGroup.Tests.ps1 b/test/module/Entra/Mock-Set-EntraGroup.Tests.ps1 index cd02acc17..a91320a47 100644 --- a/test/module/Entra/Mock-Set-EntraGroup.Tests.ps1 +++ b/test/module/Entra/Mock-Set-EntraGroup.Tests.ps1 @@ -5,11 +5,6 @@ BeforeAll { } Import-Module .\test\module\Common-Functions.ps1 -Force - $argsBlock = { - param($args) - return $args - } - Mock -CommandName Update-MgGroup -MockWith {} -ModuleName Microsoft.Graph.Entra } @@ -25,14 +20,14 @@ Describe "Set-EntraGroup" { { Set-EntraGroup -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." } It "Should contain GroupId in parameters when passed ObjectId to it" { - Mock -CommandName Update-MgGroup -MockWith $argsBlock -ModuleName Microsoft.Graph.Entra + Mock -CommandName Update-MgGroup -MockWith {$args} -ModuleName Microsoft.Graph.Entra $result = Set-EntraGroup -ObjectId 056b2531-005e-4f3e-be78-01a71ea30a04 $params = Get-Parameters -data $result $params.GroupId | Should -Be "056b2531-005e-4f3e-be78-01a71ea30a04" } It "Should contain 'User-Agent' header" { - Mock -CommandName Update-MgGroup -MockWith $argsBlock -ModuleName Microsoft.Graph.Entra + Mock -CommandName Update-MgGroup -MockWith {$args} -ModuleName Microsoft.Graph.Entra $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Set-EntraGroup" diff --git a/test/module/EntraBeta/EntraBeta.Tests.ps1 b/test/module/EntraBeta/EntraBeta.Tests.ps1 index 063a3047c..e42988451 100644 --- a/test/module/EntraBeta/EntraBeta.Tests.ps1 +++ b/test/module/EntraBeta/EntraBeta.Tests.ps1 @@ -1,11 +1,16 @@ -Import-Module Pester +$modulePath = join-path $psscriptroot "..\..\..\bin\Microsoft.Graph.Entra.Beta.psm1" +$testReportPath = join-path $psscriptroot "..\..\..\TestReport\EntraBeta" +$mockScriptsPath = join-path $psscriptroot "..\..\..\test\module\EntraBeta\Mock-*.Tests.ps1" + -$testOutputFile = ".\TestReport\EntraBeta\TestResults.xml" +Import-Module Pester +Import-Module $modulePath -Force +#Import-Module Microsoft.Graph.Entra -$reportFolder = ".\TestReport\EntraBeta" -if (!(test-path -path $reportFolder)) {new-item -path $reportFolder -itemtype directory} +$testOutputFile = "$testReportPath\TestResults.xml" +if (!(test-path -path $testReportPath)) {new-item -path $testReportPath -itemtype directory} -$mockScripts = Get-ChildItem -Path ".\test\module\EntraBeta\Mock-*.Tests.ps1" | ForEach-Object { $_.FullName } +$mockScripts = Get-ChildItem -Path $mockScriptsPath | ForEach-Object { $_.FullName } $config = New-PesterConfiguration $config.Run.Path = $mockScripts @@ -13,9 +18,10 @@ $config.Run.PassThru = $true $config.Run.Exit = $true $config.CodeCoverage.Enabled = $true $config.CodeCoverage.CoveragePercentTarget = 100 -$config.CodeCoverage.Path = @('.\bin\Microsoft.Graph.Entra.Beta.psm1') +$config.CodeCoverage.Path = $modulePath $config.TestResult.Enabled = $true $config.TestResult.OutputPath = $testOutputFile +$config.Output.Verbosity = "Detailed" Invoke-Pester -Configuration $config From 9cd20893e33517754426217f128357dc94134b1c Mon Sep 17 00:00:00 2001 From: v-uansari Date: Tue, 9 Apr 2024 13:13:55 +0530 Subject: [PATCH 14/40] entra test update --- test/module/Entra/Entra.Tests.ps1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/module/Entra/Entra.Tests.ps1 b/test/module/Entra/Entra.Tests.ps1 index d50af2994..3b7476b98 100644 --- a/test/module/Entra/Entra.Tests.ps1 +++ b/test/module/Entra/Entra.Tests.ps1 @@ -1,6 +1,7 @@ $modulePath = join-path $psscriptroot "..\..\..\bin\Microsoft.Graph.Entra.psm1" $testReportPath = join-path $psscriptroot "..\..\..\TestReport\Entra" $mockScriptsPath = join-path $psscriptroot "..\..\..\test\module\Entra\Mock-*.Tests.ps1" +$reportGenPath = join-path $psscriptroot "..\..\..\reportgenerator\ReportUnit.exe" Import-Module Pester @@ -25,4 +26,4 @@ $config.Output.Verbosity = "Detailed" Invoke-Pester -Configuration $config -.\reportgenerator\ReportUnit.exe "$testOutputFile" \ No newline at end of file +& "$reportGenPath" "$testOutputFile" \ No newline at end of file From 9304d6a2cc6196098d6dbfac952061d363cc38d4 Mon Sep 17 00:00:00 2001 From: v-uansari Date: Tue, 9 Apr 2024 13:16:39 +0530 Subject: [PATCH 15/40] upate --- test/module/EntraBeta/EntraBeta.Tests.ps1 | 28 ----------------------- 1 file changed, 28 deletions(-) delete mode 100644 test/module/EntraBeta/EntraBeta.Tests.ps1 diff --git a/test/module/EntraBeta/EntraBeta.Tests.ps1 b/test/module/EntraBeta/EntraBeta.Tests.ps1 deleted file mode 100644 index e42988451..000000000 --- a/test/module/EntraBeta/EntraBeta.Tests.ps1 +++ /dev/null @@ -1,28 +0,0 @@ -$modulePath = join-path $psscriptroot "..\..\..\bin\Microsoft.Graph.Entra.Beta.psm1" -$testReportPath = join-path $psscriptroot "..\..\..\TestReport\EntraBeta" -$mockScriptsPath = join-path $psscriptroot "..\..\..\test\module\EntraBeta\Mock-*.Tests.ps1" - - -Import-Module Pester -Import-Module $modulePath -Force -#Import-Module Microsoft.Graph.Entra - -$testOutputFile = "$testReportPath\TestResults.xml" -if (!(test-path -path $testReportPath)) {new-item -path $testReportPath -itemtype directory} - -$mockScripts = Get-ChildItem -Path $mockScriptsPath | ForEach-Object { $_.FullName } - -$config = New-PesterConfiguration -$config.Run.Path = $mockScripts -$config.Run.PassThru = $true -$config.Run.Exit = $true -$config.CodeCoverage.Enabled = $true -$config.CodeCoverage.CoveragePercentTarget = 100 -$config.CodeCoverage.Path = $modulePath -$config.TestResult.Enabled = $true -$config.TestResult.OutputPath = $testOutputFile -$config.Output.Verbosity = "Detailed" - -Invoke-Pester -Configuration $config - -.\reportgenerator\ReportUnit.exe "$testOutputFile" \ No newline at end of file From 417b6f4b94bccc4c3df5eb516616896a6c26bd1a Mon Sep 17 00:00:00 2001 From: v-uansari Date: Tue, 9 Apr 2024 16:15:53 +0530 Subject: [PATCH 16/40] updates --- .../Entra/Mock-Remove-EntraDevice.Tests.ps1 | 39 +++++++++++++++++++ .../Entra/Mock-Set-EntraDevice.Tests.ps1 | 39 +++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 test/module/Entra/Mock-Remove-EntraDevice.Tests.ps1 create mode 100644 test/module/Entra/Mock-Set-EntraDevice.Tests.ps1 diff --git a/test/module/Entra/Mock-Remove-EntraDevice.Tests.ps1 b/test/module/Entra/Mock-Remove-EntraDevice.Tests.ps1 new file mode 100644 index 000000000..8692c8656 --- /dev/null +++ b/test/module/Entra/Mock-Remove-EntraDevice.Tests.ps1 @@ -0,0 +1,39 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ + #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force + Import-Module Microsoft.Graph.Entra + } + Import-Module .\test\module\Common-Functions.ps1 -Force + + Mock -CommandName Remove-MgDevice -MockWith {} -ModuleName Microsoft.Graph.Entra +} + +Describe "Remove-EntraDevice" { + Context "Test for Remove-EntraDevice" { + It "Should return empty object" { + $result = Remove-EntraDevice -ObjectId 056b2531-005e-4f3e-be78-01a71ea30a04 + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName Remove-MgDevice -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when ObjectId is empty" { + { Remove-EntraDevice -ObjectId "" } + } + It "Should contain DeviceId in parameters when passed ObjectId to it" { + Mock -CommandName Remove-MgDevice -MockWith {$args} -ModuleName Microsoft.Graph.Entra + + $result = Remove-EntraDevice -ObjectId 056b2531-005e-4f3e-be78-01a71ea30a04 + $params = Get-Parameters -data $result + $params.DeviceId | Should -Be "056b2531-005e-4f3e-be78-01a71ea30a04" + } + It "Should contain 'User-Agent' header" { + Mock -CommandName Remove-MgDevice -MockWith {$args} -ModuleName Microsoft.Graph.Entra + + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraDevice" + + $result = Remove-EntraDevice -ObjectId 056b2531-005e-4f3e-be78-01a71ea30a04 + $params = Get-Parameters -data $result + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } + } +} \ No newline at end of file diff --git a/test/module/Entra/Mock-Set-EntraDevice.Tests.ps1 b/test/module/Entra/Mock-Set-EntraDevice.Tests.ps1 new file mode 100644 index 000000000..21e367873 --- /dev/null +++ b/test/module/Entra/Mock-Set-EntraDevice.Tests.ps1 @@ -0,0 +1,39 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ + #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force + Import-Module Microsoft.Graph.Entra + } + Import-Module .\test\module\Common-Functions.ps1 -Force + + Mock -CommandName Update-MgDevice -MockWith {} -ModuleName Microsoft.Graph.Entra +} + +Describe "Set-EntraDevice"{ + Context "Test for Set-EntraDevice" { + It "Should return empty object"{ + $result = Set-EntraDevice -ObjectId 056b2531-005e-4f3e-be78-01a71ea30a04 -DisplayName "Mock-App" -AccountEnabled $true + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName Update-MgDevice -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when ObjectId is empty" { + { Set-EntraDevice -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + } + It "Should contain DeviceId in parameters when passed ObjectId to it" { + Mock -CommandName Update-MgDevice -MockWith {$args} -ModuleName Microsoft.Graph.Entra + + $result = Set-EntraDevice -ObjectId 056b2531-005e-4f3e-be78-01a71ea30a04 + $params = Get-Parameters -data $result + $params.DeviceId | Should -Be "056b2531-005e-4f3e-be78-01a71ea30a04" + } + It "Should contain 'User-Agent' header" { + Mock -CommandName Update-MgDevice -MockWith {$args} -ModuleName Microsoft.Graph.Entra + + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Set-EntraDevice" + + $result = Set-EntraDevice -ObjectId 056b2531-005e-4f3e-be78-01a71ea30a04 + $params = Get-Parameters -data $result + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } + } +} \ No newline at end of file From c4b4d6ed706dc041758a19db1a35417910c888ae Mon Sep 17 00:00:00 2001 From: v-uansari Date: Tue, 9 Apr 2024 17:48:49 +0530 Subject: [PATCH 17/40] add mock tests --- .../Mock-Get-EntraMSApplication.Tests.ps1 | 113 ++++++++++++++++++ .../Mock-New-EntraMSApplication.Tests.ps1 | 70 +++++++++++ .../Mock-Remove-EntraMSApplication.Tests.ps1 | 39 ++++++ .../Mock-Set-EntraMSApplication.Tests.ps1 | 39 ++++++ 4 files changed, 261 insertions(+) create mode 100644 test/module/Entra/Mock-Get-EntraMSApplication.Tests.ps1 create mode 100644 test/module/Entra/Mock-New-EntraMSApplication.Tests.ps1 create mode 100644 test/module/Entra/Mock-Remove-EntraMSApplication.Tests.ps1 create mode 100644 test/module/Entra/Mock-Set-EntraMSApplication.Tests.ps1 diff --git a/test/module/Entra/Mock-Get-EntraMSApplication.Tests.ps1 b/test/module/Entra/Mock-Get-EntraMSApplication.Tests.ps1 new file mode 100644 index 000000000..5fc2e530d --- /dev/null +++ b/test/module/Entra/Mock-Get-EntraMSApplication.Tests.ps1 @@ -0,0 +1,113 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ + #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force + Import-Module Microsoft.Graph.Entra + } + Import-Module .\test\module\Common-Functions.ps1 -Force + + $scriptblock = { + # Write-Host "Mocking Get-MgApplication with parameters: $($args | ConvertTo-Json -Depth 3)" + return @( + [PSCustomObject]@{ + "AppId" = "5f783237-3457-45d8-93e7-a0edb1cfbfd1" + "DeletedDateTime" = $null + "Id" = "111cc9b5-fce9-485e-9566-c68debafac5f" + "DisplayName" = "Mock-App" + "Info" = @{LogoUrl=""; MarketingUrl=""; PrivacyStatementUrl=""; SupportUrl=""; TermsOfServiceUrl=""} + "IsDeviceOnlyAuthSupported" = $True + "IsFallbackPublicClient" = $true + "KeyCredentials" = @{CustomKeyIdentifier = @(211, 174, 247);DisplayName =""; Key="";KeyId="d903c7a3-75ea-4772-8935-5c0cf82068a7";Type="Symmetric";Usage="Sign"} + "OptionalClaims" = @{AccessToken=""; IdToken=""; Saml2Token=""} + "ParentalControlSettings" = @{CountriesBlockedForMinors=$null; LegalAgeGroupRule="Allow"} + "PasswordCredentials" = @{} + "AddIns" = @{} + "Logo" = $null + "AppRoles" = $null + "GroupMembershipClaims" = $null + "IdentifierUris" = $null + "Oauth2RequirePostResponse" = $null + "Api" = @{AcceptMappedClaims= $null; KnownClientApplications=$null; Oauth2PermissionScopes=$null; + PreAuthorizedApplications=$null; RequestedAccessTokenVersion=2; AdditionalProperties= $null} + "PublicClient" = @{RedirectUris=$null} + "RequiredResourceAccess" = $false + "PublisherDomain" = "M365x99297270.onmicrosoft.com" + "SignInAudience" = "AzureADandPersonalMicrosoftAccount" + "Web" = @{HomePageUrl="https://localhost/demoapp"; ImplicitGrantSettings=""; LogoutUrl="";} + } + ) + } + + Mock -CommandName Get-MgApplication -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra +} + +Describe "Get-EntraMSApplication" { + Context "Test for Get-EntraMSApplication" { + It "Should return specific application" { + $result = Get-EntraMSApplication -ObjectId "111cc9b5-fce9-485e-9566-c68debafac5f" + $result | Should -Not -BeNullOrEmpty + $result.Id | should -Be @('111cc9b5-fce9-485e-9566-c68debafac5f') + + Should -Invoke -CommandName Get-MgApplication -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when ObjectId is empty" { + { Get-EntraMSApplication -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + } + It "Should return all applications" { + $result = Get-EntraMSApplication -All $true + $result | Should -Not -BeNullOrEmpty + + Should -Invoke -CommandName Get-MgApplication -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when All is empty" { + { Get-EntraMSApplication -All } | Should -Throw "Missing an argument for parameter 'All'*" + } + It "Should return specific application by searchstring" { + $result = Get-EntraMSApplication -SearchString 'Mock-App' + $result | Should -Not -BeNullOrEmpty + $result.DisplayName | should -Be 'Mock-App' + + Should -Invoke -CommandName Get-MgApplication -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should return specific application by filter" { + $result = Get-EntraMSApplication -Filter "DisplayName -eq 'Mock-App'" + $result | Should -Not -BeNullOrEmpty + $result.DisplayName | should -Be 'Mock-App' + + Should -Invoke -CommandName Get-MgApplication -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should return top application" { + $result = Get-EntraMSApplication -Top 1 + $result | Should -Not -BeNullOrEmpty + + Should -Invoke -CommandName Get-MgApplication -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Result should Contain ObjectId" { + $result = Get-EntraMSApplication -ObjectId "111cc9b5-fce9-485e-9566-c68debafac5f" + $result.ObjectId | should -Be "111cc9b5-fce9-485e-9566-c68debafac5f" + } + # issue in addins param transformation in args, will uncomment after resolve. + # It "Should contain ApplicationId in parameters when passed ObjectId to it" { + # Mock -CommandName Get-MgApplication -MockWith {$args} -ModuleName Microsoft.Graph.Entra + + # $result = Get-EntraMSApplication -ObjectId "111cc9b5-fce9-485e-9566-c68debafac5f" + # $params = Get-Parameters -data $result + # $params.ApplicationId | Should -Be "111cc9b5-fce9-485e-9566-c68debafac5f" + # } + # It "Should contain Filter in parameters when passed SearchString to it" { + # Mock -CommandName Get-MgApplication -MockWith {$args} -ModuleName Microsoft.Graph.Entra + + # $result = Get-EntraMSApplication -SearchString 'Mock-App' + # $params = Get-Parameters -data $result + # $params.Filter | Should -Match "Mock-App" + # } + # It "Should contain 'User-Agent' header" { + # Mock -CommandName Get-MgApplication -MockWith {$args} -ModuleName Microsoft.Graph.Entra + + # $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraMSApplication" + + # $result = Get-EntraMSApplication -SearchString 'Mock-App' + # $params = Get-Parameters -data $result + # $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + # } + } +} \ No newline at end of file diff --git a/test/module/Entra/Mock-New-EntraMSApplication.Tests.ps1 b/test/module/Entra/Mock-New-EntraMSApplication.Tests.ps1 new file mode 100644 index 000000000..9ec3c0eea --- /dev/null +++ b/test/module/Entra/Mock-New-EntraMSApplication.Tests.ps1 @@ -0,0 +1,70 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ + #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force + Import-Module Microsoft.Graph.Entra + } + Import-Module .\test\module\Common-Functions.ps1 -Force + + $scriptblock = { + # Write-Host "Mocking New-MgApplication with parameters: $($args | ConvertTo-Json -Depth 3)" + return @( + [PSCustomObject]@{ + "AppId" = "5f783237-3457-45d8-93e7-a0edb1cfbfd1" + "DeletedDateTime" = $null + "Id" = "111cc9b5-fce9-485e-9566-c68debafac5f" + "DisplayName" = "Mock-App" + "Info" = @{LogoUrl=""; MarketingUrl=""; PrivacyStatementUrl=""; SupportUrl=""; TermsOfServiceUrl=""} + "IsDeviceOnlyAuthSupported" = $True + "IsFallbackPublicClient" = $True + "KeyCredentials" = @{CustomKeyIdentifier = @(211, 174, 247);DisplayName =""; Key="";KeyId="d903c7a3-75ea-4772-8935-5c0cf82068a7";Type="Symmetric";Usage="Sign"} + "OptionalClaims" = @{AccessToken=""; IdToken=""; Saml2Token=""} + "ParentalControlSettings" = @{CountriesBlockedForMinors=$null; LegalAgeGroupRule="Allow"} + "PasswordCredentials" = @{} + "AddIns" = @{} + "Logo" = $null + "AppRoles" = $null + "GroupMembershipClaims" = $null + "IdentifierUris" = $null + "Oauth2RequirePostResponse" = $null + "Api" = @{AcceptMappedClaims= $null; KnownClientApplications=$null; Oauth2PermissionScopes=$null; + PreAuthorizedApplications=$null; RequestedAccessTokenVersion=2; AdditionalProperties= $null} + "PublicClient" = @{RedirectUris=$null} + "RequiredResourceAccess" = $false + "PublisherDomain" = "M365x99297270.onmicrosoft.com" + "SignInAudience" = "AzureADandPersonalMicrosoftAccount" + "Web" = @{HomePageUrl="https://localhost/demoapp"; ImplicitGrantSettings=""; LogoutUrl="";} + "AdditionalProperties" = @{Context="application"} + } + ) + } + + Mock -CommandName New-MgApplication -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra +} + +Describe "New-EntraMSApplication"{ + Context "Test for New-EntraMSApplication" { + It "Should return created Application"{ + $result = New-EntraMSApplication -DisplayName "Mock-App" + $result | Should -Not -BeNullOrEmpty + $result.DisplayName | should -Be "Mock-App" + $result.IsDeviceOnlyAuthSupported | should -Be "True" + $result.IsFallbackPublicClient | should -Be "True" + $result.SignInAudience | should -Be "AzureADandPersonalMicrosoftAccount" + + Should -Invoke -CommandName New-MgApplication -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when DisplayName is empty" { + { New-EntraMSApplication -DisplayName "" } | Should -Throw "Cannot bind argument to parameter 'DisplayName' because it is an empty string." + } + # issue in addins param transformation in args, will uncomment after resolve. + # It "Should contain 'User-Agent' header" { + # Mock -CommandName New-MgApplication -MockWith {$args} -ModuleName Microsoft.Graph.Entra + + # $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion New-EntraMSApplication" + + # $result = New-EntraMSApplication -DisplayName "Mock-App" + # $params = Get-Parameters -data $result + # $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + # } + } +} \ No newline at end of file diff --git a/test/module/Entra/Mock-Remove-EntraMSApplication.Tests.ps1 b/test/module/Entra/Mock-Remove-EntraMSApplication.Tests.ps1 new file mode 100644 index 000000000..560ad8832 --- /dev/null +++ b/test/module/Entra/Mock-Remove-EntraMSApplication.Tests.ps1 @@ -0,0 +1,39 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ + #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force + Import-Module Microsoft.Graph.Entra + } + Import-Module .\test\module\Common-Functions.ps1 -Force + + Mock -CommandName Remove-MgApplication -MockWith {} -ModuleName Microsoft.Graph.Entra +} + +Describe "Remove-EntraMSApplication" { + Context "Test for Remove-EntraMSApplication" { + It "Should return empty object" { + $result = Remove-EntraMSApplication -ObjectId 056b2531-005e-4f3e-be78-01a71ea30a04 + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName Remove-MgApplication -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when ObjectId is empty" { + { Remove-EntraMSApplication -ObjectId "" } + } + It "Should contain ApplicationId in parameters when passed ObjectId to it" { + Mock -CommandName Remove-MgApplication -MockWith {$args} -ModuleName Microsoft.Graph.Entra + + $result = Remove-EntraMSApplication -ObjectId 056b2531-005e-4f3e-be78-01a71ea30a04 + $params = Get-Parameters -data $result + $params.ApplicationId | Should -Be "056b2531-005e-4f3e-be78-01a71ea30a04" + } + It "Should contain 'User-Agent' header" { + Mock -CommandName Remove-MgApplication -MockWith {$args} -ModuleName Microsoft.Graph.Entra + + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraMSApplication" + + $result = Remove-EntraMSApplication -ObjectId 056b2531-005e-4f3e-be78-01a71ea30a04 + $params = Get-Parameters -data $result + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } + } +} \ No newline at end of file diff --git a/test/module/Entra/Mock-Set-EntraMSApplication.Tests.ps1 b/test/module/Entra/Mock-Set-EntraMSApplication.Tests.ps1 new file mode 100644 index 000000000..8676b10f5 --- /dev/null +++ b/test/module/Entra/Mock-Set-EntraMSApplication.Tests.ps1 @@ -0,0 +1,39 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ + #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force + Import-Module Microsoft.Graph.Entra + } + Import-Module .\test\module\Common-Functions.ps1 -Force + + Mock -CommandName Update-MgApplication -MockWith {} -ModuleName Microsoft.Graph.Entra +} + +Describe "Set-EntraMSApplication"{ + Context "Test for Set-EntraMSApplication" { + It "Should return empty object"{ + $result = Set-EntraMSApplication -ObjectId 056b2531-005e-4f3e-be78-01a71ea30a04 -DisplayName "Mock-App" + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName Update-MgApplication -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when ObjectId is empty" { + { Set-EntraMSApplication -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + } + It "Should contain ApplicationId in parameters when passed ObjectId to it" { + Mock -CommandName Update-MgApplication -MockWith {$args} -ModuleName Microsoft.Graph.Entra + + $result = Set-EntraMSApplication -ObjectId 056b2531-005e-4f3e-be78-01a71ea30a04 + $params = Get-Parameters -data $result + $params.ApplicationId | Should -Be "056b2531-005e-4f3e-be78-01a71ea30a04" + } + It "Should contain 'User-Agent' header" { + Mock -CommandName Update-MgApplication -MockWith {$args} -ModuleName Microsoft.Graph.Entra + + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Set-EntraMSApplication" + + $result = Set-EntraMSApplication -ObjectId 056b2531-005e-4f3e-be78-01a71ea30a04 + $params = Get-Parameters -data $result + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } + } +} \ No newline at end of file From 1e1b252d368bcb743c83299ce7bea32a0c840d53 Mon Sep 17 00:00:00 2001 From: v-uansari Date: Wed, 10 Apr 2024 17:54:50 +0530 Subject: [PATCH 18/40] added tests --- ...-EntraMSAdministrativeUnitMember.Tests.ps1 | 39 +++++++++ ...Mock-Add-EntraMSApplicationOwner.Tests.ps1 | 46 ++++++++++ ...-Add-EntraMSScopedRoleMembership.Tests.ps1 | 55 ++++++++++++ ...ck-Get-EntraMSAdministrativeUnit.Tests.ps1 | 83 +++++++++++++++++++ ...Mock-Get-EntraMSApplicationOwner.Tests.ps1 | 64 ++++++++++++++ 5 files changed, 287 insertions(+) create mode 100644 test/module/Entra/Mock-Add-EntraMSAdministrativeUnitMember.Tests.ps1 create mode 100644 test/module/Entra/Mock-Add-EntraMSApplicationOwner.Tests.ps1 create mode 100644 test/module/Entra/Mock-Add-EntraMSScopedRoleMembership.Tests.ps1 create mode 100644 test/module/Entra/Mock-Get-EntraMSAdministrativeUnit.Tests.ps1 create mode 100644 test/module/Entra/Mock-Get-EntraMSApplicationOwner.Tests.ps1 diff --git a/test/module/Entra/Mock-Add-EntraMSAdministrativeUnitMember.Tests.ps1 b/test/module/Entra/Mock-Add-EntraMSAdministrativeUnitMember.Tests.ps1 new file mode 100644 index 000000000..b2f0c4429 --- /dev/null +++ b/test/module/Entra/Mock-Add-EntraMSAdministrativeUnitMember.Tests.ps1 @@ -0,0 +1,39 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ + #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force + Import-Module Microsoft.Graph.Entra + } + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force + + Mock -CommandName New-MgDirectoryAdministrativeUnitMemberByRef -MockWith {} -ModuleName Microsoft.Graph.Entra +} + +Describe "Add-EntraMSAdministrativeUnitMember" { + Context "Test for Add-EntraMSAdministrativeUnitMember" { + It "Should return empty object"{ + $result = Add-EntraMSAdministrativeUnitMember -Id "f306a126-cf2e-439d-b20f-95ce4bcb7ffa" -RefObjectId "d6873b36-81d6-4c5e-bec0-9e3ca2c86846" + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName New-MgDirectoryAdministrativeUnitMemberByRef -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when parameters are empty" { + { Add-EntraMSAdministrativeUnitMember -Id "" -RefObjectId "" } | Should -Throw "Cannot bind argument to parameter*" + } + It "Should contain AdministrativeUnitId in parameters when passed Id to it" { + Mock -CommandName New-MgDirectoryAdministrativeUnitMemberByRef -MockWith {$args} -ModuleName Microsoft.Graph.Entra + + $result = Add-EntraMSAdministrativeUnitMember -Id "f306a126-cf2e-439d-b20f-95ce4bcb7ffa" -RefObjectId "d6873b36-81d6-4c5e-bec0-9e3ca2c86846" + $params = Get-Parameters -data $result + $params.AdministrativeUnitId | Should -Be "f306a126-cf2e-439d-b20f-95ce4bcb7ffa" + } + It "Should contain 'User-Agent' header" { + Mock -CommandName New-MgDirectoryAdministrativeUnitMemberByRef -MockWith {$args} -ModuleName Microsoft.Graph.Entra + + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Add-EntraMSAdministrativeUnitMember" + + $result = Add-EntraMSAdministrativeUnitMember -Id "f306a126-cf2e-439d-b20f-95ce4bcb7ffa" -RefObjectId "d6873b36-81d6-4c5e-bec0-9e3ca2c86846" + $params = Get-Parameters -data $result + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } + } +} \ No newline at end of file diff --git a/test/module/Entra/Mock-Add-EntraMSApplicationOwner.Tests.ps1 b/test/module/Entra/Mock-Add-EntraMSApplicationOwner.Tests.ps1 new file mode 100644 index 000000000..4e463544a --- /dev/null +++ b/test/module/Entra/Mock-Add-EntraMSApplicationOwner.Tests.ps1 @@ -0,0 +1,46 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ + #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force + Import-Module Microsoft.Graph.Entra + } + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force + + Mock -CommandName New-MgApplicationOwnerByRef -MockWith {} -ModuleName Microsoft.Graph.Entra +} + +Describe "Add-EntraMSApplicationOwner" { + Context "Test for Add-EntraMSApplicationOwner" { + It "Should return empty object"{ + $result = Add-EntraMSApplicationOwner -ObjectId "c81d387e-d431-43b4-b12e-f07cbb35b771" -RefObjectId "412be9d1-1460-4061-8eed-cca203fcb215" + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName New-MgApplicationOwnerByRef -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when parameters are empty" { + { Add-EntraMSApplicationOwner -ObjectId "" -RefObjectId "" } | Should -Throw "Cannot bind argument to parameter*" + } + It "Should contain ApplicationId in parameters when passed ObjectId to it" { + Mock -CommandName New-MgApplicationOwnerByRef -MockWith {$args} -ModuleName Microsoft.Graph.Entra + + $result = Add-EntraMSApplicationOwner -ObjectId "c81d387e-d431-43b4-b12e-f07cbb35b771" -RefObjectId "412be9d1-1460-4061-8eed-cca203fcb215" + $params = Get-Parameters -data $result + $params.ApplicationId | Should -Be "c81d387e-d431-43b4-b12e-f07cbb35b771" + } + It "Should contain OdataId in parameters when passed RefObjectId to it" { + Mock -CommandName New-MgApplicationOwnerByRef -MockWith {$args} -ModuleName Microsoft.Graph.Entra + + $result = Add-EntraMSApplicationOwner -ObjectId "c81d387e-d431-43b4-b12e-f07cbb35b771" -RefObjectId "412be9d1-1460-4061-8eed-cca203fcb215" + $params = Get-Parameters -data $result + $params.OdataId | Should -Be "https://graph.microsoft.com/v1.0/directoryObjects/412be9d1-1460-4061-8eed-cca203fcb215" + } + It "Should contain 'User-Agent' header" { + Mock -CommandName New-MgApplicationOwnerByRef -MockWith {$args} -ModuleName Microsoft.Graph.Entra + + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Add-EntraMSApplicationOwner" + + $result = Add-EntraMSApplicationOwner -ObjectId "c81d387e-d431-43b4-b12e-f07cbb35b771" -RefObjectId "412be9d1-1460-4061-8eed-cca203fcb215" + $params = Get-Parameters -data $result + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } + } +} \ No newline at end of file diff --git a/test/module/Entra/Mock-Add-EntraMSScopedRoleMembership.Tests.ps1 b/test/module/Entra/Mock-Add-EntraMSScopedRoleMembership.Tests.ps1 new file mode 100644 index 000000000..bef2cd44f --- /dev/null +++ b/test/module/Entra/Mock-Add-EntraMSScopedRoleMembership.Tests.ps1 @@ -0,0 +1,55 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ + #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force + Import-Module Microsoft.Graph.Entra + } + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force + + + $scriptblock = { + # Write-Host "Mocking New-MgDirectoryAdministrativeUnitScopedRoleMember with parameters: $($args | ConvertTo-Json -Depth 3)" + return @( + [PSCustomObject]@{ + "Id" = "412be9d1-1460-4061-8eed-cca203fcb215" + "AdministrativeUnitId" = "c9ab56cc-e349-4237-856e-cab03157a91e" + "RoleId" = "526b7173-5a6e-49dc-88ec-b677a9093709" + } + ) + } + + Mock -CommandName New-MgDirectoryAdministrativeUnitScopedRoleMember -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra + + $RoleMember = New-Object -TypeName Microsoft.Open.MSGraph.Model.MsRolememberinfo + $RoleMember.Id = "96d4258f-9187-4e6c-b031-724e789b9323" +} + +Describe "Add-EntraMSScopedRoleMembership" { + Context "Test for Add-EntraMSScopedRoleMembership" { + It "Should not return empty object"{ + $result = Add-EntraMSScopedRoleMembership -Id "c9ab56cc-e349-4237-856e-cab03157a91e" -RoleId "526b7173-5a6e-49dc-88ec-b677a9093709" -RoleMemberInfo $RoleMember + $result | Should -Not -BeNullOrEmpty + $result.Id | should -Be @('412be9d1-1460-4061-8eed-cca203fcb215') + + Should -Invoke -CommandName New-MgDirectoryAdministrativeUnitScopedRoleMember -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when parameters are empty" { + { Add-EntraMSScopedRoleMembership -Id "" -RoleId "" } | Should -Throw "Cannot bind argument to parameter*" + } + It "Should contain ApplicationId in parameters when passed Id to it" { + Mock -CommandName New-MgDirectoryAdministrativeUnitScopedRoleMember -MockWith {$args} -ModuleName Microsoft.Graph.Entra + + $result = Add-EntraMSScopedRoleMembership -Id "c9ab56cc-e349-4237-856e-cab03157a91e" -RoleId "526b7173-5a6e-49dc-88ec-b677a9093709" -RoleMemberInfo $RoleMember + $params = Get-Parameters -data $result + $params.AdministrativeUnitId | Should -Be "c9ab56cc-e349-4237-856e-cab03157a91e" + } + It "Should contain 'User-Agent' header" { + Mock -CommandName New-MgDirectoryAdministrativeUnitScopedRoleMember -MockWith {$args} -ModuleName Microsoft.Graph.Entra + + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Add-EntraMSScopedRoleMembership" + + $result = Add-EntraMSScopedRoleMembership -Id "c9ab56cc-e349-4237-856e-cab03157a91e" -RoleId "526b7173-5a6e-49dc-88ec-b677a9093709" -RoleMemberInfo $RoleMember + $params = Get-Parameters -data $result + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } + } +} \ No newline at end of file diff --git a/test/module/Entra/Mock-Get-EntraMSAdministrativeUnit.Tests.ps1 b/test/module/Entra/Mock-Get-EntraMSAdministrativeUnit.Tests.ps1 new file mode 100644 index 000000000..32e2bdc76 --- /dev/null +++ b/test/module/Entra/Mock-Get-EntraMSAdministrativeUnit.Tests.ps1 @@ -0,0 +1,83 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ + #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force + Import-Module Microsoft.Graph.Entra + } + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force + + $scriptblock = { + # Write-Host "Mocking Get-MgDirectoryAdministrativeUnit with parameters: $($args | ConvertTo-Json -Depth 3)" + return @( + [PSCustomObject]@{ + "DeletedDateTime" = $null + "Description" = "Mock-Unit" + "DisplayName" = "Mock-Unit" + "Extensions" = $null + "Id" = "09cb73a9-6d82-4d4d-a9f5-9e7ba0329106" + "Members" = $null + "ScopedRoleMembers" = $null + "Visibility" = $null + "AdditionalProperties" = {} + } + ) + } + + Mock -CommandName Get-MgDirectoryAdministrativeUnit -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra +} + +Describe "Get-EntraMSAdministrativeUnit" { + Context "Test for Get-EntraMSAdministrativeUnit" { + It "Should return specific application" { + $result = Get-EntraMSAdministrativeUnit -Id "09cb73a9-6d82-4d4d-a9f5-9e7ba0329106" + $result | Should -Not -BeNullOrEmpty + $result.Id | should -Be @('09cb73a9-6d82-4d4d-a9f5-9e7ba0329106') + + Should -Invoke -CommandName Get-MgDirectoryAdministrativeUnit -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when Id is empty" { + { Get-EntraMSAdministrativeUnit -Id "" } | Should -Throw "Cannot bind argument to parameter 'Id' because it is an empty string." + } + It "Should return all administrative units" { + $result = Get-EntraMSAdministrativeUnit -All $true + $result | Should -Not -BeNullOrEmpty + + Should -Invoke -CommandName Get-MgDirectoryAdministrativeUnit -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when All is empty" { + { Get-EntraMSAdministrativeUnit -All } | Should -Throw "Missing an argument for parameter 'All'*" + } + It "Should return specific administrative unit by filter" { + $result = Get-EntraMSAdministrativeUnit -Filter "DisplayName -eq 'Mock-Unit'" + $result | Should -Not -BeNullOrEmpty + $result.DisplayName | should -Be 'Mock-Unit' + + Should -Invoke -CommandName Get-MgDirectoryAdministrativeUnit -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should return top administrative unit" { + $result = Get-EntraMSAdministrativeUnit -Top 1 + $result | Should -Not -BeNullOrEmpty + + Should -Invoke -CommandName Get-MgDirectoryAdministrativeUnit -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Result should Contain ObjectId" { + $result = Get-EntraMSAdministrativeUnit -Id "09cb73a9-6d82-4d4d-a9f5-9e7ba0329106" + $result.ObjectId | should -Be "09cb73a9-6d82-4d4d-a9f5-9e7ba0329106" + } + It "Should contain AdministrativeUnitId in parameters when passed ObjectId to it" { + Mock -CommandName Get-MgDirectoryAdministrativeUnit -MockWith {$args} -ModuleName Microsoft.Graph.Entra + + $result = Get-EntraMSAdministrativeUnit -Id "09cb73a9-6d82-4d4d-a9f5-9e7ba0329106" + $params = Get-Parameters -data $result + $params.AdministrativeUnitId | Should -Be "09cb73a9-6d82-4d4d-a9f5-9e7ba0329106" + } + It "Should contain 'User-Agent' header" { + Mock -CommandName Get-MgDirectoryAdministrativeUnit -MockWith {$args} -ModuleName Microsoft.Graph.Entra + + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraMSAdministrativeUnit" + + $result = Get-EntraMSAdministrativeUnit -Id "09cb73a9-6d82-4d4d-a9f5-9e7ba0329106" + $params = Get-Parameters -data $result + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } + } +} \ No newline at end of file diff --git a/test/module/Entra/Mock-Get-EntraMSApplicationOwner.Tests.ps1 b/test/module/Entra/Mock-Get-EntraMSApplicationOwner.Tests.ps1 new file mode 100644 index 000000000..bf8720515 --- /dev/null +++ b/test/module/Entra/Mock-Get-EntraMSApplicationOwner.Tests.ps1 @@ -0,0 +1,64 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ + #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force + Import-Module Microsoft.Graph.Entra + } + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force + + $scriptblock = { + # Write-Host "Mocking Get-MgApplicationOwner with parameters: $($args | ConvertTo-Json -Depth 3)" + return @( + [PSCustomObject]@{ + "Id" = "fd560167-ff1f-471a-8d74-3b0070abcea1" + "AdditionalProperties" = @{businessPhones={}; displayName="Conf Room Adams"; + mail="Adams@M365x99297270.OnMicrosoft.com"} + } + ) + } + + Mock -CommandName Get-MgApplicationOwner -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra +} + +Describe "Get-EntraMSApplicationOwner" { + Context "Test for Get-EntraMSApplicationOwner" { + It "Should fail when ObjectId is empty" { + { Get-EntraMSApplicationOwner -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + } + It "Should return all application owners" { + $result = Get-EntraMSApplicationOwner -ObjectId "c81d387e-d431-43b4-b12e-f07cbb35b771" -All $true + $result | Should -Not -BeNullOrEmpty + + Should -Invoke -CommandName Get-MgApplicationOwner -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when All is empty" { + { Get-EntraMSApplicationOwner -ObjectId "c81d387e-d431-43b4-b12e-f07cbb35b771" -All } | Should -Throw "Missing an argument for parameter 'All'*" + } + It "Should return top application owner" { + $result = Get-EntraMSApplicationOwner -ObjectId "c81d387e-d431-43b4-b12e-f07cbb35b771" -Top 1 + $result | Should -Not -BeNullOrEmpty + + Should -Invoke -CommandName Get-MgApplicationOwner -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Result should Contain ObjectId" { + $result = Get-EntraMSApplicationOwner -ObjectId "c81d387e-d431-43b4-b12e-f07cbb35b771" + $result.ObjectId | should -Be "fd560167-ff1f-471a-8d74-3b0070abcea1" + } + # issue in AdditionalProperties param transformation in args, will uncomment after resolve. + # It "Should contain ApplicationId in parameters when passed ObjectId to it" { + # Mock -CommandName Get-MgApplicationOwner -MockWith {$args} -ModuleName Microsoft.Graph.Entra + + # $result = Get-EntraMSApplicationOwner -ObjectId "c81d387e-d431-43b4-b12e-f07cbb35b771" + # $params = Get-Parameters -data $result + # $params.ApplicationId | Should -Be "c81d387e-d431-43b4-b12e-f07cbb35b771" + # } + # It "Should contain 'User-Agent' header" { + # Mock -CommandName Get-MgApplicationOwner -MockWith {$args} -ModuleName Microsoft.Graph.Entra + + # $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraMSApplicationOwner" + + # $result = Get-EntraMSApplicationOwner -ObjectId "c81d387e-d431-43b4-b12e-f07cbb35b771" + # $params = Get-Parameters -data $result + # $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + # } + } +} \ No newline at end of file From 937ef7f9710c24c2d54fa81894a57e9b7fd9b79a Mon Sep 17 00:00:00 2001 From: v-uansari Date: Wed, 10 Apr 2024 18:09:08 +0530 Subject: [PATCH 19/40] tests update --- test/module/Entra/Entra.Tests.ps1 | 14 +++++++------- .../Entra/Mock-Enable-EntraDirectoryRole.Tests.ps1 | 2 +- .../Entra/Mock-Get-EntraApplication.Tests.ps1 | 2 +- test/module/Entra/Mock-Get-EntraDevice.Tests.ps1 | 2 +- .../Entra/Mock-Get-EntraDirectoryRole.Tests.ps1 | 2 +- test/module/Entra/Mock-Get-EntraGroup.Tests.ps1 | 2 +- .../Entra/Mock-Get-EntraMSApplication.Tests.ps1 | 2 +- .../Entra/Mock-New-EntraApplication.Tests.ps1 | 2 +- test/module/Entra/Mock-New-EntraGroup.Tests.ps1 | 2 +- .../Entra/Mock-New-EntraMSApplication.Tests.ps1 | 2 +- .../Entra/Mock-Remove-EntraApplication.Tests.ps1 | 2 +- .../module/Entra/Mock-Remove-EntraDevice.Tests.ps1 | 2 +- test/module/Entra/Mock-Remove-EntraGroup.Tests.ps1 | 2 +- .../Entra/Mock-Remove-EntraMSApplication.Tests.ps1 | 2 +- .../Entra/Mock-Set-EntraApplication.Tests.ps1 | 2 +- test/module/Entra/Mock-Set-EntraDevice.Tests.ps1 | 2 +- test/module/Entra/Mock-Set-EntraGroup.Tests.ps1 | 2 +- .../Entra/Mock-Set-EntraMSApplication.Tests.ps1 | 2 +- 18 files changed, 24 insertions(+), 24 deletions(-) diff --git a/test/module/Entra/Entra.Tests.ps1 b/test/module/Entra/Entra.Tests.ps1 index 3b7476b98..529a1cad8 100644 --- a/test/module/Entra/Entra.Tests.ps1 +++ b/test/module/Entra/Entra.Tests.ps1 @@ -1,12 +1,12 @@ -$modulePath = join-path $psscriptroot "..\..\..\bin\Microsoft.Graph.Entra.psm1" $testReportPath = join-path $psscriptroot "..\..\..\TestReport\Entra" $mockScriptsPath = join-path $psscriptroot "..\..\..\test\module\Entra\Mock-*.Tests.ps1" $reportGenPath = join-path $psscriptroot "..\..\..\reportgenerator\ReportUnit.exe" +Write-Host 'testReportPath: '$testReportPath +Write-Host 'mockScriptsPath: '$mockScriptsPath +Write-Host 'reportGenPath: '$reportGenPath Import-Module Pester -Import-Module $modulePath -Force -#Import-Module Microsoft.Graph.Entra $testOutputFile = "$testReportPath\TestResults.xml" if (!(test-path -path $testReportPath)) {new-item -path $testReportPath -itemtype directory} @@ -17,13 +17,13 @@ $config = New-PesterConfiguration $config.Run.Path = $mockScripts $config.Run.PassThru = $true $config.Run.Exit = $true -$config.CodeCoverage.Enabled = $true -$config.CodeCoverage.CoveragePercentTarget = 100 -$config.CodeCoverage.Path = $modulePath +# $config.CodeCoverage.Enabled = $true +# $config.CodeCoverage.CoveragePercentTarget = 100 +# $config.CodeCoverage.Path = "Microsoft.Graph.Entra.psm1" $config.TestResult.Enabled = $true $config.TestResult.OutputPath = $testOutputFile $config.Output.Verbosity = "Detailed" Invoke-Pester -Configuration $config -& "$reportGenPath" "$testOutputFile" \ No newline at end of file +#& "$reportGenPath" "$testOutputFile" \ No newline at end of file diff --git a/test/module/Entra/Mock-Enable-EntraDirectoryRole.Tests.ps1 b/test/module/Entra/Mock-Enable-EntraDirectoryRole.Tests.ps1 index c1e958b6d..575fa7931 100644 --- a/test/module/Entra/Mock-Enable-EntraDirectoryRole.Tests.ps1 +++ b/test/module/Entra/Mock-Enable-EntraDirectoryRole.Tests.ps1 @@ -3,7 +3,7 @@ BeforeAll { #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force Import-Module Microsoft.Graph.Entra } - Import-Module .\test\module\Common-Functions.ps1 -Force + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force Mock -CommandName New-MgDirectoryRole -MockWith {} -ModuleName Microsoft.Graph.Entra } diff --git a/test/module/Entra/Mock-Get-EntraApplication.Tests.ps1 b/test/module/Entra/Mock-Get-EntraApplication.Tests.ps1 index d48cc7500..8aaf7786f 100644 --- a/test/module/Entra/Mock-Get-EntraApplication.Tests.ps1 +++ b/test/module/Entra/Mock-Get-EntraApplication.Tests.ps1 @@ -3,7 +3,7 @@ BeforeAll { #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force Import-Module Microsoft.Graph.Entra } - Import-Module .\test\module\Common-Functions.ps1 -Force + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force $scriptblock = { # Write-Host "Mocking Get-MgApplication with parameters: $($args | ConvertTo-Json -Depth 3)" diff --git a/test/module/Entra/Mock-Get-EntraDevice.Tests.ps1 b/test/module/Entra/Mock-Get-EntraDevice.Tests.ps1 index 3a34922f6..ea1793c9b 100644 --- a/test/module/Entra/Mock-Get-EntraDevice.Tests.ps1 +++ b/test/module/Entra/Mock-Get-EntraDevice.Tests.ps1 @@ -3,7 +3,7 @@ BeforeAll { #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force Import-Module Microsoft.Graph.Entra } - Import-Module .\test\module\Common-Functions.ps1 -Force + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force $scriptblock = { # Write-Host "Mocking Get-MgDevice with parameters: $($args | ConvertTo-Json -Depth 3)" diff --git a/test/module/Entra/Mock-Get-EntraDirectoryRole.Tests.ps1 b/test/module/Entra/Mock-Get-EntraDirectoryRole.Tests.ps1 index 72ac7159c..84d08c98d 100644 --- a/test/module/Entra/Mock-Get-EntraDirectoryRole.Tests.ps1 +++ b/test/module/Entra/Mock-Get-EntraDirectoryRole.Tests.ps1 @@ -3,7 +3,7 @@ BeforeAll { #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force Import-Module Microsoft.Graph.Entra } - Import-Module .\test\module\Common-Functions.ps1 -Force + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force $scriptblock = { # Write-Host "Mocking Get-EntraDirectoryRole with parameters: $($args | ConvertTo-Json -Depth 3)" diff --git a/test/module/Entra/Mock-Get-EntraGroup.Tests.ps1 b/test/module/Entra/Mock-Get-EntraGroup.Tests.ps1 index f10c708c9..555706a45 100644 --- a/test/module/Entra/Mock-Get-EntraGroup.Tests.ps1 +++ b/test/module/Entra/Mock-Get-EntraGroup.Tests.ps1 @@ -3,7 +3,7 @@ BeforeAll { #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force Import-Module Microsoft.Graph.Entra } - Import-Module .\test\module\Common-Functions.ps1 -Force + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force $scriptblock = { # Write-Host "Mocking Get-EntraGroup with parameters: $($args | ConvertTo-Json -Depth 3)" diff --git a/test/module/Entra/Mock-Get-EntraMSApplication.Tests.ps1 b/test/module/Entra/Mock-Get-EntraMSApplication.Tests.ps1 index 5fc2e530d..afbd85cf1 100644 --- a/test/module/Entra/Mock-Get-EntraMSApplication.Tests.ps1 +++ b/test/module/Entra/Mock-Get-EntraMSApplication.Tests.ps1 @@ -3,7 +3,7 @@ BeforeAll { #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force Import-Module Microsoft.Graph.Entra } - Import-Module .\test\module\Common-Functions.ps1 -Force + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force $scriptblock = { # Write-Host "Mocking Get-MgApplication with parameters: $($args | ConvertTo-Json -Depth 3)" diff --git a/test/module/Entra/Mock-New-EntraApplication.Tests.ps1 b/test/module/Entra/Mock-New-EntraApplication.Tests.ps1 index 2619edbd1..c0e189d7e 100644 --- a/test/module/Entra/Mock-New-EntraApplication.Tests.ps1 +++ b/test/module/Entra/Mock-New-EntraApplication.Tests.ps1 @@ -3,7 +3,7 @@ BeforeAll { #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force Import-Module Microsoft.Graph.Entra } - Import-Module .\test\module\Common-Functions.ps1 -Force + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force $scriptblock = { # Write-Host "Mocking New-MgApplication with parameters: $($args | ConvertTo-Json -Depth 3)" diff --git a/test/module/Entra/Mock-New-EntraGroup.Tests.ps1 b/test/module/Entra/Mock-New-EntraGroup.Tests.ps1 index e10f8645e..00ed9eaa8 100644 --- a/test/module/Entra/Mock-New-EntraGroup.Tests.ps1 +++ b/test/module/Entra/Mock-New-EntraGroup.Tests.ps1 @@ -3,7 +3,7 @@ BeforeAll { #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force Import-Module Microsoft.Graph.Entra } - Import-Module .\test\module\Common-Functions.ps1 -Force + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force $scriptblock = { #Write-Host "Mocking New-EntraGroup with parameters: $($args | ConvertTo-Json -Depth 3)" diff --git a/test/module/Entra/Mock-New-EntraMSApplication.Tests.ps1 b/test/module/Entra/Mock-New-EntraMSApplication.Tests.ps1 index 9ec3c0eea..e19e3d9ce 100644 --- a/test/module/Entra/Mock-New-EntraMSApplication.Tests.ps1 +++ b/test/module/Entra/Mock-New-EntraMSApplication.Tests.ps1 @@ -3,7 +3,7 @@ BeforeAll { #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force Import-Module Microsoft.Graph.Entra } - Import-Module .\test\module\Common-Functions.ps1 -Force + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force $scriptblock = { # Write-Host "Mocking New-MgApplication with parameters: $($args | ConvertTo-Json -Depth 3)" diff --git a/test/module/Entra/Mock-Remove-EntraApplication.Tests.ps1 b/test/module/Entra/Mock-Remove-EntraApplication.Tests.ps1 index c31665a3a..23a59ec67 100644 --- a/test/module/Entra/Mock-Remove-EntraApplication.Tests.ps1 +++ b/test/module/Entra/Mock-Remove-EntraApplication.Tests.ps1 @@ -3,7 +3,7 @@ BeforeAll { #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force Import-Module Microsoft.Graph.Entra } - Import-Module .\test\module\Common-Functions.ps1 -Force + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force Mock -CommandName Remove-MgApplication -MockWith {} -ModuleName Microsoft.Graph.Entra } diff --git a/test/module/Entra/Mock-Remove-EntraDevice.Tests.ps1 b/test/module/Entra/Mock-Remove-EntraDevice.Tests.ps1 index 8692c8656..3abed6213 100644 --- a/test/module/Entra/Mock-Remove-EntraDevice.Tests.ps1 +++ b/test/module/Entra/Mock-Remove-EntraDevice.Tests.ps1 @@ -3,7 +3,7 @@ BeforeAll { #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force Import-Module Microsoft.Graph.Entra } - Import-Module .\test\module\Common-Functions.ps1 -Force + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force Mock -CommandName Remove-MgDevice -MockWith {} -ModuleName Microsoft.Graph.Entra } diff --git a/test/module/Entra/Mock-Remove-EntraGroup.Tests.ps1 b/test/module/Entra/Mock-Remove-EntraGroup.Tests.ps1 index b7e51064c..8b3b02ffd 100644 --- a/test/module/Entra/Mock-Remove-EntraGroup.Tests.ps1 +++ b/test/module/Entra/Mock-Remove-EntraGroup.Tests.ps1 @@ -3,7 +3,7 @@ BeforeAll { #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force Import-Module Microsoft.Graph.Entra } - Import-Module .\test\module\Common-Functions.ps1 -Force + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force Mock -CommandName Remove-MgGroup -MockWith {} -ModuleName Microsoft.Graph.Entra } diff --git a/test/module/Entra/Mock-Remove-EntraMSApplication.Tests.ps1 b/test/module/Entra/Mock-Remove-EntraMSApplication.Tests.ps1 index 560ad8832..04a63125c 100644 --- a/test/module/Entra/Mock-Remove-EntraMSApplication.Tests.ps1 +++ b/test/module/Entra/Mock-Remove-EntraMSApplication.Tests.ps1 @@ -3,7 +3,7 @@ BeforeAll { #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force Import-Module Microsoft.Graph.Entra } - Import-Module .\test\module\Common-Functions.ps1 -Force + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force Mock -CommandName Remove-MgApplication -MockWith {} -ModuleName Microsoft.Graph.Entra } diff --git a/test/module/Entra/Mock-Set-EntraApplication.Tests.ps1 b/test/module/Entra/Mock-Set-EntraApplication.Tests.ps1 index d4167241a..f5201ee6d 100644 --- a/test/module/Entra/Mock-Set-EntraApplication.Tests.ps1 +++ b/test/module/Entra/Mock-Set-EntraApplication.Tests.ps1 @@ -3,7 +3,7 @@ BeforeAll { #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force Import-Module Microsoft.Graph.Entra } - Import-Module .\test\module\Common-Functions.ps1 -Force + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force Mock -CommandName Update-MgApplication -MockWith {} -ModuleName Microsoft.Graph.Entra } diff --git a/test/module/Entra/Mock-Set-EntraDevice.Tests.ps1 b/test/module/Entra/Mock-Set-EntraDevice.Tests.ps1 index 21e367873..26499d840 100644 --- a/test/module/Entra/Mock-Set-EntraDevice.Tests.ps1 +++ b/test/module/Entra/Mock-Set-EntraDevice.Tests.ps1 @@ -3,7 +3,7 @@ BeforeAll { #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force Import-Module Microsoft.Graph.Entra } - Import-Module .\test\module\Common-Functions.ps1 -Force + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force Mock -CommandName Update-MgDevice -MockWith {} -ModuleName Microsoft.Graph.Entra } diff --git a/test/module/Entra/Mock-Set-EntraGroup.Tests.ps1 b/test/module/Entra/Mock-Set-EntraGroup.Tests.ps1 index a91320a47..f9119fc0b 100644 --- a/test/module/Entra/Mock-Set-EntraGroup.Tests.ps1 +++ b/test/module/Entra/Mock-Set-EntraGroup.Tests.ps1 @@ -3,7 +3,7 @@ BeforeAll { #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force Import-Module Microsoft.Graph.Entra } - Import-Module .\test\module\Common-Functions.ps1 -Force + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force Mock -CommandName Update-MgGroup -MockWith {} -ModuleName Microsoft.Graph.Entra } diff --git a/test/module/Entra/Mock-Set-EntraMSApplication.Tests.ps1 b/test/module/Entra/Mock-Set-EntraMSApplication.Tests.ps1 index 8676b10f5..cac5253aa 100644 --- a/test/module/Entra/Mock-Set-EntraMSApplication.Tests.ps1 +++ b/test/module/Entra/Mock-Set-EntraMSApplication.Tests.ps1 @@ -3,7 +3,7 @@ BeforeAll { #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force Import-Module Microsoft.Graph.Entra } - Import-Module .\test\module\Common-Functions.ps1 -Force + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force Mock -CommandName Update-MgApplication -MockWith {} -ModuleName Microsoft.Graph.Entra } From 1c5e15e3088eb90fb580facb89e196a4d9b707cc Mon Sep 17 00:00:00 2001 From: v-uansari Date: Thu, 11 Apr 2024 10:01:32 +0530 Subject: [PATCH 20/40] update tests --- test/module/Entra/Entra.Tests.ps1 | 17 +++++++++++++---- .../Mock-Enable-EntraDirectoryRole.Tests.ps1 | 1 - .../Entra/Mock-Get-EntraApplication.Tests.ps1 | 1 - .../module/Entra/Mock-Get-EntraDevice.Tests.ps1 | 1 - .../Entra/Mock-Get-EntraDirectoryRole.Tests.ps1 | 1 - test/module/Entra/Mock-Get-EntraGroup.Tests.ps1 | 1 - .../Entra/Mock-Get-EntraMSApplication.Tests.ps1 | 1 - .../Entra/Mock-New-EntraApplication.Tests.ps1 | 1 - test/module/Entra/Mock-New-EntraGroup.Tests.ps1 | 1 - .../Entra/Mock-New-EntraMSApplication.Tests.ps1 | 1 - .../Mock-Remove-EntraApplication.Tests.ps1 | 1 - .../Entra/Mock-Remove-EntraDevice.Tests.ps1 | 1 - .../Entra/Mock-Remove-EntraGroup.Tests.ps1 | 1 - .../Mock-Remove-EntraMSApplication.Tests.ps1 | 1 - .../Entra/Mock-Set-EntraApplication.Tests.ps1 | 1 - .../module/Entra/Mock-Set-EntraDevice.Tests.ps1 | 1 - test/module/Entra/Mock-Set-EntraGroup.Tests.ps1 | 1 - .../Entra/Mock-Set-EntraMSApplication.Tests.ps1 | 1 - 18 files changed, 13 insertions(+), 21 deletions(-) diff --git a/test/module/Entra/Entra.Tests.ps1 b/test/module/Entra/Entra.Tests.ps1 index 529a1cad8..6d913b54a 100644 --- a/test/module/Entra/Entra.Tests.ps1 +++ b/test/module/Entra/Entra.Tests.ps1 @@ -1,12 +1,21 @@ +if($null -eq (Get-Module -Name Microsoft.Graph.Entra)){ + Import-Module Microsoft.Graph.Entra +} + +Import-Module Pester + +$psmPath = (Get-Module Microsoft.Graph.Entra).Path $testReportPath = join-path $psscriptroot "..\..\..\TestReport\Entra" $mockScriptsPath = join-path $psscriptroot "..\..\..\test\module\Entra\Mock-*.Tests.ps1" $reportGenPath = join-path $psscriptroot "..\..\..\reportgenerator\ReportUnit.exe" + +Write-Host 'psmPath: '$psmPath Write-Host 'testReportPath: '$testReportPath Write-Host 'mockScriptsPath: '$mockScriptsPath Write-Host 'reportGenPath: '$reportGenPath -Import-Module Pester + $testOutputFile = "$testReportPath\TestResults.xml" if (!(test-path -path $testReportPath)) {new-item -path $testReportPath -itemtype directory} @@ -17,9 +26,9 @@ $config = New-PesterConfiguration $config.Run.Path = $mockScripts $config.Run.PassThru = $true $config.Run.Exit = $true -# $config.CodeCoverage.Enabled = $true -# $config.CodeCoverage.CoveragePercentTarget = 100 -# $config.CodeCoverage.Path = "Microsoft.Graph.Entra.psm1" +$config.CodeCoverage.Enabled = $true +$config.CodeCoverage.CoveragePercentTarget = 100 +$config.CodeCoverage.Path = $psmPath $config.TestResult.Enabled = $true $config.TestResult.OutputPath = $testOutputFile $config.Output.Verbosity = "Detailed" diff --git a/test/module/Entra/Mock-Enable-EntraDirectoryRole.Tests.ps1 b/test/module/Entra/Mock-Enable-EntraDirectoryRole.Tests.ps1 index 575fa7931..e66410a66 100644 --- a/test/module/Entra/Mock-Enable-EntraDirectoryRole.Tests.ps1 +++ b/test/module/Entra/Mock-Enable-EntraDirectoryRole.Tests.ps1 @@ -1,6 +1,5 @@ BeforeAll { if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ - #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force Import-Module Microsoft.Graph.Entra } Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force diff --git a/test/module/Entra/Mock-Get-EntraApplication.Tests.ps1 b/test/module/Entra/Mock-Get-EntraApplication.Tests.ps1 index 8aaf7786f..37517f687 100644 --- a/test/module/Entra/Mock-Get-EntraApplication.Tests.ps1 +++ b/test/module/Entra/Mock-Get-EntraApplication.Tests.ps1 @@ -1,6 +1,5 @@ BeforeAll { if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ - #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force Import-Module Microsoft.Graph.Entra } Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force diff --git a/test/module/Entra/Mock-Get-EntraDevice.Tests.ps1 b/test/module/Entra/Mock-Get-EntraDevice.Tests.ps1 index ea1793c9b..d0c363daa 100644 --- a/test/module/Entra/Mock-Get-EntraDevice.Tests.ps1 +++ b/test/module/Entra/Mock-Get-EntraDevice.Tests.ps1 @@ -1,6 +1,5 @@ BeforeAll { if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ - #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force Import-Module Microsoft.Graph.Entra } Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force diff --git a/test/module/Entra/Mock-Get-EntraDirectoryRole.Tests.ps1 b/test/module/Entra/Mock-Get-EntraDirectoryRole.Tests.ps1 index 84d08c98d..33c9ae24c 100644 --- a/test/module/Entra/Mock-Get-EntraDirectoryRole.Tests.ps1 +++ b/test/module/Entra/Mock-Get-EntraDirectoryRole.Tests.ps1 @@ -1,6 +1,5 @@ BeforeAll { if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ - #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force Import-Module Microsoft.Graph.Entra } Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force diff --git a/test/module/Entra/Mock-Get-EntraGroup.Tests.ps1 b/test/module/Entra/Mock-Get-EntraGroup.Tests.ps1 index 555706a45..9cfcaad48 100644 --- a/test/module/Entra/Mock-Get-EntraGroup.Tests.ps1 +++ b/test/module/Entra/Mock-Get-EntraGroup.Tests.ps1 @@ -1,6 +1,5 @@ BeforeAll { if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ - #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force Import-Module Microsoft.Graph.Entra } Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force diff --git a/test/module/Entra/Mock-Get-EntraMSApplication.Tests.ps1 b/test/module/Entra/Mock-Get-EntraMSApplication.Tests.ps1 index afbd85cf1..31bab45b6 100644 --- a/test/module/Entra/Mock-Get-EntraMSApplication.Tests.ps1 +++ b/test/module/Entra/Mock-Get-EntraMSApplication.Tests.ps1 @@ -1,6 +1,5 @@ BeforeAll { if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ - #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force Import-Module Microsoft.Graph.Entra } Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force diff --git a/test/module/Entra/Mock-New-EntraApplication.Tests.ps1 b/test/module/Entra/Mock-New-EntraApplication.Tests.ps1 index c0e189d7e..12ae56ea3 100644 --- a/test/module/Entra/Mock-New-EntraApplication.Tests.ps1 +++ b/test/module/Entra/Mock-New-EntraApplication.Tests.ps1 @@ -1,6 +1,5 @@ BeforeAll { if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ - #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force Import-Module Microsoft.Graph.Entra } Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force diff --git a/test/module/Entra/Mock-New-EntraGroup.Tests.ps1 b/test/module/Entra/Mock-New-EntraGroup.Tests.ps1 index 00ed9eaa8..dd884b0ac 100644 --- a/test/module/Entra/Mock-New-EntraGroup.Tests.ps1 +++ b/test/module/Entra/Mock-New-EntraGroup.Tests.ps1 @@ -1,6 +1,5 @@ BeforeAll { if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ - #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force Import-Module Microsoft.Graph.Entra } Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force diff --git a/test/module/Entra/Mock-New-EntraMSApplication.Tests.ps1 b/test/module/Entra/Mock-New-EntraMSApplication.Tests.ps1 index e19e3d9ce..d50e272fc 100644 --- a/test/module/Entra/Mock-New-EntraMSApplication.Tests.ps1 +++ b/test/module/Entra/Mock-New-EntraMSApplication.Tests.ps1 @@ -1,6 +1,5 @@ BeforeAll { if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ - #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force Import-Module Microsoft.Graph.Entra } Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force diff --git a/test/module/Entra/Mock-Remove-EntraApplication.Tests.ps1 b/test/module/Entra/Mock-Remove-EntraApplication.Tests.ps1 index 23a59ec67..743ae44f0 100644 --- a/test/module/Entra/Mock-Remove-EntraApplication.Tests.ps1 +++ b/test/module/Entra/Mock-Remove-EntraApplication.Tests.ps1 @@ -1,6 +1,5 @@ BeforeAll { if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ - #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force Import-Module Microsoft.Graph.Entra } Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force diff --git a/test/module/Entra/Mock-Remove-EntraDevice.Tests.ps1 b/test/module/Entra/Mock-Remove-EntraDevice.Tests.ps1 index 3abed6213..aae863377 100644 --- a/test/module/Entra/Mock-Remove-EntraDevice.Tests.ps1 +++ b/test/module/Entra/Mock-Remove-EntraDevice.Tests.ps1 @@ -1,6 +1,5 @@ BeforeAll { if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ - #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force Import-Module Microsoft.Graph.Entra } Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force diff --git a/test/module/Entra/Mock-Remove-EntraGroup.Tests.ps1 b/test/module/Entra/Mock-Remove-EntraGroup.Tests.ps1 index 8b3b02ffd..97d63aa32 100644 --- a/test/module/Entra/Mock-Remove-EntraGroup.Tests.ps1 +++ b/test/module/Entra/Mock-Remove-EntraGroup.Tests.ps1 @@ -1,6 +1,5 @@ BeforeAll { if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ - #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force Import-Module Microsoft.Graph.Entra } Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force diff --git a/test/module/Entra/Mock-Remove-EntraMSApplication.Tests.ps1 b/test/module/Entra/Mock-Remove-EntraMSApplication.Tests.ps1 index 04a63125c..83beec32e 100644 --- a/test/module/Entra/Mock-Remove-EntraMSApplication.Tests.ps1 +++ b/test/module/Entra/Mock-Remove-EntraMSApplication.Tests.ps1 @@ -1,6 +1,5 @@ BeforeAll { if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ - #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force Import-Module Microsoft.Graph.Entra } Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force diff --git a/test/module/Entra/Mock-Set-EntraApplication.Tests.ps1 b/test/module/Entra/Mock-Set-EntraApplication.Tests.ps1 index f5201ee6d..c5cf0d3ce 100644 --- a/test/module/Entra/Mock-Set-EntraApplication.Tests.ps1 +++ b/test/module/Entra/Mock-Set-EntraApplication.Tests.ps1 @@ -1,6 +1,5 @@ BeforeAll { if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ - #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force Import-Module Microsoft.Graph.Entra } Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force diff --git a/test/module/Entra/Mock-Set-EntraDevice.Tests.ps1 b/test/module/Entra/Mock-Set-EntraDevice.Tests.ps1 index 26499d840..6f09d84ce 100644 --- a/test/module/Entra/Mock-Set-EntraDevice.Tests.ps1 +++ b/test/module/Entra/Mock-Set-EntraDevice.Tests.ps1 @@ -1,6 +1,5 @@ BeforeAll { if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ - #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force Import-Module Microsoft.Graph.Entra } Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force diff --git a/test/module/Entra/Mock-Set-EntraGroup.Tests.ps1 b/test/module/Entra/Mock-Set-EntraGroup.Tests.ps1 index f9119fc0b..8417b613e 100644 --- a/test/module/Entra/Mock-Set-EntraGroup.Tests.ps1 +++ b/test/module/Entra/Mock-Set-EntraGroup.Tests.ps1 @@ -1,6 +1,5 @@ BeforeAll { if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ - #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force Import-Module Microsoft.Graph.Entra } Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force diff --git a/test/module/Entra/Mock-Set-EntraMSApplication.Tests.ps1 b/test/module/Entra/Mock-Set-EntraMSApplication.Tests.ps1 index cac5253aa..2b34d99a8 100644 --- a/test/module/Entra/Mock-Set-EntraMSApplication.Tests.ps1 +++ b/test/module/Entra/Mock-Set-EntraMSApplication.Tests.ps1 @@ -1,6 +1,5 @@ BeforeAll { if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ - #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force Import-Module Microsoft.Graph.Entra } Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force From 8d49146ee061f7db6c327104ecced8e3d7951e28 Mon Sep 17 00:00:00 2001 From: v-uansari Date: Thu, 11 Apr 2024 10:07:21 +0530 Subject: [PATCH 21/40] update tests --- .../Entra/Mock-Add-EntraMSAdministrativeUnitMember.Tests.ps1 | 1 - test/module/Entra/Mock-Add-EntraMSApplicationOwner.Tests.ps1 | 1 - test/module/Entra/Mock-Add-EntraMSScopedRoleMembership.Tests.ps1 | 1 - test/module/Entra/Mock-Get-EntraMSAdministrativeUnit.Tests.ps1 | 1 - test/module/Entra/Mock-Get-EntraMSApplicationOwner.Tests.ps1 | 1 - 5 files changed, 5 deletions(-) diff --git a/test/module/Entra/Mock-Add-EntraMSAdministrativeUnitMember.Tests.ps1 b/test/module/Entra/Mock-Add-EntraMSAdministrativeUnitMember.Tests.ps1 index b2f0c4429..41a7fe3c1 100644 --- a/test/module/Entra/Mock-Add-EntraMSAdministrativeUnitMember.Tests.ps1 +++ b/test/module/Entra/Mock-Add-EntraMSAdministrativeUnitMember.Tests.ps1 @@ -1,6 +1,5 @@ BeforeAll { if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ - #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force Import-Module Microsoft.Graph.Entra } Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force diff --git a/test/module/Entra/Mock-Add-EntraMSApplicationOwner.Tests.ps1 b/test/module/Entra/Mock-Add-EntraMSApplicationOwner.Tests.ps1 index 4e463544a..8d464b73c 100644 --- a/test/module/Entra/Mock-Add-EntraMSApplicationOwner.Tests.ps1 +++ b/test/module/Entra/Mock-Add-EntraMSApplicationOwner.Tests.ps1 @@ -1,6 +1,5 @@ BeforeAll { if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ - #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force Import-Module Microsoft.Graph.Entra } Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force diff --git a/test/module/Entra/Mock-Add-EntraMSScopedRoleMembership.Tests.ps1 b/test/module/Entra/Mock-Add-EntraMSScopedRoleMembership.Tests.ps1 index bef2cd44f..53843d3aa 100644 --- a/test/module/Entra/Mock-Add-EntraMSScopedRoleMembership.Tests.ps1 +++ b/test/module/Entra/Mock-Add-EntraMSScopedRoleMembership.Tests.ps1 @@ -1,6 +1,5 @@ BeforeAll { if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ - #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force Import-Module Microsoft.Graph.Entra } Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force diff --git a/test/module/Entra/Mock-Get-EntraMSAdministrativeUnit.Tests.ps1 b/test/module/Entra/Mock-Get-EntraMSAdministrativeUnit.Tests.ps1 index 32e2bdc76..e8f1d76c8 100644 --- a/test/module/Entra/Mock-Get-EntraMSAdministrativeUnit.Tests.ps1 +++ b/test/module/Entra/Mock-Get-EntraMSAdministrativeUnit.Tests.ps1 @@ -1,6 +1,5 @@ BeforeAll { if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ - #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force Import-Module Microsoft.Graph.Entra } Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force diff --git a/test/module/Entra/Mock-Get-EntraMSApplicationOwner.Tests.ps1 b/test/module/Entra/Mock-Get-EntraMSApplicationOwner.Tests.ps1 index bf8720515..97515f606 100644 --- a/test/module/Entra/Mock-Get-EntraMSApplicationOwner.Tests.ps1 +++ b/test/module/Entra/Mock-Get-EntraMSApplicationOwner.Tests.ps1 @@ -1,6 +1,5 @@ BeforeAll { if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ - #Import-Module .\bin\Microsoft.Graph.Entra.psm1 -Force Import-Module Microsoft.Graph.Entra } Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force From 23ecfd89a44b2a3e4628d3679feec51cb2aa9fa6 Mon Sep 17 00:00:00 2001 From: v-uansari Date: Thu, 11 Apr 2024 11:52:47 +0530 Subject: [PATCH 22/40] update --- ...-EntraMSAdministrativeUnitMember.Tests.ps1 | 68 +++++++++++++++++++ ...-Get-EntraMSScopedRoleMembership.Tests.ps1 | 58 ++++++++++++++++ 2 files changed, 126 insertions(+) create mode 100644 test/module/Entra/Mock-Get-EntraMSAdministrativeUnitMember.Tests.ps1 create mode 100644 test/module/Entra/Mock-Get-EntraMSScopedRoleMembership.Tests.ps1 diff --git a/test/module/Entra/Mock-Get-EntraMSAdministrativeUnitMember.Tests.ps1 b/test/module/Entra/Mock-Get-EntraMSAdministrativeUnitMember.Tests.ps1 new file mode 100644 index 000000000..c9b75f4ea --- /dev/null +++ b/test/module/Entra/Mock-Get-EntraMSAdministrativeUnitMember.Tests.ps1 @@ -0,0 +1,68 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ + Import-Module Microsoft.Graph.Entra + } + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force + + $scriptblock = { + # Write-Host "Mocking Get-MgDirectoryAdministrativeUnitMember with parameters: $($args | ConvertTo-Json -Depth 3)" + return @( + [PSCustomObject]@{ + "DeletedDateTime" = $null + "Id" = "d67d8b7b-57e1-486e-9361-26a1e2f0e8fe" + "AdditionalProperties" = @{displayName="Tests1";givenName="Tests1"} + } + ) + } + + Mock -CommandName Get-MgDirectoryAdministrativeUnitMember -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra +} + +Describe "Get-EntraMSAdministrativeUnitMember" { + Context "Test for Get-EntraMSAdministrativeUnitMember" { + It "Should return administrative unit member" { + $result = Get-EntraMSAdministrativeUnitMember -Id "09cb73a9-6d82-4d4d-a9f5-9e7ba0329106" + $result | Should -Not -BeNullOrEmpty + + Should -Invoke -CommandName Get-MgDirectoryAdministrativeUnitMember -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when Id is empty" { + { Get-EntraMSAdministrativeUnitMember -Id "" } | Should -Throw "Cannot bind argument to parameter 'Id' because it is an empty string." + } + It "Should return all administrative units" { + $result = Get-EntraMSAdministrativeUnitMember -Id "09cb73a9-6d82-4d4d-a9f5-9e7ba0329106" -All $true + $result | Should -Not -BeNullOrEmpty + + Should -Invoke -CommandName Get-MgDirectoryAdministrativeUnitMember -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when All is empty" { + { Get-EntraMSAdministrativeUnitMember -Id "09cb73a9-6d82-4d4d-a9f5-9e7ba0329106" -All } | Should -Throw "Missing an argument for parameter 'All'*" + } + It "Should return top administrative unit" { + $result = Get-EntraMSAdministrativeUnitMember -Id "09cb73a9-6d82-4d4d-a9f5-9e7ba0329106" -Top 1 + $result | Should -Not -BeNullOrEmpty + + Should -Invoke -CommandName Get-MgDirectoryAdministrativeUnitMember -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Result should Contain ObjectId" { + $result = Get-EntraMSAdministrativeUnitMember -Id "09cb73a9-6d82-4d4d-a9f5-9e7ba0329106" -Top 1 + $result.ObjectId | should -Be "d67d8b7b-57e1-486e-9361-26a1e2f0e8fe" + } + It "Should contain AdministrativeUnitId in parameters when passed ObjectId to it" { + Mock -CommandName Get-MgDirectoryAdministrativeUnitMember -MockWith {$args} -ModuleName Microsoft.Graph.Entra + + $result = Get-EntraMSAdministrativeUnitMember -Id "09cb73a9-6d82-4d4d-a9f5-9e7ba0329106" + $params = Get-Parameters -data $result + $params.AdministrativeUnitId | Should -Be "09cb73a9-6d82-4d4d-a9f5-9e7ba0329106" + } + It "Should contain 'User-Agent' header" { + Mock -CommandName Get-MgDirectoryAdministrativeUnitMember -MockWith {$args} -ModuleName Microsoft.Graph.Entra + + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraMSAdministrativeUnitMember" + + $result = Get-EntraMSAdministrativeUnitMember -Id "09cb73a9-6d82-4d4d-a9f5-9e7ba0329106" + $params = Get-Parameters -data $result + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } + } +} \ No newline at end of file diff --git a/test/module/Entra/Mock-Get-EntraMSScopedRoleMembership.Tests.ps1 b/test/module/Entra/Mock-Get-EntraMSScopedRoleMembership.Tests.ps1 new file mode 100644 index 000000000..7cfde5543 --- /dev/null +++ b/test/module/Entra/Mock-Get-EntraMSScopedRoleMembership.Tests.ps1 @@ -0,0 +1,58 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ + Import-Module Microsoft.Graph.Entra + } + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force + + $scriptblock = { + # Write-Host "Mocking Get-MgDirectoryAdministrativeUnitScopedRoleMember with parameters: $($args | ConvertTo-Json -Depth 3)" + return @( + [PSCustomObject]@{ + "RoleMemberInfo" = @{DisplayName="Raul Razo"; Id="97d57292-02b9-4360-afb9-058268b77754"; AdditionalProperties={}} + "AdministrativeUnitId" = "d40bbf91-9b28-42bb-a42c-f2ada9332fb6" + "Id" = "zTVcE8KFQ0W4bI9tvt6kz5G_C9Qom7tCpCzyrakzL7aSctWXuQJgQ6-5BYJot3dUU" + "RoleId" = "526b7173-5a6e-49dc-88ec-b677a9093709" + "AdditionalProperties" = {} + } + ) + } + + Mock -CommandName Get-MgDirectoryAdministrativeUnitScopedRoleMember -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra +} + +Describe "Get-EntraMSScopedRoleMembership" { + Context "Test for Get-EntraMSScopedRoleMembership" { + It "Should not return empty object"{ + $result = Get-EntraMSScopedRoleMembership -Id "c9ab56cc-e349-4237-856e-cab03157a91e" + $result | Should -Not -BeNullOrEmpty + + Should -Invoke -CommandName Get-MgDirectoryAdministrativeUnitScopedRoleMember -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should return specific scoped role membership"{ + $result = Get-EntraMSScopedRoleMembership -Id "c9ab56cc-e349-4237-856e-cab03157a91e" -ScopedRoleMembershipId "526b7173-5a6e-49dc-88ec-b677a9093709" + $result | Should -Not -BeNullOrEmpty + $result.Id | Should -Be "zTVcE8KFQ0W4bI9tvt6kz5G_C9Qom7tCpCzyrakzL7aSctWXuQJgQ6-5BYJot3dUU" + + Should -Invoke -CommandName Get-MgDirectoryAdministrativeUnitScopedRoleMember -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when parameters are empty" { + { Get-EntraMSScopedRoleMembership -Id "" -ScopedRoleMembershipId "" } | Should -Throw "Cannot bind argument to parameter*" + } + It "Should contain AdministrativeUnitId in parameters when passed Id to it" { + Mock -CommandName Get-MgDirectoryAdministrativeUnitScopedRoleMember -MockWith {$args} -ModuleName Microsoft.Graph.Entra + + $result = Get-EntraMSScopedRoleMembership -Id "c9ab56cc-e349-4237-856e-cab03157a91e" -ScopedRoleMembershipId "526b7173-5a6e-49dc-88ec-b677a9093709" -RoleMemberInfo $RoleMember + $params = Get-Parameters -data $result + $params.AdministrativeUnitId | Should -Be "c9ab56cc-e349-4237-856e-cab03157a91e" + } + It "Should contain 'User-Agent' header" { + Mock -CommandName Get-MgDirectoryAdministrativeUnitScopedRoleMember -MockWith {$args} -ModuleName Microsoft.Graph.Entra + + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraMSScopedRoleMembership" + + $result = Get-EntraMSScopedRoleMembership -Id "c9ab56cc-e349-4237-856e-cab03157a91e" -ScopedRoleMembershipId "526b7173-5a6e-49dc-88ec-b677a9093709" -RoleMemberInfo $RoleMember + $params = Get-Parameters -data $result + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } + } +} \ No newline at end of file From 97d9654685a2265faec1ae2cebc22b8cfb1b1afb Mon Sep 17 00:00:00 2001 From: v-uansari Date: Thu, 11 Apr 2024 11:58:56 +0530 Subject: [PATCH 23/40] updates --- reportgenerator/ReportUnit.exe | Bin 205312 -> 0 bytes test/module/Entra/Entra.Tests.ps1 | 13 +------------ 2 files changed, 1 insertion(+), 12 deletions(-) delete mode 100644 reportgenerator/ReportUnit.exe diff --git a/reportgenerator/ReportUnit.exe b/reportgenerator/ReportUnit.exe deleted file mode 100644 index bfb952c08b91a5eba25585bc8f3b11c805530645..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 205312 zcmeFa31C#$bvJ%zB#riEB#>C_AdE4xHg*gcV?ZpH4H$z=yn{dk$QBy;jf5c>0%;aI zjh#AMvp9+EB>mDhU6Zug+Qe;>rc2ti$=9Yya(sUNb7MY&Z~j{+?&QuXBsa|YScCac_2=e( zB)0W)a|aF$XWGZS^g(a%aQptj(b4pH`@U4WH!<2iJlekT=3VWF(?hA=`udtHZPhzA z8M8H3W@de0&TiM*vnC#^jnx`61CUi|>^;}O-wyveLc31=afKTZ0zbdaDWoHw|H{m| zR~geJ|NUT1u+w;@nW zyz7Wp{3C2}Q(=xCF=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nE7b>?hp0xVSRkAp1V9cbMG#FzO4Vg_AZ{C{kzKhntv+3p2^)8 zzxlzr>Ddd<>sQ7n6(!G2OwZQqqxT*v!q&h4yDzJq3GZHxKYiKj0<@N8^Iz2KNxkYN z_YeNdG;`Vdx@KeMb2sZPcQ;*Jxc(3I?w_6M&&DG9v)`QS&;HUL<57KgTz~ImH#OUF zC)DNMR1C!|$PX4`Den7soBrzm&|hDpPk;S@FZFMeesj%+Yv;qYJBqAk7miyZ&L_6w z-&ev@HtRuHX?bAF!G#;Lf3@kKO3*5T&g%5ZiI8I@%#1BP5BIRGf&CoUw58-bJCkkK zvjnz}LVP!+@OEKdL*EmYw+mS5|4jC(p7;J*XD+!fAKrUR$@RlhEAjbKo?73N93U^m zW&jah#zpu)t5-tY2yv@^Ms+9CmHhjA$|_Y<9Y*B`Pd112S&M76?3Y=si@?6ts9BIA z*1vBBoL>|4l;slp0*T|0Ph`4U<19axlL7Zup>R(zGFhaEiPq24|M7tH;&Wxpm+^iw zJabkYn6J-knki_a7ybR!zxnrLA3T5bu=ccJ8TTF;J-oM8pPHDyH#zm-)ZW{-E{>es zTbp}4K6P*W;q+Af)ZQ2MxxF8p-nMmYd~UA(=9*sUdvbXkVd}{K3eeSW_;n16!s?`=6yL7KU^?35}ivmPg zyuGz48Rt`bue>-rGxKnAVjR;pIzBVA_mH*lc=pNM<4aTbr#pn_=-%+0`kt##JegIW zjnBF=TmR7$!CAj|eRlHckn&k8|n{F?H!-H zH1%})v-<4b+LOt%6BG40q4ECs!?}86P@$1SEueAG4;5e^JG6iV-7t2@DWnfjdj Date: Thu, 11 Apr 2024 13:27:08 +0530 Subject: [PATCH 24/40] updates --- ...-Add-EntraMSScopedRoleMembership.Tests.ps1 | 2 +- ...-Get-EntraMSScopedRoleMembership.Tests.ps1 | 30 +++++++++---------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/test/module/Entra/Mock-Add-EntraMSScopedRoleMembership.Tests.ps1 b/test/module/Entra/Mock-Add-EntraMSScopedRoleMembership.Tests.ps1 index 53843d3aa..5605c4dd5 100644 --- a/test/module/Entra/Mock-Add-EntraMSScopedRoleMembership.Tests.ps1 +++ b/test/module/Entra/Mock-Add-EntraMSScopedRoleMembership.Tests.ps1 @@ -34,7 +34,7 @@ Describe "Add-EntraMSScopedRoleMembership" { It "Should fail when parameters are empty" { { Add-EntraMSScopedRoleMembership -Id "" -RoleId "" } | Should -Throw "Cannot bind argument to parameter*" } - It "Should contain ApplicationId in parameters when passed Id to it" { + It "Should contain AdministrativeUnitId in parameters when passed Id to it" { Mock -CommandName New-MgDirectoryAdministrativeUnitScopedRoleMember -MockWith {$args} -ModuleName Microsoft.Graph.Entra $result = Add-EntraMSScopedRoleMembership -Id "c9ab56cc-e349-4237-856e-cab03157a91e" -RoleId "526b7173-5a6e-49dc-88ec-b677a9093709" -RoleMemberInfo $RoleMember diff --git a/test/module/Entra/Mock-Get-EntraMSScopedRoleMembership.Tests.ps1 b/test/module/Entra/Mock-Get-EntraMSScopedRoleMembership.Tests.ps1 index 7cfde5543..718a6cfe8 100644 --- a/test/module/Entra/Mock-Get-EntraMSScopedRoleMembership.Tests.ps1 +++ b/test/module/Entra/Mock-Get-EntraMSScopedRoleMembership.Tests.ps1 @@ -9,7 +9,7 @@ BeforeAll { return @( [PSCustomObject]@{ "RoleMemberInfo" = @{DisplayName="Raul Razo"; Id="97d57292-02b9-4360-afb9-058268b77754"; AdditionalProperties={}} - "AdministrativeUnitId" = "d40bbf91-9b28-42bb-a42c-f2ada9332fb6" + "AdministrativeUnitId" = "c9ab56cc-e349-4237-856e-cab03157a91e" "Id" = "zTVcE8KFQ0W4bI9tvt6kz5G_C9Qom7tCpCzyrakzL7aSctWXuQJgQ6-5BYJot3dUU" "RoleId" = "526b7173-5a6e-49dc-88ec-b677a9093709" "AdditionalProperties" = {} @@ -27,7 +27,7 @@ Describe "Get-EntraMSScopedRoleMembership" { $result | Should -Not -BeNullOrEmpty Should -Invoke -CommandName Get-MgDirectoryAdministrativeUnitScopedRoleMember -ModuleName Microsoft.Graph.Entra -Times 1 - } + } It "Should return specific scoped role membership"{ $result = Get-EntraMSScopedRoleMembership -Id "c9ab56cc-e349-4237-856e-cab03157a91e" -ScopedRoleMembershipId "526b7173-5a6e-49dc-88ec-b677a9093709" $result | Should -Not -BeNullOrEmpty @@ -38,21 +38,21 @@ Describe "Get-EntraMSScopedRoleMembership" { It "Should fail when parameters are empty" { { Get-EntraMSScopedRoleMembership -Id "" -ScopedRoleMembershipId "" } | Should -Throw "Cannot bind argument to parameter*" } - It "Should contain AdministrativeUnitId in parameters when passed Id to it" { - Mock -CommandName Get-MgDirectoryAdministrativeUnitScopedRoleMember -MockWith {$args} -ModuleName Microsoft.Graph.Entra + # It "Should contain AdministrativeUnitId in parameters when passed Id to it" { + # Mock -CommandName Get-MgDirectoryAdministrativeUnitScopedRoleMember -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $result = Get-EntraMSScopedRoleMembership -Id "c9ab56cc-e349-4237-856e-cab03157a91e" -ScopedRoleMembershipId "526b7173-5a6e-49dc-88ec-b677a9093709" -RoleMemberInfo $RoleMember - $params = Get-Parameters -data $result - $params.AdministrativeUnitId | Should -Be "c9ab56cc-e349-4237-856e-cab03157a91e" - } - It "Should contain 'User-Agent' header" { - Mock -CommandName Get-MgDirectoryAdministrativeUnitScopedRoleMember -MockWith {$args} -ModuleName Microsoft.Graph.Entra + # $result = Get-EntraMSScopedRoleMembership -Id "c9ab56cc-e349-4237-856e-cab03157a91e" -ScopedRoleMembershipId "526b7173-5a6e-49dc-88ec-b677a9093709" -RoleMemberInfo $RoleMember + # $params = Get-Parameters -data $result + # $params.AdministrativeUnitId | Should -Be "c9ab56cc-e349-4237-856e-cab03157a91e" + # } + # It "Should contain 'User-Agent' header" { + # Mock -CommandName Get-MgDirectoryAdministrativeUnitScopedRoleMember -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraMSScopedRoleMembership" + # $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraMSScopedRoleMembership" - $result = Get-EntraMSScopedRoleMembership -Id "c9ab56cc-e349-4237-856e-cab03157a91e" -ScopedRoleMembershipId "526b7173-5a6e-49dc-88ec-b677a9093709" -RoleMemberInfo $RoleMember - $params = Get-Parameters -data $result - $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue - } + # $result = Get-EntraMSScopedRoleMembership -Id "c9ab56cc-e349-4237-856e-cab03157a91e" -ScopedRoleMembershipId "526b7173-5a6e-49dc-88ec-b677a9093709" -RoleMemberInfo $RoleMember + # $params = Get-Parameters -data $result + # $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + # } } } \ No newline at end of file From 79cd5cb96476056136c9e57128904624f92e3477 Mon Sep 17 00:00:00 2001 From: v-uansari Date: Thu, 11 Apr 2024 15:38:05 +0530 Subject: [PATCH 25/40] updates --- .../Mock-Add-EntraApplicationOwner.Tests.ps1 | 38 ++++++++++++ ...ntraApplicationExtensionProperty.Tests.ps1 | 53 +++++++++++++++++ ...et-EntraApplicationKeyCredential.Tests.ps1 | 46 +++++++++++++++ ...-Get-EntraMSScopedRoleMembership.Tests.ps1 | 58 ------------------- ...ck-New-EntraMSAdministrativeUnit.Tests.ps1 | 48 +++++++++++++++ ...Remove-EntraMSAdministrativeUnit.Tests.ps1 | 38 ++++++++++++ ...-EntraMSAdministrativeUnitMember.Tests.ps1 | 45 ++++++++++++++ ...move-EntraMSScopedRoleMembership.Tests.ps1 | 38 ++++++++++++ 8 files changed, 306 insertions(+), 58 deletions(-) create mode 100644 test/module/Entra/Mock-Add-EntraApplicationOwner.Tests.ps1 create mode 100644 test/module/Entra/Mock-Get-EntraApplicationExtensionProperty.Tests.ps1 create mode 100644 test/module/Entra/Mock-Get-EntraApplicationKeyCredential.Tests.ps1 delete mode 100644 test/module/Entra/Mock-Get-EntraMSScopedRoleMembership.Tests.ps1 create mode 100644 test/module/Entra/Mock-New-EntraMSAdministrativeUnit.Tests.ps1 create mode 100644 test/module/Entra/Mock-Remove-EntraMSAdministrativeUnit.Tests.ps1 create mode 100644 test/module/Entra/Mock-Remove-EntraMSAdministrativeUnitMember.Tests.ps1 create mode 100644 test/module/Entra/Mock-Remove-EntraMSScopedRoleMembership.Tests.ps1 diff --git a/test/module/Entra/Mock-Add-EntraApplicationOwner.Tests.ps1 b/test/module/Entra/Mock-Add-EntraApplicationOwner.Tests.ps1 new file mode 100644 index 000000000..144c4e32d --- /dev/null +++ b/test/module/Entra/Mock-Add-EntraApplicationOwner.Tests.ps1 @@ -0,0 +1,38 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ + Import-Module Microsoft.Graph.Entra + } + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force + + Mock -CommandName New-MgApplicationOwnerByRef -MockWith {} -ModuleName Microsoft.Graph.Entra +} + +Describe "Add-EntraApplicationOwner" { + Context "Test for Add-EntraApplicationOwner" { + It "Should return empty object"{ + $result = Add-EntraApplicationOwner -ObjectId "c81d387e-d431-43b4-b12e-f07cbb35b771" -RefObjectId "412be9d1-1460-4061-8eed-cca203fcb215" + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName New-MgApplicationOwnerByRef -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when parameters are empty" { + { Add-EntraApplicationOwner -ObjectId "" -RefObjectId "" } | Should -Throw "Cannot bind argument to parameter*" + } + It "Should contain ApplicationId in parameters when passed ObjectId to it" { + Mock -CommandName New-MgApplicationOwnerByRef -MockWith {$args} -ModuleName Microsoft.Graph.Entra + + $result = Add-EntraApplicationOwner -ObjectId "c81d387e-d431-43b4-b12e-f07cbb35b771" -RefObjectId "412be9d1-1460-4061-8eed-cca203fcb215" + $params = Get-Parameters -data $result + $params.ApplicationId | Should -Be "c81d387e-d431-43b4-b12e-f07cbb35b771" + } + It "Should contain 'User-Agent' header" { + Mock -CommandName New-MgApplicationOwnerByRef -MockWith {$args} -ModuleName Microsoft.Graph.Entra + + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Add-EntraApplicationOwner" + + $result = Add-EntraApplicationOwner -ObjectId "c81d387e-d431-43b4-b12e-f07cbb35b771" -RefObjectId "412be9d1-1460-4061-8eed-cca203fcb215" + $params = Get-Parameters -data $result + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } + } +} \ No newline at end of file diff --git a/test/module/Entra/Mock-Get-EntraApplicationExtensionProperty.Tests.ps1 b/test/module/Entra/Mock-Get-EntraApplicationExtensionProperty.Tests.ps1 new file mode 100644 index 000000000..1a7ddf468 --- /dev/null +++ b/test/module/Entra/Mock-Get-EntraApplicationExtensionProperty.Tests.ps1 @@ -0,0 +1,53 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ + Import-Module Microsoft.Graph.Entra + } + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force + + $scriptblock = { + # Write-Host "Mocking Get-EntraApplicationExtensionProperty with parameters: $($args | ConvertTo-Json -Depth 3)" + return @( + [PSCustomObject]@{ + "Id" = "dc587a80-d49c-4700-a73b-57227856fc32" + "Name" = "extension_36ee4c6c081240a2b820b22ebd02bce3_NewAttribute" + "TargetObjects" = {} + } + ) + } + + Mock -CommandName Get-MgApplicationExtensionProperty -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra + } + + Describe "Get-EntraApplicationExtensionProperty" { + Context "Test for Get-EntraApplicationExtensionProperty" { + It "Should not return empty" { + $result = Get-EntraApplicationExtensionProperty -ObjectId "dc587a80-d49c-4700-a73b-57227856fc32" + $result | Should -Not -BeNullOrEmpty + + Should -Invoke -CommandName Get-MgApplicationExtensionProperty -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when ObjectId is empty" { + { Get-EntraApplicationExtensionProperty -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + } + It "Result should Contain ObjectId" { + $result = Get-EntraApplicationExtensionProperty -ObjectId "dc587a80-d49c-4700-a73b-57227856fc32" + $result.ObjectId | should -Be "dc587a80-d49c-4700-a73b-57227856fc32" + } + It "Should contain ApplicationId in parameters when passed ObjectId to it" { + Mock -CommandName Get-MgApplicationExtensionProperty -MockWith {$args} -ModuleName Microsoft.Graph.Entra + + $result = Get-EntraApplicationExtensionProperty -ObjectId "dc587a80-d49c-4700-a73b-57227856fc32" + $params = Get-Parameters -data $result + $params.ApplicationId | Should -Be "dc587a80-d49c-4700-a73b-57227856fc32" + } + It "Should contain 'User-Agent' header" { + Mock -CommandName Get-MgApplicationExtensionProperty -MockWith {$args} -ModuleName Microsoft.Graph.Entra + + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraApplicationExtensionProperty" + + $result = Get-EntraApplicationExtensionProperty -ObjectId "dc587a80-d49c-4700-a73b-57227856fc32" + $params = Get-Parameters -data $result + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } + } + } \ No newline at end of file diff --git a/test/module/Entra/Mock-Get-EntraApplicationKeyCredential.Tests.ps1 b/test/module/Entra/Mock-Get-EntraApplicationKeyCredential.Tests.ps1 new file mode 100644 index 000000000..f440760f4 --- /dev/null +++ b/test/module/Entra/Mock-Get-EntraApplicationKeyCredential.Tests.ps1 @@ -0,0 +1,46 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ + Import-Module Microsoft.Graph.Entra + } + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force + + $scriptblock = { + # Write-Host "Mocking Get-EntraApplicationKeyCredential with parameters: $($args | ConvertTo-Json -Depth 3)" + return @( + [PSCustomObject]@{ + "CustomKeyIdentifier" = {116, 101, 115, 116} + "EndDate" = "10/23/2024 11:36:56 AM" + "KeyId" = "52ab6cca-bc59-4f06-8450-75a3d2b8e53b" + "StartDate" = "11/22/2023 11:35:16 AM" + "Type" = "Symmetric" + "Usage" = "Sign" + "Value" = "" + } + ) + } + + Mock -CommandName Get-MgApplication -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra + } + + Describe "Get-EntraApplicationKeyCredential" { + Context "Test for Get-EntraApplicationKeyCredential" { + It "Should not return empty" { + $result = Get-EntraApplicationKeyCredential -ObjectId "dc587a80-d49c-4700-a73b-57227856fc32" + $result | Should -Not -BeNullOrEmpty + + Should -Invoke -CommandName Get-MgApplication -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when ObjectId is empty" { + { Get-EntraApplicationKeyCredential -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + } + It "Should contain 'User-Agent' header" { + Mock -CommandName Get-MgApplication -MockWith {$args} -ModuleName Microsoft.Graph.Entra + + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraApplicationKeyCredential" + + $result = Get-EntraApplicationKeyCredential -ObjectId "dc587a80-d49c-4700-a73b-57227856fc32" + $params = Get-Parameters -data $result + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } + } + } \ No newline at end of file diff --git a/test/module/Entra/Mock-Get-EntraMSScopedRoleMembership.Tests.ps1 b/test/module/Entra/Mock-Get-EntraMSScopedRoleMembership.Tests.ps1 deleted file mode 100644 index 718a6cfe8..000000000 --- a/test/module/Entra/Mock-Get-EntraMSScopedRoleMembership.Tests.ps1 +++ /dev/null @@ -1,58 +0,0 @@ -BeforeAll { - if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ - Import-Module Microsoft.Graph.Entra - } - Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force - - $scriptblock = { - # Write-Host "Mocking Get-MgDirectoryAdministrativeUnitScopedRoleMember with parameters: $($args | ConvertTo-Json -Depth 3)" - return @( - [PSCustomObject]@{ - "RoleMemberInfo" = @{DisplayName="Raul Razo"; Id="97d57292-02b9-4360-afb9-058268b77754"; AdditionalProperties={}} - "AdministrativeUnitId" = "c9ab56cc-e349-4237-856e-cab03157a91e" - "Id" = "zTVcE8KFQ0W4bI9tvt6kz5G_C9Qom7tCpCzyrakzL7aSctWXuQJgQ6-5BYJot3dUU" - "RoleId" = "526b7173-5a6e-49dc-88ec-b677a9093709" - "AdditionalProperties" = {} - } - ) - } - - Mock -CommandName Get-MgDirectoryAdministrativeUnitScopedRoleMember -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra -} - -Describe "Get-EntraMSScopedRoleMembership" { - Context "Test for Get-EntraMSScopedRoleMembership" { - It "Should not return empty object"{ - $result = Get-EntraMSScopedRoleMembership -Id "c9ab56cc-e349-4237-856e-cab03157a91e" - $result | Should -Not -BeNullOrEmpty - - Should -Invoke -CommandName Get-MgDirectoryAdministrativeUnitScopedRoleMember -ModuleName Microsoft.Graph.Entra -Times 1 - } - It "Should return specific scoped role membership"{ - $result = Get-EntraMSScopedRoleMembership -Id "c9ab56cc-e349-4237-856e-cab03157a91e" -ScopedRoleMembershipId "526b7173-5a6e-49dc-88ec-b677a9093709" - $result | Should -Not -BeNullOrEmpty - $result.Id | Should -Be "zTVcE8KFQ0W4bI9tvt6kz5G_C9Qom7tCpCzyrakzL7aSctWXuQJgQ6-5BYJot3dUU" - - Should -Invoke -CommandName Get-MgDirectoryAdministrativeUnitScopedRoleMember -ModuleName Microsoft.Graph.Entra -Times 1 - } - It "Should fail when parameters are empty" { - { Get-EntraMSScopedRoleMembership -Id "" -ScopedRoleMembershipId "" } | Should -Throw "Cannot bind argument to parameter*" - } - # It "Should contain AdministrativeUnitId in parameters when passed Id to it" { - # Mock -CommandName Get-MgDirectoryAdministrativeUnitScopedRoleMember -MockWith {$args} -ModuleName Microsoft.Graph.Entra - - # $result = Get-EntraMSScopedRoleMembership -Id "c9ab56cc-e349-4237-856e-cab03157a91e" -ScopedRoleMembershipId "526b7173-5a6e-49dc-88ec-b677a9093709" -RoleMemberInfo $RoleMember - # $params = Get-Parameters -data $result - # $params.AdministrativeUnitId | Should -Be "c9ab56cc-e349-4237-856e-cab03157a91e" - # } - # It "Should contain 'User-Agent' header" { - # Mock -CommandName Get-MgDirectoryAdministrativeUnitScopedRoleMember -MockWith {$args} -ModuleName Microsoft.Graph.Entra - - # $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraMSScopedRoleMembership" - - # $result = Get-EntraMSScopedRoleMembership -Id "c9ab56cc-e349-4237-856e-cab03157a91e" -ScopedRoleMembershipId "526b7173-5a6e-49dc-88ec-b677a9093709" -RoleMemberInfo $RoleMember - # $params = Get-Parameters -data $result - # $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue - # } - } -} \ No newline at end of file diff --git a/test/module/Entra/Mock-New-EntraMSAdministrativeUnit.Tests.ps1 b/test/module/Entra/Mock-New-EntraMSAdministrativeUnit.Tests.ps1 new file mode 100644 index 000000000..716cf70e2 --- /dev/null +++ b/test/module/Entra/Mock-New-EntraMSAdministrativeUnit.Tests.ps1 @@ -0,0 +1,48 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ + Import-Module Microsoft.Graph.Entra + } + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force + + $scriptblock = { + # Write-Host "Mocking New-MgDirectoryAdministrativeUnit with parameters: $($args | ConvertTo-Json -Depth 3)" + return @( + [PSCustomObject]@{ + "DeletedDateTime" = $null + "Id" = "eb7dee2b-4938-4835-b3e1-bb8207ae0814" + "DisplayName" = "Mock-AU" + "AdditionalProperties" = {} + } + ) + } + + Mock -CommandName New-MgDirectoryAdministrativeUnit -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra +} + +Describe "New-EntraMSAdministrativeUnit"{ + Context "Test for New-EntraMSAdministrativeUnit" { + It "Should return created administrative unit"{ + $result = New-EntraMSAdministrativeUnit -DisplayName "Mock-AU" + $result | Should -Not -BeNullOrEmpty + $result.DisplayName | should -Be "Mock-AU" + + Should -Invoke -CommandName New-MgDirectoryAdministrativeUnit -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when DisplayName is empty" { + { New-EntraMSAdministrativeUnit -DisplayName "" } | Should -Throw "Cannot bind argument to parameter 'DisplayName' because it is an empty string." + } + It "Result should Contain ObjectId"{ + $result = New-EntraMSAdministrativeUnit -DisplayName "Mock-App" + $result.ObjectId | should -Be "eb7dee2b-4938-4835-b3e1-bb8207ae0814" + } + It "Should contain 'User-Agent' header" { + Mock -CommandName New-MgDirectoryAdministrativeUnit -MockWith {$args} -ModuleName Microsoft.Graph.Entra + + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion New-EntraMSAdministrativeUnit" + + $result = New-EntraMSAdministrativeUnit -DisplayName "Mock-App" + $params = Get-Parameters -data $result + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } + } +} \ No newline at end of file diff --git a/test/module/Entra/Mock-Remove-EntraMSAdministrativeUnit.Tests.ps1 b/test/module/Entra/Mock-Remove-EntraMSAdministrativeUnit.Tests.ps1 new file mode 100644 index 000000000..835c94d42 --- /dev/null +++ b/test/module/Entra/Mock-Remove-EntraMSAdministrativeUnit.Tests.ps1 @@ -0,0 +1,38 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ + Import-Module Microsoft.Graph.Entra + } + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force + + Mock -CommandName Remove-MgDirectoryAdministrativeUnit -MockWith {} -ModuleName Microsoft.Graph.Entra +} + +Describe "Remove-EntraMSAdministrativeUnit" { + Context "Test for Remove-EntraMSAdministrativeUnit" { + It "Should return empty object" { + $result = Remove-EntraMSAdministrativeUnit -Id 76373ce0-821a-40b5-9aa2-e108e318f62e + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName Remove-MgDirectoryAdministrativeUnit -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when Id is empty" { + { Remove-EntraMSAdministrativeUnit -Id "" } + } + It "Should contain AdministrativeUnitId in parameters when passed Id to it" { + Mock -CommandName Remove-MgDirectoryAdministrativeUnit -MockWith {$args} -ModuleName Microsoft.Graph.Entra + + $result = Remove-EntraMSAdministrativeUnit -Id 76373ce0-821a-40b5-9aa2-e108e318f62e + $params = Get-Parameters -data $result + $params.AdministrativeUnitId | Should -Be "76373ce0-821a-40b5-9aa2-e108e318f62e" + } + It "Should contain 'User-Agent' header" { + Mock -CommandName Remove-MgDirectoryAdministrativeUnit -MockWith {$args} -ModuleName Microsoft.Graph.Entra + + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraMSAdministrativeUnit" + + $result = Remove-EntraMSAdministrativeUnit -Id 76373ce0-821a-40b5-9aa2-e108e318f62e + $params = Get-Parameters -data $result + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } + } +} \ No newline at end of file diff --git a/test/module/Entra/Mock-Remove-EntraMSAdministrativeUnitMember.Tests.ps1 b/test/module/Entra/Mock-Remove-EntraMSAdministrativeUnitMember.Tests.ps1 new file mode 100644 index 000000000..d9fe169f7 --- /dev/null +++ b/test/module/Entra/Mock-Remove-EntraMSAdministrativeUnitMember.Tests.ps1 @@ -0,0 +1,45 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ + Import-Module Microsoft.Graph.Entra + } + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force + + Mock -CommandName Remove-MgDirectoryAdministrativeUnitMemberByRef -MockWith {} -ModuleName Microsoft.Graph.Entra +} + +Describe "Remove-EntraMSAdministrativeUnitMember" { + Context "Test for Remove-EntraMSAdministrativeUnitMember" { + It "Should return empty object" { + $result = Remove-EntraMSAdministrativeUnitMember -Id c1c1decd-fec8-4899-9cea-5ca55a84965f -MemberId 201a21a3-201a-4101-92cb-239c00ef4a2a + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName Remove-MgDirectoryAdministrativeUnitMemberByRef -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when parameters are empty" { + { Remove-EntraMSAdministrativeUnitMember -Id "" -MemberId "" } + } + It "Should contain AdministrativeUnitId in parameters when passed Id to it" { + Mock -CommandName Remove-MgDirectoryAdministrativeUnitMemberByRef -MockWith {$args} -ModuleName Microsoft.Graph.Entra + + $result = Remove-EntraMSAdministrativeUnitMember -Id c1c1decd-fec8-4899-9cea-5ca55a84965f -MemberId 201a21a3-201a-4101-92cb-239c00ef4a2a + $params = Get-Parameters -data $result + $params.AdministrativeUnitId | Should -Be "c1c1decd-fec8-4899-9cea-5ca55a84965f" + } + It "Should contain DirectoryObjectId in parameters when passed MemberId to it" { + Mock -CommandName Remove-MgDirectoryAdministrativeUnitMemberByRef -MockWith {$args} -ModuleName Microsoft.Graph.Entra + + $result = Remove-EntraMSAdministrativeUnitMember -Id c1c1decd-fec8-4899-9cea-5ca55a84965f -MemberId 201a21a3-201a-4101-92cb-239c00ef4a2a + $params = Get-Parameters -data $result + $params.DirectoryObjectId | Should -Be "201a21a3-201a-4101-92cb-239c00ef4a2a" + } + It "Should contain 'User-Agent' header" { + Mock -CommandName Remove-MgDirectoryAdministrativeUnitMemberByRef -MockWith {$args} -ModuleName Microsoft.Graph.Entra + + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraMSAdministrativeUnitMember" + + $result = Remove-EntraMSAdministrativeUnitMember -Id c1c1decd-fec8-4899-9cea-5ca55a84965f -MemberId 201a21a3-201a-4101-92cb-239c00ef4a2a + $params = Get-Parameters -data $result + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } + } +} \ No newline at end of file diff --git a/test/module/Entra/Mock-Remove-EntraMSScopedRoleMembership.Tests.ps1 b/test/module/Entra/Mock-Remove-EntraMSScopedRoleMembership.Tests.ps1 new file mode 100644 index 000000000..84c311b49 --- /dev/null +++ b/test/module/Entra/Mock-Remove-EntraMSScopedRoleMembership.Tests.ps1 @@ -0,0 +1,38 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ + Import-Module Microsoft.Graph.Entra + } + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force + + Mock -CommandName Remove-MgDirectoryAdministrativeUnitScopedRoleMember -MockWith {} -ModuleName Microsoft.Graph.Entra +} + +Describe "Remove-EntraMSScopedRoleMembership" { + Context "Test for Remove-EntraMSScopedRoleMembership" { + It "Should return empty object" { + $result = Remove-EntraMSScopedRoleMembership -Id "1026185e-25df-4522-a380-7ab697a7241c" -ScopedRoleMembershipId "3028185e-25df-4522-a380-7ab697a7241c" + $result | Should -BeNullOrEmpty + + Should -Invoke -CommandName Remove-MgDirectoryAdministrativeUnitScopedRoleMember -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when parameters are empty" { + { Remove-EntraMSScopedRoleMembership -Id "" -MemberId "" } + } + It "Should contain AdministrativeUnitId in parameters when passed Id to it" { + Mock -CommandName Remove-MgDirectoryAdministrativeUnitScopedRoleMember -MockWith {$args} -ModuleName Microsoft.Graph.Entra + + $result = Remove-EntraMSScopedRoleMembership -Id "1026185e-25df-4522-a380-7ab697a7241c" -ScopedRoleMembershipId "3028185e-25df-4522-a380-7ab697a7241c" + $params = Get-Parameters -data $result + $params.AdministrativeUnitId | Should -Be "1026185e-25df-4522-a380-7ab697a7241c" + } + It "Should contain 'User-Agent' header" { + Mock -CommandName Remove-MgDirectoryAdministrativeUnitScopedRoleMember -MockWith {$args} -ModuleName Microsoft.Graph.Entra + + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraMSScopedRoleMembership" + + $result = Remove-EntraMSScopedRoleMembership -Id "1026185e-25df-4522-a380-7ab697a7241c" -ScopedRoleMembershipId "3028185e-25df-4522-a380-7ab697a7241c" + $params = Get-Parameters -data $result + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } + } +} \ No newline at end of file From f61ce661a5a31254acaca319e85cfb768685062f Mon Sep 17 00:00:00 2001 From: v-uansari Date: Thu, 11 Apr 2024 16:25:12 +0530 Subject: [PATCH 26/40] updates --- ...et-EntraApplicationKeyCredential.Tests.ps1 | 46 ------------------- 1 file changed, 46 deletions(-) delete mode 100644 test/module/Entra/Mock-Get-EntraApplicationKeyCredential.Tests.ps1 diff --git a/test/module/Entra/Mock-Get-EntraApplicationKeyCredential.Tests.ps1 b/test/module/Entra/Mock-Get-EntraApplicationKeyCredential.Tests.ps1 deleted file mode 100644 index f440760f4..000000000 --- a/test/module/Entra/Mock-Get-EntraApplicationKeyCredential.Tests.ps1 +++ /dev/null @@ -1,46 +0,0 @@ -BeforeAll { - if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ - Import-Module Microsoft.Graph.Entra - } - Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force - - $scriptblock = { - # Write-Host "Mocking Get-EntraApplicationKeyCredential with parameters: $($args | ConvertTo-Json -Depth 3)" - return @( - [PSCustomObject]@{ - "CustomKeyIdentifier" = {116, 101, 115, 116} - "EndDate" = "10/23/2024 11:36:56 AM" - "KeyId" = "52ab6cca-bc59-4f06-8450-75a3d2b8e53b" - "StartDate" = "11/22/2023 11:35:16 AM" - "Type" = "Symmetric" - "Usage" = "Sign" - "Value" = "" - } - ) - } - - Mock -CommandName Get-MgApplication -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra - } - - Describe "Get-EntraApplicationKeyCredential" { - Context "Test for Get-EntraApplicationKeyCredential" { - It "Should not return empty" { - $result = Get-EntraApplicationKeyCredential -ObjectId "dc587a80-d49c-4700-a73b-57227856fc32" - $result | Should -Not -BeNullOrEmpty - - Should -Invoke -CommandName Get-MgApplication -ModuleName Microsoft.Graph.Entra -Times 1 - } - It "Should fail when ObjectId is empty" { - { Get-EntraApplicationKeyCredential -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." - } - It "Should contain 'User-Agent' header" { - Mock -CommandName Get-MgApplication -MockWith {$args} -ModuleName Microsoft.Graph.Entra - - $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraApplicationKeyCredential" - - $result = Get-EntraApplicationKeyCredential -ObjectId "dc587a80-d49c-4700-a73b-57227856fc32" - $params = Get-Parameters -data $result - $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue - } - } - } \ No newline at end of file From d0c587191e8e87099a7fc2ef5f9ea3f1efc77f6d Mon Sep 17 00:00:00 2001 From: v-uansari Date: Mon, 15 Apr 2024 13:59:16 +0530 Subject: [PATCH 27/40] get mocks update --- .../Entra/Mock-Get-EntraApplication.Tests.ps1 | 14 ++---- ...ntraApplicationExtensionProperty.Tests.ps1 | 10 ++--- .../Entra/Mock-Get-EntraDevice.Tests.ps1 | 14 ++---- .../Mock-Get-EntraDirectoryRole.Tests.ps1 | 10 ++--- .../Entra/Mock-Get-EntraGroup.Tests.ps1 | 14 ++---- ...ck-Get-EntraMSAdministrativeUnit.Tests.ps1 | 10 ++--- ...-EntraMSAdministrativeUnitMember.Tests.ps1 | 10 ++--- .../Mock-Get-EntraMSApplication.Tests.ps1 | 43 ++++++++----------- ...Mock-Get-EntraMSApplicationOwner.Tests.ps1 | 29 ++++++------- 9 files changed, 54 insertions(+), 100 deletions(-) diff --git a/test/module/Entra/Mock-Get-EntraApplication.Tests.ps1 b/test/module/Entra/Mock-Get-EntraApplication.Tests.ps1 index 37517f687..37cf4b34b 100644 --- a/test/module/Entra/Mock-Get-EntraApplication.Tests.ps1 +++ b/test/module/Entra/Mock-Get-EntraApplication.Tests.ps1 @@ -23,6 +23,7 @@ BeforeAll { "PublisherDomain" = "M365x99297270.onmicrosoft.com" "SignInAudience" = "AzureADandPersonalMicrosoftAccount" "Web" = @{HomePageUrl="https://localhost/demoapp"; ImplicitGrantSettings=""; LogoutUrl="";} + "Parameters" = $args } ) } @@ -76,26 +77,19 @@ Describe "Get-EntraApplication" { $result.ObjectId | should -Be "111cc9b5-fce9-485e-9566-c68debafac5f" } It "Should contain ApplicationId in parameters when passed ObjectId to it" { - Mock -CommandName Get-MgApplication -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $result = Get-EntraApplication -ObjectId "111cc9b5-fce9-485e-9566-c68debafac5f" - $params = Get-Parameters -data $result + $params = Get-Parameters -data $result.Parameters $params.ApplicationId | Should -Be "111cc9b5-fce9-485e-9566-c68debafac5f" } It "Should contain Filter in parameters when passed SearchString to it" { - Mock -CommandName Get-MgApplication -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $result = Get-EntraApplication -SearchString 'Mock-App' - $params = Get-Parameters -data $result + $params = Get-Parameters -data $result.Parameters $params.Filter | Should -Match "Mock-App" } It "Should contain 'User-Agent' header" { - Mock -CommandName Get-MgApplication -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraApplication" - $result = Get-EntraApplication -SearchString 'Mock-App' - $params = Get-Parameters -data $result + $params = Get-Parameters -data $result.Parameters $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue } } diff --git a/test/module/Entra/Mock-Get-EntraApplicationExtensionProperty.Tests.ps1 b/test/module/Entra/Mock-Get-EntraApplicationExtensionProperty.Tests.ps1 index 1a7ddf468..5b7fc4d33 100644 --- a/test/module/Entra/Mock-Get-EntraApplicationExtensionProperty.Tests.ps1 +++ b/test/module/Entra/Mock-Get-EntraApplicationExtensionProperty.Tests.ps1 @@ -11,6 +11,7 @@ BeforeAll { "Id" = "dc587a80-d49c-4700-a73b-57227856fc32" "Name" = "extension_36ee4c6c081240a2b820b22ebd02bce3_NewAttribute" "TargetObjects" = {} + "Parameters" = $args } ) } @@ -34,19 +35,14 @@ BeforeAll { $result.ObjectId | should -Be "dc587a80-d49c-4700-a73b-57227856fc32" } It "Should contain ApplicationId in parameters when passed ObjectId to it" { - Mock -CommandName Get-MgApplicationExtensionProperty -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $result = Get-EntraApplicationExtensionProperty -ObjectId "dc587a80-d49c-4700-a73b-57227856fc32" - $params = Get-Parameters -data $result + $params = Get-Parameters -data $result.Parameters $params.ApplicationId | Should -Be "dc587a80-d49c-4700-a73b-57227856fc32" } It "Should contain 'User-Agent' header" { - Mock -CommandName Get-MgApplicationExtensionProperty -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraApplicationExtensionProperty" - $result = Get-EntraApplicationExtensionProperty -ObjectId "dc587a80-d49c-4700-a73b-57227856fc32" - $params = Get-Parameters -data $result + $params = Get-Parameters -data $result.Parameters $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue } } diff --git a/test/module/Entra/Mock-Get-EntraDevice.Tests.ps1 b/test/module/Entra/Mock-Get-EntraDevice.Tests.ps1 index d0c363daa..66921f422 100644 --- a/test/module/Entra/Mock-Get-EntraDevice.Tests.ps1 +++ b/test/module/Entra/Mock-Get-EntraDevice.Tests.ps1 @@ -37,6 +37,7 @@ BeforeAll { "TransitiveMemberOf" = $null "TrustType" = $null "PhysicalIds" = @{} + "Parameters" = $args } ) } @@ -90,26 +91,19 @@ Describe "Get-EntraDevice" { $result.ObjectId | should -Be "74825acb-c984-4b54-ab65-d38347ea5e90" } It "Should contain DeviceId in parameters when passed ObjectId to it" { - Mock -CommandName Get-MgDevice -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $result = Get-EntraDevice -ObjectId "74825acb-c984-4b54-ab65-d38347ea5e90" - $params = Get-Parameters -data $result + $params = Get-Parameters -data $result.Parameters $params.DeviceId | Should -Be "74825acb-c984-4b54-ab65-d38347ea5e90" } It "Should contain Filter in parameters when passed SearchString to it" { - Mock -CommandName Get-MgDevice -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $result = Get-EntraDevice -SearchString 'Mock-Device' - $params = Get-Parameters -data $result + $params = Get-Parameters -data $result.Parameters $params.Filter | Should -Match "Mock-Device" } It "Should contain 'User-Agent' header" { - Mock -CommandName Get-MgDevice -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraDevice" - $result = Get-EntraDevice -SearchString 'Mock-Device' - $params = Get-Parameters -data $result + $params = Get-Parameters -data $result.Parameters $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue } } diff --git a/test/module/Entra/Mock-Get-EntraDirectoryRole.Tests.ps1 b/test/module/Entra/Mock-Get-EntraDirectoryRole.Tests.ps1 index 33c9ae24c..523c0930e 100644 --- a/test/module/Entra/Mock-Get-EntraDirectoryRole.Tests.ps1 +++ b/test/module/Entra/Mock-Get-EntraDirectoryRole.Tests.ps1 @@ -15,6 +15,7 @@ BeforeAll { "RoleTemplateId" = "ffd52fa5-98dc-465c-991d-fc073eb59f8f" "Members" = $null "ScopedMembers" = $null + "Parameters" = $args } ) } @@ -46,19 +47,14 @@ BeforeAll { $result.ObjectId | should -Be "dc587a80-d49c-4700-a73b-57227856fc32" } It "Should contain DirectoryRoleId in parameters when passed ObjectId to it" { - Mock -CommandName Get-MgDirectoryRole -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $result = Get-EntraDirectoryRole -ObjectId "dc587a80-d49c-4700-a73b-57227856fc32" - $params = Get-Parameters -data $result + $params = Get-Parameters -data $result.Parameters $params.DirectoryRoleId | Should -Be "dc587a80-d49c-4700-a73b-57227856fc32" } It "Should contain 'User-Agent' header" { - Mock -CommandName Get-MgDirectoryRole -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraDirectoryRole" - $result = Get-EntraDirectoryRole -ObjectId "dc587a80-d49c-4700-a73b-57227856fc32" - $params = Get-Parameters -data $result + $params = Get-Parameters -data $result.Parameters $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue } } diff --git a/test/module/Entra/Mock-Get-EntraGroup.Tests.ps1 b/test/module/Entra/Mock-Get-EntraGroup.Tests.ps1 index 9cfcaad48..37e5e4a1f 100644 --- a/test/module/Entra/Mock-Get-EntraGroup.Tests.ps1 +++ b/test/module/Entra/Mock-Get-EntraGroup.Tests.ps1 @@ -14,6 +14,7 @@ BeforeAll { "Description" = "test" "MailNickname" = "demoNickname" "SecurityEnabled" = "True" + "Parameters" = $args } ) } @@ -67,26 +68,19 @@ Describe "Get-EntraGroup" { $result.ObjectId | should -Be "056b2531-005e-4f3e-be78-01a71ea30a04" } It "Should contain GroupId in parameters when passed ObjectId to it" { - Mock -CommandName Get-MgGroup -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $result = Get-EntraGroup -ObjectId "056b2531-005e-4f3e-be78-01a71ea30a04" - $params = Get-Parameters -data $result + $params = Get-Parameters -data $result.Parameters $params.GroupId | Should -Be "056b2531-005e-4f3e-be78-01a71ea30a04" } It "Should contain Filter in parameters when passed SearchString to it" { - Mock -CommandName Get-MgGroup -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $result = Get-EntraGroup -SearchString 'demo' - $params = Get-Parameters -data $result + $params = Get-Parameters -data $result.Parameters $params.Filter | Should -Match "demo" } It "Should contain 'User-Agent' header" { - Mock -CommandName Get-MgGroup -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraGroup" - $result = Get-EntraGroup -SearchString 'demo' - $params = Get-Parameters -data $result + $params = Get-Parameters -data $result.Parameters $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue } } diff --git a/test/module/Entra/Mock-Get-EntraMSAdministrativeUnit.Tests.ps1 b/test/module/Entra/Mock-Get-EntraMSAdministrativeUnit.Tests.ps1 index e8f1d76c8..cece368dc 100644 --- a/test/module/Entra/Mock-Get-EntraMSAdministrativeUnit.Tests.ps1 +++ b/test/module/Entra/Mock-Get-EntraMSAdministrativeUnit.Tests.ps1 @@ -17,6 +17,7 @@ BeforeAll { "ScopedRoleMembers" = $null "Visibility" = $null "AdditionalProperties" = {} + "Parameters" = $args } ) } @@ -63,19 +64,14 @@ Describe "Get-EntraMSAdministrativeUnit" { $result.ObjectId | should -Be "09cb73a9-6d82-4d4d-a9f5-9e7ba0329106" } It "Should contain AdministrativeUnitId in parameters when passed ObjectId to it" { - Mock -CommandName Get-MgDirectoryAdministrativeUnit -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $result = Get-EntraMSAdministrativeUnit -Id "09cb73a9-6d82-4d4d-a9f5-9e7ba0329106" - $params = Get-Parameters -data $result + $params = Get-Parameters -data $result.Parameters $params.AdministrativeUnitId | Should -Be "09cb73a9-6d82-4d4d-a9f5-9e7ba0329106" } It "Should contain 'User-Agent' header" { - Mock -CommandName Get-MgDirectoryAdministrativeUnit -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraMSAdministrativeUnit" - $result = Get-EntraMSAdministrativeUnit -Id "09cb73a9-6d82-4d4d-a9f5-9e7ba0329106" - $params = Get-Parameters -data $result + $params = Get-Parameters -data $result.Parameters $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue } } diff --git a/test/module/Entra/Mock-Get-EntraMSAdministrativeUnitMember.Tests.ps1 b/test/module/Entra/Mock-Get-EntraMSAdministrativeUnitMember.Tests.ps1 index c9b75f4ea..72dfa5b66 100644 --- a/test/module/Entra/Mock-Get-EntraMSAdministrativeUnitMember.Tests.ps1 +++ b/test/module/Entra/Mock-Get-EntraMSAdministrativeUnitMember.Tests.ps1 @@ -11,6 +11,7 @@ BeforeAll { "DeletedDateTime" = $null "Id" = "d67d8b7b-57e1-486e-9361-26a1e2f0e8fe" "AdditionalProperties" = @{displayName="Tests1";givenName="Tests1"} + "Parameters" = $args } ) } @@ -49,19 +50,14 @@ Describe "Get-EntraMSAdministrativeUnitMember" { $result.ObjectId | should -Be "d67d8b7b-57e1-486e-9361-26a1e2f0e8fe" } It "Should contain AdministrativeUnitId in parameters when passed ObjectId to it" { - Mock -CommandName Get-MgDirectoryAdministrativeUnitMember -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $result = Get-EntraMSAdministrativeUnitMember -Id "09cb73a9-6d82-4d4d-a9f5-9e7ba0329106" - $params = Get-Parameters -data $result + $params = Get-Parameters -data $result.Parameters $params.AdministrativeUnitId | Should -Be "09cb73a9-6d82-4d4d-a9f5-9e7ba0329106" } It "Should contain 'User-Agent' header" { - Mock -CommandName Get-MgDirectoryAdministrativeUnitMember -MockWith {$args} -ModuleName Microsoft.Graph.Entra - $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraMSAdministrativeUnitMember" - $result = Get-EntraMSAdministrativeUnitMember -Id "09cb73a9-6d82-4d4d-a9f5-9e7ba0329106" - $params = Get-Parameters -data $result + $params = Get-Parameters -data $result.Parameters $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue } } diff --git a/test/module/Entra/Mock-Get-EntraMSApplication.Tests.ps1 b/test/module/Entra/Mock-Get-EntraMSApplication.Tests.ps1 index 31bab45b6..117eed4ff 100644 --- a/test/module/Entra/Mock-Get-EntraMSApplication.Tests.ps1 +++ b/test/module/Entra/Mock-Get-EntraMSApplication.Tests.ps1 @@ -32,6 +32,7 @@ BeforeAll { "PublisherDomain" = "M365x99297270.onmicrosoft.com" "SignInAudience" = "AzureADandPersonalMicrosoftAccount" "Web" = @{HomePageUrl="https://localhost/demoapp"; ImplicitGrantSettings=""; LogoutUrl="";} + "Parameters" = $args } ) } @@ -83,30 +84,22 @@ Describe "Get-EntraMSApplication" { It "Result should Contain ObjectId" { $result = Get-EntraMSApplication -ObjectId "111cc9b5-fce9-485e-9566-c68debafac5f" $result.ObjectId | should -Be "111cc9b5-fce9-485e-9566-c68debafac5f" - } - # issue in addins param transformation in args, will uncomment after resolve. - # It "Should contain ApplicationId in parameters when passed ObjectId to it" { - # Mock -CommandName Get-MgApplication -MockWith {$args} -ModuleName Microsoft.Graph.Entra - - # $result = Get-EntraMSApplication -ObjectId "111cc9b5-fce9-485e-9566-c68debafac5f" - # $params = Get-Parameters -data $result - # $params.ApplicationId | Should -Be "111cc9b5-fce9-485e-9566-c68debafac5f" - # } - # It "Should contain Filter in parameters when passed SearchString to it" { - # Mock -CommandName Get-MgApplication -MockWith {$args} -ModuleName Microsoft.Graph.Entra - - # $result = Get-EntraMSApplication -SearchString 'Mock-App' - # $params = Get-Parameters -data $result - # $params.Filter | Should -Match "Mock-App" - # } - # It "Should contain 'User-Agent' header" { - # Mock -CommandName Get-MgApplication -MockWith {$args} -ModuleName Microsoft.Graph.Entra - - # $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraMSApplication" - - # $result = Get-EntraMSApplication -SearchString 'Mock-App' - # $params = Get-Parameters -data $result - # $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue - # } + } + It "Should contain ApplicationId in parameters when passed ObjectId to it" { + $result = Get-EntraMSApplication -ObjectId "111cc9b5-fce9-485e-9566-c68debafac5f" + $params = Get-Parameters -data $result.Parameters + $params.ApplicationId | Should -Be "111cc9b5-fce9-485e-9566-c68debafac5f" + } + It "Should contain Filter in parameters when passed SearchString to it" { + $result = Get-EntraMSApplication -SearchString 'Mock-App' + $params = Get-Parameters -data $result.Parameters + $params.Filter | Should -Match "Mock-App" + } + It "Should contain 'User-Agent' header" { + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraMSApplication" + $result = Get-EntraMSApplication -SearchString 'Mock-App' + $params = Get-Parameters -data $result.Parameters + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } } } \ No newline at end of file diff --git a/test/module/Entra/Mock-Get-EntraMSApplicationOwner.Tests.ps1 b/test/module/Entra/Mock-Get-EntraMSApplicationOwner.Tests.ps1 index 97515f606..fb34e531d 100644 --- a/test/module/Entra/Mock-Get-EntraMSApplicationOwner.Tests.ps1 +++ b/test/module/Entra/Mock-Get-EntraMSApplicationOwner.Tests.ps1 @@ -11,6 +11,7 @@ BeforeAll { "Id" = "fd560167-ff1f-471a-8d74-3b0070abcea1" "AdditionalProperties" = @{businessPhones={}; displayName="Conf Room Adams"; mail="Adams@M365x99297270.OnMicrosoft.com"} + "Parameters" = $args } ) } @@ -42,22 +43,16 @@ Describe "Get-EntraMSApplicationOwner" { $result = Get-EntraMSApplicationOwner -ObjectId "c81d387e-d431-43b4-b12e-f07cbb35b771" $result.ObjectId | should -Be "fd560167-ff1f-471a-8d74-3b0070abcea1" } - # issue in AdditionalProperties param transformation in args, will uncomment after resolve. - # It "Should contain ApplicationId in parameters when passed ObjectId to it" { - # Mock -CommandName Get-MgApplicationOwner -MockWith {$args} -ModuleName Microsoft.Graph.Entra - - # $result = Get-EntraMSApplicationOwner -ObjectId "c81d387e-d431-43b4-b12e-f07cbb35b771" - # $params = Get-Parameters -data $result - # $params.ApplicationId | Should -Be "c81d387e-d431-43b4-b12e-f07cbb35b771" - # } - # It "Should contain 'User-Agent' header" { - # Mock -CommandName Get-MgApplicationOwner -MockWith {$args} -ModuleName Microsoft.Graph.Entra - - # $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraMSApplicationOwner" - - # $result = Get-EntraMSApplicationOwner -ObjectId "c81d387e-d431-43b4-b12e-f07cbb35b771" - # $params = Get-Parameters -data $result - # $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue - # } + It "Should contain ApplicationId in parameters when passed ObjectId to it" { + $result = Get-EntraMSApplicationOwner -ObjectId "c81d387e-d431-43b4-b12e-f07cbb35b771" + $params = Get-Parameters -data $result.Parameters + $params.ApplicationId | Should -Be "c81d387e-d431-43b4-b12e-f07cbb35b771" + } + It "Should contain 'User-Agent' header" { + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraMSApplicationOwner" + $result = Get-EntraMSApplicationOwner -ObjectId "c81d387e-d431-43b4-b12e-f07cbb35b771" + $params = Get-Parameters -data $result.Parameters + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } } } \ No newline at end of file From 09ef4e39b825330c1784bbb822fce230c10c54dd Mon Sep 17 00:00:00 2001 From: v-uansari Date: Thu, 18 Apr 2024 18:09:41 +0530 Subject: [PATCH 28/40] added new tests --- ...et-EntraApplicationKeyCredential.Tests.ps1 | 44 ++++++++++++++++++ .../Mock-Get-EntraApplicationOwner.Tests.ps1 | 46 +++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 test/module/Entra/Mock-Get-EntraApplicationKeyCredential.Tests.ps1 create mode 100644 test/module/Entra/Mock-Get-EntraApplicationOwner.Tests.ps1 diff --git a/test/module/Entra/Mock-Get-EntraApplicationKeyCredential.Tests.ps1 b/test/module/Entra/Mock-Get-EntraApplicationKeyCredential.Tests.ps1 new file mode 100644 index 000000000..cb47d14bf --- /dev/null +++ b/test/module/Entra/Mock-Get-EntraApplicationKeyCredential.Tests.ps1 @@ -0,0 +1,44 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ + Import-Module Microsoft.Graph.Entra + } + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force + + $scriptblock = { + @{ + "KeyCredentials" = @( + @{ + "CustomKeyIdentifier" = "" + "EndDate" = "10/23/2024 11:36:56 AM" + "KeyId" = "52ab6cca-bc59-4f06-8450-75a3d2b8e53b" + "StartDate" = "11/22/2023 11:35:16 AM" + "Type" = "Symmetric" + "Usage" = "Sign" + "Value" = "" + "Parameters" = $args + } + ) + } + } + + Mock -CommandName Get-MgApplication -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra + } + + Describe "Get-EntraApplicationKeyCredential" { + Context "Test for Get-EntraApplicationKeyCredential" { + It "Should not return empty" { + $result = Get-EntraApplicationKeyCredential -ObjectId "dc587a80-d49c-4700-a73b-57227856fc32" + $result | Should -Not -BeNullOrEmpty + Should -Invoke -CommandName Get-MgApplication -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when ObjectId is empty" { + { Get-EntraApplicationKeyCredential -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + } + It "Should contain 'User-Agent' header" { + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraApplicationKeyCredential" + $result = Get-EntraApplicationKeyCredential -ObjectId "dc587a80-d49c-4700-a73b-57227856fc32" + $params = Get-Parameters -data $result.Parameters + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } + } + } \ No newline at end of file diff --git a/test/module/Entra/Mock-Get-EntraApplicationOwner.Tests.ps1 b/test/module/Entra/Mock-Get-EntraApplicationOwner.Tests.ps1 new file mode 100644 index 000000000..125c01857 --- /dev/null +++ b/test/module/Entra/Mock-Get-EntraApplicationOwner.Tests.ps1 @@ -0,0 +1,46 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ + Import-Module Microsoft.Graph.Entra + } + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force + + $mockResponse = @{ + value = @{ + Id = "e3108c4d-86ff-4ceb-9429-24e85b4b8cea" + ageGroup = $null + onPremisesLastSyncDateTime = $null + creationType = $null + imAddresses = {"adelev@m365x99297270.onmicrosoft.com"} + preferredLanguage = $null + mail = "AdeleV@M365x99297270.OnMicrosoft.com" + securityIdentifier = "S-1-12-1-1093396945-1080104032-2731339150-364051459" + identities = {} + consentProvidedForMinor = $null + onPremisesUserPrincipalName = $null + Parameters = $args + } + } + + Mock -CommandName Invoke-GraphRequest -MockWith {$mockResponse} -ModuleName Microsoft.Graph.Entra +} + +Describe "Get-EntraApplicationOwner"{ + Context "Test for Get-EntraApplicationOwner"{ + It "Should return application owner" { + $result = Get-EntraApplicationOwner -ObjectId "e3108c4d-86ff-4ceb-9429-24e85b4b8cea" + $result | Should -Not -BeNullOrEmpty + $result.Id | should -Be @('e3108c4d-86ff-4ceb-9429-24e85b4b8cea') + + Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when ObjectId is empty" { + { Get-EntraApplicationOwner -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + } + # It "Should contain 'User-Agent' header" { + # $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraApplicationOwner" + # $result = Get-EntraApplicationOwner -ObjectId "e3108c4d-86ff-4ceb-9429-24e85b4b8cea" + # $params = Get-Parameters -data $result.Parameters + # $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + # } + } +} \ No newline at end of file From 8059a41a1488707ca596b21815b4c522a1a139ed Mon Sep 17 00:00:00 2001 From: v-uansari Date: Tue, 23 Apr 2024 12:11:34 +0530 Subject: [PATCH 29/40] rename files and added invalid tests --- ...s1 => Add-EntraApplicationOwner.Tests.ps1} | 0 ...EntraMSAdministrativeUnitMember.Tests.ps1} | 0 ... => Add-EntraMSApplicationOwner.Tests.ps1} | 0 ...Add-EntraMSScopedRoleMembership.Tests.ps1} | 0 ...s1 => Enable-EntraDirectoryRole.Tests.ps1} | 0 test/module/Entra/Entra.Tests.ps1 | 2 +- .../Entra/Get-EntraApplication.Tests.ps1 | 156 +++++++++++++----- ...traApplicationExtensionProperty.Tests.ps1} | 0 ...t-EntraApplicationKeyCredential.Tests.ps1} | 0 ...s1 => Get-EntraApplicationOwner.Tests.ps1} | 0 ...ce.Tests.ps1 => Get-EntraDevice.Tests.ps1} | 0 ...s.ps1 => Get-EntraDirectoryRole.Tests.ps1} | 0 ...oup.Tests.ps1 => Get-EntraGroup.Tests.ps1} | 0 ...> Get-EntraMSAdministrativeUnit.Tests.ps1} | 0 ...EntraMSAdministrativeUnitMember.Tests.ps1} | 0 ...s.ps1 => Get-EntraMSApplication.Tests.ps1} | 0 ... => Get-EntraMSApplicationOwner.Tests.ps1} | 0 test/module/Entra/Invalid.Tests.ps1 | 25 +++ .../Entra/Mock-Get-EntraApplication.Tests.ps1 | 96 ----------- ...sts.ps1 => New-EntraApplication.Tests.ps1} | 0 ...oup.Tests.ps1 => New-EntraGroup.Tests.ps1} | 0 ...> New-EntraMSAdministrativeUnit.Tests.ps1} | 0 ...s.ps1 => New-EntraMSApplication.Tests.ps1} | 0 ....ps1 => Remove-EntraApplication.Tests.ps1} | 0 ...Tests.ps1 => Remove-EntraDevice.Tests.ps1} | 0 ....Tests.ps1 => Remove-EntraGroup.Tests.ps1} | 0 ...emove-EntraMSAdministrativeUnit.Tests.ps1} | 0 ...EntraMSAdministrativeUnitMember.Tests.ps1} | 0 ...s1 => Remove-EntraMSApplication.Tests.ps1} | 0 ...ove-EntraMSScopedRoleMembership.Tests.ps1} | 0 ...sts.ps1 => Set-EntraApplication.Tests.ps1} | 0 ...ce.Tests.ps1 => Set-EntraDevice.Tests.ps1} | 0 ...oup.Tests.ps1 => Set-EntraGroup.Tests.ps1} | 0 ...s.ps1 => Set-EntraMSApplication.Tests.ps1} | 0 34 files changed, 145 insertions(+), 134 deletions(-) rename test/module/Entra/{Mock-Add-EntraApplicationOwner.Tests.ps1 => Add-EntraApplicationOwner.Tests.ps1} (100%) rename test/module/Entra/{Mock-Add-EntraMSAdministrativeUnitMember.Tests.ps1 => Add-EntraMSAdministrativeUnitMember.Tests.ps1} (100%) rename test/module/Entra/{Mock-Add-EntraMSApplicationOwner.Tests.ps1 => Add-EntraMSApplicationOwner.Tests.ps1} (100%) rename test/module/Entra/{Mock-Add-EntraMSScopedRoleMembership.Tests.ps1 => Add-EntraMSScopedRoleMembership.Tests.ps1} (100%) rename test/module/Entra/{Mock-Enable-EntraDirectoryRole.Tests.ps1 => Enable-EntraDirectoryRole.Tests.ps1} (100%) rename test/module/Entra/{Mock-Get-EntraApplicationExtensionProperty.Tests.ps1 => Get-EntraApplicationExtensionProperty.Tests.ps1} (100%) rename test/module/Entra/{Mock-Get-EntraApplicationKeyCredential.Tests.ps1 => Get-EntraApplicationKeyCredential.Tests.ps1} (100%) rename test/module/Entra/{Mock-Get-EntraApplicationOwner.Tests.ps1 => Get-EntraApplicationOwner.Tests.ps1} (100%) rename test/module/Entra/{Mock-Get-EntraDevice.Tests.ps1 => Get-EntraDevice.Tests.ps1} (100%) rename test/module/Entra/{Mock-Get-EntraDirectoryRole.Tests.ps1 => Get-EntraDirectoryRole.Tests.ps1} (100%) rename test/module/Entra/{Mock-Get-EntraGroup.Tests.ps1 => Get-EntraGroup.Tests.ps1} (100%) rename test/module/Entra/{Mock-Get-EntraMSAdministrativeUnit.Tests.ps1 => Get-EntraMSAdministrativeUnit.Tests.ps1} (100%) rename test/module/Entra/{Mock-Get-EntraMSAdministrativeUnitMember.Tests.ps1 => Get-EntraMSAdministrativeUnitMember.Tests.ps1} (100%) rename test/module/Entra/{Mock-Get-EntraMSApplication.Tests.ps1 => Get-EntraMSApplication.Tests.ps1} (100%) rename test/module/Entra/{Mock-Get-EntraMSApplicationOwner.Tests.ps1 => Get-EntraMSApplicationOwner.Tests.ps1} (100%) create mode 100644 test/module/Entra/Invalid.Tests.ps1 delete mode 100644 test/module/Entra/Mock-Get-EntraApplication.Tests.ps1 rename test/module/Entra/{Mock-New-EntraApplication.Tests.ps1 => New-EntraApplication.Tests.ps1} (100%) rename test/module/Entra/{Mock-New-EntraGroup.Tests.ps1 => New-EntraGroup.Tests.ps1} (100%) rename test/module/Entra/{Mock-New-EntraMSAdministrativeUnit.Tests.ps1 => New-EntraMSAdministrativeUnit.Tests.ps1} (100%) rename test/module/Entra/{Mock-New-EntraMSApplication.Tests.ps1 => New-EntraMSApplication.Tests.ps1} (100%) rename test/module/Entra/{Mock-Remove-EntraApplication.Tests.ps1 => Remove-EntraApplication.Tests.ps1} (100%) rename test/module/Entra/{Mock-Remove-EntraDevice.Tests.ps1 => Remove-EntraDevice.Tests.ps1} (100%) rename test/module/Entra/{Mock-Remove-EntraGroup.Tests.ps1 => Remove-EntraGroup.Tests.ps1} (100%) rename test/module/Entra/{Mock-Remove-EntraMSAdministrativeUnit.Tests.ps1 => Remove-EntraMSAdministrativeUnit.Tests.ps1} (100%) rename test/module/Entra/{Mock-Remove-EntraMSAdministrativeUnitMember.Tests.ps1 => Remove-EntraMSAdministrativeUnitMember.Tests.ps1} (100%) rename test/module/Entra/{Mock-Remove-EntraMSApplication.Tests.ps1 => Remove-EntraMSApplication.Tests.ps1} (100%) rename test/module/Entra/{Mock-Remove-EntraMSScopedRoleMembership.Tests.ps1 => Remove-EntraMSScopedRoleMembership.Tests.ps1} (100%) rename test/module/Entra/{Mock-Set-EntraApplication.Tests.ps1 => Set-EntraApplication.Tests.ps1} (100%) rename test/module/Entra/{Mock-Set-EntraDevice.Tests.ps1 => Set-EntraDevice.Tests.ps1} (100%) rename test/module/Entra/{Mock-Set-EntraGroup.Tests.ps1 => Set-EntraGroup.Tests.ps1} (100%) rename test/module/Entra/{Mock-Set-EntraMSApplication.Tests.ps1 => Set-EntraMSApplication.Tests.ps1} (100%) diff --git a/test/module/Entra/Mock-Add-EntraApplicationOwner.Tests.ps1 b/test/module/Entra/Add-EntraApplicationOwner.Tests.ps1 similarity index 100% rename from test/module/Entra/Mock-Add-EntraApplicationOwner.Tests.ps1 rename to test/module/Entra/Add-EntraApplicationOwner.Tests.ps1 diff --git a/test/module/Entra/Mock-Add-EntraMSAdministrativeUnitMember.Tests.ps1 b/test/module/Entra/Add-EntraMSAdministrativeUnitMember.Tests.ps1 similarity index 100% rename from test/module/Entra/Mock-Add-EntraMSAdministrativeUnitMember.Tests.ps1 rename to test/module/Entra/Add-EntraMSAdministrativeUnitMember.Tests.ps1 diff --git a/test/module/Entra/Mock-Add-EntraMSApplicationOwner.Tests.ps1 b/test/module/Entra/Add-EntraMSApplicationOwner.Tests.ps1 similarity index 100% rename from test/module/Entra/Mock-Add-EntraMSApplicationOwner.Tests.ps1 rename to test/module/Entra/Add-EntraMSApplicationOwner.Tests.ps1 diff --git a/test/module/Entra/Mock-Add-EntraMSScopedRoleMembership.Tests.ps1 b/test/module/Entra/Add-EntraMSScopedRoleMembership.Tests.ps1 similarity index 100% rename from test/module/Entra/Mock-Add-EntraMSScopedRoleMembership.Tests.ps1 rename to test/module/Entra/Add-EntraMSScopedRoleMembership.Tests.ps1 diff --git a/test/module/Entra/Mock-Enable-EntraDirectoryRole.Tests.ps1 b/test/module/Entra/Enable-EntraDirectoryRole.Tests.ps1 similarity index 100% rename from test/module/Entra/Mock-Enable-EntraDirectoryRole.Tests.ps1 rename to test/module/Entra/Enable-EntraDirectoryRole.Tests.ps1 diff --git a/test/module/Entra/Entra.Tests.ps1 b/test/module/Entra/Entra.Tests.ps1 index f8aa11c46..7e9478471 100644 --- a/test/module/Entra/Entra.Tests.ps1 +++ b/test/module/Entra/Entra.Tests.ps1 @@ -6,7 +6,7 @@ Import-Module Pester $psmPath = (Get-Module Microsoft.Graph.Entra).Path $testReportPath = join-path $psscriptroot "..\..\..\TestReport\Entra" -$mockScriptsPath = join-path $psscriptroot "..\..\..\test\module\Entra\Mock-*.Tests.ps1" +$mockScriptsPath = join-path $psscriptroot "..\..\..\test\module\Entra\*-*.Tests.ps1" $testOutputFile = "$testReportPath\TestResults.xml" if (!(test-path -path $testReportPath)) {new-item -path $testReportPath -itemtype directory} diff --git a/test/module/Entra/Get-EntraApplication.Tests.ps1 b/test/module/Entra/Get-EntraApplication.Tests.ps1 index 61c81cc91..592fe354d 100644 --- a/test/module/Entra/Get-EntraApplication.Tests.ps1 +++ b/test/module/Entra/Get-EntraApplication.Tests.ps1 @@ -1,44 +1,126 @@ -# ------------------------------------------------------------------------------ -# Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information. -# ------------------------------------------------------------------------------ -Describe "Get-EntraApplication" { - BeforeAll { - if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ - Import-Module Microsoft.Graph.Entra - } - } - - It "Should support minimum set of parameter sets" { - $GetAzureADApplication = Get-Command Get-EntraApplication - $GetAzureADApplication.ParameterSets.Name | Should -BeIn @("GetQuery", "GetVague", "GetById") - $GetAzureADApplication.Visibility | Should -Be "Public" - $GetAzureADApplication.CommandType | Should -Be "Function" +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ + Import-Module Microsoft.Graph.Entra } - - It "Should return a list of applications by default" { - $GetAzureADApplication = Get-Command Get-EntraApplication - $GetAzureADApplication.ModuleName | Should -Be "Microsoft.Graph.Entra" - $GetAzureADApplication.DefaultParameterSet | Should -Be "GetQuery" + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force + + $scriptblock = { + # Write-Host "Mocking Get-MgApplication with parameters: $($args | ConvertTo-Json -Depth 3)" + return @( + [PSCustomObject]@{ + "AppId" = "5f783237-3457-45d8-93e7-a0edb1cfbfd1" + "DeletedDateTime" = $null + "Id" = "111cc9b5-fce9-485e-9566-c68debafac5f" + "DisplayName" = "Mock-App" + "Info" = @{LogoUrl=""; MarketingUrl=""; PrivacyStatementUrl=""; SupportUrl=""; TermsOfServiceUrl=""} + "IsDeviceOnlyAuthSupported" = $True + "IsFallbackPublicClient" = $true + "KeyCredentials" = @{CustomKeyIdentifier = @(211, 174, 247);DisplayName =""; Key="";KeyId="d903c7a3-75ea-4772-8935-5c0cf82068a7";Type="Symmetric";Usage="Sign"} + "OptionalClaims" = @{AccessToken=""; IdToken=""; Saml2Token=""} + "ParentalControlSettings" = @{CountriesBlockedForMinors=$null; LegalAgeGroupRule="Allow"} + "PasswordCredentials" = @{} + "PublicClient" = @{RedirectUris=$null} + "PublisherDomain" = "M365x99297270.onmicrosoft.com" + "SignInAudience" = "AzureADandPersonalMicrosoftAccount" + "Web" = @{HomePageUrl="https://localhost/demoapp"; ImplicitGrantSettings=""; LogoutUrl="";} + "Parameters" = $args + } + ) } - It 'Should have List parameterSet' { - $GetAzureADApplication = Get-Command Get-EntraApplication - $ListParameterSet = $GetAzureADApplication.ParameterSets | Where-Object Name -eq "GetQuery" - $ListParameterSet.Parameters.Name | Should -Contain All - $ListParameterSet.Parameters.Name | Should -Contain Filter - $ListParameterSet.Parameters.Name | Should -Contain Top - } + Mock -CommandName Get-MgApplication -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra +} + +Describe "Get-EntraApplication" { + Context "Test for Get-EntraApplication" { + It "Should return specific application" { + $result = Get-EntraApplication -ObjectId "111cc9b5-fce9-485e-9566-c68debafac5f" + $result | Should -Not -BeNullOrEmpty + $result.Id | should -Be @('111cc9b5-fce9-485e-9566-c68debafac5f') - It 'Should have Get parameterSet' { - $GetAzureADApplication = Get-Command Get-EntraApplication - $GetParameterSet = $GetAzureADApplication.ParameterSets | Where-Object Name -eq "GetById" - $GetParameterSet.Parameters.Name | Should -Contain ObjectId - } + Should -Invoke -CommandName Get-MgApplication -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when ObjectId is empty" { + { Get-EntraApplication -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + } + It "Should return all applications" { + $result = Get-EntraApplication -All $true + $result | Should -Not -BeNullOrEmpty + + Should -Invoke -CommandName Get-MgApplication -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when All is empty" { + { Get-EntraApplication -All } | Should -Throw "Missing an argument for parameter 'All'*" + } + It "Should return specific application by searchstring" { + $result = Get-EntraApplication -SearchString 'Mock-App' + $result | Should -Not -BeNullOrEmpty + $result.DisplayName | should -Be 'Mock-App' + + Should -Invoke -CommandName Get-MgApplication -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should return specific application by filter" { + $result = Get-EntraApplication -Filter "DisplayName -eq 'Mock-App'" + $result | Should -Not -BeNullOrEmpty + $result.DisplayName | should -Be 'Mock-App' - It 'Should have GetViaIdentity parameterSet' { - $GetAzureADApplication = Get-Command Get-EntraApplication - $GetViaIdentityParameterSet = $GetAzureADApplication.ParameterSets | Where-Object Name -eq "GetVague" - $GetViaIdentityParameterSet.Parameters.Name | Should -Contain SearchString - $GetViaIdentityParameterSet.Parameters.Name | Should -Contain All + Should -Invoke -CommandName Get-MgApplication -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should return top application" { + $result = Get-EntraApplication -Top 1 + $result | Should -Not -BeNullOrEmpty + + Should -Invoke -CommandName Get-MgApplication -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Result should Contain ObjectId" { + $result = Get-EntraApplication -ObjectId "111cc9b5-fce9-485e-9566-c68debafac5f" + $result.ObjectId | should -Be "111cc9b5-fce9-485e-9566-c68debafac5f" + } + It "Should contain ApplicationId in parameters when passed ObjectId to it" { + $result = Get-EntraApplication -ObjectId "111cc9b5-fce9-485e-9566-c68debafac5f" + $params = Get-Parameters -data $result.Parameters + $params.ApplicationId | Should -Be "111cc9b5-fce9-485e-9566-c68debafac5f" + } + It "Should contain Filter in parameters when passed SearchString to it" { + $result = Get-EntraApplication -SearchString 'Mock-App' + $params = Get-Parameters -data $result.Parameters + $params.Filter | Should -Match "Mock-App" + } + It "Should contain 'User-Agent' header" { + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraApplication" + $result = Get-EntraApplication -SearchString 'Mock-App' + $params = Get-Parameters -data $result.Parameters + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } + It "Should support minimum set of parameter sets" { + $GetAzureADApplication = Get-Command Get-EntraApplication + $GetAzureADApplication.ParameterSets.Name | Should -BeIn @("GetQuery", "GetVague", "GetById") + $GetAzureADApplication.Visibility | Should -Be "Public" + $GetAzureADApplication.CommandType | Should -Be "Function" + } + + It "Should return a list of applications by default" { + $GetAzureADApplication = Get-Command Get-EntraApplication + $GetAzureADApplication.ModuleName | Should -Be "Microsoft.Graph.Entra" + $GetAzureADApplication.DefaultParameterSet | Should -Be "GetQuery" + } + It 'Should have List parameterSet' { + $GetAzureADApplication = Get-Command Get-EntraApplication + $ListParameterSet = $GetAzureADApplication.ParameterSets | Where-Object Name -eq "GetQuery" + $ListParameterSet.Parameters.Name | Should -Contain All + $ListParameterSet.Parameters.Name | Should -Contain Filter + $ListParameterSet.Parameters.Name | Should -Contain Top + } + It 'Should have Get parameterSet' { + $GetAzureADApplication = Get-Command Get-EntraApplication + $GetParameterSet = $GetAzureADApplication.ParameterSets | Where-Object Name -eq "GetById" + $GetParameterSet.Parameters.Name | Should -Contain ObjectId + } + It 'Should have GetViaIdentity parameterSet' { + $GetAzureADApplication = Get-Command Get-EntraApplication + $GetViaIdentityParameterSet = $GetAzureADApplication.ParameterSets | Where-Object Name -eq "GetVague" + $GetViaIdentityParameterSet.Parameters.Name | Should -Contain SearchString + $GetViaIdentityParameterSet.Parameters.Name | Should -Contain All + } } } \ No newline at end of file diff --git a/test/module/Entra/Mock-Get-EntraApplicationExtensionProperty.Tests.ps1 b/test/module/Entra/Get-EntraApplicationExtensionProperty.Tests.ps1 similarity index 100% rename from test/module/Entra/Mock-Get-EntraApplicationExtensionProperty.Tests.ps1 rename to test/module/Entra/Get-EntraApplicationExtensionProperty.Tests.ps1 diff --git a/test/module/Entra/Mock-Get-EntraApplicationKeyCredential.Tests.ps1 b/test/module/Entra/Get-EntraApplicationKeyCredential.Tests.ps1 similarity index 100% rename from test/module/Entra/Mock-Get-EntraApplicationKeyCredential.Tests.ps1 rename to test/module/Entra/Get-EntraApplicationKeyCredential.Tests.ps1 diff --git a/test/module/Entra/Mock-Get-EntraApplicationOwner.Tests.ps1 b/test/module/Entra/Get-EntraApplicationOwner.Tests.ps1 similarity index 100% rename from test/module/Entra/Mock-Get-EntraApplicationOwner.Tests.ps1 rename to test/module/Entra/Get-EntraApplicationOwner.Tests.ps1 diff --git a/test/module/Entra/Mock-Get-EntraDevice.Tests.ps1 b/test/module/Entra/Get-EntraDevice.Tests.ps1 similarity index 100% rename from test/module/Entra/Mock-Get-EntraDevice.Tests.ps1 rename to test/module/Entra/Get-EntraDevice.Tests.ps1 diff --git a/test/module/Entra/Mock-Get-EntraDirectoryRole.Tests.ps1 b/test/module/Entra/Get-EntraDirectoryRole.Tests.ps1 similarity index 100% rename from test/module/Entra/Mock-Get-EntraDirectoryRole.Tests.ps1 rename to test/module/Entra/Get-EntraDirectoryRole.Tests.ps1 diff --git a/test/module/Entra/Mock-Get-EntraGroup.Tests.ps1 b/test/module/Entra/Get-EntraGroup.Tests.ps1 similarity index 100% rename from test/module/Entra/Mock-Get-EntraGroup.Tests.ps1 rename to test/module/Entra/Get-EntraGroup.Tests.ps1 diff --git a/test/module/Entra/Mock-Get-EntraMSAdministrativeUnit.Tests.ps1 b/test/module/Entra/Get-EntraMSAdministrativeUnit.Tests.ps1 similarity index 100% rename from test/module/Entra/Mock-Get-EntraMSAdministrativeUnit.Tests.ps1 rename to test/module/Entra/Get-EntraMSAdministrativeUnit.Tests.ps1 diff --git a/test/module/Entra/Mock-Get-EntraMSAdministrativeUnitMember.Tests.ps1 b/test/module/Entra/Get-EntraMSAdministrativeUnitMember.Tests.ps1 similarity index 100% rename from test/module/Entra/Mock-Get-EntraMSAdministrativeUnitMember.Tests.ps1 rename to test/module/Entra/Get-EntraMSAdministrativeUnitMember.Tests.ps1 diff --git a/test/module/Entra/Mock-Get-EntraMSApplication.Tests.ps1 b/test/module/Entra/Get-EntraMSApplication.Tests.ps1 similarity index 100% rename from test/module/Entra/Mock-Get-EntraMSApplication.Tests.ps1 rename to test/module/Entra/Get-EntraMSApplication.Tests.ps1 diff --git a/test/module/Entra/Mock-Get-EntraMSApplicationOwner.Tests.ps1 b/test/module/Entra/Get-EntraMSApplicationOwner.Tests.ps1 similarity index 100% rename from test/module/Entra/Mock-Get-EntraMSApplicationOwner.Tests.ps1 rename to test/module/Entra/Get-EntraMSApplicationOwner.Tests.ps1 diff --git a/test/module/Entra/Invalid.Tests.ps1 b/test/module/Entra/Invalid.Tests.ps1 new file mode 100644 index 000000000..d3fdb0ece --- /dev/null +++ b/test/module/Entra/Invalid.Tests.ps1 @@ -0,0 +1,25 @@ +if($null -eq (Get-Module -Name Microsoft.Graph.Entra)){ + Import-Module Microsoft.Graph.Entra +} + +Describe "demo"{ + It "Should fail when parameters are empty"{ + $module = Get-Module -Name Microsoft.Graph.Entra + $module.ExportedCommands.Keys | ForEach-Object{ + $command = Get-Command $_ + $GetViaIdentityParameterSet = $command.ParameterSets | Where-Object Name -eq "GetById" + if($GetViaIdentityParameterSet.Parameters.Name -contains 'ObjectId'){ + $objectId = "" + $commandScriptBlock = [scriptblock]::Create("$command -ObjectId $objectId") + {Invoke-Command -ScriptBlock $commandScriptBlock} | Should -Throw "Missing an argument for parameter 'ObjectId'.*" + } + } + } + It "Should fail when parameters are invalid"{ + $module = Get-Module -Name Microsoft.Graph.Entra + $module.ExportedCommands.Keys | ForEach-Object{ + $command = Get-Command $_ + { Invoke-Command $command -demo "" } | Should -Throw "A parameter cannot be found that matches parameter name 'demo'." + } + } +} \ No newline at end of file diff --git a/test/module/Entra/Mock-Get-EntraApplication.Tests.ps1 b/test/module/Entra/Mock-Get-EntraApplication.Tests.ps1 deleted file mode 100644 index 37cf4b34b..000000000 --- a/test/module/Entra/Mock-Get-EntraApplication.Tests.ps1 +++ /dev/null @@ -1,96 +0,0 @@ -BeforeAll { - if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ - Import-Module Microsoft.Graph.Entra - } - Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force - - $scriptblock = { - # Write-Host "Mocking Get-MgApplication with parameters: $($args | ConvertTo-Json -Depth 3)" - return @( - [PSCustomObject]@{ - "AppId" = "5f783237-3457-45d8-93e7-a0edb1cfbfd1" - "DeletedDateTime" = $null - "Id" = "111cc9b5-fce9-485e-9566-c68debafac5f" - "DisplayName" = "Mock-App" - "Info" = @{LogoUrl=""; MarketingUrl=""; PrivacyStatementUrl=""; SupportUrl=""; TermsOfServiceUrl=""} - "IsDeviceOnlyAuthSupported" = $True - "IsFallbackPublicClient" = $true - "KeyCredentials" = @{CustomKeyIdentifier = @(211, 174, 247);DisplayName =""; Key="";KeyId="d903c7a3-75ea-4772-8935-5c0cf82068a7";Type="Symmetric";Usage="Sign"} - "OptionalClaims" = @{AccessToken=""; IdToken=""; Saml2Token=""} - "ParentalControlSettings" = @{CountriesBlockedForMinors=$null; LegalAgeGroupRule="Allow"} - "PasswordCredentials" = @{} - "PublicClient" = @{RedirectUris=$null} - "PublisherDomain" = "M365x99297270.onmicrosoft.com" - "SignInAudience" = "AzureADandPersonalMicrosoftAccount" - "Web" = @{HomePageUrl="https://localhost/demoapp"; ImplicitGrantSettings=""; LogoutUrl="";} - "Parameters" = $args - } - ) - } - - Mock -CommandName Get-MgApplication -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra -} - -Describe "Get-EntraApplication" { - Context "Test for Get-EntraApplication" { - It "Should return specific application" { - $result = Get-EntraApplication -ObjectId "111cc9b5-fce9-485e-9566-c68debafac5f" - $result | Should -Not -BeNullOrEmpty - $result.Id | should -Be @('111cc9b5-fce9-485e-9566-c68debafac5f') - - Should -Invoke -CommandName Get-MgApplication -ModuleName Microsoft.Graph.Entra -Times 1 - } - It "Should fail when ObjectId is empty" { - { Get-EntraApplication -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." - } - It "Should return all applications" { - $result = Get-EntraApplication -All $true - $result | Should -Not -BeNullOrEmpty - - Should -Invoke -CommandName Get-MgApplication -ModuleName Microsoft.Graph.Entra -Times 1 - } - It "Should fail when All is empty" { - { Get-EntraApplication -All } | Should -Throw "Missing an argument for parameter 'All'*" - } - It "Should return specific application by searchstring" { - $result = Get-EntraApplication -SearchString 'Mock-App' - $result | Should -Not -BeNullOrEmpty - $result.DisplayName | should -Be 'Mock-App' - - Should -Invoke -CommandName Get-MgApplication -ModuleName Microsoft.Graph.Entra -Times 1 - } - It "Should return specific application by filter" { - $result = Get-EntraApplication -Filter "DisplayName -eq 'Mock-App'" - $result | Should -Not -BeNullOrEmpty - $result.DisplayName | should -Be 'Mock-App' - - Should -Invoke -CommandName Get-MgApplication -ModuleName Microsoft.Graph.Entra -Times 1 - } - It "Should return top application" { - $result = Get-EntraApplication -Top 1 - $result | Should -Not -BeNullOrEmpty - - Should -Invoke -CommandName Get-MgApplication -ModuleName Microsoft.Graph.Entra -Times 1 - } - It "Result should Contain ObjectId" { - $result = Get-EntraApplication -ObjectId "111cc9b5-fce9-485e-9566-c68debafac5f" - $result.ObjectId | should -Be "111cc9b5-fce9-485e-9566-c68debafac5f" - } - It "Should contain ApplicationId in parameters when passed ObjectId to it" { - $result = Get-EntraApplication -ObjectId "111cc9b5-fce9-485e-9566-c68debafac5f" - $params = Get-Parameters -data $result.Parameters - $params.ApplicationId | Should -Be "111cc9b5-fce9-485e-9566-c68debafac5f" - } - It "Should contain Filter in parameters when passed SearchString to it" { - $result = Get-EntraApplication -SearchString 'Mock-App' - $params = Get-Parameters -data $result.Parameters - $params.Filter | Should -Match "Mock-App" - } - It "Should contain 'User-Agent' header" { - $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraApplication" - $result = Get-EntraApplication -SearchString 'Mock-App' - $params = Get-Parameters -data $result.Parameters - $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue - } - } -} \ No newline at end of file diff --git a/test/module/Entra/Mock-New-EntraApplication.Tests.ps1 b/test/module/Entra/New-EntraApplication.Tests.ps1 similarity index 100% rename from test/module/Entra/Mock-New-EntraApplication.Tests.ps1 rename to test/module/Entra/New-EntraApplication.Tests.ps1 diff --git a/test/module/Entra/Mock-New-EntraGroup.Tests.ps1 b/test/module/Entra/New-EntraGroup.Tests.ps1 similarity index 100% rename from test/module/Entra/Mock-New-EntraGroup.Tests.ps1 rename to test/module/Entra/New-EntraGroup.Tests.ps1 diff --git a/test/module/Entra/Mock-New-EntraMSAdministrativeUnit.Tests.ps1 b/test/module/Entra/New-EntraMSAdministrativeUnit.Tests.ps1 similarity index 100% rename from test/module/Entra/Mock-New-EntraMSAdministrativeUnit.Tests.ps1 rename to test/module/Entra/New-EntraMSAdministrativeUnit.Tests.ps1 diff --git a/test/module/Entra/Mock-New-EntraMSApplication.Tests.ps1 b/test/module/Entra/New-EntraMSApplication.Tests.ps1 similarity index 100% rename from test/module/Entra/Mock-New-EntraMSApplication.Tests.ps1 rename to test/module/Entra/New-EntraMSApplication.Tests.ps1 diff --git a/test/module/Entra/Mock-Remove-EntraApplication.Tests.ps1 b/test/module/Entra/Remove-EntraApplication.Tests.ps1 similarity index 100% rename from test/module/Entra/Mock-Remove-EntraApplication.Tests.ps1 rename to test/module/Entra/Remove-EntraApplication.Tests.ps1 diff --git a/test/module/Entra/Mock-Remove-EntraDevice.Tests.ps1 b/test/module/Entra/Remove-EntraDevice.Tests.ps1 similarity index 100% rename from test/module/Entra/Mock-Remove-EntraDevice.Tests.ps1 rename to test/module/Entra/Remove-EntraDevice.Tests.ps1 diff --git a/test/module/Entra/Mock-Remove-EntraGroup.Tests.ps1 b/test/module/Entra/Remove-EntraGroup.Tests.ps1 similarity index 100% rename from test/module/Entra/Mock-Remove-EntraGroup.Tests.ps1 rename to test/module/Entra/Remove-EntraGroup.Tests.ps1 diff --git a/test/module/Entra/Mock-Remove-EntraMSAdministrativeUnit.Tests.ps1 b/test/module/Entra/Remove-EntraMSAdministrativeUnit.Tests.ps1 similarity index 100% rename from test/module/Entra/Mock-Remove-EntraMSAdministrativeUnit.Tests.ps1 rename to test/module/Entra/Remove-EntraMSAdministrativeUnit.Tests.ps1 diff --git a/test/module/Entra/Mock-Remove-EntraMSAdministrativeUnitMember.Tests.ps1 b/test/module/Entra/Remove-EntraMSAdministrativeUnitMember.Tests.ps1 similarity index 100% rename from test/module/Entra/Mock-Remove-EntraMSAdministrativeUnitMember.Tests.ps1 rename to test/module/Entra/Remove-EntraMSAdministrativeUnitMember.Tests.ps1 diff --git a/test/module/Entra/Mock-Remove-EntraMSApplication.Tests.ps1 b/test/module/Entra/Remove-EntraMSApplication.Tests.ps1 similarity index 100% rename from test/module/Entra/Mock-Remove-EntraMSApplication.Tests.ps1 rename to test/module/Entra/Remove-EntraMSApplication.Tests.ps1 diff --git a/test/module/Entra/Mock-Remove-EntraMSScopedRoleMembership.Tests.ps1 b/test/module/Entra/Remove-EntraMSScopedRoleMembership.Tests.ps1 similarity index 100% rename from test/module/Entra/Mock-Remove-EntraMSScopedRoleMembership.Tests.ps1 rename to test/module/Entra/Remove-EntraMSScopedRoleMembership.Tests.ps1 diff --git a/test/module/Entra/Mock-Set-EntraApplication.Tests.ps1 b/test/module/Entra/Set-EntraApplication.Tests.ps1 similarity index 100% rename from test/module/Entra/Mock-Set-EntraApplication.Tests.ps1 rename to test/module/Entra/Set-EntraApplication.Tests.ps1 diff --git a/test/module/Entra/Mock-Set-EntraDevice.Tests.ps1 b/test/module/Entra/Set-EntraDevice.Tests.ps1 similarity index 100% rename from test/module/Entra/Mock-Set-EntraDevice.Tests.ps1 rename to test/module/Entra/Set-EntraDevice.Tests.ps1 diff --git a/test/module/Entra/Mock-Set-EntraGroup.Tests.ps1 b/test/module/Entra/Set-EntraGroup.Tests.ps1 similarity index 100% rename from test/module/Entra/Mock-Set-EntraGroup.Tests.ps1 rename to test/module/Entra/Set-EntraGroup.Tests.ps1 diff --git a/test/module/Entra/Mock-Set-EntraMSApplication.Tests.ps1 b/test/module/Entra/Set-EntraMSApplication.Tests.ps1 similarity index 100% rename from test/module/Entra/Mock-Set-EntraMSApplication.Tests.ps1 rename to test/module/Entra/Set-EntraMSApplication.Tests.ps1 From ff5144f7304cb2520b0d555f2396b586603b9d02 Mon Sep 17 00:00:00 2001 From: v-uansari Date: Tue, 23 Apr 2024 17:33:45 +0530 Subject: [PATCH 30/40] update test --- test/module/Entra/Invalid.Tests.ps1 | 76 +++++++++++++++++++++++++---- 1 file changed, 67 insertions(+), 9 deletions(-) diff --git a/test/module/Entra/Invalid.Tests.ps1 b/test/module/Entra/Invalid.Tests.ps1 index d3fdb0ece..1b3b6f626 100644 --- a/test/module/Entra/Invalid.Tests.ps1 +++ b/test/module/Entra/Invalid.Tests.ps1 @@ -2,24 +2,82 @@ if($null -eq (Get-Module -Name Microsoft.Graph.Entra)){ Import-Module Microsoft.Graph.Entra } -Describe "demo"{ - It "Should fail when parameters are empty"{ +Describe "Invalid Tests"{ + It "Should fail when parameters are invalid"{ $module = Get-Module -Name Microsoft.Graph.Entra $module.ExportedCommands.Keys | ForEach-Object{ $command = Get-Command $_ - $GetViaIdentityParameterSet = $command.ParameterSets | Where-Object Name -eq "GetById" - if($GetViaIdentityParameterSet.Parameters.Name -contains 'ObjectId'){ - $objectId = "" + { Invoke-Command $command -demo "" } | Should -Throw "A parameter cannot be found that matches parameter name 'demo'." + } + } + It "Should fail with 'TenantId' parameter" { + $module = Get-Module -Name Microsoft.Graph.Entra + $module.ExportedCommands.Keys | ForEach-Object { + $command = Get-Command $_ + if ($command.ParameterSets.Parameters.Name -contains 'TenantId'){ + $commandScriptBlock = [scriptblock]::Create("$command -TenantId $objectId") + { Invoke-Command -ScriptBlock $commandScriptBlock } | Should -Throw "Missing an argument for parameter 'TenantId'.*" + } + } + } + It "Should fail with 'Id' parameter" { + $module = Get-Module -Name Microsoft.Graph.Entra + $module.ExportedCommands.Keys | ForEach-Object { + $command = Get-Command $_ + if ($command.ParameterSets.Parameters.Name -contains 'Id'){ + $commandScriptBlock = [scriptblock]::Create("$command -Id $objectId") + { Invoke-Command -ScriptBlock $commandScriptBlock } | Should -Throw "Missing an argument for parameter 'Id'.*" + } + } + } + It "Should fail with 'ObjectId' parameter" { + $module = Get-Module -Name Microsoft.Graph.Entra + $module.ExportedCommands.Keys | ForEach-Object { + $command = Get-Command $_ + if ($command.ParameterSets.Parameters.Name -contains 'ObjectId'){ $commandScriptBlock = [scriptblock]::Create("$command -ObjectId $objectId") - {Invoke-Command -ScriptBlock $commandScriptBlock} | Should -Throw "Missing an argument for parameter 'ObjectId'.*" + { Invoke-Command -ScriptBlock $commandScriptBlock } | Should -Throw "Missing an argument for parameter 'ObjectId'.*" } } } - It "Should fail when parameters are invalid"{ + It "Should fail with 'All' parameter" { $module = Get-Module -Name Microsoft.Graph.Entra - $module.ExportedCommands.Keys | ForEach-Object{ + $module.ExportedCommands.Keys | ForEach-Object { $command = Get-Command $_ - { Invoke-Command $command -demo "" } | Should -Throw "A parameter cannot be found that matches parameter name 'demo'." + if ($command.ParameterSets.Parameters.Name -contains 'All'){ + $commandScriptBlock = [scriptblock]::Create("$command -All ") + { Invoke-Command -ScriptBlock $commandScriptBlock } | Should -Throw "Missing an argument for parameter 'All'*" } + } } + It "Should fail with 'Top' parameter" { + $module = Get-Module -Name Microsoft.Graph.Entra + $module.ExportedCommands.Keys | ForEach-Object { + $command = Get-Command $_ + if ($command.ParameterSets.Parameters.Name -contains 'Top'){ + $commandScriptBlock = [scriptblock]::Create("$command -Top ") + { Invoke-Command -ScriptBlock $commandScriptBlock } | Should -Throw "Missing an argument for parameter 'Top'*" + } + } + } + It "Should fail with 'Filter' parameter" { + $module = Get-Module -Name Microsoft.Graph.Entra + $module.ExportedCommands.Keys | ForEach-Object { + $command = Get-Command $_ + if ($command.ParameterSets.Parameters.Name -contains 'Filter'){ + $commandScriptBlock = [scriptblock]::Create("$command -Filter ") + { Invoke-Command -ScriptBlock $commandScriptBlock } | Should -Throw "Missing an argument for parameter 'Filter'*" + } + } + } + It "Should fail with 'SearchString' parameter" { + $module = Get-Module -Name Microsoft.Graph.Entra + $module.ExportedCommands.Keys | ForEach-Object { + $command = Get-Command $_ + if ($command.ParameterSets.Parameters.Name -contains 'SearchString'){ + $commandScriptBlock = [scriptblock]::Create("$command -SearchString ") + { Invoke-Command -ScriptBlock $commandScriptBlock } | Should -Throw "Missing an argument for parameter 'SearchString'*" + } + } + } } \ No newline at end of file From 42470b6e4417595912d80155d76c5af644b5ebc4 Mon Sep 17 00:00:00 2001 From: v-uansari Date: Fri, 26 Apr 2024 17:57:22 +0530 Subject: [PATCH 31/40] added valid parameter general tests --- test/module/Entra/Valid.Tests.ps1 | 106 ++++++++++++++++++++++++++++++ test/module/EntraCmdletsMap.ps1 | 102 ++++++++++++++++++++++++++++ 2 files changed, 208 insertions(+) create mode 100644 test/module/Entra/Valid.Tests.ps1 create mode 100644 test/module/EntraCmdletsMap.ps1 diff --git a/test/module/Entra/Valid.Tests.ps1 b/test/module/Entra/Valid.Tests.ps1 new file mode 100644 index 000000000..b92249f16 --- /dev/null +++ b/test/module/Entra/Valid.Tests.ps1 @@ -0,0 +1,106 @@ +BeforeAll{ + if($null -eq (Get-Module -Name Microsoft.Graph.Entra)){ + Import-Module Microsoft.Graph.Entra + } + Import-Module (Join-Path $psscriptroot "..\EntraCmdletsMap.ps1") -Force + + $module = Get-Module -Name Microsoft.Graph.Entra +} + +Describe "Valid parameter Tests"{ + Context "Test for valid parameters"{ + It "Should return empty object with Id parameter"{ + Write-Host "--------Start mock remove cmdlets with Id parameter only--------" + $count=0 + $module.ExportedCommands.Keys | ForEach-Object{ + $commandName = $_ + $command = Get-Command $_ + if($command.Name.StartsWith('Remove')){ + $params = ($command.ParameterSets.Parameters | Where-Object {$_.IsMandatory -eq $true} | select -expand Name) + if($params.count -eq 1 -and $params -eq 'Id'){ + $filter = $cmdlets | Where-Object { $_.SourceName -eq $command } + if($null -ne $filter){ + try { + Write-Host "$command" + $commandScriptBlock = [scriptblock]::Create("$commandName -Id 056b2531-005e-4f3e-be78-01a71ea30a04") + if($filter.IsApi){ + Mock -CommandName Invoke-GraphRequest -MockWith {} -ModuleName Microsoft.Graph.Entra + $result = Invoke-Command -ScriptBlock $commandScriptBlock + $result | Should -BeNullOrEmpty + Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 + } + else { + Mock -CommandName $filter.TargetName -MockWith {} -ModuleName Microsoft.Graph.Entra + $result = Invoke-Command -ScriptBlock $commandScriptBlock + $result | Should -BeNullOrEmpty + Should -Invoke -CommandName $filter.TargetName -ModuleName Microsoft.Graph.Entra -Times 1 + } + } + catch { + Write-Host "Exception in cmdlet" $command + } + $count++ + } + } + } + } + Write-Host "Cmdlets count: $count" + Write-Host "---------End mock remove cmdlets with Id parameter only---------" + } + It "Should return empty object with ObjectId param"{ + Write-Host "-----Start mock remove cmdlets with ObjectId parameter only-----" + $count=0 + $module.ExportedCommands.Keys | ForEach-Object{ + $commandName = $_ + $command = Get-Command $_ + if($command.Name.StartsWith('Remove')){ + $params = ($command.ParameterSets.Parameters | Where-Object {$_.IsMandatory -eq $true} | select -expand Name) + if($params.count -eq 1 -and $params -eq 'ObjectId'){ + $filter = $cmdlets | Where-Object { $_.SourceName -eq $command } + if($null -ne $filter){ + try { + Write-Host "$command" + $commandScriptBlock = [scriptblock]::Create("$commandName -ObjectId 056b2531-005e-4f3e-be78-01a71ea30a04") + if($filter.IsApi){ + Mock -CommandName Invoke-GraphRequest -MockWith {} -ModuleName Microsoft.Graph.Entra + $result = Invoke-Command -ScriptBlock $commandScriptBlock + $result | Should -BeNullOrEmpty + Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra -Times 1 + } + else { + Mock -CommandName $filter.TargetName -MockWith {} -ModuleName Microsoft.Graph.Entra + $result = Invoke-Command -ScriptBlock $commandScriptBlock + $result | Should -BeNullOrEmpty + Should -Invoke -CommandName $filter.TargetName -ModuleName Microsoft.Graph.Entra -Times 1 + } + } + catch { + Write-Host "Exception in cmdlet" $command + } + $count++ + } + } + } + } + Write-Host "Cmdlets count: $count" + Write-Host "------End mock remove cmdlets with ObjectId parameter only------" + } + # It "Should pass with 'Id' or 'ObjectId' parameter" { + # $count=0 + # $module.ExportedCommands.Keys | ForEach-Object { + + # $command = Get-Command $_ + # if ($command.Name.StartsWith('Remove')) + # { + # $params = ($command.ParameterSets.Parameters | Where-Object {$_.IsMandatory -eq $true} | select -expand Name) + # if($params.count -eq 1 -and ($params -eq 'ObjectId' -or $params-eq 'Id')){ + # $stringParams = $params -join ',' + # Write-Host "$command | $stringParams" + # $count++ + # } + # } + # } + # Write-Host $count + # } + } +} \ No newline at end of file diff --git a/test/module/EntraCmdletsMap.ps1 b/test/module/EntraCmdletsMap.ps1 new file mode 100644 index 000000000..c9fe7202e --- /dev/null +++ b/test/module/EntraCmdletsMap.ps1 @@ -0,0 +1,102 @@ +$cmdlets = @( + @{ + SourceName = "Remove-EntraMSAdministrativeUnit"; + TargetName = "Remove-MgDirectoryAdministrativeUnit"; + IsApi = $false + }, + @{ + SourceName = "Remove-EntraMSDeletedDirectoryObject"; + TargetName = ""; + IsApi = $true + }, + @{ + SourceName = "Remove-EntraMSGroup"; + TargetName = "Remove-MgGroup"; + IsApi = $false + }, + @{ + SourceName = "Remove-EntraMSGroupLifecyclePolicy"; + TargetName = "Remove-MgGroupLifecyclePolicy"; + IsApi = $false + }, + @{ + SourceName = "Remove-EntraMSIdentityProvider"; + TargetName = "Remove-MgIdentityProvider"; + IsApi = $false + }, + @{ + SourceName = "Remove-EntraMSPermissionGrantPolicy"; + TargetName = "Remove-MgPolicyPermissionGrantPolicy"; + IsApi = $false + }, + @{ + SourceName = "Remove-EntraMSRoleAssignment"; + TargetName = "Remove-MgRoleManagementDirectoryRoleAssignment" + IsApi = $false + }, + @{ + SourceName = "Remove-EntraMSRoleDefinition"; + TargetName = "Remove-MgRoleManagementDirectoryRoleDefinition"; + IsApi = $false + }, + @{ + SourceName = "Remove-EntraApplication"; + TargetName = "Remove-MgApplication"; + IsApi = $false + }, + @{ + SourceName = "Remove-EntraContact"; + TargetName = "Remove-MgContact"; + IsApi = $false + }, + @{ + SourceName = "Remove-EntraDeletedApplication"; + TargetName = "Remove-MgDirectoryDeletedItem"; + IsApi = $false + }, + @{ + SourceName = "Remove-EntraDevice"; + TargetName = "Remove-MgDevice"; + IsApi = $false + }, + @{ + SourceName = "Remove-EntraGroup"; + TargetName = "Remove-MgGroup"; + IsApi = $false + }, + @{ + SourceName = "Remove-EntraMSApplication"; + TargetName = "Remove-MgApplication"; + IsApi = $false + }, + @{ + SourceName = "Remove-EntraMSApplicationKey"; + TargetName = "Remove-MgApplicationKey"; + IsApi = $false + }, + @{ + SourceName = "Remove-EntraMSApplicationPassword"; + TargetName = "Remove-MgApplicationPassword"; + IsApi = $false + }, + @{ + SourceName = "Remove-EntraOAuth2PermissionGrant"; + TargetName = "Remove-MgOAuth2PermissionGrant"; + IsApi = $false + }, + @{ + SourceName = "Remove-EntraServicePrincipal"; + TargetName = "Remove-MgServicePrincipal"; + IsApi = $false + }, + @{ + SourceName = "Remove-EntraUser"; + TargetName = "Remove-MgUser"; + IsApi = $false + }, + @{ + SourceName = "Remove-EntraUserManager"; + TargetName = "Remove-MgUserManagerByRef"; + IsApi = $false + } +) \ No newline at end of file From 30ecc91564ca4709e5f50def7ae8c2c326e98942 Mon Sep 17 00:00:00 2001 From: Ashwini Karke Date: Mon, 29 Apr 2024 16:59:32 +0530 Subject: [PATCH 32/40] Added test case for no parameter exception --- test/module/Entra/Invalid.Tests.ps1 | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/module/Entra/Invalid.Tests.ps1 b/test/module/Entra/Invalid.Tests.ps1 index 1b3b6f626..35edacd5f 100644 --- a/test/module/Entra/Invalid.Tests.ps1 +++ b/test/module/Entra/Invalid.Tests.ps1 @@ -79,5 +79,22 @@ Describe "Invalid Tests"{ { Invoke-Command -ScriptBlock $commandScriptBlock } | Should -Throw "Missing an argument for parameter 'SearchString'*" } } + } + It "Should fail with exception when no parameter is passed" { + $cmdlets = @( + @{ CmdletName = 'Enable-EntraDirectoryRole'; Exception = "Could not resolve request to a valid role template." } + @{ CmdletName = 'New-EntraMSConditionalAccessPolicy'; Exception = "1006: 'displayName' cannot be null" }, + @{ CmdletName = 'New-EntraMSNamedLocationPolicy'; Exception = "1042: Unexpected type: namedLocationType for NamedLocations." }, + @{ CmdletName = 'New-EntraMSPermissionGrantPolicy'; Exception = "PermissionGrantPolicy's Id must not be null or empty." } + ) + $cmdlets | ForEach-Object { + $commandName = $_.CmdletName + $Exception = $_.Exception + $commandScriptBlock = [scriptblock]::Create("$commandName -ErrorAction Stop") + try { + Invoke-Command -ScriptBlock $commandScriptBlock + } + catch { $_ -match $Exception | Should -BeTrue } + } } } \ No newline at end of file From 5409db9f4fecdb980d06951d5ef1d6bee5743849 Mon Sep 17 00:00:00 2001 From: v-uansari Date: Mon, 6 May 2024 17:47:41 +0530 Subject: [PATCH 33/40] added mock tests --- .../Entra/Get-EntraApplicationOwner.Tests.ps1 | 49 ++++++++-------- ...elegatedPermissionClassification.Tests.ps1 | 50 +++++++++++++++++ ...-EntraServicePrincipalMembership.Tests.ps1 | 56 +++++++++++++++++++ .../Remove-EntraApplicationOwner.Tests.ps1 | 41 ++++++++++++++ 4 files changed, 174 insertions(+), 22 deletions(-) create mode 100644 test/module/Entra/Get-EntraMSServicePrincipalDelegatedPermissionClassification.Tests.ps1 create mode 100644 test/module/Entra/Get-EntraServicePrincipalMembership.Tests.ps1 create mode 100644 test/module/Entra/Remove-EntraApplicationOwner.Tests.ps1 diff --git a/test/module/Entra/Get-EntraApplicationOwner.Tests.ps1 b/test/module/Entra/Get-EntraApplicationOwner.Tests.ps1 index 125c01857..e806d2502 100644 --- a/test/module/Entra/Get-EntraApplicationOwner.Tests.ps1 +++ b/test/module/Entra/Get-EntraApplicationOwner.Tests.ps1 @@ -4,24 +4,28 @@ BeforeAll { } Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force - $mockResponse = @{ - value = @{ - Id = "e3108c4d-86ff-4ceb-9429-24e85b4b8cea" - ageGroup = $null - onPremisesLastSyncDateTime = $null - creationType = $null - imAddresses = {"adelev@m365x99297270.onmicrosoft.com"} - preferredLanguage = $null - mail = "AdeleV@M365x99297270.OnMicrosoft.com" - securityIdentifier = "S-1-12-1-1093396945-1080104032-2731339150-364051459" - identities = {} - consentProvidedForMinor = $null - onPremisesUserPrincipalName = $null - Parameters = $args + $mockResponse = { + return @{ + value = @( + @{ + Id = "e3108c4d-86ff-4ceb-9429-24e85b4b8cea" + ageGroup = $null + onPremisesLastSyncDateTime = $null + creationType = $null + imAddresses = {"adelev@m365x99297270.onmicrosoft.com"} + preferredLanguage = $null + mail = "AdeleV@M365x99297270.OnMicrosoft.com" + securityIdentifier = "S-1-12-1-1093396945-1080104032-2731339150-364051459" + identities = {} + consentProvidedForMinor = $null + onPremisesUserPrincipalName = $null + Parameters = $args + } + ) } - } + } - Mock -CommandName Invoke-GraphRequest -MockWith {$mockResponse} -ModuleName Microsoft.Graph.Entra + Mock -CommandName Invoke-GraphRequest -MockWith $mockResponse -ModuleName Microsoft.Graph.Entra } Describe "Get-EntraApplicationOwner"{ @@ -36,11 +40,12 @@ Describe "Get-EntraApplicationOwner"{ It "Should fail when ObjectId is empty" { { Get-EntraApplicationOwner -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." } - # It "Should contain 'User-Agent' header" { - # $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraApplicationOwner" - # $result = Get-EntraApplicationOwner -ObjectId "e3108c4d-86ff-4ceb-9429-24e85b4b8cea" - # $params = Get-Parameters -data $result.Parameters - # $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue - # } + It "Should contain 'User-Agent' header" { + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraApplicationOwner" + $result = Get-EntraApplicationOwner -ObjectId "e3108c4d-86ff-4ceb-9429-24e85b4b8cea" + $params = Get-Parameters -data $result.Parameters + $a= $params | ConvertTo-json | ConvertFrom-Json + $a.headers.'User-Agent' | Should -Be $userAgentHeaderValue + } } } \ No newline at end of file diff --git a/test/module/Entra/Get-EntraMSServicePrincipalDelegatedPermissionClassification.Tests.ps1 b/test/module/Entra/Get-EntraMSServicePrincipalDelegatedPermissionClassification.Tests.ps1 new file mode 100644 index 000000000..cd28cac17 --- /dev/null +++ b/test/module/Entra/Get-EntraMSServicePrincipalDelegatedPermissionClassification.Tests.ps1 @@ -0,0 +1,50 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ + Import-Module Microsoft.Graph.Entra + } + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force + + $scriptblock = { + return @( + [PSCustomObject]@{ + "Id" = "5XBeIKarUkypdm0tRsSAQwE" + "Classification" = "low" + "PermissionId" = "205e70e5-aba6-4c52-a976-6d2d46c48043" + "PermissionName" = "Sites.Read.All" + "Parameters" = $args + } + ) + } + + Mock -CommandName Get-MgServicePrincipalDelegatedPermissionClassification -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra +} +Describe "Get-EntraMSServicePrincipalDelegatedPermissionClassification"{ + It "Should fail when ServicePrincipalId is empty" { + { Get-EntraMSServicePrincipalDelegatedPermissionClassification -ServicePrincipalId "" } | Should -Throw "Cannot bind argument to parameter 'ServicePrincipalId' because it is an empty string." + } + It "Result should Contain ObjectId when ServicePrincipalId is passed" { + $result = Get-EntraMSServicePrincipalDelegatedPermissionClassification -ServicePrincipalId "fd560167-ff1f-471a-8d74-3b0070abcea1" + $result.ObjectId | should -Be "5XBeIKarUkypdm0tRsSAQwE" + } + It "Result should Contain ObjectId when Id is passed" { + $result = Get-EntraMSServicePrincipalDelegatedPermissionClassification -ServicePrincipalId "fd560167-ff1f-471a-8d74-3b0070abcea1" -Id "5XBeIKarUkypdm0tRsSAQwE" + $result.ObjectId | should -Be "5XBeIKarUkypdm0tRsSAQwE" + } + It "Should return specific application by filter" { + $result = Get-EntraMSServicePrincipalDelegatedPermissionClassification -ServicePrincipalId "fd560167-ff1f-471a-8d74-3b0070abcea1" -Filter "PermissionName eq 'Sites.Read.All'" + $result | Should -Not -BeNullOrEmpty + $result.Id | should -Be '5XBeIKarUkypdm0tRsSAQwE' + Should -Invoke -CommandName Get-MgServicePrincipalDelegatedPermissionClassification -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should contain DelegatedPermissionClassificationId in parameters when passed Id to it" { + $result = Get-EntraMSServicePrincipalDelegatedPermissionClassification -ServicePrincipalId "fd560167-ff1f-471a-8d74-3b0070abcea1" -Id "5XBeIKarUkypdm0tRsSAQwE" + $params = Get-Parameters -data $result.Parameters + $params.DelegatedPermissionClassificationId | Should -Be "5XBeIKarUkypdm0tRsSAQwE" + } + It "Should contain 'User-Agent' header" { + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraMSServicePrincipalDelegatedPermissionClassification" + $result = Get-EntraMSServicePrincipalDelegatedPermissionClassification -ServicePrincipalId "fd560167-ff1f-471a-8d74-3b0070abcea1" + $params = Get-Parameters -data $result.Parameters + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } +} \ No newline at end of file diff --git a/test/module/Entra/Get-EntraServicePrincipalMembership.Tests.ps1 b/test/module/Entra/Get-EntraServicePrincipalMembership.Tests.ps1 new file mode 100644 index 000000000..ec9d0d3fe --- /dev/null +++ b/test/module/Entra/Get-EntraServicePrincipalMembership.Tests.ps1 @@ -0,0 +1,56 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ + Import-Module Microsoft.Graph.Entra + } + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force + + $scriptblock = { + return @( + [PSCustomObject]@{ + "Id" = "7dc3a38a-4c92-40bd-b290-ea00f85b478c" + "AdditionalProperties" = @{DeletedDateTime = $null} + "Parameters" = $args + } + ) + } + + Mock -CommandName Get-MgServicePrincipalTransitiveMemberOf -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra +} +Describe "Get-EntraServicePrincipalMembership"{ + It "Result should not be empty" { + $result = Get-EntraServicePrincipalMembership -ObjectId "02ed943d-6eca-4f99-83d6-e6fbf9dc63ae" + $result | Should -Not -BeNullOrEmpty + Should -Invoke -CommandName Get-MgServicePrincipalTransitiveMemberOf -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when ObjectId is empty" { + { Get-EntraServicePrincipalMembership -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + } + It "Should return all applications" { + $result = Get-EntraServicePrincipalMembership -ObjectId "02ed943d-6eca-4f99-83d6-e6fbf9dc63ae" -All $true + $result | Should -Not -BeNullOrEmpty + Should -Invoke -CommandName Get-MgServicePrincipalTransitiveMemberOf -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when All is empty" { + { Get-EntraServicePrincipalMembership -ObjectId "02ed943d-6eca-4f99-83d6-e6fbf9dc63ae" -All } | Should -Throw "Missing an argument for parameter 'All'*" + } + It "Should return top application" { + $result = Get-EntraServicePrincipalMembership -ObjectId "02ed943d-6eca-4f99-83d6-e6fbf9dc63ae" -Top 1 + $result | Should -Not -BeNullOrEmpty + Should -Invoke -CommandName Get-MgServicePrincipalTransitiveMemberOf -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Result should Contain ObjectId" { + $result = Get-EntraServicePrincipalMembership -ObjectId "02ed943d-6eca-4f99-83d6-e6fbf9dc63ae" + $result.ObjectId | should -Be "7dc3a38a-4c92-40bd-b290-ea00f85b478c" + } + It "Should contain ServicePrincipalId in parameters when passed ObjectId to it" { + $result = Get-EntraServicePrincipalMembership -ObjectId "02ed943d-6eca-4f99-83d6-e6fbf9dc63ae" + $params = Get-Parameters -data $result.Parameters + $params.ServicePrincipalId | Should -Be "02ed943d-6eca-4f99-83d6-e6fbf9dc63ae" + } + It "Should contain 'User-Agent' header" { + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraServicePrincipalMembership" + $result = Get-EntraServicePrincipalMembership -ObjectId "02ed943d-6eca-4f99-83d6-e6fbf9dc63ae" + $params = Get-Parameters -data $result.Parameters + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } +} \ No newline at end of file diff --git a/test/module/Entra/Remove-EntraApplicationOwner.Tests.ps1 b/test/module/Entra/Remove-EntraApplicationOwner.Tests.ps1 new file mode 100644 index 000000000..9d138df5b --- /dev/null +++ b/test/module/Entra/Remove-EntraApplicationOwner.Tests.ps1 @@ -0,0 +1,41 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ + Import-Module Microsoft.Graph.Entra + } + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force + + Mock -CommandName Remove-MgApplicationOwnerByRef -MockWith {} -ModuleName Microsoft.Graph.Entra +} + +Describe "Remove-EntraApplicationOwner"{ + It "Should return empty object" { + $result = Remove-EntraApplicationOwner -ObjectId "3ddd22e7-a150-4bb3-b100-e410dea1cb84" -OwnerId "c13dd34a-492b-4561-b171-40fcce2916c5" + $result | Should -BeNullOrEmpty + Should -Invoke -CommandName Remove-MgApplicationOwnerByRef -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when ObjectId is empty" { + { Remove-EntraApplicationOwner -ObjectId "" } + } + It "Should fail when -OwnerId is empty" { + { Remove-EntraApplicationOwner -OwnerId "" } + } + It "Should contain DeviceId in parameters" { + Mock -CommandName Remove-MgApplicationOwnerByRef -MockWith {$args} -ModuleName Microsoft.Graph.Entra + $result = Remove-EntraApplicationOwner -ObjectId "3ddd22e7-a150-4bb3-b100-e410dea1cb84" -OwnerId "c13dd34a-492b-4561-b171-40fcce2916c5" + $params = Get-Parameters -data $result + $params.ApplicationId | Should -Be "3ddd22e7-a150-4bb3-b100-e410dea1cb84" + } + It "Should contain DeviceId in parameters" { + Mock -CommandName Remove-MgApplicationOwnerByRef -MockWith {$args} -ModuleName Microsoft.Graph.Entra + $result = Remove-EntraApplicationOwner -ObjectId "3ddd22e7-a150-4bb3-b100-e410dea1cb84" -OwnerId "c13dd34a-492b-4561-b171-40fcce2916c5" + $params = Get-Parameters -data $result + $params.DirectoryObjectId | Should -Be "c13dd34a-492b-4561-b171-40fcce2916c5" + } + It "Should contain 'User-Agent' header" { + Mock -CommandName Remove-MgApplicationOwnerByRef -MockWith {$args} -ModuleName Microsoft.Graph.Entra + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraApplicationOwner" + $result = Remove-EntraApplicationOwner -ObjectId "3ddd22e7-a150-4bb3-b100-e410dea1cb84" -OwnerId "c13dd34a-492b-4561-b171-40fcce2916c5" + $params = Get-Parameters -data $result + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } +} \ No newline at end of file From b9b0e6e09da19e7fcae89c92cdeabd022a284a3a Mon Sep 17 00:00:00 2001 From: v-uansari Date: Tue, 7 May 2024 12:10:13 +0530 Subject: [PATCH 34/40] added mock tests --- ...cePrincipalOAuth2PermissionGrant.tests.ps1 | 60 ++++++++++++++ .../Get-EntraServicePrincipalOwner.Tests.ps1 | 80 +++++++++++++++++++ ...ew-EntraServiceAppRoleAssignment.Tests.ps1 | 79 ++++++++++++++++++ 3 files changed, 219 insertions(+) create mode 100644 test/module/Entra/Get-EntraServicePrincipalOAuth2PermissionGrant.tests.ps1 create mode 100644 test/module/Entra/Get-EntraServicePrincipalOwner.Tests.ps1 create mode 100644 test/module/Entra/New-EntraServiceAppRoleAssignment.Tests.ps1 diff --git a/test/module/Entra/Get-EntraServicePrincipalOAuth2PermissionGrant.tests.ps1 b/test/module/Entra/Get-EntraServicePrincipalOAuth2PermissionGrant.tests.ps1 new file mode 100644 index 000000000..f5e18d753 --- /dev/null +++ b/test/module/Entra/Get-EntraServicePrincipalOAuth2PermissionGrant.tests.ps1 @@ -0,0 +1,60 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ + Import-Module Microsoft.Graph.Entra + } + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force + + $scriptblock = { + return @( + [PSCustomObject]@{ + "Id" = "9uBzRwC0s0CFCDQN6O4Ik_fW8XpadQNIoHik9aQxrVE" + "ClientId" = "4773e0f6-b400-40b3-8508-340de8ee0893" + "ConsentType" = "AllPrincipals" + "PrincipalId" = "7af1d6f7-755a-4803-a078-a4f5a431ad5" + "ResourceId" = "412be9d1-1460-4061-8eed-cca203fcb215" + "Scope" = "openid" + "Parameters" = $args + } + ) + } + + Mock -CommandName Get-MgServicePrincipalOauth2PermissionGrant -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra +} +Describe "Get-EntraServicePrincipalOAuth2PermissionGrant"{ + It "Result should not be empty" { + $result = Get-EntraServicePrincipalOAuth2PermissionGrant -ObjectId "02ed943d-6eca-4f99-83d6-e6fbf9dc63ae" + $result | Should -Not -BeNullOrEmpty + Should -Invoke -CommandName Get-MgServicePrincipalOauth2PermissionGrant -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when ObjectId is empty" { + { Get-EntraServicePrincipalOAuth2PermissionGrant -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + } + It "Should return all applications" { + $result = Get-EntraServicePrincipalOAuth2PermissionGrant -ObjectId "02ed943d-6eca-4f99-83d6-e6fbf9dc63ae" -All $true + $result | Should -Not -BeNullOrEmpty + Should -Invoke -CommandName Get-MgServicePrincipalOauth2PermissionGrant -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when All is empty" { + { Get-EntraServicePrincipalOAuth2PermissionGrant -ObjectId "02ed943d-6eca-4f99-83d6-e6fbf9dc63ae" -All } | Should -Throw "Missing an argument for parameter 'All'*" + } + It "Should return top application" { + $result = Get-EntraServicePrincipalOAuth2PermissionGrant -ObjectId "02ed943d-6eca-4f99-83d6-e6fbf9dc63ae" -Top 1 + $result | Should -Not -BeNullOrEmpty + Should -Invoke -CommandName Get-MgServicePrincipalOauth2PermissionGrant -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Result should Contain ObjectId" { + $result = Get-EntraServicePrincipalOAuth2PermissionGrant -ObjectId "02ed943d-6eca-4f99-83d6-e6fbf9dc63ae" + $result.ObjectId | should -Be "9uBzRwC0s0CFCDQN6O4Ik_fW8XpadQNIoHik9aQxrVE" + } + It "Should contain ServicePrincipalId in parameters when passed ObjectId to it" { + $result = Get-EntraServicePrincipalOAuth2PermissionGrant -ObjectId "02ed943d-6eca-4f99-83d6-e6fbf9dc63ae" + $params = Get-Parameters -data $result.Parameters + $params.ServicePrincipalId | Should -Be "02ed943d-6eca-4f99-83d6-e6fbf9dc63ae" + } + It "Should contain 'User-Agent' header" { + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraServicePrincipalOAuth2PermissionGrant" + $result = Get-EntraServicePrincipalOAuth2PermissionGrant -ObjectId "02ed943d-6eca-4f99-83d6-e6fbf9dc63ae" + $params = Get-Parameters -data $result.Parameters + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } +} \ No newline at end of file diff --git a/test/module/Entra/Get-EntraServicePrincipalOwner.Tests.ps1 b/test/module/Entra/Get-EntraServicePrincipalOwner.Tests.ps1 new file mode 100644 index 000000000..93b2ac7e4 --- /dev/null +++ b/test/module/Entra/Get-EntraServicePrincipalOwner.Tests.ps1 @@ -0,0 +1,80 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ + Import-Module Microsoft.Graph.Entra + } + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force + + $scriptblock = { + return @( + [PSCustomObject]@{ + "Id" = "fd560167-ff1f-471a-8d74-3b0070abcea1" + "DisplayName" = "Adams Smith" + "UserPrincipalName" = "Adams@contoso.com" + "UserType" = "Member" + "appRoles" = @{ + allowedMemberTypes=$null; + description="msiam_access"; + displayName="msiam_access"; + id="d0d7e4e4-96be-41c9-805a-08e0526868ad"; + isEnabled=$True; + origin="Application" + } + "oauth2PermissionScopes" = @{ + adminConsentDescription="Allow the application to access from tmplate test 3 on behalf of the signed-in user."; + adminConsentDisplayName="Access from tmplate test 3"; + id="64c2cef3-e118-4795-a580-a32bdbd7ba88"; + isEnabled=$True; + type="User"; + userConsentDescription="Allow the application to access from tmplate test 3 on your behalf."; + userConsentDisplayName="Access from tmplate test 3"; + value="user_impersonation" + } + "AdditionalProperties" = @{ + "@odata.type" = "#microsoft.graph.servicePrincipal"; + accountEnabled = $true + } + "Parameters" = $args + } + ) + } + + Mock -CommandName Get-MgServicePrincipalOwner -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra +} +Describe "Get-EntraServicePrincipalOwner"{ + It "Result should not be empty" { + $result = Get-EntraServicePrincipalOwner -ObjectId "02ed943d-6eca-4f99-83d6-e6fbf9dc63ae" + $result | Should -Not -BeNullOrEmpty + Should -Invoke -CommandName Get-MgServicePrincipalOwner -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when ObjectId is empty" { + { Get-EntraServicePrincipalOwner -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + } + It "Should return all applications" { + $result = Get-EntraServicePrincipalOwner -ObjectId "02ed943d-6eca-4f99-83d6-e6fbf9dc63ae" -All $true + $result | Should -Not -BeNullOrEmpty + Should -Invoke -CommandName Get-MgServicePrincipalOwner -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when All is empty" { + { Get-EntraServicePrincipalOwner -ObjectId "02ed943d-6eca-4f99-83d6-e6fbf9dc63ae" -All } | Should -Throw "Missing an argument for parameter 'All'*" + } + It "Should return top application" { + $result = Get-EntraServicePrincipalOwner -ObjectId "02ed943d-6eca-4f99-83d6-e6fbf9dc63ae" -Top 1 + $result | Should -Not -BeNullOrEmpty + Should -Invoke -CommandName Get-MgServicePrincipalOwner -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Result should Contain ObjectId" { + $result = Get-EntraServicePrincipalOwner -ObjectId "02ed943d-6eca-4f99-83d6-e6fbf9dc63ae" + $result.ObjectId | should -Be "fd560167-ff1f-471a-8d74-3b0070abcea1" + } + It "Should contain ServicePrincipalId in parameters when passed ObjectId to it" { + $result = Get-EntraServicePrincipalOwner -ObjectId "02ed943d-6eca-4f99-83d6-e6fbf9dc63ae" + $params = Get-Parameters -data $result.Parameters + $params.ServicePrincipalId | Should -Be "02ed943d-6eca-4f99-83d6-e6fbf9dc63ae" + } + It "Should contain 'User-Agent' header" { + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraServicePrincipalOwner" + $result = Get-EntraServicePrincipalOwner -ObjectId "02ed943d-6eca-4f99-83d6-e6fbf9dc63ae" + $params = Get-Parameters -data $result.Parameters + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } +} \ No newline at end of file diff --git a/test/module/Entra/New-EntraServiceAppRoleAssignment.Tests.ps1 b/test/module/Entra/New-EntraServiceAppRoleAssignment.Tests.ps1 new file mode 100644 index 000000000..dcc18e511 --- /dev/null +++ b/test/module/Entra/New-EntraServiceAppRoleAssignment.Tests.ps1 @@ -0,0 +1,79 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ + Import-Module Microsoft.Graph.Entra + } + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force + + $scriptblock = { + # Write-Host "Mocking New-MgServicePrincipalAppRoleAssignment with parameters: $($args | ConvertTo-Json -Depth 3)" + return @( + [PSCustomObject]@{ + "DeletedDateTime" = $null + "Id" = "gsx_zBushUevRyyjtwUohm_RMYjcGsJIjXwKOVMr3ww" + "PrincipalDisplayName" = "Mock-App" + "AppRoleId" = "e18f0405-fdec-4ae8-a8a0-d8edb98b061f" + "CreatedDateTime" = "3/12/2024 11:05:29 AM" + "PrincipalId" = "d2d0a585-0c52-4bab-8c64-a096b98b061f" + "Parameters" = $args + } + ) + } + + Mock -CommandName New-MgServicePrincipalAppRoleAssignment -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra +} + +Describe "New-EntraServiceAppRoleAssignment"{ + Context "Test for New-EntraServiceAppRoleAssignment" { + It "Should return EntraServiceAppRoleAssignment"{ + $result = New-EntraServiceAppRoleAssignment -ObjectId "02ed943d-6eca-4f99-83d6-e6fbf9dc63ae" -ResourceId "02ed943d-6eca-4f99-83d6-e6fbf9dc63ae" -Id "e18f0405-fdec-4ae8-a8a0-d8edb98b061f" -PrincipalId "d2d0a585-0c52-4bab-8c64-a096b98b061f" + $result | Should -Not -BeNullOrEmpty + $result.PrincipalDisplayName | should -Be "Mock-App" + $result.PrincipalId | should -Be "d2d0a585-0c52-4bab-8c64-a096b98b061f" + + Should -Invoke -CommandName New-MgServicePrincipalAppRoleAssignment -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when ObjectId is empty" { + { New-EntraServiceAppRoleAssignment -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId'*" + } + It "Should fail when ObjectId is null" { + { New-EntraServiceAppRoleAssignment -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + } + It "Should fail when ResourceId is empty" { + { New-EntraServiceAppRoleAssignment -ResourceId "" } | Should -Throw "Cannot bind argument to parameter 'ResourceId'*" + } + It "Should fail when ResourceId is null" { + { New-EntraServiceAppRoleAssignment -ResourceId } | Should -Throw "Missing an argument for parameter 'ResourceId'*" + } + It "Should fail when Id is empty" { + { New-EntraServiceAppRoleAssignment -Id "" } | Should -Throw "Cannot bind argument to parameter 'Id'*" + } + It "Should fail when Id is null" { + { New-EntraServiceAppRoleAssignment -Id } | Should -Throw "Missing an argument for parameter 'Id'*" + } + It "Should fail when PrincipalId is empty" { + { New-EntraServiceAppRoleAssignment -PrincipalId "" } | Should -Throw "Cannot bind argument to parameter 'PrincipalId'*" + } + It "Should fail when PrincipalId is null" { + { New-EntraServiceAppRoleAssignment -PrincipalId } | Should -Throw "Missing an argument for parameter 'PrincipalId'*" + } + It "Should fail when invalid parameter is passed" { + { New-EntraServiceAppRoleAssignment -DisplayName "abc" } | Should -Throw "A parameter cannot be found that matches parameter name 'DisplayName'." + } + It "Should contain AppRoleId in parameters when passed Id to it" { + $result = New-EntraServiceAppRoleAssignment -ObjectId "02ed943d-6eca-4f99-83d6-e6fbf9dc63ae" -ResourceId "02ed943d-6eca-4f99-83d6-e6fbf9dc63ae" -Id "e18f0405-fdec-4ae8-a8a0-d8edb98b061f" -PrincipalId "d2d0a585-0c52-4bab-8c64-a096b98b061f" + $params = Get-Parameters -data $result.Parameters + $params.AppRoleId | Should -Be "e18f0405-fdec-4ae8-a8a0-d8edb98b061f" + } + It "Should contain ServicePrincipalId in parameters when passed ObjectId to it" { + $result = New-EntraServiceAppRoleAssignment -ObjectId "02ed943d-6eca-4f99-83d6-e6fbf9dc63ae" -ResourceId "02ed943d-6eca-4f99-83d6-e6fbf9dc63ae" -Id "e18f0405-fdec-4ae8-a8a0-d8edb98b061f" -PrincipalId "d2d0a585-0c52-4bab-8c64-a096b98b061f" + $params = Get-Parameters -data $result.Parameters + $params.ServicePrincipalId | Should -Be "02ed943d-6eca-4f99-83d6-e6fbf9dc63ae" + } + It "Should contain 'User-Agent' header" { + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion New-EntraServiceAppRoleAssignment" + $result = New-EntraServiceAppRoleAssignment -ObjectId "02ed943d-6eca-4f99-83d6-e6fbf9dc63ae" -ResourceId "02ed943d-6eca-4f99-83d6-e6fbf9dc63ae" -Id "e18f0405-fdec-4ae8-a8a0-d8edb98b061f" -PrincipalId "d2d0a585-0c52-4bab-8c64-a096b98b061f" + $params = Get-Parameters -data $result.Parameters + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } + } +} \ No newline at end of file From ce19bbb58a628efbbf81f7b13ac70fe2882c72bb Mon Sep 17 00:00:00 2001 From: v-uansari Date: Tue, 7 May 2024 17:41:07 +0530 Subject: [PATCH 35/40] added mock tests --- ...traApplicationPasswordCredential.Tests.ps1 | 50 +++++++ .../Get-EntraDeletedApplication.Tests.ps1 | 140 ++++++++++++++++++ ...ntraApplicationExtensionProperty.Tests.ps1 | 71 +++++++++ 3 files changed, 261 insertions(+) create mode 100644 test/module/Entra/Get-EntraApplicationPasswordCredential.Tests.ps1 create mode 100644 test/module/Entra/Get-EntraDeletedApplication.Tests.ps1 create mode 100644 test/module/Entra/New-EntraApplicationExtensionProperty.Tests.ps1 diff --git a/test/module/Entra/Get-EntraApplicationPasswordCredential.Tests.ps1 b/test/module/Entra/Get-EntraApplicationPasswordCredential.Tests.ps1 new file mode 100644 index 000000000..c29fe8c83 --- /dev/null +++ b/test/module/Entra/Get-EntraApplicationPasswordCredential.Tests.ps1 @@ -0,0 +1,50 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ + Import-Module Microsoft.Graph.Entra + } + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force + + $scriptblock = { + @{ + "PasswordCredentials" = @( + @{ + "CustomKeyIdentifier" = {116, 101, 115, 116} + "DisplayName" = "" + "EndDateTime" = "10/23/2024 11:36:56 AM" + "KeyId" = "52ab6cca-bc59-4f06-8450-75a3d2b8e53b" + "StartDateTime" = "11/22/2023 11:35:16 AM" + "Hint" = "123" + "SecretText" = "" + "Parameters" = $args + } + ) + } + } + + Mock -CommandName Get-MgApplication -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra + } + + Describe "Get-EntraApplicationPasswordCredential" { + Context "Test for Get-EntraApplicationPasswordCredential" { + It "Should not return empty" { + $result = Get-EntraApplicationPasswordCredential -ObjectId "dc587a80-d49c-4700-a73b-57227856fc32" + $result | Should -Not -BeNullOrEmpty + Should -Invoke -CommandName Get-MgApplication -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when ObjectId is empty" { + { Get-EntraApplicationPasswordCredential -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId'*" + } + It "Should fail when ObjectId is empty" { + { Get-EntraApplicationPasswordCredential -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + } + It "Should fail when invalid parameter is passed" { + { Get-EntraApplicationPasswordCredential -DisplayName "abc" } | Should -Throw "A parameter cannot be found that matches parameter name 'DisplayName'*" + } + It "Should contain 'User-Agent' header" { + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraApplicationPasswordCredential" + $result = Get-EntraApplicationPasswordCredential -ObjectId "dc587a80-d49c-4700-a73b-57227856fc32" + $params = Get-Parameters -data $result.Parameters + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } + } + } \ No newline at end of file diff --git a/test/module/Entra/Get-EntraDeletedApplication.Tests.ps1 b/test/module/Entra/Get-EntraDeletedApplication.Tests.ps1 new file mode 100644 index 000000000..b32b7e398 --- /dev/null +++ b/test/module/Entra/Get-EntraDeletedApplication.Tests.ps1 @@ -0,0 +1,140 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ + Import-Module Microsoft.Graph.Entra + } + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force + + $scriptblock = { + return @( + [PSCustomObject]@{ + "AddIns" = {} + "AppRoles" = {} + "GroupMembershipClaims" = {} + "IdentifierUris" = {} + "Info" = @{ + LogoUrl=""; + MarketingUrl=""; + PrivacyStatementUrl=""; + SupportUrl=""; + TermsOfServiceUrl=""; + } + "IsDeviceOnlyAuthSupported" = $null + "KeyCredentials" = {} + "OptionalClaims" = {} + "ParentalControlSettings" = @{ + CountriesBlockedForMinors=@{}; + LegalAgeGroupRule="Allow"; + } + "PasswordCredentials" = {} + "Api" = @{ + AcceptMappedClaims=@{}; + KnownClientApplications=@{}; + Oauth2PermissionScopes=@{}; + PreAuthorizedApplications=@{}; + RequestedAccessTokenVersion="2"; + } + "PublicClient" = @{ + RedirectUris=@{}; + } + "PublisherDomain" = "M365x99297270.onmicrosoft.com" + "Web" = @{ + HomePageUrl=""; + ImplicitGrantSettings=""; + LogoutUrl=""; + RedirectUriSettings=@{}; + RedirectUris=@{}; + } + "RequiredResourceAccess" = $null + "AppId" = "9c17362d-20b6-4572-bb6f-600e57c840e5" + "AppManagementPolicies" = $null + "ApplicationTemplateId" = $null + "Certification" = {} + "CreatedDateTime" = "12/12/2023 11:28:45 AM" + "CreatedOnBehalfOf" = {} + "DefaultRedirectUri" = $null + "DeletedDateTime" = "12/12/2023 12:23:39 PM" + "Description" = $null + "DisabledByMicrosoftStatus" = $null + "DisplayName" = "Mock-test-App" + "ExtensionProperties" = $null + "FederatedIdentityCredentials" = $null + "HomeRealmDiscoveryPolicies" = $null + "Id" = "01157307-373c-47b0-889a-3bc57033d73e" + "IsFallbackPublicClient" = $null + "Logo" = $null + "Notes" = $null + "Oauth2RequirePostResponse" = $null + "Owners" = $null + "RequestSignatureVerification" = {} + "SamlMetadataUrl" = $null + "ServiceManagementReference" = $null + "ServicePrincipalLockConfiguration" = {} + "SignInAudience" = "AzureADandPersonalMicrosoftAccount" + "Spa" = {} + "Synchronization" = {} + "Tags" = {} + "TokenEncryptionKeyId" = $null + "TokenIssuancePolicies" = $null + "TokenLifetimePolicies" = $null + "UniqueName" = $null + "VerifiedPublisher" = {} + "AdditionalProperties" = {} + "Parameters" = $args + } + ) + } + + Mock -CommandName Get-MgDirectoryDeletedItemAsApplication -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra +} + +Describe "Get-EntraDeletedApplication" { + Context "Test for Get-EntraDeletedApplication" { + It "Should return all applications" { + $result = Get-EntraDeletedApplication | ConvertTo-Json | ConvertFrom-Json + $result | Should -Not -BeNullOrEmpty + Should -Invoke -CommandName Get-MgDirectoryDeletedItemAsApplication -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when All is empty" { + { Get-EntraDeletedApplication -All } | Should -Throw "Missing an argument for parameter 'All'*" + } + It "Should fail when invalid parameter is passed" { + { Get-EntraDeletedApplication -DisplayName "abc" } | Should -Throw "A parameter cannot be found that matches parameter name 'DisplayName'*" + } + It "Should return specific application by searchstring" { + $result = Get-EntraDeletedApplication -SearchString 'Mock-test-App' | ConvertTo-Json | ConvertFrom-Json + $result | Should -Not -BeNullOrEmpty + $result.DisplayName | should -Be 'Mock-test-App' + + Should -Invoke -CommandName Get-MgDirectoryDeletedItemAsApplication -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should return specific application by filter" { + $result = Get-EntraDeletedApplication -Filter "DisplayName -eq 'Mock-test-App'" | ConvertTo-Json | ConvertFrom-Json + $result | Should -Not -BeNullOrEmpty + $result.DisplayName | should -Be 'Mock-test-App' + + Should -Invoke -CommandName Get-MgDirectoryDeletedItemAsApplication -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should return top application" { + $result = Get-EntraDeletedApplication -Top 1 | ConvertTo-Json | ConvertFrom-Json + $result | Should -Not -BeNullOrEmpty + + Should -Invoke -CommandName Get-MgDirectoryDeletedItemAsApplication -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Result should Contain ObjectId" { + $result = Get-EntraDeletedApplication -Filter "DisplayName -eq 'Mock-test-App'" | ConvertTo-Json | ConvertFrom-Json + $result.ObjectId | should -Be "01157307-373c-47b0-889a-3bc57033d73e" + } + It "Should contain Filter in parameters when passed SearchString to it" { + $result = Get-EntraDeletedApplication -SearchString 'Mock-test-App' | ConvertTo-Json | ConvertFrom-Json + $params = Get-Parameters -data $result.Parameters + $params.Filter | Should -Match "Mock-test-App" + } + It "Should contain 'User-Agent' header" { + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraDeletedApplication" + $result = Get-EntraDeletedApplication -Top 1 | ConvertTo-Json | ConvertFrom-Json + $params = Get-Parameters -data $result.Parameters + $a= $params | ConvertTo-json | ConvertFrom-Json + $a.headers.'User-Agent' | Should -Be $userAgentHeaderValue + } + } +} \ No newline at end of file diff --git a/test/module/Entra/New-EntraApplicationExtensionProperty.Tests.ps1 b/test/module/Entra/New-EntraApplicationExtensionProperty.Tests.ps1 new file mode 100644 index 000000000..0e70b3976 --- /dev/null +++ b/test/module/Entra/New-EntraApplicationExtensionProperty.Tests.ps1 @@ -0,0 +1,71 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ + Import-Module Microsoft.Graph.Entra + } + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force + + $scriptblock = { + return @( + [PSCustomObject]@{ + "DeletedDateTime" = $null + "Id" = "d083d12d-c280-4a23-a644-b4e71a09a4cb" + "AppDisplayName" = "Mock-App" + "DataType" = "String" + "IsSyncedFromOnPremises" = $False + "Name" = "extension_ec5edf3fe79749dd8d1e7760a1c1c943_NewAttribute" + "TargetObjects" = { "User" } + "Parameters" = $args + } + ) + } + + Mock -CommandName New-MgApplicationExtensionProperty -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra + + $targets = New-Object System.Collections.Generic.List[System.String] + $targets.Add('User') +} +Describe "New-EntraApplicationExtensionProperty"{ + It "Should return created extension property"{ + $result = New-EntraApplicationExtensionProperty -ObjectID "3ddd22e7-a150-4bb3-b100-e410dea1cb84" -Name "NewAttribute" -TargetObjects $targets + $result | Should -Not -BeNullOrEmpty + $result.AppDisplayName | should -Be "Mock-App" + $result.Name | Should -Be "extension_ec5edf3fe79749dd8d1e7760a1c1c943_NewAttribute" + Should -Invoke -CommandName New-MgApplicationExtensionProperty -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when ObjectId is empty" { + { New-EntraApplicationExtensionProperty -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId'*" + } + It "Should fail when ObjectId is null" { + { New-EntraApplicationExtensionProperty -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + } + It "Should fail when Name is null" { + { New-EntraApplicationExtensionProperty -ObjectID "3ddd22e7-a150-4bb3-b100-e410dea1cb84" -Name } | Should -Throw "Missing an argument for parameter 'Name'*" + } + It "Should fail when DataType is null" { + { New-EntraApplicationExtensionProperty -ObjectID "3ddd22e7-a150-4bb3-b100-e410dea1cb84" -Name "NewAttribute" -DataType } | Should -Throw "Missing an argument for parameter 'DataType'*" + } + It "Should fail when TargetObjects is null" { + { New-EntraApplicationExtensionProperty -ObjectID "3ddd22e7-a150-4bb3-b100-e410dea1cb84" -Name "NewAttribute" -TargetObjects } | Should -Throw "Missing an argument for parameter 'TargetObjects'*" + } + It "Should fail when invalid parameter is passed" { + { New-EntraApplicationExtensionProperty -DisplayName "abc" } | Should -Throw "A parameter cannot be found that matches parameter name 'DisplayName'." + } + It "Should return result when TargetObjects is empty" { + New-EntraApplicationExtensionProperty -ObjectID "3ddd22e7-a150-4bb3-b100-e410dea1cb84" -Name "NewAttribute" -TargetObjects {} | Should -Not -BeNullOrEmpty + } + It "Should contain ObjectId in result"{ + $result = New-EntraApplicationExtensionProperty -ObjectID "3ddd22e7-a150-4bb3-b100-e410dea1cb84" -Name "NewAttribute" + $result.ObjectID | Should -Be "d083d12d-c280-4a23-a644-b4e71a09a4cb" + } + It "Should contain ApplicationId in parameters when passed ObjectId to it" { + $result = New-EntraApplicationExtensionProperty -ObjectID "3ddd22e7-a150-4bb3-b100-e410dea1cb84" -Name "NewAttribute" + $params = Get-Parameters -data $result.Parameters + $params.ApplicationId | Should -Be "3ddd22e7-a150-4bb3-b100-e410dea1cb84" + } + It "Should contain 'User-Agent' header" { + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion New-EntraApplicationExtensionProperty" + $result = New-EntraApplicationExtensionProperty -ObjectID "3ddd22e7-a150-4bb3-b100-e410dea1cb84" -Name "NewAttribute" + $params = Get-Parameters -data $result.Parameters + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } +} \ No newline at end of file From 70ac4ca4b48ed73509c473d9c972e6faa6bd9464 Mon Sep 17 00:00:00 2001 From: v-uansari Date: Wed, 8 May 2024 17:37:39 +0530 Subject: [PATCH 36/40] added tests --- ...traApplicationPasswordCredential.Tests.ps1 | 76 +++++++++++++++++++ .../New-EntraMSApplicationPassword.Tests.ps1 | 70 +++++++++++++++++ ...ntraApplicationExtensionProperty.Tests.ps1 | 44 +++++++++++ .../Remove-EntraApplicationOwner.Tests.ps1 | 2 +- ...traApplicationPasswordCredential.Tests.ps1 | 44 +++++++++++ 5 files changed, 235 insertions(+), 1 deletion(-) create mode 100644 test/module/Entra/New-EntraApplicationPasswordCredential.Tests.ps1 create mode 100644 test/module/Entra/New-EntraMSApplicationPassword.Tests.ps1 create mode 100644 test/module/Entra/Remove-EntraApplicationExtensionProperty.Tests.ps1 create mode 100644 test/module/Entra/Remove-EntraApplicationPasswordCredential.Tests.ps1 diff --git a/test/module/Entra/New-EntraApplicationPasswordCredential.Tests.ps1 b/test/module/Entra/New-EntraApplicationPasswordCredential.Tests.ps1 new file mode 100644 index 000000000..4bcacb82c --- /dev/null +++ b/test/module/Entra/New-EntraApplicationPasswordCredential.Tests.ps1 @@ -0,0 +1,76 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ + Import-Module Microsoft.Graph.Entra + } + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force + + $scriptblock = { + return @( + [PSCustomObject]@{ + "CustomKeyIdentifier" = $null + "DisplayName" = "" + "EndDateTime" = "10/23/2024 11:36:56 AM" + "KeyId" = "52ab6cca-bc59-4f06-8450-75a3d2b8e53b" + "StartDateTime" = "11/22/2023 11:35:16 AM" + "Hint" = "123" + "SecretText" = "wbBNW8kCuiPjNRg9NX98W_EaU6cqG" + "Parameters" = $args + } + ) + } + + Mock -CommandName Add-MgApplicationPassword -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra +} +Describe "New-EntraApplicationPasswordCredential"{ + It "Should return created password credential"{ + $result = New-EntraApplicationPasswordCredential -ObjectID "3ddd22e7-a150-4bb3-b100-e410dea1cb84" + $result | Should -Not -BeNullOrEmpty + $result.KeyId | should -Be "52ab6cca-bc59-4f06-8450-75a3d2b8e53b" + $result.SecretText | Should -Be "wbBNW8kCuiPjNRg9NX98W_EaU6cqG" + Should -Invoke -CommandName Add-MgApplicationPassword -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when ObjectId is empty" { + { New-EntraApplicationPasswordCredential -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId'*" + } + It "Should fail when ObjectId is null" { + { New-EntraApplicationPasswordCredential -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + } + It "Should fail when StartDate is empty" { + { New-EntraApplicationPasswordCredential -ObjectID "3ddd22e7-a150-4bb3-b100-e410dea1cb84" -StartDate "" } | Should -Throw "Cannot process argument transformation on parameter 'StartDate'*" + } + It "Should fail when StartDate is null" { + { New-EntraApplicationPasswordCredential -ObjectID "3ddd22e7-a150-4bb3-b100-e410dea1cb84" -StartDate } | Should -Throw "Missing an argument for parameter 'StartDate'*" + } + It "Should fail when EndDate is empty" { + { New-EntraApplicationPasswordCredential -ObjectID "3ddd22e7-a150-4bb3-b100-e410dea1cb84" -EndDate "" } | Should -Throw "Cannot process argument transformation on parameter 'EndDate'*" + } + It "Should fail when EndDate is null" { + { New-EntraApplicationPasswordCredential -ObjectID "3ddd22e7-a150-4bb3-b100-e410dea1cb84" -EndDate } | Should -Throw "Missing an argument for parameter 'EndDate'*" + } + It "Should fail when invalid parameter is passed" { + { New-EntraApplicationPasswordCredential -DisplayName "abc" } | Should -Throw "A parameter cannot be found that matches parameter name 'DisplayName'." + } + It "Should contain ApplicationId in parameters when passed ObjectId to it" { + $result = New-EntraApplicationPasswordCredential -ObjectID "3ddd22e7-a150-4bb3-b100-e410dea1cb84" + $params = Get-Parameters -data $result.Parameters + $params.ApplicationId | Should -Be "3ddd22e7-a150-4bb3-b100-e410dea1cb84" + } + It "should contain startDateTime in body parameter when passed StartDate to it"{ + $result = New-EntraApplicationPasswordCredential -ObjectID "3ddd22e7-a150-4bb3-b100-e410dea1cb84" -StartDate (get-date).AddYears(0) + $params = Get-Parameters -data $result.Parameters + $a = $params.PasswordCredential | ConvertTo-json | ConvertFrom-Json + $a.startDateTime | Should -Not -BeNullOrEmpty + } + It "should contain endDateTime in body parameter when passed EndDate to it"{ + $result = New-EntraApplicationPasswordCredential -ObjectID "3ddd22e7-a150-4bb3-b100-e410dea1cb84" -EndDate (get-date).AddYears(0) + $params = Get-Parameters -data $result.Parameters + $a = $params.PasswordCredential | ConvertTo-json | ConvertFrom-Json + $a.endDateTime | Should -Not -BeNullOrEmpty + } + It "Should contain 'User-Agent' header" { + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion New-EntraApplicationPasswordCredential" + $result = New-EntraApplicationPasswordCredential -ObjectID "3ddd22e7-a150-4bb3-b100-e410dea1cb84" + $params = Get-Parameters -data $result.Parameters + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } +} \ No newline at end of file diff --git a/test/module/Entra/New-EntraMSApplicationPassword.Tests.ps1 b/test/module/Entra/New-EntraMSApplicationPassword.Tests.ps1 new file mode 100644 index 000000000..5352e3417 --- /dev/null +++ b/test/module/Entra/New-EntraMSApplicationPassword.Tests.ps1 @@ -0,0 +1,70 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ + Import-Module Microsoft.Graph.Entra + } + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force + + $scriptblock = { + return @( + [PSCustomObject]@{ + "CustomKeyIdentifier" = $null + "DisplayName" = "mypassword" + "EndDateTime" = "10/23/2024 11:36:56 AM" + "KeyId" = "52ab6cca-bc59-4f06-8450-75a3d2b8e53b" + "StartDateTime" = "11/22/2023 11:35:16 AM" + "Hint" = "123" + "SecretText" = "wbBNW8kCuiPjNRg9NX98W_EaU6cqG" + "Parameters" = $args + } + ) + } + + Mock -CommandName Add-MgApplicationPassword -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra +} +Describe "New-EntraMSApplicationPassword"{ + It "Should return created password credential"{ + $result = New-EntraMSApplicationPassword -ObjectID "3ddd22e7-a150-4bb3-b100-e410dea1cb84" -PasswordCredential @{ displayname = "mypassword" } | ConvertTo-Json | ConvertFrom-Json + $result | Should -Not -BeNullOrEmpty + $result.KeyId | should -Be "52ab6cca-bc59-4f06-8450-75a3d2b8e53b" + $result.SecretText | Should -Be "wbBNW8kCuiPjNRg9NX98W_EaU6cqG" + Should -Invoke -CommandName Add-MgApplicationPassword -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when ObjectId is empty" { + { New-EntraMSApplicationPassword -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId'*" + } + It "Should fail when ObjectId is null" { + { New-EntraMSApplicationPassword -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + } + It "Should fail when PasswordCredential is null" { + { New-EntraMSApplicationPassword -PasswordCredential } | Should -Throw "Missing an argument for parameter 'PasswordCredential'*" + } + It "Should fail when StartDate is empty" { + { New-EntraMSApplicationPassword -ObjectID "3ddd22e7-a150-4bb3-b100-e410dea1cb84" -PasswordCredential @{ StartDateTime = "" } } | Should -Throw "Cannot process argument transformation on parameter 'PasswordCredential'*" + } + It "Should fail when EndDate is empty" { + { New-EntraMSApplicationPassword -ObjectID "3ddd22e7-a150-4bb3-b100-e410dea1cb84" -PasswordCredential @{ EndDateTime = "" } } | Should -Throw "Cannot process argument transformation on parameter 'PasswordCredential'*" + } + It "Should fail when invalid parameter is passed" { + { New-EntraMSApplicationPassword -DisplayName "abc" } | Should -Throw "A parameter cannot be found that matches parameter name 'DisplayName'." + } + It "Should contain ApplicationId in parameters when passed ObjectId to it" { + $result = New-EntraMSApplicationPassword -ObjectID "3ddd22e7-a150-4bb3-b100-e410dea1cb84" -PasswordCredential @{ displayname = "mypassword" } + $params = Get-Parameters -data $result.Parameters + $params.ApplicationId | Should -Be "3ddd22e7-a150-4bb3-b100-e410dea1cb84" + } + It "should contain password credential parameters in body parameter when passed PasswordCredential to it"{ + $result = New-EntraMSApplicationPassword -ObjectID "3ddd22e7-a150-4bb3-b100-e410dea1cb84" -PasswordCredential @{ DisplayName = "mypassword"; Hint = "123"; StartDateTime=(get-date).AddYears(0); EndDateTime=(get-date).AddYears(2) } + $params = Get-Parameters -data $result.Parameters + $a = $params.PasswordCredential | ConvertTo-json | ConvertFrom-Json + $a.DisplayName | Should -Be "mypassword" + $a.Hint | Should -Be "123" + $a.StartDateTime | Should -Not -BeNullOrEmpty + $a.EndDateTime | Should -Not -BeNullOrEmpty + } + It "Should contain 'User-Agent' header" { + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion New-EntraMSApplicationPassword" + $result = New-EntraMSApplicationPassword -ObjectID "3ddd22e7-a150-4bb3-b100-e410dea1cb84" -PasswordCredential @{ displayname = "mypassword" } + $params = Get-Parameters -data $result.Parameters + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } +} \ No newline at end of file diff --git a/test/module/Entra/Remove-EntraApplicationExtensionProperty.Tests.ps1 b/test/module/Entra/Remove-EntraApplicationExtensionProperty.Tests.ps1 new file mode 100644 index 000000000..dd372e2d6 --- /dev/null +++ b/test/module/Entra/Remove-EntraApplicationExtensionProperty.Tests.ps1 @@ -0,0 +1,44 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ + Import-Module Microsoft.Graph.Entra + } + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force + + Mock -CommandName Remove-MgApplicationExtensionProperty -MockWith {} -ModuleName Microsoft.Graph.Entra +} + +Describe "Remove-EntraApplicationExtensionProperty"{ + It "Should return empty object" { + $result = Remove-EntraApplicationExtensionProperty -ObjectId "3ddd22e7-a150-4bb3-b100-e410dea1cb84" -ExtensionPropertyId "c13dd34a-492b-4561-b171-40fcce2916c5" + $result | Should -BeNullOrEmpty + Should -Invoke -CommandName Remove-MgApplicationExtensionProperty -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when ObjectId is empty" { + { Remove-EntraApplicationExtensionProperty -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId'*" + } + It "Should fail when ObjectId is null" { + { Remove-EntraApplicationExtensionProperty -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + } + It "Should fail when ExtensionPropertyId is empty" { + { Remove-EntraApplicationExtensionProperty -ExtensionPropertyId "" } | Should -Throw "Cannot bind argument to parameter 'ExtensionPropertyId'*" + } + It "Should fail when ExtensionPropertyId is null" { + { Remove-EntraApplicationExtensionProperty -ExtensionPropertyId } | Should -Throw "Missing an argument for parameter 'ExtensionPropertyId'*" + } + It "Should fail when invalid parameter is passed" { + { Remove-EntraApplicationExtensionProperty -DisplayName "abc" } | Should -Throw "A parameter cannot be found that matches parameter name 'DisplayName'." + } + It "Should contain ApplicationId in parameters when passed ObjectId to it" { + Mock -CommandName Remove-MgApplicationExtensionProperty -MockWith {$args} -ModuleName Microsoft.Graph.Entra + $result = Remove-EntraApplicationExtensionProperty -ObjectId "3ddd22e7-a150-4bb3-b100-e410dea1cb84" -ExtensionPropertyId "c13dd34a-492b-4561-b171-40fcce2916c5" + $params = Get-Parameters -data $result + $params.ApplicationId | Should -Be "3ddd22e7-a150-4bb3-b100-e410dea1cb84" + } + It "Should contain 'User-Agent' header" { + Mock -CommandName Remove-MgApplicationExtensionProperty -MockWith {$args} -ModuleName Microsoft.Graph.Entra + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraApplicationExtensionProperty" + $result = Remove-EntraApplicationExtensionProperty -ObjectId "3ddd22e7-a150-4bb3-b100-e410dea1cb84" -ExtensionPropertyId "c13dd34a-492b-4561-b171-40fcce2916c5" + $params = Get-Parameters -data $result + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } +} \ No newline at end of file diff --git a/test/module/Entra/Remove-EntraApplicationOwner.Tests.ps1 b/test/module/Entra/Remove-EntraApplicationOwner.Tests.ps1 index 9d138df5b..03ac65fe2 100644 --- a/test/module/Entra/Remove-EntraApplicationOwner.Tests.ps1 +++ b/test/module/Entra/Remove-EntraApplicationOwner.Tests.ps1 @@ -25,7 +25,7 @@ Describe "Remove-EntraApplicationOwner"{ $params = Get-Parameters -data $result $params.ApplicationId | Should -Be "3ddd22e7-a150-4bb3-b100-e410dea1cb84" } - It "Should contain DeviceId in parameters" { + It "Should contain DirectoryObjectId in parameters" { Mock -CommandName Remove-MgApplicationOwnerByRef -MockWith {$args} -ModuleName Microsoft.Graph.Entra $result = Remove-EntraApplicationOwner -ObjectId "3ddd22e7-a150-4bb3-b100-e410dea1cb84" -OwnerId "c13dd34a-492b-4561-b171-40fcce2916c5" $params = Get-Parameters -data $result diff --git a/test/module/Entra/Remove-EntraApplicationPasswordCredential.Tests.ps1 b/test/module/Entra/Remove-EntraApplicationPasswordCredential.Tests.ps1 new file mode 100644 index 000000000..0c41af57c --- /dev/null +++ b/test/module/Entra/Remove-EntraApplicationPasswordCredential.Tests.ps1 @@ -0,0 +1,44 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ + Import-Module Microsoft.Graph.Entra + } + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force + + Mock -CommandName Remove-MgApplicationPassword -MockWith {} -ModuleName Microsoft.Graph.Entra +} + +Describe "Remove-EntraApplicationPasswordCredential"{ + It "Should return empty object" { + $result = Remove-EntraApplicationPasswordCredential -ObjectId "3ddd22e7-a150-4bb3-b100-e410dea1cb84" -KeyId "c13dd34a-492b-4561-b171-40fcce2916c5" + $result | Should -BeNullOrEmpty + Should -Invoke -CommandName Remove-MgApplicationPassword -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when ObjectId is empty" { + { Remove-EntraApplicationPasswordCredential -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId'*" + } + It "Should fail when ObjectId is null" { + { Remove-EntraApplicationPasswordCredential -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + } + It "Should fail when KeyId is empty" { + { Remove-EntraApplicationPasswordCredential -KeyId "" } | Should -Throw "Cannot bind argument to parameter 'KeyId'*" + } + It "Should fail when KeyId is null" { + { Remove-EntraApplicationPasswordCredential -KeyId } | Should -Throw "Missing an argument for parameter 'KeyId'*" + } + It "Should fail when invalid parameter is passed" { + { Remove-EntraApplicationPasswordCredential -DisplayName "abc" } | Should -Throw "A parameter cannot be found that matches parameter name 'DisplayName'." + } + It "Should contain ApplicationId in parameters when passed ObjectId to it" { + Mock -CommandName Remove-MgApplicationPassword -MockWith {$args} -ModuleName Microsoft.Graph.Entra + $result = Remove-EntraApplicationPasswordCredential -ObjectId "3ddd22e7-a150-4bb3-b100-e410dea1cb84" -KeyId "c13dd34a-492b-4561-b171-40fcce2916c5" + $params = Get-Parameters -data $result + $params.ApplicationId | Should -Be "3ddd22e7-a150-4bb3-b100-e410dea1cb84" + } + It "Should contain 'User-Agent' header" { + Mock -CommandName Remove-MgApplicationPassword -MockWith {$args} -ModuleName Microsoft.Graph.Entra + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraApplicationPasswordCredential" + $result = Remove-EntraApplicationPasswordCredential -ObjectId "3ddd22e7-a150-4bb3-b100-e410dea1cb84" -KeyId "c13dd34a-492b-4561-b171-40fcce2916c5" + $params = Get-Parameters -data $result + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } +} \ No newline at end of file From 69f76ed79230171cbb3feeaffdfef1a758d27f50 Mon Sep 17 00:00:00 2001 From: v-uansari Date: Thu, 9 May 2024 18:17:42 +0530 Subject: [PATCH 37/40] added mock tests --- ...traApplicationPasswordCredential.Tests.ps1 | 2 +- ...et-EntraMSDeletedDirectoryObject.Tests.ps1 | 46 +++++++++++++++ ...traMSPermissionGrantConditionSet.Tests.ps1 | 57 +++++++++++++++++++ ...traMSPermissionGrantConditionSet.Tests.ps1 | 54 ++++++++++++++++++ .../Remove-EntraMSApplicationOwner.Tests.ps1 | 41 +++++++++++++ ...emove-EntraMSApplicationPassword.Tests.ps1 | 41 +++++++++++++ 6 files changed, 240 insertions(+), 1 deletion(-) create mode 100644 test/module/Entra/Get-EntraMSDeletedDirectoryObject.Tests.ps1 create mode 100644 test/module/Entra/Get-EntraMSPermissionGrantConditionSet.Tests.ps1 create mode 100644 test/module/Entra/New-EntraMSPermissionGrantConditionSet.Tests.ps1 create mode 100644 test/module/Entra/Remove-EntraMSApplicationOwner.Tests.ps1 create mode 100644 test/module/Entra/Remove-EntraMSApplicationPassword.Tests.ps1 diff --git a/test/module/Entra/Get-EntraApplicationPasswordCredential.Tests.ps1 b/test/module/Entra/Get-EntraApplicationPasswordCredential.Tests.ps1 index c29fe8c83..52a9babd4 100644 --- a/test/module/Entra/Get-EntraApplicationPasswordCredential.Tests.ps1 +++ b/test/module/Entra/Get-EntraApplicationPasswordCredential.Tests.ps1 @@ -34,7 +34,7 @@ BeforeAll { It "Should fail when ObjectId is empty" { { Get-EntraApplicationPasswordCredential -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId'*" } - It "Should fail when ObjectId is empty" { + It "Should fail when ObjectId is null" { { Get-EntraApplicationPasswordCredential -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" } It "Should fail when invalid parameter is passed" { diff --git a/test/module/Entra/Get-EntraMSDeletedDirectoryObject.Tests.ps1 b/test/module/Entra/Get-EntraMSDeletedDirectoryObject.Tests.ps1 new file mode 100644 index 000000000..5a043f8cd --- /dev/null +++ b/test/module/Entra/Get-EntraMSDeletedDirectoryObject.Tests.ps1 @@ -0,0 +1,46 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ + Import-Module Microsoft.Graph.Entra + } + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force + + $scriptblock = { + return @( + [PSCustomObject]@{ + "Id" = "fd560167-ff1f-471a-8d74-3b0070abcea1" + "AdditionalProperties" = @{DisplayName="Test-App";} + "DeletedDateTime" = "2/2/2024 5:33:56 AM" + "Parameters" = $args + } + ) + } + + Mock -CommandName Get-MgDirectoryDeletedItem -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra +} + +Describe "Get-EntraMSDeletedDirectoryObject"{ + It "Should fail when Id is empty" { + { Get-EntraMSDeletedDirectoryObject -Id "" } | Should -Throw "Cannot bind argument to parameter 'Id'*" + } + It "Should fail when Id is null" { + { Get-EntraMSDeletedDirectoryObject -Id } | Should -Throw "Missing an argument for parameter 'Id'*" + } + It "Should fail when invalid parameter is passed" { + { Get-EntraMSDeletedDirectoryObject -DisplayName "abc" } | Should -Throw "A parameter cannot be found that matches parameter name 'DisplayName'*" + } + It "Result should Contain ObjectId" { + $result = Get-EntraMSDeletedDirectoryObject -Id "fd560167-ff1f-471a-8d74-3b0070abcea1" + $result.ObjectId | should -Be "fd560167-ff1f-471a-8d74-3b0070abcea1" + } + It "Should contain DirectoryObjectId in parameters when passed Id to it" { + $result = Get-EntraMSDeletedDirectoryObject -Id "fd560167-ff1f-471a-8d74-3b0070abcea1" + $params = Get-Parameters -data $result.Parameters + $params.DirectoryObjectId | Should -Be "fd560167-ff1f-471a-8d74-3b0070abcea1" + } + It "Should contain 'User-Agent' header" { + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraMSDeletedDirectoryObject" + $result = Get-EntraMSDeletedDirectoryObject -Id "fd560167-ff1f-471a-8d74-3b0070abcea1" + $params = Get-Parameters -data $result.Parameters + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } +} \ No newline at end of file diff --git a/test/module/Entra/Get-EntraMSPermissionGrantConditionSet.Tests.ps1 b/test/module/Entra/Get-EntraMSPermissionGrantConditionSet.Tests.ps1 new file mode 100644 index 000000000..d4ca9f7a3 --- /dev/null +++ b/test/module/Entra/Get-EntraMSPermissionGrantConditionSet.Tests.ps1 @@ -0,0 +1,57 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ + Import-Module Microsoft.Graph.Entra + } + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force + + $scriptblock = { + return @( + [PSCustomObject]@{ + "Id" = "4ccf1a57-4c5e-4ba6-9175-00407743b0e2" + "ClientApplicationIds" = {"All"} + "ClientApplicationPublisherIds" = {"All"} + "ClientApplicationTenantIds" = {"All"} + "ClientApplicationsFromVerifiedPublisherOnly" = $true + "Parameters" = $args + } + ) + } + + Mock -CommandName Get-MgPolicyPermissionGrantPolicyInclude -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra + + Mock -CommandName Get-MgPolicyPermissionGrantPolicyExclude -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra +} +Describe "Get-EntraMSPermissionGrantConditionSet"{ + It "Should not return empty object for condition set 'includes'"{ + $result = Get-EntraMSPermissionGrantConditionSet -PolicyId "policy1" -ConditionSetType "includes" -Id "4ccf1a57-4c5e-4ba6-9175-00407743b0e2" + $result | Should -Not -BeNullOrEmpty + Should -Invoke -CommandName Get-MgPolicyPermissionGrantPolicyInclude -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should not return empty object for condition set 'excludes'"{ + $result = Get-EntraMSPermissionGrantConditionSet -PolicyId "policy1" -ConditionSetType "excludes" -Id "4ccf1a57-4c5e-4ba6-9175-00407743b0e2" + $result | Should -Not -BeNullOrEmpty + Should -Invoke -CommandName Get-MgPolicyPermissionGrantPolicyExclude -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when parameters are empty" { + { Get-EntraMSPermissionGrantConditionSet -PolicyId "" -ConditionSetType "" -Id ""} | Should -Throw "Cannot bind argument to parameter*" + } + It "Should fail when parameters are null" { + { Get-EntraMSPermissionGrantConditionSet -PolicyId -ConditionSetType -Id} | Should -Throw "Missing an argument for parameter*" + } + It "Should contain PermissionGrantConditionSetId in parameters when passed Id to it" { + $result = Get-EntraMSPermissionGrantConditionSet -PolicyId "policy1" -ConditionSetType "includes" -Id "4ccf1a57-4c5e-4ba6-9175-00407743b0e2" + $params = Get-Parameters -data $result.Parameters + $params.PermissionGrantConditionSetId | Should -Be "4ccf1a57-4c5e-4ba6-9175-00407743b0e2" + } + It "Should contain PermissionGrantPolicyId in parameters when passed PolicyId to it" { + $result = Get-EntraMSPermissionGrantConditionSet -PolicyId "policy1" -ConditionSetType "includes" -Id "4ccf1a57-4c5e-4ba6-9175-00407743b0e2" + $params = Get-Parameters -data $result.Parameters + $params.PermissionGrantPolicyId | Should -Be "policy1" + } + It "Should contain 'User-Agent' header" { + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraMSPermissionGrantConditionSet" + $result = Get-EntraMSPermissionGrantConditionSet -PolicyId "policy1" -ConditionSetType "includes" + $params = Get-Parameters -data $result.Parameters + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } +} \ No newline at end of file diff --git a/test/module/Entra/New-EntraMSPermissionGrantConditionSet.Tests.ps1 b/test/module/Entra/New-EntraMSPermissionGrantConditionSet.Tests.ps1 new file mode 100644 index 000000000..ed46df378 --- /dev/null +++ b/test/module/Entra/New-EntraMSPermissionGrantConditionSet.Tests.ps1 @@ -0,0 +1,54 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ + Import-Module Microsoft.Graph.Entra + } + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force + + $scriptblock = { + return @( + [PSCustomObject]@{ + "Id" = "4ccf1a57-4c5e-4ba6-9175-00407743b0e2" + "ClientApplicationIds" = {"All"} + "ClientApplicationPublisherIds" = {"All"} + "ClientApplicationTenantIds" = {"All"} + "ClientApplicationsFromVerifiedPublisherOnly" = $true + "PermissionClassification" = "all" + "PermissionType" = "delegated" + "Parameters" = $args + } + ) + } + + Mock -CommandName New-MgPolicyPermissionGrantPolicyInclude -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra + + Mock -CommandName New-MgPolicyPermissionGrantPolicyExclude -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra +} +Describe "New-EntraMSPermissionGrantConditionSet"{ + It "Should not return empty object for condition set 'includes'"{ + $result = New-EntraMSPermissionGrantConditionSet -PolicyId "test1" -ConditionSetType "includes" -PermissionType "delegated" + $result | Should -Not -BeNullOrEmpty + Should -Invoke -CommandName New-MgPolicyPermissionGrantPolicyInclude -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should not return empty object for condition set 'excludes'"{ + $result = New-EntraMSPermissionGrantConditionSet -PolicyId "test1" -ConditionSetType "excludes" -PermissionType "delegated" + $result | Should -Not -BeNullOrEmpty + Should -Invoke -CommandName New-MgPolicyPermissionGrantPolicyExclude -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when parameters are empty" { + { New-EntraMSPermissionGrantConditionSet -PolicyId "" -ConditionSetType ""} | Should -Throw "Cannot bind argument to parameter*" + } + It "Should fail when parameters are null" { + { New-EntraMSPermissionGrantConditionSet -PolicyId -ConditionSetType } | Should -Throw "Missing an argument for parameter*" + } + It "Should contain PermissionGrantPolicyId in parameters when passed PolicyId to it" { + $result = New-EntraMSPermissionGrantConditionSet -PolicyId "test1" -ConditionSetType "includes" -PermissionType "delegated" + $params = Get-Parameters -data $result.Parameters + $params.PermissionGrantPolicyId | Should -Be "test1" + } + It "Should contain 'User-Agent' header" { + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion New-EntraMSPermissionGrantConditionSet" + $result = New-EntraMSPermissionGrantConditionSet -PolicyId "test1" -ConditionSetType "includes" -PermissionType "delegated" + $params = Get-Parameters -data $result.Parameters + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } +} \ No newline at end of file diff --git a/test/module/Entra/Remove-EntraMSApplicationOwner.Tests.ps1 b/test/module/Entra/Remove-EntraMSApplicationOwner.Tests.ps1 new file mode 100644 index 000000000..bfba0aa4d --- /dev/null +++ b/test/module/Entra/Remove-EntraMSApplicationOwner.Tests.ps1 @@ -0,0 +1,41 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ + Import-Module Microsoft.Graph.Entra + } + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force + + Mock -CommandName Remove-MgApplicationOwnerByRef -MockWith {} -ModuleName Microsoft.Graph.Entra +} + +Describe "Remove-EntraMSApplicationOwner"{ + It "Should return empty object" { + $result = Remove-EntraMSApplicationOwner -ObjectId "3ddd22e7-a150-4bb3-b100-e410dea1cb84" -OwnerId "c13dd34a-492b-4561-b171-40fcce2916c5" + $result | Should -BeNullOrEmpty + Should -Invoke -CommandName Remove-MgApplicationOwnerByRef -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when ObjectId is empty" { + { Remove-EntraMSApplicationOwner -ObjectId "" } + } + It "Should fail when -OwnerId is empty" { + { Remove-EntraMSApplicationOwner -OwnerId "" } + } + It "Should contain DeviceId in parameters" { + Mock -CommandName Remove-MgApplicationOwnerByRef -MockWith {$args} -ModuleName Microsoft.Graph.Entra + $result = Remove-EntraMSApplicationOwner -ObjectId "3ddd22e7-a150-4bb3-b100-e410dea1cb84" -OwnerId "c13dd34a-492b-4561-b171-40fcce2916c5" + $params = Get-Parameters -data $result + $params.ApplicationId | Should -Be "3ddd22e7-a150-4bb3-b100-e410dea1cb84" + } + It "Should contain DirectoryObjectId in parameters" { + Mock -CommandName Remove-MgApplicationOwnerByRef -MockWith {$args} -ModuleName Microsoft.Graph.Entra + $result = Remove-EntraMSApplicationOwner -ObjectId "3ddd22e7-a150-4bb3-b100-e410dea1cb84" -OwnerId "c13dd34a-492b-4561-b171-40fcce2916c5" + $params = Get-Parameters -data $result + $params.DirectoryObjectId | Should -Be "c13dd34a-492b-4561-b171-40fcce2916c5" + } + It "Should contain 'User-Agent' header" { + Mock -CommandName Remove-MgApplicationOwnerByRef -MockWith {$args} -ModuleName Microsoft.Graph.Entra + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraMSApplicationOwner" + $result = Remove-EntraMSApplicationOwner -ObjectId "3ddd22e7-a150-4bb3-b100-e410dea1cb84" -OwnerId "c13dd34a-492b-4561-b171-40fcce2916c5" + $params = Get-Parameters -data $result + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } +} \ No newline at end of file diff --git a/test/module/Entra/Remove-EntraMSApplicationPassword.Tests.ps1 b/test/module/Entra/Remove-EntraMSApplicationPassword.Tests.ps1 new file mode 100644 index 000000000..74fcca5fd --- /dev/null +++ b/test/module/Entra/Remove-EntraMSApplicationPassword.Tests.ps1 @@ -0,0 +1,41 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ + Import-Module Microsoft.Graph.Entra + } + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force + + Mock -CommandName Remove-MgApplicationPassword -MockWith {} -ModuleName Microsoft.Graph.Entra +} + +Describe "Remove-EntraMSApplicationPassword"{ + It "Should return empty object" { + $result = Remove-EntraMSApplicationPassword -ObjectId "3ddd22e7-a150-4bb3-b100-e410dea1cb84" -KeyId "c13dd34a-492b-4561-b171-40fcce2916c5" + $result | Should -BeNullOrEmpty + Should -Invoke -CommandName Remove-MgApplicationPassword -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when ObjectId is empty" { + { Remove-EntraMSApplicationPassword -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId'*" + } + It "Should fail when ObjectId is null" { + { Remove-EntraMSApplicationPassword -ObjectId } | Should -Throw "Missing an argument for parameter 'ObjectId'*" + } + It "Should fail when KeyId is null" { + { Remove-EntraMSApplicationPassword -ObjectId "3ddd22e7-a150-4bb3-b100-e410dea1cb84" -KeyId } | Should -Throw "Missing an argument for parameter 'KeyId'*" + } + It "Should fail when invalid parameter is passed" { + { Remove-EntraMSApplicationPassword -DisplayName "abc" } | Should -Throw "A parameter cannot be found that matches parameter name 'DisplayName'." + } + It "Should contain ApplicationId in parameters when passed ObjectId to it" { + Mock -CommandName Remove-MgApplicationPassword -MockWith {$args} -ModuleName Microsoft.Graph.Entra + $result = Remove-EntraMSApplicationPassword -ObjectId "3ddd22e7-a150-4bb3-b100-e410dea1cb84" -KeyId "c13dd34a-492b-4561-b171-40fcce2916c5" + $params = Get-Parameters -data $result + $params.ApplicationId | Should -Be "3ddd22e7-a150-4bb3-b100-e410dea1cb84" + } + It "Should contain 'User-Agent' header" { + Mock -CommandName Remove-MgApplicationPassword -MockWith {$args} -ModuleName Microsoft.Graph.Entra + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraMSApplicationPassword" + $result = Remove-EntraMSApplicationPassword -ObjectId "3ddd22e7-a150-4bb3-b100-e410dea1cb84" -KeyId "c13dd34a-492b-4561-b171-40fcce2916c5" + $params = Get-Parameters -data $result + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } +} \ No newline at end of file From ced92f2246e00d0a180f3daf3fee9decc0269a09 Mon Sep 17 00:00:00 2001 From: v-uansari Date: Fri, 10 May 2024 17:14:39 +0530 Subject: [PATCH 38/40] added mock tests --- test/module/Common-Functions.ps1 | 7 +- .../Get-EntraMSScopedRoleMembership.Tests.ps1 | 52 ++++++++ ...EntraTrustedCertificateAuthority.Tests.ps1 | 59 +++++++++ .../Set-EntraMSAdministrativeUnit.Tests.ps1 | 46 +++++++ ...traMSPermissionGrantConditionSet.Tests.ps1 | 51 +++++++ .../Get-EntraBetaApplication.Tests.ps1 | 125 ++++++++++++++++++ .../Get-EntraBetaMSApplication.Tests.ps1 | 103 +++++++++++++++ .../New-EntraBetaApplication.Tests.ps1 | 58 ++++++++ .../New-EntraBetaMSApplication.Tests.ps1 | 68 ++++++++++ 9 files changed, 568 insertions(+), 1 deletion(-) create mode 100644 test/module/Entra/Get-EntraMSScopedRoleMembership.Tests.ps1 create mode 100644 test/module/Entra/Get-EntraTrustedCertificateAuthority.Tests.ps1 create mode 100644 test/module/Entra/Set-EntraMSAdministrativeUnit.Tests.ps1 create mode 100644 test/module/Entra/Set-EntraMSPermissionGrantConditionSet.Tests.ps1 create mode 100644 test/module/EntraBeta/Get-EntraBetaApplication.Tests.ps1 create mode 100644 test/module/EntraBeta/Get-EntraBetaMSApplication.Tests.ps1 create mode 100644 test/module/EntraBeta/New-EntraBetaApplication.Tests.ps1 create mode 100644 test/module/EntraBeta/New-EntraBetaMSApplication.Tests.ps1 diff --git a/test/module/Common-Functions.ps1 b/test/module/Common-Functions.ps1 index a899a6355..134309dae 100644 --- a/test/module/Common-Functions.ps1 +++ b/test/module/Common-Functions.ps1 @@ -1,5 +1,10 @@ $psVersion = $global:PSVersionTable.PSVersion -$entraVersion = (Get-module Microsoft.Graph.Entra | select version).Version.ToString() +if($null -ne (Get-Module -Name Microsoft.Graph.Entra.Beta)){ + $entraVersion = (Get-module Microsoft.Graph.Entra.Beta | select version).Version.ToString() +} +if($null -ne (Get-Module -Name Microsoft.Graph.Entra)){ + $entraVersion = (Get-module Microsoft.Graph.Entra | select version).Version.ToString() +} function Get-Parameters{ param( diff --git a/test/module/Entra/Get-EntraMSScopedRoleMembership.Tests.ps1 b/test/module/Entra/Get-EntraMSScopedRoleMembership.Tests.ps1 new file mode 100644 index 000000000..81fdb11f2 --- /dev/null +++ b/test/module/Entra/Get-EntraMSScopedRoleMembership.Tests.ps1 @@ -0,0 +1,52 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ + Import-Module Microsoft.Graph.Entra + } + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force + + $scriptblock = { + # Write-Host "Mocking Get-MgDirectoryAdministrativeUnitScopedRoleMember with parameters: $($args | ConvertTo-Json -Depth 3)" + return @( + [PSCustomObject]@{ + "RoleMemberInfo" = @{DisplayName="Raul Razo"; Id="97d57292-02b9-4360-afb9-058268b77754"; AdditionalProperties={}} + "AdministrativeUnitId" = "c9ab56cc-e349-4237-856e-cab03157a91e" + "Id" = "zTVcE8KFQ0W4bI9tvt6kz5G_C9Qom7tCpCzyrakzL7aSctWXuQJgQ6-5BYJot3dUU" + "RoleId" = "526b7173-5a6e-49dc-88ec-b677a9093709" + "AdditionalProperties" = {} + "Parameters" = $args + } + ) + } + + Mock -CommandName Get-MgDirectoryAdministrativeUnitScopedRoleMember -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra +} + +Describe "Get-EntraMSScopedRoleMembership" { + Context "Test for Get-EntraMSScopedRoleMembership" { + It "Should not return empty object"{ + $result = Get-EntraMSScopedRoleMembership -Id "c9ab56cc-e349-4237-856e-cab03157a91e" + $result | Should -Not -BeNullOrEmpty + Should -Invoke -CommandName Get-MgDirectoryAdministrativeUnitScopedRoleMember -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should return specific scoped role membership"{ + $result = Get-EntraMSScopedRoleMembership -Id "c9ab56cc-e349-4237-856e-cab03157a91e" -ScopedRoleMembershipId "526b7173-5a6e-49dc-88ec-b677a9093709" + $result | Should -Not -BeNullOrEmpty + $result.Id | Should -Be "zTVcE8KFQ0W4bI9tvt6kz5G_C9Qom7tCpCzyrakzL7aSctWXuQJgQ6-5BYJot3dUU" + Should -Invoke -CommandName Get-MgDirectoryAdministrativeUnitScopedRoleMember -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when parameters are empty" { + { Get-EntraMSScopedRoleMembership -Id "" -ScopedRoleMembershipId "" } | Should -Throw "Cannot bind argument to parameter*" + } + It "Should contain AdministrativeUnitId in parameters when passed Id to it" { + $result = Get-EntraMSScopedRoleMembership -Id "c9ab56cc-e349-4237-856e-cab03157a91e" -ScopedRoleMembershipId "526b7173-5a6e-49dc-88ec-b677a9093709" + $params = Get-Parameters -data $result.Parameters + $params.AdministrativeUnitId | Should -Be "c9ab56cc-e349-4237-856e-cab03157a91e" + } + It "Should contain 'User-Agent' header" { + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraMSScopedRoleMembership" + $result = Get-EntraMSScopedRoleMembership -Id "c9ab56cc-e349-4237-856e-cab03157a91e" -ScopedRoleMembershipId "526b7173-5a6e-49dc-88ec-b677a9093709" + $params = Get-Parameters -data $result.Parameters + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } + } +} \ No newline at end of file diff --git a/test/module/Entra/Get-EntraTrustedCertificateAuthority.Tests.ps1 b/test/module/Entra/Get-EntraTrustedCertificateAuthority.Tests.ps1 new file mode 100644 index 000000000..79e4f920b --- /dev/null +++ b/test/module/Entra/Get-EntraTrustedCertificateAuthority.Tests.ps1 @@ -0,0 +1,59 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ + Import-Module Microsoft.Graph.Entra + } + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force + + $scriptblock = { + @{ + "CertificateAuthorities" = @( + @{ + "isRootAuthority" = $true + "certificateRevocationListUrl"= "https://example.crl" + "deltaCertificateRevocationListUrl"= "https://test.crl" + "certificate"= + "MIIDADCCAeigAwIBAgIQZUf+HS6ftbZKl+KtsZRsTDANBgkqhkiG9w0BAQsFADATMREwDwYDVQQDDAhtc2NtZGxldDAeFw0yNDAzMDYwNzIwMzhaFw0yNT + AzMDYwNzQwMzhaMBMxETAPBgNVBAMMCG1zY21kbGV0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApxIWxFGyuCi8kxmdjJI1WfY7zWqtgwvpk + wswBKrYmzN1/MzG2YX9yXsSLSd8Exh45P28ET3HpstVCXU1NnlQLW6c1ZEicRfj+Lv/h/z7Ckip8ccpJUNTaeyygC0pvqYjn+6zIVstMSOjNrWbQ8KrHTCh + lL3YvzD96PLbRHHHVcdT35fjezayWhMBSoc7rPO5Y0zgo9jKQt5rsIlEM72VssHy2H+dFkTCw2LbNy06oMoHpwXIDuQJSWXTu//G/DAuMIQ9hFDXh8hXJN5 + NCuesPF0tPqF4MbcGLREV2k6+MC7WZGsu2zcnr44Us0GZEq7F/h+hRGUeVGa/1Ve2oJmFqQIDAQABo1AwTjAOBgNVHQ8BAf8EBAMCBaAwHQYDVR0lBBYwFA + YIKwYBBQUHAwIGCCsGAQUFBwMBMB0GA1UdDgQWBBSgpCZWuICzX6fIkpoBGmIRMVD3iDANBgkqhkiG9w0BAQsFAAOCAQEAAYGPkNJMnBQ44FEIc7uWBI1dy + 3qtSVX3oLIawt2qtRiy7QybJCrVFhh7L5P2wcJeQAKJCwc6kL+KzL1IUSrieNt2OK0FblcW6yqLE4RnJEaa30Uog5Cwji8EOXwo1SA6P6ltXMC3qULCNjsf + VivDE3urizDBDvA8qBnh7vaQooiIwwxA0i+lqeGjB4ySpIR4rjM7PNISOWctmdgoFydJkBsyjGfTilZWI2Y4duW+CULJtuIQtw/buY/Km+CcBbbLAbE+PGF + MpTynQ2Lh66QPFimLCldkgFBsy0ShM5zMHhd8zJP3iDZ46eO03Hw/NZK/GXya3gAzDxmzaEc6iiFSig==" + "issuer"= "CN=mscmdlet" + "issuerSki"= "A0A42656B880B35FA7C8929A011A62113150F788" + "Parameters" = $args + } + ) + } + } + + Mock -CommandName Get-MgOrganizationCertificateBasedAuthConfiguration -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra +} +Describe "Get-EntraTrustedCertificateAuthority"{ + It "Result should not be empty when no parameter passed" { + $result = Get-EntraTrustedCertificateAuthority + $result | Should -Not -BeNullOrEmpty + Should -Invoke -CommandName Get-MgOrganizationCertificateBasedAuthConfiguration -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Result should not be empty when parameters are empty" { + $result = Get-EntraTrustedCertificateAuthority -TrustedIssuer '' -TrustedIssuerSki '' + $result | Should -Not -BeNullOrEmpty + Should -Invoke -CommandName Get-MgOrganizationCertificateBasedAuthConfiguration -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when TrustedIssuer is null" { + { Get-EntraTrustedCertificateAuthority -TrustedIssuer } | Should -Throw "Missing an argument for parameter*" + } + It "Should fail when TrustedIssuerSki is null" { + { Get-EntraTrustedCertificateAuthority -TrustedIssuerSki } | Should -Throw "Missing an argument for parameter*" + } + It "Should contain 'User-Agent' header" { + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraTrustedCertificateAuthority" + $result = Get-EntraTrustedCertificateAuthority | ConvertTo-json | ConvertFrom-Json + $params = Get-Parameters -data $result.Parameters + Write-Host $result + #$a.headers.'User-Agent' | Should -Be $userAgentHeaderValue + #$params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } +} \ No newline at end of file diff --git a/test/module/Entra/Set-EntraMSAdministrativeUnit.Tests.ps1 b/test/module/Entra/Set-EntraMSAdministrativeUnit.Tests.ps1 new file mode 100644 index 000000000..e6e93f61a --- /dev/null +++ b/test/module/Entra/Set-EntraMSAdministrativeUnit.Tests.ps1 @@ -0,0 +1,46 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ + Import-Module Microsoft.Graph.Entra + } + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force + + Mock -CommandName Update-MgDirectoryAdministrativeUnit -MockWith {} -ModuleName Microsoft.Graph.Entra +} + +Describe "Set-EntraMSAdministrativeUnit" { + Context "Test for Set-EntraMSAdministrativeUnit" { + It "Should return empty object" { + $result = Set-EntraMSAdministrativeUnit -Id 76373ce0-821a-40b5-9aa2-e108e318f62e + $result | Should -BeNullOrEmpty + Should -Invoke -CommandName Update-MgDirectoryAdministrativeUnit -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when Id parameter is empty" { + { Set-EntraMSAdministrativeUnit -Id '' } | Should -Throw "Cannot bind argument to parameter*" + } + It "Should fail when Id parameter is null" { + { Set-EntraMSAdministrativeUnit -Id } | Should -Throw "Missing an argument for parameter*" + } + It "Should fail when DisplayName parameter is null" { + { Set-EntraMSAdministrativeUnit -Id 76373ce0-821a-40b5-9aa2-e108e318f62e -DisplayName } | Should -Throw "Missing an argument for parameter*" + } + It "Should fail when Description parameter is null" { + { Set-EntraMSAdministrativeUnit -Id 76373ce0-821a-40b5-9aa2-e108e318f62e -Description } | Should -Throw "Missing an argument for parameter*" + } + It "Should fail when invalid parameter is passed" { + { Set-EntraMSAdministrativeUnit -ObjectId "abc" } | Should -Throw "A parameter cannot be found that matches parameter name 'ObjectId'." + } + It "Should contain AdministrativeUnitId in parameters when passed Id to it" { + Mock -CommandName Update-MgDirectoryAdministrativeUnit -MockWith {$args} -ModuleName Microsoft.Graph.Entra + $result = Set-EntraMSAdministrativeUnit -Id 76373ce0-821a-40b5-9aa2-e108e318f62e + $params = Get-Parameters -data $result + $params.AdministrativeUnitId | Should -Be "76373ce0-821a-40b5-9aa2-e108e318f62e" + } + It "Should contain 'User-Agent' header" { + Mock -CommandName Update-MgDirectoryAdministrativeUnit -MockWith {$args} -ModuleName Microsoft.Graph.Entra + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Set-EntraMSAdministrativeUnit" + $result = Set-EntraMSAdministrativeUnit -Id 76373ce0-821a-40b5-9aa2-e108e318f62e + $params = Get-Parameters -data $result + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } + } +} \ No newline at end of file diff --git a/test/module/Entra/Set-EntraMSPermissionGrantConditionSet.Tests.ps1 b/test/module/Entra/Set-EntraMSPermissionGrantConditionSet.Tests.ps1 new file mode 100644 index 000000000..1bb795ed9 --- /dev/null +++ b/test/module/Entra/Set-EntraMSPermissionGrantConditionSet.Tests.ps1 @@ -0,0 +1,51 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra) -eq $null){ + Import-Module Microsoft.Graph.Entra + } + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force + + Mock -CommandName Update-MgPolicyPermissionGrantPolicyInclude -MockWith {} -ModuleName Microsoft.Graph.Entra + + Mock -CommandName Update-MgPolicyPermissionGrantPolicyExclude -MockWith {} -ModuleName Microsoft.Graph.Entra +} +Describe "Set-EntraMSPermissionGrantConditionSet"{ + It "Should return empty object for condition set 'includes'"{ + $result = Set-EntraMSPermissionGrantConditionSet -PolicyId "policy1" -ConditionSetType "includes" -Id "665a9903-0398-48ab-b4e9-7a570d468b66" -PermissionClassification "Low" + $result | Should -BeNullOrEmpty + Should -Invoke -CommandName Update-MgPolicyPermissionGrantPolicyInclude -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should return empty object for condition set 'excludes'"{ + $result = Set-EntraMSPermissionGrantConditionSet -PolicyId "policy1" -ConditionSetType "excludes" -Id "665a9903-0398-48ab-b4e9-7a570d468b66" -PermissionClassification "Low" + $result | Should -BeNullOrEmpty + Should -Invoke -CommandName Update-MgPolicyPermissionGrantPolicyExclude -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should fail when parameters are empty" { + { Set-EntraMSPermissionGrantConditionSet -PolicyId "" -ConditionSetType "" -Id ""} | Should -Throw "Cannot bind argument to parameter*" + } + It "Should fail when parameters are null" { + { Set-EntraMSPermissionGrantConditionSet -PolicyId -ConditionSetType -Id } | Should -Throw "Missing an argument for parameter*" + } + It "Should contain parameters for condition set 'includes'" { + Mock -CommandName Update-MgPolicyPermissionGrantPolicyInclude -MockWith {$args} -ModuleName Microsoft.Graph.Entra + $result = Set-EntraMSPermissionGrantConditionSet -PolicyId "policy1" -ConditionSetType "includes" -Id "665a9903-0398-48ab-b4e9-7a570d468b66" -PermissionClassification "Low" + $params = Get-Parameters -data $result + $params.PermissionGrantPolicyId | Should -Be "policy1" + $params.PermissionGrantConditionSetId | Should -Be "665a9903-0398-48ab-b4e9-7a570d468b66" + Should -Invoke -CommandName Update-MgPolicyPermissionGrantPolicyInclude -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should contain parameters for condition set 'excludes'" { + Mock -CommandName Update-MgPolicyPermissionGrantPolicyExclude -MockWith {$args} -ModuleName Microsoft.Graph.Entra + $result = Set-EntraMSPermissionGrantConditionSet -PolicyId "policy1" -ConditionSetType "excludes" -Id "665a9903-0398-48ab-b4e9-7a570d468b66" -PermissionClassification "Low" + $params = Get-Parameters -data $result + $params.PermissionGrantPolicyId | Should -Be "policy1" + $params.PermissionGrantConditionSetId | Should -Be "665a9903-0398-48ab-b4e9-7a570d468b66" + Should -Invoke -CommandName Update-MgPolicyPermissionGrantPolicyExclude -ModuleName Microsoft.Graph.Entra -Times 1 + } + It "Should contain 'User-Agent' header" { + Mock -CommandName Update-MgPolicyPermissionGrantPolicyInclude -MockWith {$args} -ModuleName Microsoft.Graph.Entra + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Set-EntraMSPermissionGrantConditionSet" + $result = Set-EntraMSPermissionGrantConditionSet -PolicyId "policy1" -ConditionSetType "includes" -Id "665a9903-0398-48ab-b4e9-7a570d468b66" + $params = Get-Parameters -data $result + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } +} \ No newline at end of file diff --git a/test/module/EntraBeta/Get-EntraBetaApplication.Tests.ps1 b/test/module/EntraBeta/Get-EntraBetaApplication.Tests.ps1 new file mode 100644 index 000000000..be8c7e37d --- /dev/null +++ b/test/module/EntraBeta/Get-EntraBetaApplication.Tests.ps1 @@ -0,0 +1,125 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra.Beta) -eq $null){ + Import-Module Microsoft.Graph.Entra.Beta + } + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force + + $scriptblock = { + # Write-Host "Mocking Get-MgBetaApplication with parameters: $($args | ConvertTo-Json -Depth 3)" + return @( + [PSCustomObject]@{ + "AppId" = "5f783237-3457-45d8-93e7-a0edb1cfbfd1" + "AppRoles" = $null + "DeletedDateTime" = $null + "Id" = "111cc9b5-fce9-485e-9566-c68debafac5f" + "DisplayName" = "Mock-App" + "Info" = @{LogoUrl=""; MarketingUrl=""; PrivacyStatementUrl=""; SupportUrl=""; TermsOfServiceUrl=""} + "IsDeviceOnlyAuthSupported" = $True + "IsFallbackPublicClient" = $true + "KeyCredentials" = @{CustomKeyIdentifier = @(211, 174, 247);DisplayName =""; Key="";KeyId="d903c7a3-75ea-4772-8935-5c0cf82068a7";Type="Symmetric";Usage="Sign"} + "OptionalClaims" = @{AccessToken=""; IdToken=""; Saml2Token=""} + "ParentalControlSettings" = @{CountriesBlockedForMinors=$null; LegalAgeGroupRule="Allow"} + "PasswordCredentials" = @{} + "PublicClient" = @{RedirectUris=$null} + "PublisherDomain" = "M365x99297270.onmicrosoft.com" + "SignInAudience" = "AzureADandPersonalMicrosoftAccount" + "Web" = @{HomePageUrl="https://localhost/demoapp"; ImplicitGrantSettings=""; LogoutUrl="";} + "Parameters" = $args + } + ) + } + + Mock -CommandName Get-MgBetaApplication -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra.Beta +} + +Describe "Get-EntraBetaApplication" { + Context "Test for Get-EntraBetaApplication" { + It "Should return specific application" { + $result = Get-EntraBetaApplication -ObjectId "111cc9b5-fce9-485e-9566-c68debafac5f" + $result | Should -Not -BeNullOrEmpty + $result.Id | should -Be @('111cc9b5-fce9-485e-9566-c68debafac5f') + Should -Invoke -CommandName Get-MgBetaApplication -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should fail when ObjectId is empty" { + { Get-EntraBetaApplication -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + } + It "Should return all applications" { + $result = Get-EntraBetaApplication -All $true + $result | Should -Not -BeNullOrEmpty + Should -Invoke -CommandName Get-MgBetaApplication -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should fail when All is empty" { + { Get-EntraBetaApplication -All } | Should -Throw "Missing an argument for parameter 'All'*" + } + It "Should fail when invalid parameter is passed" { + { Get-EntraBetaApplication -Power "abc" } | Should -Throw "A parameter cannot be found that matches parameter name 'Power'*" + } + It "Should return specific application by searchstring" { + $result = Get-EntraBetaApplication -SearchString 'Mock-App' + $result | Should -Not -BeNullOrEmpty + $result.DisplayName | should -Be 'Mock-App' + Should -Invoke -CommandName Get-MgBetaApplication -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should return specific application by filter" { + $result = Get-EntraBetaApplication -Filter "DisplayName -eq 'Mock-App'" + $result | Should -Not -BeNullOrEmpty + $result.DisplayName | should -Be 'Mock-App' + Should -Invoke -CommandName Get-MgBetaApplication -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should return top application" { + $result = Get-EntraBetaApplication -Top 1 + $result | Should -Not -BeNullOrEmpty + Should -Invoke -CommandName Get-MgBetaApplication -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Result should Contain ObjectId" { + $result = Get-EntraBetaApplication -ObjectId "111cc9b5-fce9-485e-9566-c68debafac5f" + $result.ObjectId | should -Be "111cc9b5-fce9-485e-9566-c68debafac5f" + } + It "Should contain ApplicationId in parameters when passed ObjectId to it" { + $result = Get-EntraBetaApplication -ObjectId "111cc9b5-fce9-485e-9566-c68debafac5f" + $params = Get-Parameters -data $result.Parameters + $params.ApplicationId | Should -Be "111cc9b5-fce9-485e-9566-c68debafac5f" + } + It "Should contain Filter in parameters when passed SearchString to it" { + $result = Get-EntraBetaApplication -SearchString 'Mock-App' + $params = Get-Parameters -data $result.Parameters + $params.Filter | Should -Match "Mock-App" + } + It "Should contain 'User-Agent' header" { + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraBetaApplication" + $result = Get-EntraBetaApplication -SearchString 'Mock-App' + $params = Get-Parameters -data $result.Parameters + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } + It "Should support minimum set of parameter sets" { + $GetAzureADApplication = Get-Command Get-EntraBetaApplication + $GetAzureADApplication.ParameterSets.Name | Should -BeIn @("GetQuery", "GetVague", "GetById") + $GetAzureADApplication.Visibility | Should -Be "Public" + $GetAzureADApplication.CommandType | Should -Be "Function" + } + + It "Should return a list of applications by default" { + $GetAzureADApplication = Get-Command Get-EntraBetaApplication + $GetAzureADApplication.ModuleName | Should -Be "Microsoft.Graph.Entra.Beta" + $GetAzureADApplication.DefaultParameterSet | Should -Be "GetQuery" + } + It 'Should have List parameterSet' { + $GetAzureADApplication = Get-Command Get-EntraBetaApplication + $ListParameterSet = $GetAzureADApplication.ParameterSets | Where-Object Name -eq "GetQuery" + $ListParameterSet.Parameters.Name | Should -Contain All + $ListParameterSet.Parameters.Name | Should -Contain Filter + $ListParameterSet.Parameters.Name | Should -Contain Top + } + It 'Should have Get parameterSet' { + $GetAzureADApplication = Get-Command Get-EntraBetaApplication + $GetParameterSet = $GetAzureADApplication.ParameterSets | Where-Object Name -eq "GetById" + $GetParameterSet.Parameters.Name | Should -Contain ObjectId + } + It 'Should have GetViaIdentity parameterSet' { + $GetAzureADApplication = Get-Command Get-EntraBetaApplication + $GetViaIdentityParameterSet = $GetAzureADApplication.ParameterSets | Where-Object Name -eq "GetVague" + $GetViaIdentityParameterSet.Parameters.Name | Should -Contain SearchString + $GetViaIdentityParameterSet.Parameters.Name | Should -Contain All + } + } +} \ No newline at end of file diff --git a/test/module/EntraBeta/Get-EntraBetaMSApplication.Tests.ps1 b/test/module/EntraBeta/Get-EntraBetaMSApplication.Tests.ps1 new file mode 100644 index 000000000..e8d964bd3 --- /dev/null +++ b/test/module/EntraBeta/Get-EntraBetaMSApplication.Tests.ps1 @@ -0,0 +1,103 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra.Beta) -eq $null){ + Import-Module Microsoft.Graph.Entra.Beta + } + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force + + $scriptblock = { + # Write-Host "Mocking Get-MgBetaApplication with parameters: $($args | ConvertTo-Json -Depth 3)" + return @( + [PSCustomObject]@{ + "AppId" = "5f783237-3457-45d8-93e7-a0edb1cfbfd1" + "DeletedDateTime" = $null + "Id" = "111cc9b5-fce9-485e-9566-c68debafac5f" + "DisplayName" = "Mock-App" + "Info" = @{LogoUrl=""; MarketingUrl=""; PrivacyStatementUrl=""; SupportUrl=""; TermsOfServiceUrl=""} + "IsDeviceOnlyAuthSupported" = $True + "IsFallbackPublicClient" = $true + "KeyCredentials" = @{CustomKeyIdentifier = @(211, 174, 247);DisplayName =""; Key="";KeyId="d903c7a3-75ea-4772-8935-5c0cf82068a7";Type="Symmetric";Usage="Sign"} + "OptionalClaims" = @{AccessToken=""; IdToken=""; Saml2Token=""} + "ParentalControlSettings" = @{CountriesBlockedForMinors=$null; LegalAgeGroupRule="Allow"} + "PasswordCredentials" = @{} + "AddIns" = @{} + "Logo" = $null + "AppRoles" = $null + "GroupMembershipClaims" = $null + "IdentifierUris" = $null + "Oauth2RequirePostResponse" = $null + "Api" = @{AcceptMappedClaims= $null; KnownClientApplications=$null; Oauth2PermissionScopes=$null; + PreAuthorizedApplications=$null; RequestedAccessTokenVersion=2; AdditionalProperties= $null} + "PublicClient" = @{RedirectUris=$null} + "RequiredResourceAccess" = $false + "PublisherDomain" = "M365x99297270.onmicrosoft.com" + "SignInAudience" = "AzureADandPersonalMicrosoftAccount" + "Web" = @{HomePageUrl="https://localhost/demoapp"; ImplicitGrantSettings=""; LogoutUrl="";} + "Parameters" = $args + } + ) + } + + Mock -CommandName Get-MgBetaApplication -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra.Beta +} + +Describe "Get-EntraBetaMSApplication" { + Context "Test for Get-EntraBetaMSApplication" { + It "Should return specific application" { + $result = Get-EntraBetaMSApplication -ObjectId "111cc9b5-fce9-485e-9566-c68debafac5f" + $result | Should -Not -BeNullOrEmpty + $result.Id | should -Be @('111cc9b5-fce9-485e-9566-c68debafac5f') + Should -Invoke -CommandName Get-MgBetaApplication -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should fail when ObjectId is empty" { + { Get-EntraBetaMSApplication -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + } + It "Should return all applications" { + $result = Get-EntraBetaMSApplication -All $true + $result | Should -Not -BeNullOrEmpty + Should -Invoke -CommandName Get-MgBetaApplication -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should fail when All is empty" { + { Get-EntraBetaMSApplication -All } | Should -Throw "Missing an argument for parameter 'All'*" + } + It "Should fail when invalid parameter is passed" { + { Get-EntraBetaMSApplication -Power "abc" } | Should -Throw "A parameter cannot be found that matches parameter name 'Power'*" + } + It "Should return specific application by searchstring" { + $result = Get-EntraBetaMSApplication -SearchString 'Mock-App' + $result | Should -Not -BeNullOrEmpty + $result.DisplayName | should -Be 'Mock-App' + Should -Invoke -CommandName Get-MgBetaApplication -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should return specific application by filter" { + $result = Get-EntraBetaMSApplication -Filter "DisplayName -eq 'Mock-App'" + $result | Should -Not -BeNullOrEmpty + $result.DisplayName | should -Be 'Mock-App' + Should -Invoke -CommandName Get-MgBetaApplication -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should return top application" { + $result = Get-EntraBetaMSApplication -Top 1 + $result | Should -Not -BeNullOrEmpty + Should -Invoke -CommandName Get-MgBetaApplication -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Result should Contain ObjectId" { + $result = Get-EntraBetaMSApplication -ObjectId "111cc9b5-fce9-485e-9566-c68debafac5f" + $result.ObjectId | should -Be "111cc9b5-fce9-485e-9566-c68debafac5f" + } + It "Should contain ApplicationId in parameters when passed ObjectId to it" { + $result = Get-EntraBetaMSApplication -ObjectId "111cc9b5-fce9-485e-9566-c68debafac5f" + $params = Get-Parameters -data $result.Parameters + $params.ApplicationId | Should -Be "111cc9b5-fce9-485e-9566-c68debafac5f" + } + It "Should contain Filter in parameters when passed SearchString to it" { + $result = Get-EntraBetaMSApplication -SearchString 'Mock-App' + $params = Get-Parameters -data $result.Parameters + $params.Filter | Should -Match "Mock-App" + } + It "Should contain 'User-Agent' header" { + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Get-EntraBetaMSApplication" + $result = Get-EntraBetaMSApplication -SearchString 'Mock-App' + $params = Get-Parameters -data $result.Parameters + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } + } +} \ No newline at end of file diff --git a/test/module/EntraBeta/New-EntraBetaApplication.Tests.ps1 b/test/module/EntraBeta/New-EntraBetaApplication.Tests.ps1 new file mode 100644 index 000000000..7165d4e20 --- /dev/null +++ b/test/module/EntraBeta/New-EntraBetaApplication.Tests.ps1 @@ -0,0 +1,58 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra.Beta) -eq $null){ + Import-Module Microsoft.Graph.Entra.Beta + } + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force + + $scriptblock = { + # Write-Host "Mocking New-MgBetaApplication with parameters: $($args | ConvertTo-Json -Depth 3)" + return @( + [PSCustomObject]@{ + "AppId" = "5f783237-3457-45d8-93e7-a0edb1cfbfd1" + "DeletedDateTime" = $null + "Id" = "111cc9b5-fce9-485e-9566-c68debafac5f" + "DisplayName" = "Mock-App" + "Info" = @{LogoUrl=""; MarketingUrl=""; PrivacyStatementUrl=""; SupportUrl=""; TermsOfServiceUrl=""} + "IsDeviceOnlyAuthSupported" = $True + "IsFallbackPublicClient" = $true + "KeyCredentials" = @{CustomKeyIdentifier = @(211, 174, 247);DisplayName =""; Key="";KeyId="d903c7a3-75ea-4772-8935-5c0cf82068a7";Type="Symmetric";Usage="Sign"} + "OptionalClaims" = @{AccessToken=""; IdToken=""; Saml2Token=""} + "ParentalControlSettings" = @{CountriesBlockedForMinors=$null; LegalAgeGroupRule="Allow"} + "PasswordCredentials" = @{} + "PublicClient" = @{RedirectUris=$null} + "PublisherDomain" = "M365x99297270.onmicrosoft.com" + "SignInAudience" = "AzureADandPersonalMicrosoftAccount" + "Web" = @{HomePageUrl="https://localhost/demoapp"; ImplicitGrantSettings=""; LogoutUrl="";} + "Parameters" = $args + } + ) + } + + Mock -CommandName New-MgBetaApplication -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra.Beta +} + +Describe "New-EntraBetaApplication"{ + Context "Test for New-EntraBetaApplication" { + It "Should return created Application"{ + $result = New-EntraBetaApplication -DisplayName "Mock-App" + $result | Should -Not -BeNullOrEmpty + $result.DisplayName | should -Be "Mock-App" + $result.IsDeviceOnlyAuthSupported | should -Be "True" + $result.IsFallbackPublicClient | should -Be "True" + $result.SignInAudience | should -Be "AzureADandPersonalMicrosoftAccount" + Should -Invoke -CommandName New-MgBetaApplication -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should fail when DisplayName is empty" { + { New-EntraBetaApplication -DisplayName "" } | Should -Throw "Cannot bind argument to parameter*" + } + It "Should fail when invalid parameter is passed" { + { New-EntraBetaApplication -Power "abc" } | Should -Throw "A parameter cannot be found that matches parameter name 'Power'*" + } + It "Should contain 'User-Agent' header" { + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion New-EntraBetaApplication" + $result = New-EntraBetaApplication -DisplayName "Mock-App" + $params = Get-Parameters -data $result.Parameters + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } + } +} \ No newline at end of file diff --git a/test/module/EntraBeta/New-EntraBetaMSApplication.Tests.ps1 b/test/module/EntraBeta/New-EntraBetaMSApplication.Tests.ps1 new file mode 100644 index 000000000..cab515150 --- /dev/null +++ b/test/module/EntraBeta/New-EntraBetaMSApplication.Tests.ps1 @@ -0,0 +1,68 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra.Beta) -eq $null){ + Import-Module Microsoft.Graph.Entra.Beta + } + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force + + $scriptblock = { + # Write-Host "Mocking New-MgBetaApplication with parameters: $($args | ConvertTo-Json -Depth 3)" + return @( + [PSCustomObject]@{ + "AppId" = "5f783237-3457-45d8-93e7-a0edb1cfbfd1" + "DeletedDateTime" = $null + "Id" = "111cc9b5-fce9-485e-9566-c68debafac5f" + "DisplayName" = "Mock-App" + "Info" = @{LogoUrl=""; MarketingUrl=""; PrivacyStatementUrl=""; SupportUrl=""; TermsOfServiceUrl=""} + "IsDeviceOnlyAuthSupported" = $True + "IsFallbackPublicClient" = $True + "KeyCredentials" = @{CustomKeyIdentifier = @(211, 174, 247);DisplayName =""; Key="";KeyId="d903c7a3-75ea-4772-8935-5c0cf82068a7";Type="Symmetric";Usage="Sign"} + "OptionalClaims" = @{AccessToken=""; IdToken=""; Saml2Token=""} + "ParentalControlSettings" = @{CountriesBlockedForMinors=$null; LegalAgeGroupRule="Allow"} + "PasswordCredentials" = @{} + "AddIns" = @{} + "Logo" = $null + "AppRoles" = $null + "GroupMembershipClaims" = $null + "IdentifierUris" = $null + "Oauth2RequirePostResponse" = $null + "Api" = @{AcceptMappedClaims= $null; KnownClientApplications=$null; Oauth2PermissionScopes=$null; + PreAuthorizedApplications=$null; RequestedAccessTokenVersion=2; AdditionalProperties= $null} + "PublicClient" = @{RedirectUris=$null} + "RequiredResourceAccess" = $false + "PublisherDomain" = "M365x99297270.onmicrosoft.com" + "SignInAudience" = "AzureADandPersonalMicrosoftAccount" + "Web" = @{HomePageUrl="https://localhost/demoapp"; ImplicitGrantSettings=""; LogoutUrl="";} + "AdditionalProperties" = @{Context="application"} + "Parameters" = $args + } + ) + } + + Mock -CommandName New-MgBetaApplication -MockWith $scriptblock -ModuleName Microsoft.Graph.Entra.Beta +} + +Describe "New-EntraBetaMSApplication"{ + Context "Test for New-EntraBetaMSApplication" { + It "Should return created Application"{ + $result = New-EntraBetaMSApplication -DisplayName "Mock-App" + $result | Should -Not -BeNullOrEmpty + $result.DisplayName | should -Be "Mock-App" + $result.IsDeviceOnlyAuthSupported | should -Be "True" + $result.IsFallbackPublicClient | should -Be "True" + $result.SignInAudience | should -Be "AzureADandPersonalMicrosoftAccount" + Should -Invoke -CommandName New-MgBetaApplication -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should fail when DisplayName is empty" { + { New-EntraBetaMSApplication -DisplayName "" } | Should -Throw "Cannot bind argument to parameter*" + } + It "Should fail when invalid parameter is passed" { + { New-EntraBetaMSApplication -Power "abc" } | Should -Throw "A parameter cannot be found that matches parameter name 'Power'*" + } + It "Should contain 'User-Agent' header" { + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion New-EntraBetaMSApplication" + $result = New-EntraBetaMSApplication -DisplayName "Mock-App" + $params = Get-Parameters -data $result.Parameters + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } + } +} \ No newline at end of file From e280d935b16a80f6ca998ed413ecb573f0e796ef Mon Sep 17 00:00:00 2001 From: v-uansari Date: Mon, 13 May 2024 16:37:40 +0530 Subject: [PATCH 39/40] added mock tests --- test/module/EntraBeta/Invalid.Tests.ps1 | 100 +++++++++++++++++ .../Remove-EntraBetaApplication.Tests.ps1 | 37 ++++++ .../Remove-EntraBetaMSApplication.Tests.ps1 | 37 ++++++ .../Set-EntraBetaApplication.Tests.ps1 | 37 ++++++ .../Set-EntraBetaMSApplication.Tests.ps1 | 37 ++++++ test/module/EntraBeta/Valid.Tests.ps1 | 106 ++++++++++++++++++ test/module/EntraBetaCmdletsMap.ps1 | 102 +++++++++++++++++ 7 files changed, 456 insertions(+) create mode 100644 test/module/EntraBeta/Invalid.Tests.ps1 create mode 100644 test/module/EntraBeta/Remove-EntraBetaApplication.Tests.ps1 create mode 100644 test/module/EntraBeta/Remove-EntraBetaMSApplication.Tests.ps1 create mode 100644 test/module/EntraBeta/Set-EntraBetaApplication.Tests.ps1 create mode 100644 test/module/EntraBeta/Set-EntraBetaMSApplication.Tests.ps1 create mode 100644 test/module/EntraBeta/Valid.Tests.ps1 create mode 100644 test/module/EntraBetaCmdletsMap.ps1 diff --git a/test/module/EntraBeta/Invalid.Tests.ps1 b/test/module/EntraBeta/Invalid.Tests.ps1 new file mode 100644 index 000000000..cfff18fa3 --- /dev/null +++ b/test/module/EntraBeta/Invalid.Tests.ps1 @@ -0,0 +1,100 @@ +if($null -eq (Get-Module -Name Microsoft.Graph.Entra.Beta)){ + Import-Module Microsoft.Graph.Entra.Beta +} + +Describe "Invalid Tests"{ + It "Should fail when parameters are invalid"{ + $module = Get-Module -Name Microsoft.Graph.Entra.Beta + $module.ExportedCommands.Keys | ForEach-Object{ + $command = Get-Command $_ + { Invoke-Command $command -demo "" } | Should -Throw "A parameter cannot be found that matches parameter name 'demo'." + } + } + It "Should fail with 'TenantId' parameter" { + $module = Get-Module -Name Microsoft.Graph.Entra.Beta + $module.ExportedCommands.Keys | ForEach-Object { + $command = Get-Command $_ + if ($command.ParameterSets.Parameters.Name -contains 'TenantId'){ + $commandScriptBlock = [scriptblock]::Create("$command -TenantId $objectId") + { Invoke-Command -ScriptBlock $commandScriptBlock } | Should -Throw "Missing an argument for parameter 'TenantId'.*" + } + } + } + It "Should fail with 'Id' parameter" { + $module = Get-Module -Name Microsoft.Graph.Entra.Beta + $module.ExportedCommands.Keys | ForEach-Object { + $command = Get-Command $_ + if ($command.ParameterSets.Parameters.Name -contains 'Id'){ + $commandScriptBlock = [scriptblock]::Create("$command -Id $objectId") + { Invoke-Command -ScriptBlock $commandScriptBlock } | Should -Throw "Missing an argument for parameter 'Id'.*" + } + } + } + It "Should fail with 'ObjectId' parameter" { + $module = Get-Module -Name Microsoft.Graph.Entra.Beta + $module.ExportedCommands.Keys | ForEach-Object { + $command = Get-Command $_ + if ($command.ParameterSets.Parameters.Name -contains 'ObjectId'){ + $commandScriptBlock = [scriptblock]::Create("$command -ObjectId $objectId") + { Invoke-Command -ScriptBlock $commandScriptBlock } | Should -Throw "Missing an argument for parameter 'ObjectId'.*" + } + } + } + It "Should fail with 'All' parameter" { + $module = Get-Module -Name Microsoft.Graph.Entra.Beta + $module.ExportedCommands.Keys | ForEach-Object { + $command = Get-Command $_ + if ($command.ParameterSets.Parameters.Name -contains 'All'){ + $commandScriptBlock = [scriptblock]::Create("$command -All ") + { Invoke-Command -ScriptBlock $commandScriptBlock } | Should -Throw "Missing an argument for parameter 'All'*" + } + } + } + It "Should fail with 'Top' parameter" { + $module = Get-Module -Name Microsoft.Graph.Entra.Beta + $module.ExportedCommands.Keys | ForEach-Object { + $command = Get-Command $_ + if ($command.ParameterSets.Parameters.Name -contains 'Top'){ + $commandScriptBlock = [scriptblock]::Create("$command -Top ") + { Invoke-Command -ScriptBlock $commandScriptBlock } | Should -Throw "Missing an argument for parameter 'Top'*" + } + } + } + It "Should fail with 'Filter' parameter" { + $module = Get-Module -Name Microsoft.Graph.Entra.Beta + $module.ExportedCommands.Keys | ForEach-Object { + $command = Get-Command $_ + if ($command.ParameterSets.Parameters.Name -contains 'Filter'){ + $commandScriptBlock = [scriptblock]::Create("$command -Filter ") + { Invoke-Command -ScriptBlock $commandScriptBlock } | Should -Throw "Missing an argument for parameter 'Filter'*" + } + } + } + It "Should fail with 'SearchString' parameter" { + $module = Get-Module -Name Microsoft.Graph.Entra.Beta + $module.ExportedCommands.Keys | ForEach-Object { + $command = Get-Command $_ + if ($command.ParameterSets.Parameters.Name -contains 'SearchString'){ + $commandScriptBlock = [scriptblock]::Create("$command -SearchString ") + { Invoke-Command -ScriptBlock $commandScriptBlock } | Should -Throw "Missing an argument for parameter 'SearchString'*" + } + } + } + It "Should fail with exception when no parameter is passed" { + $cmdlets = @( + @{ CmdletName = 'Enable-EntraBetaDirectoryRole'; Exception = "Could not resolve request to a valid role template." } + @{ CmdletName = 'New-EntraBetaMSConditionalAccessPolicy'; Exception = "1006: 'displayName' cannot be null" }, + @{ CmdletName = 'New-EntraBetaMSNamedLocationPolicy'; Exception = "1042: Unexpected type: namedLocationType for NamedLocations." }, + @{ CmdletName = 'New-EntraBetaMSPermissionGrantPolicy'; Exception = "PermissionGrantPolicy's Id must not be null or empty." } + ) + $cmdlets | ForEach-Object { + $commandName = $_.CmdletName + $Exception = $_.Exception + $commandScriptBlock = [scriptblock]::Create("$commandName -ErrorAction Stop") + try { + Invoke-Command -ScriptBlock $commandScriptBlock + } + catch { $_ -match $Exception | Should -BeTrue } + } + } +} \ No newline at end of file diff --git a/test/module/EntraBeta/Remove-EntraBetaApplication.Tests.ps1 b/test/module/EntraBeta/Remove-EntraBetaApplication.Tests.ps1 new file mode 100644 index 000000000..ce585a8a5 --- /dev/null +++ b/test/module/EntraBeta/Remove-EntraBetaApplication.Tests.ps1 @@ -0,0 +1,37 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra.Beta) -eq $null){ + Import-Module Microsoft.Graph.Entra.Beta + } + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force + + Mock -CommandName Remove-MgBetaApplication -MockWith {} -ModuleName Microsoft.Graph.Entra.Beta +} + +Describe "Remove-EntraBetaApplication" { + Context "Test for Remove-EntraBetaApplication" { + It "Should return empty object" { + $result = Remove-EntraBetaApplication -ObjectId 056b2531-005e-4f3e-be78-01a71ea30a04 + $result | Should -BeNullOrEmpty + Should -Invoke -CommandName Remove-MgBetaApplication -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should fail when ObjectId is empty" { + { Remove-EntraBetaApplication -ObjectId "" } | Should -Throw "Cannot bind argument to parameter*" + } + It "Should fail when invalid parameter is passed" { + { Remove-EntraBetaApplication -Power "abc" } | Should -Throw "A parameter cannot be found that matches parameter name 'Power'*" + } + It "Should contain ApplicationId in parameters when passed ObjectId to it" { + Mock -CommandName Remove-MgBetaApplication -MockWith {$args} -ModuleName Microsoft.Graph.Entra.Beta + $result = Remove-EntraBetaApplication -ObjectId 056b2531-005e-4f3e-be78-01a71ea30a04 + $params = Get-Parameters -data $result + $params.ApplicationId | Should -Be "056b2531-005e-4f3e-be78-01a71ea30a04" + } + It "Should contain 'User-Agent' header" { + Mock -CommandName Remove-MgBetaApplication -MockWith {$args} -ModuleName Microsoft.Graph.Entra.Beta + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraBetaApplication" + $result = Remove-EntraBetaApplication -ObjectId 056b2531-005e-4f3e-be78-01a71ea30a04 + $params = Get-Parameters -data $result + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } + } +} \ No newline at end of file diff --git a/test/module/EntraBeta/Remove-EntraBetaMSApplication.Tests.ps1 b/test/module/EntraBeta/Remove-EntraBetaMSApplication.Tests.ps1 new file mode 100644 index 000000000..9f65294a6 --- /dev/null +++ b/test/module/EntraBeta/Remove-EntraBetaMSApplication.Tests.ps1 @@ -0,0 +1,37 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra.Beta) -eq $null){ + Import-Module Microsoft.Graph.Entra.Beta + } + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force + + Mock -CommandName Remove-MgBetaApplication -MockWith {} -ModuleName Microsoft.Graph.Entra.Beta +} + +Describe "Remove-EntraBetaMSApplication" { + Context "Test for Remove-EntraBetaMSApplication" { + It "Should return empty object" { + $result = Remove-EntraBetaMSApplication -ObjectId 056b2531-005e-4f3e-be78-01a71ea30a04 + $result | Should -BeNullOrEmpty + Should -Invoke -CommandName Remove-MgBetaApplication -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should fail when ObjectId is empty" { + { Remove-EntraBetaMSApplication -ObjectId "" } | Should -Throw "Cannot bind argument to parameter*" + } + It "Should fail when invalid parameter is passed" { + { Remove-EntraBetaApplication -Power "abc" } | Should -Throw "A parameter cannot be found that matches parameter name 'Power'*" + } + It "Should contain ApplicationId in parameters when passed ObjectId to it" { + Mock -CommandName Remove-MgBetaApplication -MockWith {$args} -ModuleName Microsoft.Graph.Entra.Beta + $result = Remove-EntraBetaMSApplication -ObjectId 056b2531-005e-4f3e-be78-01a71ea30a04 + $params = Get-Parameters -data $result + $params.ApplicationId | Should -Be "056b2531-005e-4f3e-be78-01a71ea30a04" + } + It "Should contain 'User-Agent' header" { + Mock -CommandName Remove-MgBetaApplication -MockWith {$args} -ModuleName Microsoft.Graph.Entra.Beta + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Remove-EntraBetaMSApplication" + $result = Remove-EntraBetaMSApplication -ObjectId 056b2531-005e-4f3e-be78-01a71ea30a04 + $params = Get-Parameters -data $result + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } + } +} \ No newline at end of file diff --git a/test/module/EntraBeta/Set-EntraBetaApplication.Tests.ps1 b/test/module/EntraBeta/Set-EntraBetaApplication.Tests.ps1 new file mode 100644 index 000000000..0ca2a4181 --- /dev/null +++ b/test/module/EntraBeta/Set-EntraBetaApplication.Tests.ps1 @@ -0,0 +1,37 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra.Beta) -eq $null){ + Import-Module Microsoft.Graph.Entra.Beta + } + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force + + Mock -CommandName Update-MgBetaApplication -MockWith {} -ModuleName Microsoft.Graph.Entra.Beta +} + +Describe "Set-EntraBetaApplication"{ + Context "Test for Set-EntraBetaApplication" { + It "Should return empty object"{ + $result = Set-EntraBetaApplication -ObjectId 056b2531-005e-4f3e-be78-01a71ea30a04 -DisplayName "Mock-App" + $result | Should -BeNullOrEmpty + Should -Invoke -CommandName Update-MgBetaApplication -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should fail when ObjectId is empty" { + { Set-EntraBetaApplication -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + } + It "Should fail when invalid parameter is passed" { + { Set-EntraBetaApplication -Power "abc" } | Should -Throw "A parameter cannot be found that matches parameter name 'Power'*" + } + It "Should contain ApplicationId in parameters when passed ObjectId to it" { + Mock -CommandName Update-MgBetaApplication -MockWith {$args} -ModuleName Microsoft.Graph.Entra.Beta + $result = Set-EntraBetaApplication -ObjectId 056b2531-005e-4f3e-be78-01a71ea30a04 + $params = Get-Parameters -data $result + $params.ApplicationId | Should -Be "056b2531-005e-4f3e-be78-01a71ea30a04" + } + It "Should contain 'User-Agent' header" { + Mock -CommandName Update-MgBetaApplication -MockWith {$args} -ModuleName Microsoft.Graph.Entra.Beta + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Set-EntraBetaApplication" + $result = Set-EntraBetaApplication -ObjectId 056b2531-005e-4f3e-be78-01a71ea30a04 + $params = Get-Parameters -data $result + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } + } +} \ No newline at end of file diff --git a/test/module/EntraBeta/Set-EntraBetaMSApplication.Tests.ps1 b/test/module/EntraBeta/Set-EntraBetaMSApplication.Tests.ps1 new file mode 100644 index 000000000..dc7d7f693 --- /dev/null +++ b/test/module/EntraBeta/Set-EntraBetaMSApplication.Tests.ps1 @@ -0,0 +1,37 @@ +BeforeAll { + if((Get-Module -Name Microsoft.Graph.Entra.Beta) -eq $null){ + Import-Module Microsoft.Graph.Entra.Beta + } + Import-Module (Join-Path $psscriptroot "..\Common-Functions.ps1") -Force + + Mock -CommandName Update-MgBetaApplication -MockWith {} -ModuleName Microsoft.Graph.Entra.Beta +} + +Describe "Set-EntraBetaMSApplication"{ + Context "Test for Set-EntraBetaMSApplication" { + It "Should return empty object"{ + $result = Set-EntraBetaMSApplication -ObjectId 056b2531-005e-4f3e-be78-01a71ea30a04 -DisplayName "Mock-App" + $result | Should -BeNullOrEmpty + Should -Invoke -CommandName Update-MgBetaApplication -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + It "Should fail when ObjectId is empty" { + { Set-EntraBetaMSApplication -ObjectId "" } | Should -Throw "Cannot bind argument to parameter 'ObjectId' because it is an empty string." + } + It "Should fail when invalid parameter is passed" { + { Set-EntraBetaMSApplication -Power "abc" } | Should -Throw "A parameter cannot be found that matches parameter name 'Power'*" + } + It "Should contain ApplicationId in parameters when passed ObjectId to it" { + Mock -CommandName Update-MgBetaApplication -MockWith {$args} -ModuleName Microsoft.Graph.Entra.Beta + $result = Set-EntraBetaMSApplication -ObjectId 056b2531-005e-4f3e-be78-01a71ea30a04 + $params = Get-Parameters -data $result + $params.ApplicationId | Should -Be "056b2531-005e-4f3e-be78-01a71ea30a04" + } + It "Should contain 'User-Agent' header" { + Mock -CommandName Update-MgBetaApplication -MockWith {$args} -ModuleName Microsoft.Graph.Entra.Beta + $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Set-EntraBetaMSApplication" + $result = Set-EntraBetaMSApplication -ObjectId 056b2531-005e-4f3e-be78-01a71ea30a04 + $params = Get-Parameters -data $result + $params.Headers["User-Agent"] | Should -Be $userAgentHeaderValue + } + } +} \ No newline at end of file diff --git a/test/module/EntraBeta/Valid.Tests.ps1 b/test/module/EntraBeta/Valid.Tests.ps1 new file mode 100644 index 000000000..eb61c6b10 --- /dev/null +++ b/test/module/EntraBeta/Valid.Tests.ps1 @@ -0,0 +1,106 @@ +BeforeAll{ + if($null -eq (Get-Module -Name Microsoft.Graph.Entra.Beta)){ + Import-Module Microsoft.Graph.Entra.Beta + } + Import-Module (Join-Path $psscriptroot "..\EntraBetaCmdletsMap.ps1") -Force + + $module = Get-Module -Name Microsoft.Graph.Entra.Beta +} + +Describe "Valid parameter Tests"{ + Context "Test for valid parameters"{ + It "Should return empty object with Id parameter"{ + Write-Host "--------Start mock remove cmdlets with Id parameter only--------" + $count=0 + $module.ExportedCommands.Keys | ForEach-Object{ + $commandName = $_ + $command = Get-Command $_ + if($command.Name.StartsWith('Remove')){ + $params = ($command.ParameterSets.Parameters | Where-Object {$_.IsMandatory -eq $true} | select -expand Name) + if($params.count -eq 1 -and $params -eq 'Id'){ + $filter = $cmdlets | Where-Object { $_.SourceName -eq $command } + if($null -ne $filter){ + try { + Write-Host "$command" + $commandScriptBlock = [scriptblock]::Create("$commandName -Id 056b2531-005e-4f3e-be78-01a71ea30a04") + if($filter.IsApi){ + Mock -CommandName Invoke-GraphRequest -MockWith {} -ModuleName Microsoft.Graph.Entra.Beta + $result = Invoke-Command -ScriptBlock $commandScriptBlock + $result | Should -BeNullOrEmpty + Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + else { + Mock -CommandName $filter.TargetName -MockWith {} -ModuleName Microsoft.Graph.Entra.Beta + $result = Invoke-Command -ScriptBlock $commandScriptBlock + $result | Should -BeNullOrEmpty + Should -Invoke -CommandName $filter.TargetName -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + } + catch { + Write-Host "Exception in cmdlet" $command + } + $count++ + } + } + } + } + Write-Host "Cmdlets count: $count" + Write-Host "---------End mock remove cmdlets with Id parameter only---------" + } + It "Should return empty object with ObjectId param"{ + Write-Host "-----Start mock remove cmdlets with ObjectId parameter only-----" + $count=0 + $module.ExportedCommands.Keys | ForEach-Object{ + $commandName = $_ + $command = Get-Command $_ + if($command.Name.StartsWith('Remove')){ + $params = ($command.ParameterSets.Parameters | Where-Object {$_.IsMandatory -eq $true} | select -expand Name) + if($params.count -eq 1 -and $params -eq 'ObjectId'){ + $filter = $cmdlets | Where-Object { $_.SourceName -eq $command } + if($null -ne $filter){ + try { + Write-Host "$command" + $commandScriptBlock = [scriptblock]::Create("$commandName -ObjectId 056b2531-005e-4f3e-be78-01a71ea30a04") + if($filter.IsApi){ + Mock -CommandName Invoke-GraphRequest -MockWith {} -ModuleName Microsoft.Graph.Entra.Beta + $result = Invoke-Command -ScriptBlock $commandScriptBlock + $result | Should -BeNullOrEmpty + Should -Invoke -CommandName Invoke-GraphRequest -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + else { + Mock -CommandName $filter.TargetName -MockWith {} -ModuleName Microsoft.Graph.Entra.Beta + $result = Invoke-Command -ScriptBlock $commandScriptBlock + $result | Should -BeNullOrEmpty + Should -Invoke -CommandName $filter.TargetName -ModuleName Microsoft.Graph.Entra.Beta -Times 1 + } + } + catch { + Write-Host "Exception in cmdlet" $command + } + $count++ + } + } + } + } + Write-Host "Cmdlets count: $count" + Write-Host "------End mock remove cmdlets with ObjectId parameter only------" + } + # It "Should pass with 'Id' or 'ObjectId' parameter" { + # $count=0 + # $module.ExportedCommands.Keys | ForEach-Object { + + # $command = Get-Command $_ + # if ($command.Name.StartsWith('Remove')) + # { + # $params = ($command.ParameterSets.Parameters | Where-Object {$_.IsMandatory -eq $true} | select -expand Name) + # if($params.count -eq 1 -and ($params -eq 'ObjectId' -or $params-eq 'Id')){ + # $stringParams = $params -join ',' + # Write-Host "$command | $stringParams" + # $count++ + # } + # } + # } + # Write-Host $count + # } + } +} \ No newline at end of file diff --git a/test/module/EntraBetaCmdletsMap.ps1 b/test/module/EntraBetaCmdletsMap.ps1 new file mode 100644 index 000000000..724dd8dea --- /dev/null +++ b/test/module/EntraBetaCmdletsMap.ps1 @@ -0,0 +1,102 @@ +$cmdlets = @( + @{ + SourceName = "Remove-EntraBetaMSAdministrativeUnit"; + TargetName = "Remove-MgBetaDirectoryAdministrativeUnit"; + IsApi = $false + }, + @{ + SourceName = "Remove-EntraBetaMSDeletedDirectoryObject"; + TargetName = ""; + IsApi = $true + }, + @{ + SourceName = "Remove-EntraBetaMSGroup"; + TargetName = "Remove-MgBetaGroup"; + IsApi = $false + }, + @{ + SourceName = "Remove-EntraBetaMSGroupLifecyclePolicy"; + TargetName = "Remove-MgBetaGroupLifecyclePolicy"; + IsApi = $false + }, + @{ + SourceName = "Remove-EntraBetaMSIdentityProvider"; + TargetName = "Remove-MgBetaIdentityProvider"; + IsApi = $false + }, + @{ + SourceName = "Remove-EntraBetaMSPermissionGrantPolicy"; + TargetName = "Remove-MgBetaPolicyPermissionGrantPolicy"; + IsApi = $false + }, + @{ + SourceName = "Remove-EntraBetaMSRoleAssignment"; + TargetName = "Remove-MgBetaRoleManagementDirectoryRoleAssignment" + IsApi = $false + }, + @{ + SourceName = "Remove-EntraBetaMSRoleDefinition"; + TargetName = "Remove-MgBetaRoleManagementDirectoryRoleDefinition"; + IsApi = $false + }, + @{ + SourceName = "Remove-EntraBetaApplication"; + TargetName = "Remove-MgBetaApplication"; + IsApi = $false + }, + @{ + SourceName = "Remove-EntraBetaContact"; + TargetName = "Remove-MgBetaContact"; + IsApi = $false + }, + @{ + SourceName = "Remove-EntraBetaDeletedApplication"; + TargetName = "Remove-MgBetaDirectoryDeletedItem"; + IsApi = $false + }, + @{ + SourceName = "Remove-EntraBetaDevice"; + TargetName = "Remove-MgBetaDevice"; + IsApi = $false + }, + @{ + SourceName = "Remove-EntraBetaGroup"; + TargetName = "Remove-MgBetaGroup"; + IsApi = $false + }, + @{ + SourceName = "Remove-EntraBetaMSApplication"; + TargetName = "Remove-MgBetaApplication"; + IsApi = $false + }, + @{ + SourceName = "Remove-EntraBetaMSApplicationKey"; + TargetName = "Remove-MgBetaApplicationKey"; + IsApi = $false + }, + @{ + SourceName = "Remove-EntraBetaMSApplicationPassword"; + TargetName = "Remove-MgBetaApplicationPassword"; + IsApi = $false + }, + @{ + SourceName = "Remove-EntraBetaOAuth2PermissionGrant"; + TargetName = "Remove-MgBetaOAuth2PermissionGrant"; + IsApi = $false + }, + @{ + SourceName = "Remove-EntraBetaServicePrincipal"; + TargetName = "Remove-MgBetaServicePrincipal"; + IsApi = $false + }, + @{ + SourceName = "Remove-EntraBetaUser"; + TargetName = "Remove-MgBetaUser"; + IsApi = $false + }, + @{ + SourceName = "Remove-EntraBetaUserManager"; + TargetName = "Remove-MgBetaUserManagerByRef"; + IsApi = $false + } +) \ No newline at end of file From c350013bcab668d9f4b9873b6d374154760dc270 Mon Sep 17 00:00:00 2001 From: v-uansari Date: Tue, 14 May 2024 16:31:28 +0530 Subject: [PATCH 40/40] mock tests beta application beta --- test/module/Entra/Entra.Tests.ps1 | 27 --------------------------- 1 file changed, 27 deletions(-) delete mode 100644 test/module/Entra/Entra.Tests.ps1 diff --git a/test/module/Entra/Entra.Tests.ps1 b/test/module/Entra/Entra.Tests.ps1 deleted file mode 100644 index 7e9478471..000000000 --- a/test/module/Entra/Entra.Tests.ps1 +++ /dev/null @@ -1,27 +0,0 @@ -if($null -eq (Get-Module -Name Microsoft.Graph.Entra)){ - Import-Module Microsoft.Graph.Entra -} - -Import-Module Pester - -$psmPath = (Get-Module Microsoft.Graph.Entra).Path -$testReportPath = join-path $psscriptroot "..\..\..\TestReport\Entra" -$mockScriptsPath = join-path $psscriptroot "..\..\..\test\module\Entra\*-*.Tests.ps1" - -$testOutputFile = "$testReportPath\TestResults.xml" -if (!(test-path -path $testReportPath)) {new-item -path $testReportPath -itemtype directory} - -$mockScripts = Get-ChildItem -Path $mockScriptsPath | ForEach-Object { $_.FullName } - -$config = New-PesterConfiguration -$config.Run.Path = $mockScripts -$config.Run.PassThru = $true -$config.Run.Exit = $true -$config.CodeCoverage.Enabled = $true -$config.CodeCoverage.CoveragePercentTarget = 100 -$config.CodeCoverage.Path = $psmPath -$config.TestResult.Enabled = $true -$config.TestResult.OutputPath = $testOutputFile -$config.Output.Verbosity = "Detailed" - -Invoke-Pester -Configuration $config \ No newline at end of file