-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathEntraBetaObjectSetting.Tests.ps1
More file actions
50 lines (40 loc) · 2.53 KB
/
Copy pathEntraBetaObjectSetting.Tests.ps1
File metadata and controls
50 lines (40 loc) · 2.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
Describe "The EntraBetaObjectSetting commands executing unmocked" {
Context "When Changing group settings" {
BeforeAll {
$testReportPath = join-path $psscriptroot "\setenv.ps1"
Import-Module -Name $testReportPath
$appId = $env:TEST_APPID
$tenantId = $env:TEST_TENANTID
$cert = $env:CERTIFICATETHUMBPRINT
Connect-MgGraph -TenantId $tenantId -AppId $appId -CertificateThumbprint $cert
$thisTestInstanceId = New-Guid | select -expandproperty guid
$testGroupName = 'SimpleTestAppRead' + $testGroupName
$global:testGroup = New-EntraBetaGroup -DisplayName $testGroupName -MailEnabled $false -SecurityEnabled $true -MailNickName $testGroupName -Description $testGroupName
}
It "Should successfully block guest access" {
$template = Get-EntraBetaDirectorySettingTemplate | ? {$_.displayname -eq "group.unified.guest"}
$settingsCopy = $template.CreateDirectorySetting()
$settingsCopy["AllowToAddGuests"]=$False
$groupID= (Get-EntraBetaGroup -ObjectId $testGroup.Id).ObjectId
$global:newObjectSetting = New-EntraBetaObjectSetting -TargetType Groups -TargetObjectId $groupID -DirectorySetting $settingsCopy
$ObjectSettings = Get-EntraBetaObjectSetting -TargetType Groups -TargetObjectId $testGroup.Id
$ObjectSettings.values.value | Should -be 'False'
}
It "Should successfully allow guest access" {
$template = Get-EntraBetaDirectorySettingTemplate | ? {$_.displayname -eq "group.unified.guest"}
$settingsCopy = $template.CreateDirectorySetting()
$settingsCopy["AllowToAddGuests"]=$True
$groupID= (Get-EntraBetaGroup -ObjectId $testGroup.Id).ObjectId
Set-EntraBetaObjectSetting -TargetType Groups -TargetObjectId $groupID -DirectorySetting $settingsCopy -Id $newObjectSetting.Id
$ObjectSettings = Get-EntraBetaObjectSetting -TargetType Groups -TargetObjectId $testGroup.Id
$ObjectSettings.values.value | Should -be 'True'
}
AfterAll {
$groupId = (Get-EntraBetaGroup -ObjectId $testGroup.Id).ObjectId
Remove-EntraBetaObjectSetting -TargetType Groups -TargetObjectId $groupId -Id $newObjectSetting.Id
$ObjectSettings = Get-EntraBetaObjectSetting -TargetType Groups -TargetObjectId $testGroup.Id
$ObjectSettings | Should -BeNullorEmpty
Remove-EntraBetaGroup -ObjectId $groupId
}
}
}