Skip to content

Commit ebe7cef

Browse files
committed
Fix AuthStateAsyncReturnsUnrelatedCancelledTask_TreatAsFailure flake
1 parent a058aca commit ebe7cef

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/Components/Server/test/Circuits/RevalidatingServerAuthenticationStateProvider.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,17 +185,20 @@ public async Task SuppliesCancellationTokenThatSignalsWhenRevalidationLoopIsBein
185185
}
186186

187187
[Fact]
188-
[QuarantinedTest("https://github.com/dotnet/aspnetcore/issues/19940")]
189188
public async Task IfValidateAuthenticationStateAsyncReturnsUnrelatedCancelledTask_TreatAsFailure()
190189
{
191190
// Arrange
192191
var validationTcs = new TaskCompletionSource<bool>();
192+
var incrementExecuted = new TaskCompletionSource<bool>();
193193
var authenticationStateChangedCount = 0;
194194
using var provider = new TestRevalidatingServerAuthenticationStateProvider(
195195
TimeSpan.FromMilliseconds(50));
196196
provider.NextValidationResult = validationTcs.Task;
197197
provider.SetAuthenticationState(CreateAuthenticationStateTask("test user"));
198-
provider.AuthenticationStateChanged += _ => { authenticationStateChangedCount++; };
198+
provider.AuthenticationStateChanged += _ => {
199+
authenticationStateChangedCount++;
200+
incrementExecuted.TrySetResult(true);
201+
};
199202

200203
// Be waiting for the first ValidateAuthenticationStateAsync to complete
201204
await provider.NextValidateAuthenticationStateAsyncCall;
@@ -208,6 +211,7 @@ public async Task IfValidateAuthenticationStateAsyncReturnsUnrelatedCancelledTas
208211

209212
// Assert: Since we didn't ask for that operation to be canceled, this is treated as
210213
// a failure to validate, so we force a logout
214+
await incrementExecuted.Task.TimeoutAfter(TimeSpan.FromSeconds(1));
211215
Assert.Equal(1, authenticationStateChangedCount);
212216
var newAuthState = await provider.GetAuthenticationStateAsync();
213217
Assert.False(newAuthState.User.Identity.IsAuthenticated);

0 commit comments

Comments
 (0)