Skip to content

Commit e0efc54

Browse files
committed
fix: formatting
1 parent e3083bf commit e0efc54

4 files changed

+38
-47
lines changed

source/Private/Initialize-TkAppName.ps1

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
.PARAMETER Prefix
88
A short prefix for your app name (2-4 alphanumeric characters). This parameter is mandatory.
99
.PARAMETER ScenarioName
10-
An optional scenario name to include in the app name (e.g., AuditGraphEmail, MemPolicy, etc.). Defaults to "GraphApp".
10+
An optional scenario name to include in the app name (e.g., AuditGraphEmail, MemPolicy, etc.). Defaults to "TkEmailApp".
1111
.PARAMETER UserId
1212
An optional user email to append an "As-[username]" suffix to the app name. The email must be in a valid format.
13+
.PARAMETER DoNotUseDomainSuffix
14+
A switch to add session domain suffix to the app name. If not specified, the domain suffix is derived from USERDNSDOMAIN.
1315
.EXAMPLE
1416
PS> Initialize-TkAppName -Prefix "MSN"
1517
Generates an app name with the prefix "MSN" and default scenario name "GraphApp".

source/Private/Initialize-TkEmailAppParamsObject.ps1

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
.DESCRIPTION
55
The Initialize-TkEmailAppParamsObject function creates and returns a new instance of the TkEmailAppParams class using the provided parameters. This function ensures that all necessary parameters are provided and initializes the object accordingly.
66
.PARAMETER AppId
7-
The application ID used to identify the email application.
7+
The application ID used to uniquely identify the email application.
88
.PARAMETER Id
9-
The unique identifier for the email application instance.
9+
The unique identifier for the specific email application instance.
1010
.PARAMETER AppName
1111
The name of the email application being initialized.
12-
.PARAMETER ClientCertName
13-
The name of the client certificate used by the email application.
12+
.PARAMETER CertificateSubject
13+
The subject name of the client certificate used by the email application.
1414
.PARAMETER AppRestrictedSendGroup
1515
The group that is restricted from sending emails within the application.
1616
.PARAMETER CertExpires
@@ -31,7 +31,7 @@
3131
[TkEmailAppParams]
3232
Returns a new instance of the TkEmailAppParams class initialized with the provided parameters.
3333
.EXAMPLE
34-
$tkEmailAppParams = Initialize-TkEmailAppParamsObject -AppId "12345" -Id "67890" -AppName "MyEmailApp" -AppRestrictedSendGroup "RestrictedGroup" -CertExpires "2023-12-31" -CertThumbprint "ABCDEF123456" -ConsentUrl "https://consent.url" -DefaultDomain "example.com" -SendAsUser "[email protected]" -SendAsUserEmail "[email protected]" -TenantID "tenant123"
34+
$tkEmailAppParams = Initialize-TkEmailAppParamsObject -AppId "12345" -Id "67890" -AppName "MyEmailApp" -CertificateSubject "CN=MyCert" -AppRestrictedSendGroup "RestrictedGroup" -CertExpires "2023-12-31" -CertThumbprint "ABCDEF123456" -ConsentUrl "https://consent.url" -DefaultDomain "example.com" -SendAsUser "[email protected]" -SendAsUserEmail "[email protected]" -TenantID "tenant123"
3535
3636
This example initializes a TkEmailAppParams object with the specified parameters.
3737
#>

source/Public/Publish-TkMemPolicyManagerApp.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<#
1+
<#
22
.SYNOPSIS
33
Publishes a new MEM (Intune) Policy Manager App in Azure AD with read-only or read-write permissions.
44
.DESCRIPTION

tests/Unit/Private/Connect-TkMsService.tests.ps1

+29-40
Original file line numberDiff line numberDiff line change
@@ -8,82 +8,71 @@ Import-Module $ProjectName
88

99
InModuleScope $ProjectName {
1010
Describe 'Connect-TkMsService' {
11-
12-
# -- Mock your own function from your module:
13-
Mock -CommandName 'Write-AuditLog' -ModuleName 'GraphAppToolkit'
14-
15-
# -- Microsoft.Graph commands:
16-
Mock -CommandName 'Get-MgUser' -ModuleName 'Microsoft.Graph'
17-
Mock -CommandName 'Get-MgContext' -ModuleName 'Microsoft.Graph'
18-
Mock -CommandName 'Connect-MgGraph' -ModuleName 'Microsoft.Graph'
19-
Mock -CommandName 'Remove-MgContext' -ModuleName 'Microsoft.Graph'
20-
Mock -CommandName 'Get-MgOrganization' -ModuleName 'Microsoft.Graph'
21-
22-
# -- ExchangeOnlineManagement commands:
23-
Mock -CommandName 'Get-OrganizationConfig' -ModuleName 'ExchangeOnlineManagement'
24-
Mock -CommandName 'Connect-ExchangeOnline' -ModuleName 'ExchangeOnlineManagement'
25-
Mock -CommandName 'Disconnect-ExchangeOnline' -ModuleName 'ExchangeOnlineManagement'
11+
BeforeAll {
12+
# Mocks are now set up once for the entire Describe block
13+
Mock -CommandName 'Write-AuditLog' -ModuleName GraphAppToolkit
14+
Mock -CommandName 'Get-MgUser' -ModuleName GraphAppToolkit
15+
Mock -CommandName 'Get-MgContext' -ModuleName GraphAppToolkit
16+
Mock -CommandName 'Get-MgOrganization' -ModuleName GraphAppToolkit
17+
Mock -CommandName 'Remove-MgContext' -ModuleName GraphAppToolkit
18+
Mock -CommandName 'Connect-MgGraph' -ModuleName GraphAppToolkit
19+
Mock -CommandName 'Get-OrganizationConfig' -ModuleName GraphAppToolkit
20+
Mock -CommandName 'Disconnect-ExchangeOnline' -ModuleName GraphAppToolkit
21+
Mock -CommandName 'Connect-ExchangeOnline' -ModuleName GraphAppToolkit
22+
}
2623

2724
Context 'When connecting to Microsoft Graph' {
28-
2925
It 'Should connect to Microsoft Graph with specified scopes' {
3026
$params = @{
31-
MgGraph = $true
27+
MgGraph = $true
3228
GraphAuthScopes = @('User.Read', 'Mail.Read')
33-
Confirm = $false
3429
}
30+
3531
Connect-TkMsService @params
3632

37-
# Notice the -ModuleName arguments below, matching the mocks
38-
Assert-MockCalled -CommandName 'Connect-MgGraph' -ModuleName 'Microsoft.Graph' -Times 1
39-
Assert-MockCalled -CommandName 'Write-AuditLog' -ModuleName 'GraphAppToolkit' -Times 1 `
40-
-ParameterFilter { $_ -eq 'Connected to Microsoft Graph.' }
33+
Assert-MockCalled -CommandName 'Connect-MgGraph' -ModuleName GraphAppToolkit -Exactly -Times 1
34+
Assert-MockCalled -CommandName 'Write-AuditLog' -ModuleName GraphAppToolkit -Exactly -Times 1 -Scope It -ParameterFilter { $_ -eq 'Connected to Microsoft Graph.' }
4135
}
4236

4337
It 'Should reuse existing Microsoft Graph session if valid' {
44-
Mock -CommandName 'Get-MgUser' -ModuleName 'Microsoft.Graph' -MockWith { $null }
45-
Mock -CommandName 'Get-MgContext' -ModuleName 'Microsoft.Graph' -MockWith { @{ Scopes = @('User.Read', 'Mail.Read') } }
38+
Mock -CommandName 'Get-MgUser' -ModuleName GraphAppToolkit -MockWith { }
39+
Mock -CommandName 'Get-MgContext' -ModuleName GraphAppToolkit -MockWith { @{ Scopes = @('User.Read', 'Mail.Read') } }
4640

4741
$params = @{
48-
MgGraph = $true
42+
MgGraph = $true
4943
GraphAuthScopes = @('User.Read', 'Mail.Read')
50-
Confirm = $false
5144
}
45+
5246
Connect-TkMsService @params
5347

54-
Assert-MockCalled -CommandName 'Get-MgUser' -ModuleName 'Microsoft.Graph' -Times 1
55-
Assert-MockCalled -CommandName 'Write-AuditLog' -ModuleName 'GraphAppToolkit' -Times 1 `
56-
-ParameterFilter { $_ -eq 'An active Microsoft Graph session is detected and all required scopes are present.' }
48+
Assert-MockCalled -CommandName 'Get-MgUser' -ModuleName GraphAppToolkit -Exactly -Times 1
49+
Assert-MockCalled -CommandName 'Write-AuditLog' -ModuleName GraphAppToolkit -Exactly -Times 1 -Scope It -ParameterFilter { $_ -eq 'Using existing Microsoft Graph session.' }
5750
}
5851
}
5952

6053
Context 'When connecting to Exchange Online' {
61-
6254
It 'Should connect to Exchange Online' {
6355
$params = @{
6456
ExchangeOnline = $true
65-
Confirm = $false
6657
}
58+
6759
Connect-TkMsService @params
6860

69-
Assert-MockCalled -CommandName 'Connect-ExchangeOnline' -ModuleName 'ExchangeOnlineManagement' -Times 1
70-
Assert-MockCalled -CommandName 'Write-AuditLog' -ModuleName 'GraphAppToolkit' -Times 1 `
71-
-ParameterFilter { $_ -eq 'Connected to Exchange Online.' }
61+
Assert-MockCalled -CommandName 'Connect-ExchangeOnline' -ModuleName GraphAppToolkit -Exactly -Times 1
62+
Assert-MockCalled -CommandName 'Write-AuditLog' -ModuleName GraphAppToolkit -Exactly -Times 1 -Scope It -ParameterFilter { $_ -eq 'Connected to Exchange Online.' }
7263
}
7364

7465
It 'Should reuse existing Exchange Online session if valid' {
75-
# Provide a mock for Get-OrganizationConfig from ExchangeOnlineManagement
76-
Mock -CommandName 'Get-OrganizationConfig' -ModuleName 'ExchangeOnlineManagement' -MockWith { @{ Identity = 'TestOrg' } }
66+
Mock -CommandName 'Get-OrganizationConfig' -ModuleName GraphAppToolkit -MockWith { }
7767

7868
$params = @{
7969
ExchangeOnline = $true
80-
Confirm = $false
8170
}
71+
8272
Connect-TkMsService @params
8373

84-
Assert-MockCalled -CommandName 'Get-OrganizationConfig' -ModuleName 'ExchangeOnlineManagement' -Times 1
85-
Assert-MockCalled -CommandName 'Write-AuditLog' -ModuleName 'GraphAppToolkit' -Times 1 `
86-
-ParameterFilter { $_ -eq 'An active Exchange Online session is detected.' }
74+
Assert-MockCalled -CommandName 'Get-OrganizationConfig' -ModuleName GraphAppToolkit -Exactly -Times 1
75+
Assert-MockCalled -CommandName 'Write-AuditLog' -ModuleName GraphAppToolkit -Exactly -Times 1 -Scope It -ParameterFilter { $_ -eq 'Using existing Exchange Online session.' }
8776
}
8877
}
8978
}

0 commit comments

Comments
 (0)