mirror of
https://github.com/bitwarden/server.git
synced 2024-12-05 14:23:30 +01:00
4e7b9d2edd
* Extract Import-Api endpoints into separate controller Moved ciphers/import and ciphers/import-organization into new ImportController Paths have been kept intact for now (no changes on clients needed) Moved request-models used for import into tools-subfolder * Update CODEOWNERS for team-tools-dev * Move HibpController (reports) to tools * Moving files related to Send * Moving files related to ReferenceEvent * Removed unneeded newline
72 lines
2.4 KiB
C#
72 lines
2.4 KiB
C#
using AutoFixture;
|
|
using AutoFixture.Kernel;
|
|
using Bit.Core.Test.AutoFixture.UserFixtures;
|
|
using Bit.Core.Tools.Entities;
|
|
using Bit.Infrastructure.EFIntegration.Test.AutoFixture;
|
|
using Bit.Infrastructure.EFIntegration.Test.AutoFixture.Relays;
|
|
using Bit.Infrastructure.EntityFramework.Repositories;
|
|
using Bit.Infrastructure.EntityFramework.Tools.Repositories;
|
|
using Bit.Test.Common.AutoFixture;
|
|
using Bit.Test.Common.AutoFixture.Attributes;
|
|
|
|
namespace Bit.Infrastructure.EFIntegration.Test.Tools.AutoFixture;
|
|
|
|
internal class SendBuilder : ISpecimenBuilder
|
|
{
|
|
public bool OrganizationOwned { get; set; }
|
|
public object Create(object request, ISpecimenContext context)
|
|
{
|
|
if (context == null)
|
|
{
|
|
throw new ArgumentNullException(nameof(context));
|
|
}
|
|
|
|
var type = request as Type;
|
|
if (type == null || type != typeof(Send))
|
|
{
|
|
return new NoSpecimen();
|
|
}
|
|
|
|
var fixture = new Fixture();
|
|
fixture.Customizations.Insert(0, new MaxLengthStringRelay());
|
|
if (!OrganizationOwned)
|
|
{
|
|
fixture.Customize<Send>(composer => composer
|
|
.Without(c => c.OrganizationId));
|
|
}
|
|
var obj = fixture.WithAutoNSubstitutions().Create<Send>();
|
|
return obj;
|
|
}
|
|
}
|
|
|
|
internal class EfSend : ICustomization
|
|
{
|
|
public bool OrganizationOwned { get; set; }
|
|
public void Customize(IFixture fixture)
|
|
{
|
|
fixture.Customizations.Add(new IgnoreVirtualMembersCustomization());
|
|
fixture.Customizations.Add(new GlobalSettingsBuilder());
|
|
fixture.Customizations.Add(new SendBuilder());
|
|
fixture.Customizations.Add(new UserBuilder());
|
|
fixture.Customizations.Add(new OrganizationBuilder());
|
|
fixture.Customizations.Add(new EfRepositoryListBuilder<SendRepository>());
|
|
fixture.Customizations.Add(new EfRepositoryListBuilder<UserRepository>());
|
|
fixture.Customizations.Add(new EfRepositoryListBuilder<OrganizationRepository>());
|
|
}
|
|
}
|
|
|
|
internal class EfUserSendAutoDataAttribute : CustomAutoDataAttribute
|
|
{
|
|
public EfUserSendAutoDataAttribute() : base(new SutProviderCustomization(), new EfSend())
|
|
{ }
|
|
}
|
|
|
|
internal class EfOrganizationSendAutoDataAttribute : CustomAutoDataAttribute
|
|
{
|
|
public EfOrganizationSendAutoDataAttribute() : base(new SutProviderCustomization(), new EfSend()
|
|
{
|
|
OrganizationOwned = true,
|
|
})
|
|
{ }
|
|
}
|