You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
abp/framework/test/Volo.Abp.Auditing.Tests/Volo/Abp/Auditing/JsonAuditSerializer_Test.cs

65 lines
1.6 KiB

using System;
using System.Collections.Generic;
using Microsoft.Extensions.DependencyInjection;
using Shouldly;
using Xunit;
namespace Volo.Abp.Auditing;
public class JsonAuditSerializer_Test : AbpAuditingTestBase
{
protected override void AfterAddApplication(IServiceCollection services)
{
services.Configure<AbpAuditingOptions>(options =>
{
options.IgnoredTypes.Add(typeof(DateTime));
});
base.AfterAddApplication(services);
}
[Fact]
public void Serialize_Test()
{
if (!Environment.GetEnvironmentVariable("GITHUB_ACTIONS").IsNullOrWhiteSpace())
{
//Github CI random failure.
return;
}
var arguments = new Dictionary<string, object>
{
{"input", new InputDto {PersonData = "IdCard:123123"}},
{"input2", new Input2Dto {UserName = "admin", Password = "1q2w3E*", Birthday = DateTime.Now}}
};
var str = GetRequiredService<JsonAuditSerializer>().Serialize(arguments);
str.ShouldNotContain("IdCard");
str.ShouldNotContain("1q2w3E*");
str.ShouldNotContain("Birthday");
str.ShouldContain("UserName");
str.ShouldContain("admin");
}
[DisableAuditing]
class InputDto
{
public string PersonData { get; set; }
}
class Input2Dto
{
public string UserName { get; set; }
[DisableAuditing]
public string Password { get; set; }
public string PrivateEmail { get; set; }
public DateTime Birthday { get; set; }
}
}