Skip to content

Fix AuthStateAsyncReturnsUnrelatedCancelledTask_TreatAsFailure flake #20881

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 17, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool>();
var incrementExecuted = new TaskCompletionSource<bool>();
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;
Expand All @@ -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);
Expand Down