1
0
mirror of https://github.com/bitwarden/server.git synced 2024-12-05 14:23:30 +01:00
bitwarden-server/test/Core.Test/Vault/AutoFixture/CipherAttachmentMetaDataFixtures.cs
Federico Maccaroni 10782d55f3
[PM-2682] Fix v0 attachments migration on share cipher with org (#3051)
* PM-2682 Fix v0 attachments migration on share cipher with org

* PM-2682 Fix format

* PM-2682 Fix tests recursion

* Update src/Core/Vault/Models/Data/CipherAttachment.cs

Co-authored-by: Matt Gibson <mgibson@bitwarden.com>

---------

Co-authored-by: Matt Gibson <mgibson@bitwarden.com>
2023-07-21 16:08:08 -03:00

37 lines
1.4 KiB
C#

using AutoFixture;
using AutoFixture.Dsl;
using Bit.Core.Vault.Models.Data;
namespace Bit.Core.Test.AutoFixture.CipherAttachmentMetaData;
public class MetaData : ICustomization
{
protected virtual IPostprocessComposer<CipherAttachment.MetaData> ComposerAction(IFixture fixture,
ICustomizationComposer<CipherAttachment.MetaData> composer)
{
return composer.With(d => d.Size, fixture.Create<long>());
}
public void Customize(IFixture fixture)
{
fixture.Customize<CipherAttachment.MetaData>(composer => ComposerAction(fixture, composer));
fixture.Behaviors.OfType<ThrowingRecursionBehavior>()
.ToList()
.ForEach(b => fixture.Behaviors.Remove(b));
fixture.Behaviors.Add(new OmitOnRecursionBehavior(1));
}
}
public class MetaDataWithoutContainer : MetaData
{
protected override IPostprocessComposer<CipherAttachment.MetaData> ComposerAction(IFixture fixture,
ICustomizationComposer<CipherAttachment.MetaData> composer) =>
base.ComposerAction(fixture, composer).With(d => d.ContainerName, (string)null);
}
public class MetaDataWithoutKey : MetaDataWithoutContainer
{
protected override IPostprocessComposer<CipherAttachment.MetaData> ComposerAction(IFixture fixture,
ICustomizationComposer<CipherAttachment.MetaData> composer) =>
base.ComposerAction(fixture, composer).Without(d => d.Key);
}