mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 15:42:48 -05:00
chore: update LastActivityDate
on installation token refresh (#5081)
This commit is contained in:
@ -0,0 +1,40 @@
|
||||
using Bit.Test.Common.AutoFixture;
|
||||
using Bit.Test.Common.AutoFixture.Attributes;
|
||||
using Microsoft.Extensions.Time.Testing;
|
||||
using NSubstitute;
|
||||
using Xunit;
|
||||
|
||||
namespace Bit.Core.Platform.Installations.Tests;
|
||||
|
||||
[SutProviderCustomize]
|
||||
public class UpdateInstallationCommandTests
|
||||
{
|
||||
[Theory]
|
||||
[BitAutoData]
|
||||
public async Task UpdateLastActivityDateAsync_ShouldUpdateLastActivityDate(
|
||||
Installation installation
|
||||
)
|
||||
{
|
||||
// Arrange
|
||||
var sutProvider = new SutProvider<UpdateInstallationCommand>()
|
||||
.WithFakeTimeProvider()
|
||||
.Create();
|
||||
|
||||
var someDate = new DateTime(2014, 11, 3, 18, 27, 0, DateTimeKind.Utc);
|
||||
sutProvider.GetDependency<FakeTimeProvider>().SetUtcNow(someDate);
|
||||
|
||||
sutProvider
|
||||
.GetDependency<IGetInstallationQuery>()
|
||||
.GetByIdAsync(installation.Id)
|
||||
.Returns(installation);
|
||||
|
||||
// Act
|
||||
await sutProvider.Sut.UpdateLastActivityDateAsync(installation.Id);
|
||||
|
||||
// Assert
|
||||
await sutProvider
|
||||
.GetDependency<IInstallationRepository>()
|
||||
.Received(1)
|
||||
.UpsertAsync(Arg.Is<Installation>(inst => inst.LastActivityDate == someDate));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user