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:
parent
0075a15485
commit
15b498184f
@ -75,4 +75,8 @@
|
|||||||
<Folder Include="Resources\" />
|
<Folder Include="Resources\" />
|
||||||
<Folder Include="Properties\" />
|
<Folder Include="Properties\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<InternalsVisibleTo Include="Infrastructure.IntegrationTest" />
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -1,10 +1,5 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<!-- Temp exclusions until warnings are fixed -->
|
|
||||||
<WarningsNotAsErrors>$(WarningsNotAsErrors);CS0108</WarningsNotAsErrors>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
|
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
|
||||||
<PackageReference Include="linq2db" Version="5.4.1" />
|
<PackageReference Include="linq2db" Version="5.4.1" />
|
||||||
|
@ -3,22 +3,12 @@ using C = Bit.Core.Platform.Installations;
|
|||||||
|
|
||||||
namespace Bit.Infrastructure.EntityFramework.Platform;
|
namespace Bit.Infrastructure.EntityFramework.Platform;
|
||||||
|
|
||||||
public class Installation : C.Installation
|
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 InstallationMapperProfile : Profile
|
public class InstallationMapperProfile : Profile
|
||||||
{
|
{
|
||||||
public InstallationMapperProfile()
|
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();
|
CreateMap<C.Installation, Installation>().ReverseMap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user