Skip to content

Commit cf893dc

Browse files
scott.waye@hubse.netbgavrilMS
authored andcommitted
AddTest when no ID and no ClientInfo is returned
1 parent 24ceb70 commit cf893dc

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
@@ -1086,6 +1086,38 @@ public async Task SaveAccessAndRefreshTokenWithIntersectingScopesTestAsync()
10861086
Assert.AreEqual("access-token-2", (cache.Accessor.GetAllAccessTokens()).First().Secret);
10871087
}
10881088

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

0 commit comments

Comments
 (0)