-
Notifications
You must be signed in to change notification settings - Fork 704
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #373 from microsoft/users/johsch/preview-release
Promote 1.0.2-preview release to 1.0.2 release
- Loading branch information
Showing
28 changed files
with
565 additions
and
142 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
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 |
---|---|---|
@@ -1,7 +1,8 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<CredentialProviderVersion>1.0.1</CredentialProviderVersion> | ||
<CredentialProviderVersion>1.0.2</CredentialProviderVersion> | ||
<VersionSuffix></VersionSuffix> | ||
<TargetFrameworks>netcoreapp3.1;net461;net6.0</TargetFrameworks> | ||
</PropertyGroup> | ||
</Project> |
114 changes: 114 additions & 0 deletions
114
CredentialProvider.Microsoft.Tests/CredentialProviders/Vsts/AccountPriorityTests.cs
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 |
---|---|---|
@@ -0,0 +1,114 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// | ||
// Licensed under the MIT license. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Microsoft.Identity.Client; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using NuGetCredentialProvider.CredentialProviders.Vsts; | ||
|
||
namespace CredentialProvider.Microsoft.Tests.CredentialProviders.Vsts | ||
{ | ||
[TestClass] | ||
public class AccountPriorityTests | ||
{ | ||
private class TestAccount : IAccount | ||
{ | ||
public string Username {get; set;} | ||
public string Environment {get; set;} | ||
public AccountId HomeAccountId {get; set;} | ||
} | ||
|
||
private static readonly Guid ContosoTenant = Guid.NewGuid(); | ||
private static readonly Guid FabrikamTenant = Guid.NewGuid(); | ||
|
||
private static readonly IAccount FabrikamUser = new TestAccount | ||
{ | ||
Username = "billg@fabrikam.com", | ||
Environment = string.Empty, | ||
HomeAccountId = new AccountId(string.Empty, string.Empty, FabrikamTenant.ToString()), | ||
}; | ||
|
||
private static readonly IAccount ContosoUser = new TestAccount | ||
{ | ||
Username = "billg@contoso.com", | ||
Environment = string.Empty, | ||
HomeAccountId = new AccountId(string.Empty, string.Empty, ContosoTenant.ToString()), | ||
}; | ||
|
||
private static readonly IAccount MsaUser = new TestAccount | ||
{ | ||
Username = "bill.gates@live.com", | ||
Environment = string.Empty, | ||
HomeAccountId = new AccountId(string.Empty, string.Empty, AuthUtil.MsaAccountTenant.ToString()), | ||
}; | ||
|
||
private static readonly List<List<IAccount>> Permutations = new List<List<IAccount>>() | ||
{ | ||
new List<IAccount> { ContosoUser, MsaUser, FabrikamUser }, | ||
new List<IAccount> { ContosoUser, FabrikamUser, MsaUser }, | ||
new List<IAccount> { MsaUser, ContosoUser, FabrikamUser }, | ||
new List<IAccount> { MsaUser, FabrikamUser, ContosoUser }, | ||
new List<IAccount> { FabrikamUser, MsaUser, ContosoUser }, | ||
new List<IAccount> { FabrikamUser, ContosoUser, MsaUser }, | ||
}; | ||
|
||
[TestMethod] | ||
public void MsaMatchesMsa() | ||
{ | ||
foreach (var accounts in Permutations) | ||
{ | ||
var applicable = MsalUtil.GetApplicableAccounts(accounts, AuthUtil.FirstPartyTenant, loginHint: null); | ||
Assert.AreEqual(applicable[0].Item1.Username, MsaUser.Username); | ||
} | ||
} | ||
|
||
[TestMethod] | ||
public void ContosoMatchesContoso() | ||
{ | ||
foreach (var accounts in Permutations) | ||
{ | ||
var applicable = MsalUtil.GetApplicableAccounts(accounts, ContosoTenant, loginHint: null); | ||
Assert.AreEqual(applicable[0].Item1.Username, ContosoUser.Username); | ||
} | ||
} | ||
|
||
[TestMethod] | ||
public void FabrikamMatchesFabrikam() | ||
{ | ||
foreach (var accounts in Permutations) | ||
{ | ||
var applicable = MsalUtil.GetApplicableAccounts(accounts, FabrikamTenant, loginHint: null); | ||
Assert.AreEqual(applicable[0].Item1.Username, FabrikamUser.Username); | ||
} | ||
} | ||
|
||
[TestMethod] | ||
public void LoginHintOverride() | ||
{ | ||
foreach (var accounts in Permutations) | ||
{ | ||
foreach (var tenantId in Permutations[0].Select(a => Guid.Parse(a.HomeAccountId.TenantId))) | ||
{ | ||
foreach (var loginHint in Permutations[0].Select(a => a.Username)) | ||
{ | ||
var applicable = MsalUtil.GetApplicableAccounts(accounts, tenantId, loginHint); | ||
Assert.AreEqual(applicable[0].Item1.Username, loginHint); | ||
} | ||
} | ||
} | ||
} | ||
|
||
[TestMethod] | ||
public void UnknownAuthorityTenantPrefersMsa() | ||
{ | ||
foreach (var accounts in Permutations) | ||
{ | ||
var applicable = MsalUtil.GetApplicableAccounts(accounts, Guid.Empty, loginHint: null); | ||
Assert.AreEqual(applicable[0].Item1.Username, MsaUser.Username); | ||
} | ||
} | ||
} | ||
} |
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
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
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
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
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
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
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
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
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
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
Oops, something went wrong.