mirror of
https://github.com/bitwarden/server.git
synced 2026-02-01 22:53:12 +08:00
27 lines
1.1 KiB
C#
27 lines
1.1 KiB
C#
|
|
using System.Reflection;
|
|||
|
|
using AutoFixture;
|
|||
|
|
using AutoFixture.Xunit2;
|
|||
|
|
using Bit.Core.Entities;
|
|||
|
|
using Bit.Core.Models.Data;
|
|||
|
|
using Bit.Core.Utilities;
|
|||
|
|
|
|||
|
|
namespace Bit.Identity.Test.AutoFixture;
|
|||
|
|
|
|||
|
|
internal class OrganizationUserWithDefaultPermissionsCustomization : ICustomization
|
|||
|
|
{
|
|||
|
|
public void Customize(IFixture fixture)
|
|||
|
|
{
|
|||
|
|
fixture.Customize<OrganizationUser>(composer => composer
|
|||
|
|
// On OrganizationUser, Permissions can be JSON data (as string) or sometimes null.
|
|||
|
|
// Entity APIs should prevent it from being anything else.
|
|||
|
|
// An un-modified fixture for OrganizationUser will return a bare string Permissions{guid}
|
|||
|
|
// in the member, throwing a JsonException on deserialization of a bare string.
|
|||
|
|
.With(organizationUser => organizationUser.Permissions, CoreHelpers.ClassToJsonData(new Permissions())));
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public class OrganizationUserWithDefaultPermissionsAttribute : CustomizeAttribute
|
|||
|
|
{
|
|||
|
|
public override ICustomization GetCustomization(ParameterInfo parameter) => new OrganizationUserWithDefaultPermissionsCustomization();
|
|||
|
|
}
|