-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wincred: add tests for namespace matching of creds
- Loading branch information
1 parent
de7b93b
commit 88e1297
Showing
1 changed file
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -270,6 +270,70 @@ public void WindowsCredentialManager_IsMatch( | |
Assert.Equal(expected, actual); | ||
} | ||
|
||
[PlatformFact(Platforms.Windows)] | ||
public void WindowsCredentialManager_IsMatch_NoNamespace_NotMatched() | ||
{ | ||
var win32Cred = new Win32Credential | ||
{ | ||
UserName = "test", | ||
TargetName = $"{WindowsCredentialManager.TargetNameLegacyGenericPrefix}https://example.com" | ||
}; | ||
|
||
var credManager = new WindowsCredentialManager(TestNamespace); | ||
|
||
bool result = credManager.IsMatch("https://example.com", null, win32Cred); | ||
|
||
Assert.False(result); | ||
} | ||
|
||
[PlatformFact(Platforms.Windows)] | ||
public void WindowsCredentialManager_IsMatch_DifferentNamespace_NotMatched() | ||
{ | ||
var win32Cred = new Win32Credential | ||
{ | ||
UserName = "test", | ||
TargetName = $"{WindowsCredentialManager.TargetNameLegacyGenericPrefix}:random-namespace:https://example.com" | ||
}; | ||
|
||
var credManager = new WindowsCredentialManager(TestNamespace); | ||
|
||
bool result = credManager.IsMatch("https://example.com", null, win32Cred); | ||
|
||
Assert.False(result); | ||
} | ||
|
||
[PlatformFact(Platforms.Windows)] | ||
public void WindowsCredentialManager_IsMatch_CaseSensitiveNamespace_NotMatched() | ||
{ | ||
var win32Cred = new Win32Credential | ||
{ | ||
UserName = "test", | ||
TargetName = $"{WindowsCredentialManager.TargetNameLegacyGenericPrefix}:nAmEsPaCe:https://example.com" | ||
}; | ||
|
||
var credManager = new WindowsCredentialManager("namespace"); | ||
|
||
bool result = credManager.IsMatch("https://example.com", null, win32Cred); | ||
|
||
Assert.False(result); | ||
} | ||
|
||
[PlatformFact(Platforms.Windows)] | ||
public void WindowsCredentialManager_IsMatch_NoNamespaceInQuery_IsMatched() | ||
{ | ||
var win32Cred = new Win32Credential | ||
{ | ||
UserName = "test", | ||
TargetName = $"{WindowsCredentialManager.TargetNameLegacyGenericPrefix}https://example.com" | ||
}; | ||
|
||
var credManager = new WindowsCredentialManager(); | ||
|
||
bool result = credManager.IsMatch("https://example.com", null, win32Cred); | ||
|
||
Assert.True(result); | ||
} | ||
|
||
[PlatformTheory(Platforms.Windows)] | ||
[InlineData("https://example.com", null, "https://example.com")] | ||
[InlineData("https://example.com", "bob", "https://[email protected]")] | ||
|