Skip to content

Commit ed13246

Browse files
committed
Add pester test to validate debug logs.
1 parent 0b85ece commit ed13246

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/Authentication/Authentication/test/Connect-MgGraph.Tests.ps1

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,17 @@ Describe 'Connect-MgGraph In App Mode' {
9595
}
9696

9797
}
98+
9899
Describe 'Connect-MgGraph Dependency Resolution' {
99100
It 'Should load Mg module side by side with Az module.' {
100101
{ Connect-AzAccount -ApplicationId $RandomClientId -CertificateThumbprint "Invalid" -Tenant "Invalid" -ErrorAction Stop } | Should -Throw -ExpectedMessage "*Could not find tenant id*"
101102
{ Connect-MgGraph -TenantId "thisdomaindoesnotexist.com" -ErrorAction Stop -UseDeviceAuthentication } | Should -Throw -ExpectedMessage "*AADSTS90002*"
102103
}
104+
}
105+
106+
Describe 'Connect-MgGraph Logging' {
107+
It 'Should write MSAL logs to debug stream.' {
108+
$MgDebugStream = $(Connect-MgGraph -TenantId "thisdomaindoesnotexist.com" -UseDeviceAuthentication -Debug -ErrorAction SilentlyContinue) 5>&1
109+
$MgDebugStream[0] | Should -Match "DeviceCodeCredential.Authenticate invoked. Scopes: \[ User.Read \]"
110+
}
103111
}

0 commit comments

Comments
 (0)