From 1c4a60391a6197c87b8ba4d525ad0523a508f21f Mon Sep 17 00:00:00 2001 From: Chris R Date: Thu, 16 Sep 2021 13:19:23 -0700 Subject: [PATCH] Use a fake clock in the test --- .../test/Identity.Test/SecurityStampValidatorTest.cs | 6 +++++- src/Identity/test/{InMemory.Test => Shared}/TestClock.cs | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) rename src/Identity/test/{InMemory.Test => Shared}/TestClock.cs (91%) diff --git a/src/Identity/test/Identity.Test/SecurityStampValidatorTest.cs b/src/Identity/test/Identity.Test/SecurityStampValidatorTest.cs index 9a22add05c0a..663b7dc807b8 100644 --- a/src/Identity/test/Identity.Test/SecurityStampValidatorTest.cs +++ b/src/Identity/test/Identity.Test/SecurityStampValidatorTest.cs @@ -285,7 +285,11 @@ public async Task OnValidateIdentityDoesNotExtendExpirationWhenSlidingIsDisabled var services = new ServiceCollection(); services.AddSingleton(options.Object); services.AddSingleton(signInManager.Object); - var clock = new SystemClock(); + var clock = new TestClock() + { + // Second precision + UtcNow = new DateTimeOffset(2013, 6, 11, 12, 34, 56, 0, TimeSpan.Zero) + }; services.AddSingleton(new SecurityStampValidator(options.Object, signInManager.Object, clock, new LoggerFactory())); httpContext.Setup(c => c.RequestServices).Returns(services.BuildServiceProvider()); var id = new ClaimsIdentity(IdentityConstants.ApplicationScheme); diff --git a/src/Identity/test/InMemory.Test/TestClock.cs b/src/Identity/test/Shared/TestClock.cs similarity index 91% rename from src/Identity/test/InMemory.Test/TestClock.cs rename to src/Identity/test/Shared/TestClock.cs index 3219f29a3934..6a5ad364f3ac 100644 --- a/src/Identity/test/InMemory.Test/TestClock.cs +++ b/src/Identity/test/Shared/TestClock.cs @@ -4,7 +4,7 @@ using System; using Microsoft.AspNetCore.Authentication; -namespace Microsoft.AspNetCore.Identity.InMemory +namespace Microsoft.AspNetCore.Identity.Test { public class TestClock : ISystemClock {