Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
19f4a4c
Mock Get-AzureADApplication
v-akarke Mar 25, 2024
fd77011
Mock Get-AzureADApplication
v-akarke Mar 25, 2024
572a5d6
testcases
v-akarke Apr 1, 2024
93ae2cb
testcases
v-akarke Apr 1, 2024
094f4a9
testcases
v-akarke Apr 1, 2024
664bfb8
test-Get-AzureADApplication
v-akarke Apr 2, 2024
4c8b1dc
test-Get-AzureADApplication
v-akarke Apr 2, 2024
7931203
Merge branch 'test-Get-AzureADApplication' of https://github.com/micr…
v-uansari Apr 3, 2024
1a8ff73
added single test file for mock tests
v-uansari Apr 3, 2024
f23b39d
update file
v-uansari Apr 3, 2024
9c96533
took main pull
v-akarke Apr 3, 2024
57193f4
Added validation for transformed parameters
v-akarke Apr 4, 2024
435a0e4
main pull
v-akarke Apr 4, 2024
413ea96
test-Get-AzureADApplication
v-akarke Apr 5, 2024
ac5e2d0
crud operation for entraApplication
v-uansari Apr 5, 2024
08df1ae
Merge branch 'main' of https://github.com/microsoftgraph/entra-powers…
v-uansari Apr 5, 2024
1038850
updated mock tests
v-uansari Apr 8, 2024
a2a9050
mock test updates
v-uansari Apr 8, 2024
4435142
Merge branch 'main' of https://github.com/microsoftgraph/entra-powers…
v-uansari Apr 8, 2024
812a56b
Merge branch 'main' into test-Get-AzureADApplication
SteveMutungi254 Apr 8, 2024
23c64a7
Merge branch 'main' of https://github.com/microsoftgraph/entra-powers…
v-uansari Apr 9, 2024
932f5b6
Merge branch 'test-Get-AzureADApplication' of https://github.com/micr…
v-uansari Apr 9, 2024
49a3c30
mock tests update
v-uansari Apr 9, 2024
9cd2089
entra test update
v-uansari Apr 9, 2024
9304d6a
upate
v-uansari Apr 9, 2024
417b6f4
updates
v-uansari Apr 9, 2024
d106573
Merge branch 'main' of https://github.com/microsoftgraph/entra-powers…
v-uansari Apr 9, 2024
c4b4d6e
add mock tests
v-uansari Apr 9, 2024
1e1b252
added tests
v-uansari Apr 10, 2024
937ef7f
tests update
v-uansari Apr 10, 2024
cd07a42
Merge branch 'test-Get-AzureADApplication' of https://github.com/micr…
v-uansari Apr 10, 2024
1c5e15e
update tests
v-uansari Apr 11, 2024
d706da9
Merge branch 'test-Get-AzureADApplication' of https://github.com/micr…
v-uansari Apr 11, 2024
8d49146
update tests
v-uansari Apr 11, 2024
23ecfd8
update
v-uansari Apr 11, 2024
97d9654
updates
v-uansari Apr 11, 2024
f621288
Merge branch 'test-Get-AzureADApplication' of https://github.com/micr…
v-uansari Apr 11, 2024
bd46fe7
updates
v-uansari Apr 11, 2024
79cd5cb
updates
v-uansari Apr 11, 2024
f61ce66
updates
v-uansari Apr 11, 2024
ffc52b9
Merge branch 'main' of https://github.com/microsoftgraph/entra-powers…
v-uansari Apr 11, 2024
29d9b1b
Merge branch 'main' of https://github.com/microsoftgraph/entra-powers…
v-uansari Apr 15, 2024
d0c5871
get mocks update
v-uansari Apr 15, 2024
67ea6b9
Merge branch 'main' of https://github.com/microsoftgraph/entra-powers…
v-uansari Apr 15, 2024
7bcccf7
Merge branch 'main' of https://github.com/microsoftgraph/entra-powers…
v-uansari Apr 17, 2024
09ef4e3
added new tests
v-uansari Apr 18, 2024
cafbf04
Merge branch 'main' of https://github.com/microsoftgraph/entra-powers…
v-uansari Apr 22, 2024
8059a41
rename files and added invalid tests
v-uansari Apr 23, 2024
ff5144f
update test
v-uansari Apr 23, 2024
42470b6
added valid parameter general tests
v-uansari Apr 26, 2024
30ecc91
Added test case for no parameter exception
v-akarke Apr 29, 2024
ca78120
Merge branch 'main' of https://github.com/microsoftgraph/entra-powers…
v-uansari May 6, 2024
5409db9
added mock tests
v-uansari May 6, 2024
b9b0e6e
added mock tests
v-uansari May 7, 2024
ce19bbb
added mock tests
v-uansari May 7, 2024
70ac4ca
added tests
v-uansari May 8, 2024
67231c8
Merge branch 'main' of https://github.com/microsoftgraph/entra-powers…
v-uansari May 8, 2024
69f76ed
added mock tests
v-uansari May 9, 2024
ced92f2
added mock tests
v-uansari May 10, 2024
e280d93
added mock tests
v-uansari May 13, 2024
1049d64
Merge branch 'main' of https://github.com/microsoftgraph/entra-powers…
v-uansari May 14, 2024
c350013
mock tests beta application beta
v-uansari May 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion test/module/Common-Functions.ps1
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
38 changes: 38 additions & 0 deletions test/module/Entra/Add-EntraApplicationOwner.Tests.ps1
Original file line number Diff line number Diff line change
@@ -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
}
}
}
38 changes: 38 additions & 0 deletions test/module/Entra/Add-EntraMSAdministrativeUnitMember.Tests.ps1
Original file line number Diff line number Diff line change
@@ -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-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
}
}
}
45 changes: 45 additions & 0 deletions test/module/Entra/Add-EntraMSApplicationOwner.Tests.ps1
Original file line number Diff line number Diff line change
@@ -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 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
}
}
}
54 changes: 54 additions & 0 deletions test/module/Entra/Add-EntraMSScopedRoleMembership.Tests.ps1
Original file line number Diff line number Diff line change
@@ -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 = {
# 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 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
$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
}
}
}
27 changes: 0 additions & 27 deletions test/module/Entra/Entra.Tests.ps1

This file was deleted.

Loading