Skip to content

Commit 601272e

Browse files
scott.waye@hubse.netbgavrilMS
authored andcommitted
AddTest when no ID and no ClientInfo is returned
1 parent 28147bb commit 601272e

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

tests/Microsoft.Identity.Test.Unit/CacheTests/TokenCacheTests.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,6 +1085,38 @@ public async Task SaveAccessAndRefreshTokenWithIntersectingScopesTestAsync()
10851085
Assert.AreEqual("access-token-2", (cache.Accessor.GetAllAccessTokens()).First().Secret);
10861086
}
10871087

1088+
[TestMethod]
1089+
[TestCategory(TestCategories.TokenCacheTests)]
1090+
public async Task SaveAccessAndRefreshTokenWithNoClientInfoAsync()
1091+
{
1092+
var serviceBundle = TestCommon.CreateDefaultServiceBundle();
1093+
ITokenCacheInternal cache = new TokenCache(serviceBundle, false);
1094+
MsalTokenResponse response = TestConstants.CreateMsalTokenResponse();
1095+
1096+
var requestParams = TestCommon.CreateAuthenticationRequestParameters(serviceBundle);
1097+
requestParams.AuthorityManager = new AuthorityManager(
1098+
requestParams.RequestContext,
1099+
Authority.CreateAuthorityWithTenant(
1100+
requestParams.AuthorityInfo,
1101+
TestConstants.Utid));
1102+
AddHostToInstanceCache(serviceBundle, TestConstants.ProductionPrefNetworkEnvironment);
1103+
1104+
await cache.SaveTokenResponseAsync(requestParams, response).ConfigureAwait(false);
1105+
1106+
requestParams.Account = new Account(_homeAccountId, null, null);
1107+
response.IdToken = null;
1108+
response.ClientInfo = null;
1109+
response.AccessToken = "access-token-2";
1110+
response.RefreshToken = "refresh-token-2";
1111+
1112+
await cache.SaveTokenResponseAsync(requestParams, response).ConfigureAwait(false);
1113+
1114+
Assert.AreEqual(1, cache.Accessor.GetAllRefreshTokens().Count());
1115+
Assert.AreEqual(1, cache.Accessor.GetAllAccessTokens().Count());
1116+
Assert.AreEqual("refresh-token-2", (cache.Accessor.GetAllRefreshTokens()).First().Secret);
1117+
Assert.AreEqual("access-token-2", (cache.Accessor.GetAllAccessTokens()).First().Secret);
1118+
}
1119+
10881120
[TestMethod]
10891121
[TestCategory(TestCategories.TokenCacheTests)]
10901122
public void CacheAdfsTokenTest()

0 commit comments

Comments
 (0)