Skip to content

Commit 52648ab

Browse files
trwalketrwalke
andauthored
Fixing flaky test (#5163)
* Fixing test * Fix null check in unit test. --------- Co-authored-by: trwalke <[email protected]>
1 parent 25ff828 commit 52648ab

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

tests/Microsoft.Identity.Test.Unit/PublicApiTests/ClientCredentialWithCertTest.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Microsoft Corporation. All rights reserved.
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

44
#if !ANDROID && !iOS
@@ -872,7 +872,13 @@ public async Task EnsureDefaultCacheKeyBehaviorWhenCertSerialNumberIsNotUsedTest
872872
Assert.AreEqual(TokenSource.IdentityProvider, result.AuthenticationResultMetadata.TokenSource);
873873
Assert.AreEqual("header.payload.signature", result.AccessToken);
874874

875-
var token = app2.AppTokenCacheInternal.Accessor.GetAllAccessTokens().Where(x => x.AdditionalCacheKeyComponents.Any()).FirstOrDefault();
875+
var token = app2.AppTokenCacheInternal.Accessor.GetAllAccessTokens()
876+
.Where(x =>
877+
x.AdditionalCacheKeyComponents?.Any() == true &&
878+
x.AdditionalCacheKeyComponents.Any()).FirstOrDefault();
879+
880+
Assert.IsNotNull(token);
881+
876882
Assert.AreEqual(certificate.SerialNumber, token.AdditionalCacheKeyComponents.FirstOrDefault().Value);
877883
}
878884
}

0 commit comments

Comments
 (0)