1
0
mirror of https://github.com/bitwarden/server.git synced 2025-05-12 07:02:16 -05:00

Resolve platform warnings (#5798)

* Installation Repository tests

* Formatting

* Remove extra LastActivityDate property

* Remove exclusion
This commit is contained in:
Justin Baur 2025-05-09 16:03:09 -04:00 committed by GitHub
parent 0075a15485
commit 15b498184f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 51 additions and 16 deletions

View File

@ -75,4 +75,8 @@
<Folder Include="Resources\" />
<Folder Include="Properties\" />
</ItemGroup>
<ItemGroup>
<InternalsVisibleTo Include="Infrastructure.IntegrationTest" />
</ItemGroup>
</Project>

View File

@ -1,10 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<!-- Temp exclusions until warnings are fixed -->
<WarningsNotAsErrors>$(WarningsNotAsErrors);CS0108</WarningsNotAsErrors>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
<PackageReference Include="linq2db" Version="5.4.1" />

View File

@ -3,22 +3,12 @@ using C = Bit.Core.Platform.Installations;
namespace Bit.Infrastructure.EntityFramework.Platform;
public class Installation : C.Installation
{
// Shadow property - to be introduced by https://bitwarden.atlassian.net/browse/PM-11129
// This isn't a value or entity used by self hosted servers, but it's
// being added for synchronicity between database provider options.
public DateTime? LastActivityDate { get; set; }
}
public class Installation : C.Installation;
public class InstallationMapperProfile : Profile
{
public InstallationMapperProfile()
{
CreateMap<C.Installation, Installation>()
// Shadow property - to be introduced by https://bitwarden.atlassian.net/browse/PM-11129
.ForMember(i => i.LastActivityDate, opt => opt.Ignore())
.ReverseMap();
CreateMap<C.Installation, Installation>().ReverseMap();
}
}

View File

@ -0,0 +1,46 @@
using Bit.Core.Platform.Installations;
using Bit.Infrastructure.IntegrationTest.Comparers;
using Xunit;
namespace Bit.Infrastructure.IntegrationTest.Platform.Installations;
public class InstallationRepositoryTests
{
[DatabaseTheory, DatabaseData]
public async Task GetByIdAsync_Works(IInstallationRepository installationRepository)
{
var installation = await installationRepository.CreateAsync(new Installation
{
Email = "test@email.com",
Key = "installation_key",
Enabled = true,
});
var retrievedInstallation = await installationRepository.GetByIdAsync(installation.Id);
Assert.NotNull(retrievedInstallation);
Assert.Equal("installation_key", retrievedInstallation.Key);
}
[DatabaseTheory, DatabaseData]
public async Task UpdateAsync_Works(IInstallationRepository installationRepository)
{
var installation = await installationRepository.CreateAsync(new Installation
{
Email = "test@email.com",
Key = "installation_key",
Enabled = true,
});
var now = DateTime.UtcNow;
installation.LastActivityDate = now;
await installationRepository.ReplaceAsync(installation);
var retrievedInstallation = await installationRepository.GetByIdAsync(installation.Id);
Assert.NotNull(retrievedInstallation.LastActivityDate);
Assert.Equal(now, retrievedInstallation.LastActivityDate.Value, LaxDateTimeComparer.Default);
}
}