From a608981543a7c374e201dd63d447b4822bb2d956 Mon Sep 17 00:00:00 2001 From: Safia Abdalla Date: Wed, 15 Apr 2020 11:32:20 -0700 Subject: [PATCH] Fix AuthStateAsyncReturnsUnrelatedCancelledTask_TreatAsFailure flake --- ...RevalidatingServerAuthenticationStateProviderTest.cs} | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) rename src/Components/Server/test/Circuits/{RevalidatingServerAuthenticationStateProvider.cs => RevalidatingServerAuthenticationStateProviderTest.cs} (97%) diff --git a/src/Components/Server/test/Circuits/RevalidatingServerAuthenticationStateProvider.cs b/src/Components/Server/test/Circuits/RevalidatingServerAuthenticationStateProviderTest.cs similarity index 97% rename from src/Components/Server/test/Circuits/RevalidatingServerAuthenticationStateProvider.cs rename to src/Components/Server/test/Circuits/RevalidatingServerAuthenticationStateProviderTest.cs index 324821cf433a..05ccb17879fb 100644 --- a/src/Components/Server/test/Circuits/RevalidatingServerAuthenticationStateProvider.cs +++ b/src/Components/Server/test/Circuits/RevalidatingServerAuthenticationStateProviderTest.cs @@ -185,17 +185,21 @@ public async Task SuppliesCancellationTokenThatSignalsWhenRevalidationLoopIsBein } [Fact] - [QuarantinedTest("https://github.com/dotnet/aspnetcore/issues/19940")] public async Task IfValidateAuthenticationStateAsyncReturnsUnrelatedCancelledTask_TreatAsFailure() { // Arrange var validationTcs = new TaskCompletionSource(); + var incrementExecuted = new TaskCompletionSource(); var authenticationStateChangedCount = 0; using var provider = new TestRevalidatingServerAuthenticationStateProvider( TimeSpan.FromMilliseconds(50)); provider.NextValidationResult = validationTcs.Task; provider.SetAuthenticationState(CreateAuthenticationStateTask("test user")); - provider.AuthenticationStateChanged += _ => { authenticationStateChangedCount++; }; + provider.AuthenticationStateChanged += _ => + { + authenticationStateChangedCount++; + incrementExecuted.TrySetResult(true); + }; // Be waiting for the first ValidateAuthenticationStateAsync to complete await provider.NextValidateAuthenticationStateAsyncCall; @@ -208,6 +212,7 @@ public async Task IfValidateAuthenticationStateAsyncReturnsUnrelatedCancelledTas // Assert: Since we didn't ask for that operation to be canceled, this is treated as // a failure to validate, so we force a logout + await incrementExecuted.Task.TimeoutAfter(TimeSpan.FromSeconds(5)); Assert.Equal(1, authenticationStateChangedCount); var newAuthState = await provider.GetAuthenticationStateAsync(); Assert.False(newAuthState.User.Identity.IsAuthenticated);