|
2 | 2 | # Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information. |
3 | 3 | # ------------------------------------------------------------------------------ |
4 | 4 |
|
5 | | -BeforeAll { |
| 5 | +BeforeAll { |
6 | 6 | if ((Get-Module -Name Microsoft.Entra.Beta.Groups) -eq $null) { |
7 | | - Import-Module Microsoft.Entra.Beta.Groups |
| 7 | + Import-Module Microsoft.Entra.Beta.Groups |
8 | 8 | } |
9 | | - Import-Module (Join-Path $PSScriptRoot "..\..\Common-Functions.ps1") -Force |
| 9 | + Import-Module (Join-Path $PSScriptRoot '..\..\Common-Functions.ps1') -Force |
10 | 10 |
|
11 | 11 | Mock -CommandName Update-MgBetaGroup -MockWith {} -ModuleName Microsoft.Entra.Beta.Groups |
12 | | - Mock -CommandName Get-EntraContext -MockWith { @{Scopes = @("Group.ReadWrite.All") } } -ModuleName Microsoft.Entra.Beta.Groups |
| 12 | + Mock -CommandName Get-EntraContext -MockWith { @{Scopes = @('Group.ReadWrite.All') } } -ModuleName Microsoft.Entra.Beta.Groups |
13 | 13 | } |
14 | 14 |
|
15 | | -Describe "Set-EntraBetaGroup" { |
16 | | - Context "Test for Set-EntraBetaGroup" { |
17 | | - It "Should return empty object" { |
18 | | - $result = Set-EntraBetaGroup -GroupId "aaaaaaaa-1111-2222-3333-cccccccccccc" -Description "Update Group" -DisplayName "Update My Test san" -MailEnabled $false -MailNickname "Update nickname" -SecurityEnabled $true |
| 15 | +Describe 'Set-EntraBetaGroup' { |
| 16 | + Context 'Test for Set-EntraBetaGroup' { |
| 17 | + It 'Should return empty object' { |
| 18 | + $result = Set-EntraBetaGroup -GroupId 'aaaaaaaa-1111-2222-3333-cccccccccccc' -Description 'Update Group' -DisplayName 'Update My Test san' -MailEnabled $false -MailNickname 'Update nickname' -SecurityEnabled $true |
19 | 19 | $result | Should -BeNullOrEmpty |
20 | 20 |
|
21 | 21 | Should -Invoke -CommandName Update-MgBetaGroup -ModuleName Microsoft.Entra.Beta.Groups -Times 1 |
22 | 22 | } |
23 | 23 |
|
24 | | - It "Should execute successfully with Alias" { |
25 | | - $result = Set-EntraBetaGroup -Id "aaaaaaaa-1111-2222-3333-cccccccccccc" -Description "Update Group" -DisplayName "Update My Test san" -MailEnabled $false -MailNickname "Update nickname" -SecurityEnabled $true |
| 24 | + It 'Should execute successfully with Alias' { |
| 25 | + $result = Set-EntraBetaGroup -Id 'aaaaaaaa-1111-2222-3333-cccccccccccc' -Description 'Update Group' -DisplayName 'Update My Test san' -MailEnabled $false -MailNickname 'Update nickname' -SecurityEnabled $true |
26 | 26 | $result | Should -BeNullOrEmpty |
27 | 27 |
|
28 | 28 | Should -Invoke -CommandName Update-MgBetaGroup -ModuleName Microsoft.Entra.Beta.Groups -Times 1 |
29 | 29 | } |
30 | 30 |
|
31 | | - It "Should fail when GroupId is empty" { |
| 31 | + It 'Should fail when GroupId is empty' { |
32 | 32 | { Set-EntraBetaGroup -GroupId } | Should -Throw "Missing an argument for parameter 'GroupId'*" |
33 | | - } |
| 33 | + } |
34 | 34 |
|
35 | | - It "Should fail when Description is empty" { |
36 | | - { Set-EntraBetaGroup -GroupId "aaaaaaaa-1111-2222-3333-cccccccccccc" -Description } | Should -Throw "Missing an argument for parameter 'Description'.*" |
37 | | - } |
| 35 | + It 'Should fail when Description is empty' { |
| 36 | + { Set-EntraBetaGroup -GroupId 'aaaaaaaa-1111-2222-3333-cccccccccccc' -Description } | Should -Throw "Missing an argument for parameter 'Description'.*" |
| 37 | + } |
38 | 38 |
|
39 | | - It "Should fail when DisplayName is empty" { |
40 | | - { Set-EntraBetaGroup -GroupId "aaaaaaaa-1111-2222-3333-cccccccccccc" -DisplayName } | Should -Throw "Missing an argument for parameter 'DisplayName'.*" |
41 | | - } |
| 39 | + It 'Should fail when DisplayName is empty' { |
| 40 | + { Set-EntraBetaGroup -GroupId 'aaaaaaaa-1111-2222-3333-cccccccccccc' -DisplayName } | Should -Throw "Missing an argument for parameter 'DisplayName'.*" |
| 41 | + } |
42 | 42 |
|
43 | | - It "Should fail when MailEnabled is empty" { |
44 | | - { Set-EntraBetaGroup -GroupId "aaaaaaaa-1111-2222-3333-cccccccccccc" -MailEnabled } | Should -Throw "Missing an argument for parameter*" |
45 | | - } |
| 43 | + It 'Should fail when MailEnabled is empty' { |
| 44 | + { Set-EntraBetaGroup -GroupId 'aaaaaaaa-1111-2222-3333-cccccccccccc' -MailEnabled } | Should -Throw 'Missing an argument for parameter*' |
| 45 | + } |
46 | 46 |
|
47 | | - It "Should fail when MailNickname is empty" { |
48 | | - { Set-EntraBetaGroup -GroupId "aaaaaaaa-1111-2222-3333-cccccccccccc" -MailNickname } | Should -Throw "Missing an argument for parameter*" |
49 | | - } |
| 47 | + It 'Should fail when MailNickname is empty' { |
| 48 | + { Set-EntraBetaGroup -GroupId 'aaaaaaaa-1111-2222-3333-cccccccccccc' -MailNickname } | Should -Throw 'Missing an argument for parameter*' |
| 49 | + } |
50 | 50 |
|
51 | | - It "Should fail when SecurityEnabled is empty" { |
52 | | - { Set-EntraBetaGroup -GroupId "aaaaaaaa-1111-2222-3333-cccccccccccc" -SecurityEnabled } | Should -Throw "Missing an argument for parameter*" |
53 | | - } |
| 51 | + It 'Should fail when SecurityEnabled is empty' { |
| 52 | + { Set-EntraBetaGroup -GroupId 'aaaaaaaa-1111-2222-3333-cccccccccccc' -SecurityEnabled } | Should -Throw 'Missing an argument for parameter*' |
| 53 | + } |
54 | 54 |
|
55 | | - It "Should contain GroupId in parameters when passed GroupId to it" { |
| 55 | + It 'Should contain GroupId in parameters when passed GroupId to it' { |
56 | 56 | Mock -CommandName Update-MgBetaGroup -MockWith { $args } -ModuleName Microsoft.Entra.Beta.Groups |
57 | 57 |
|
58 | | - $result = Set-EntraBetaGroup -GroupId "aaaaaaaa-1111-2222-3333-cccccccccccc" |
| 58 | + $result = Set-EntraBetaGroup -GroupId 'aaaaaaaa-1111-2222-3333-cccccccccccc' |
59 | 59 | $params = Get-Parameters -data $result |
60 | | - $params.GroupId | Should -Be "aaaaaaaa-1111-2222-3333-cccccccccccc" |
61 | | - } |
| 60 | + $params.GroupId | Should -Be 'aaaaaaaa-1111-2222-3333-cccccccccccc' |
| 61 | + } |
| 62 | + |
| 63 | + It 'Should contain Visibility in parameters when passed Visibility to it' { |
| 64 | + Mock -CommandName Update-MgBetaGroup -MockWith { $args } -ModuleName Microsoft.Entra.Beta.Groups |
| 65 | + |
| 66 | + $result = Set-EntraBetaGroup -GroupId 'aaaaaaaa-1111-2222-3333-cccccccccccc' -Visibility 'Private' |
| 67 | + $params = Get-Parameters -data $result |
| 68 | + $params.Visibility | Should -Be 'Private' |
| 69 | + } |
62 | 70 |
|
63 | 71 | It "Should contain 'User-Agent' header" { |
64 | 72 | $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Set-EntraBetaGroup" |
65 | | - $result = Set-EntraBetaGroup -GroupId "aaaaaaaa-1111-2222-3333-cccccccccccc" |
| 73 | + $result = Set-EntraBetaGroup -GroupId 'aaaaaaaa-1111-2222-3333-cccccccccccc' |
66 | 74 | $result | Should -BeNullOrEmpty |
67 | 75 | $userAgentHeaderValue = "PowerShell/$psVersion EntraPowershell/$entraVersion Set-EntraBetaGroup" |
68 | 76 | Should -Invoke -CommandName Update-MgBetaGroup -ModuleName Microsoft.Entra.Beta.Groups -Times 1 -ParameterFilter { |
69 | 77 | $Headers.'User-Agent' | Should -Be $userAgentHeaderValue |
70 | 78 | $true |
71 | 79 | } |
72 | | - } |
| 80 | + } |
73 | 81 |
|
74 | | - It "Should execute successfully without throwing an error " { |
75 | | - # Disable confirmation prompts |
| 82 | + It 'Should execute successfully without throwing an error ' { |
| 83 | + # Disable confirmation prompts |
76 | 84 | $originalDebugPreference = $DebugPreference |
77 | 85 | $DebugPreference = 'Continue' |
78 | | - |
| 86 | + |
79 | 87 | try { |
80 | 88 | # Act & Assert: Ensure the function doesn't throw an exception |
81 | | - { Set-EntraBetaGroup -GroupId "aaaaaaaa-1111-2222-3333-cccccccccccc" -Debug } | Should -Not -Throw |
82 | | - } |
83 | | - finally { |
84 | | - # Restore original confirmation preference |
85 | | - $DebugPreference = $originalDebugPreference |
| 89 | + { Set-EntraBetaGroup -GroupId 'aaaaaaaa-1111-2222-3333-cccccccccccc' -Debug } | Should -Not -Throw |
| 90 | + } finally { |
| 91 | + # Restore original confirmation preference |
| 92 | + $DebugPreference = $originalDebugPreference |
86 | 93 | } |
87 | | - } |
| 94 | + } |
88 | 95 | } |
89 | 96 | } |
90 | | - |
|
0 commit comments