Regenerate the stamp once if there's a token collision in test (#7364)

This commit is contained in:
Hao Kung 2019-02-07 15:49:17 -08:00 committed by GitHub
parent a677464ed0
commit ff83aea5fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -1846,6 +1846,11 @@ namespace Microsoft.AspNetCore.Identity.Test
token = await manager.GenerateTwoFactorTokenAsync(user, factorId);
Assert.NotNull(token);
IdentityResultAssert.IsSuccess(await manager.UpdateSecurityStampAsync(user));
var token2 = await manager.GenerateTwoFactorTokenAsync(user, factorId);
if (token == token2) // Guard against the rare case there's a totp collision once
{
IdentityResultAssert.IsSuccess(await manager.UpdateSecurityStampAsync(user));
}
Assert.False(await manager.VerifyTwoFactorTokenAsync(user, factorId, token));
IdentityResultAssert.VerifyLogMessage(manager.Logger, $"VerifyTwoFactorTokenAsync() failed for user {await manager.GetUserIdAsync(user)}.");
}