mirror of
https://github.com/Sea-Haven-Industries/shoc-backend.git
synced 2026-10-03 22:33:19 +00:00
test(auth): build the password-policy service with the reset queue, throttle and keyed hash
This commit is contained in:
parent
613bfa48d8
commit
fe5f27c8e1
1 changed files with 5 additions and 3 deletions
|
|
@ -133,7 +133,8 @@ public sealed class PasswordPolicyTests : IAsyncDisposable
|
||||||
Microsoft.Extensions.Options.Options.Create(new JwtOptions { Secret = new string('x', 64) }),
|
Microsoft.Extensions.Options.Options.Create(new JwtOptions { Secret = new string('x', 64) }),
|
||||||
Mock.Of<IUserDataService>(),
|
Mock.Of<IUserDataService>(),
|
||||||
Mock.Of<IForgetPasswordDataService>(),
|
Mock.Of<IForgetPasswordDataService>(),
|
||||||
Mock.Of<IEmailSender>(),
|
Mock.Of<IPasswordResetEmailQueue>(),
|
||||||
|
new InMemoryPasswordResetThrottle(TimeProvider.System),
|
||||||
TimeProvider.System);
|
TimeProvider.System);
|
||||||
|
|
||||||
var result = await service.ChangePasswordAsync(user.Id, CurrentPassword, "Next2@x", CancellationToken.None);
|
var result = await service.ChangePasswordAsync(user.Id, CurrentPassword, "Next2@x", CancellationToken.None);
|
||||||
|
|
@ -179,7 +180,7 @@ public sealed class PasswordPolicyTests : IAsyncDisposable
|
||||||
Email = user.Email!,
|
Email = user.Email!,
|
||||||
UserId = user.Id,
|
UserId = user.Id,
|
||||||
CodeSalt = salt,
|
CodeSalt = salt,
|
||||||
CodeHash = PasswordResetCodeSecrets.Hash(salt, "123456"),
|
CodeHash = PasswordResetCodeSecrets.Hash(PasswordResetCodeSecrets.DeriveKey(new string('x', 64)), salt, "123456"),
|
||||||
ExpiresAtUtc = DateTime.UtcNow.AddMinutes(10)
|
ExpiresAtUtc = DateTime.UtcNow.AddMinutes(10)
|
||||||
});
|
});
|
||||||
forget.Setup(f => f.TryConsumeAttemptAsync(7, It.IsAny<int>(), It.IsAny<DateTime>(), It.IsAny<CancellationToken>()))
|
forget.Setup(f => f.TryConsumeAttemptAsync(7, It.IsAny<int>(), It.IsAny<DateTime>(), It.IsAny<CancellationToken>()))
|
||||||
|
|
@ -220,7 +221,8 @@ public sealed class PasswordPolicyTests : IAsyncDisposable
|
||||||
Microsoft.Extensions.Options.Options.Create(new JwtOptions { Secret = new string('x', 64) }),
|
Microsoft.Extensions.Options.Options.Create(new JwtOptions { Secret = new string('x', 64) }),
|
||||||
Mock.Of<IUserDataService>(),
|
Mock.Of<IUserDataService>(),
|
||||||
(forget ?? new Mock<IForgetPasswordDataService>()).Object,
|
(forget ?? new Mock<IForgetPasswordDataService>()).Object,
|
||||||
Mock.Of<IEmailSender>(),
|
Mock.Of<IPasswordResetEmailQueue>(),
|
||||||
|
new InMemoryPasswordResetThrottle(TimeProvider.System),
|
||||||
TimeProvider.System);
|
TimeProvider.System);
|
||||||
|
|
||||||
public async ValueTask DisposeAsync()
|
public async ValueTask DisposeAsync()
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue