public void Defaults()
        {
            Assert.Equal("[REDACTED]", RedactorOptions.DefaultMask);

            var options = new RedactorOptions();

            Assert.Equal(ComplexTypeHandling.RedactValue, options.ComplexTypeHandling);
            Assert.Null(options.IfIsRedacts);
            Assert.Equal(RedactorOptions.DefaultMask, options.Mask);
            Assert.Equal(OnErrorRedact.All, options.OnErrorRedact);
            Assert.Null(options.Redacts);
            Assert.Equal(StringComparison.OrdinalIgnoreCase, options.StringComparison);
        }
Esempio n. 2
0
 public XmlRedactor(RedactorOptions options) : base(options)
 {
 }
Esempio n. 3
0
        public void RedactorOptionsIsSpecified()
        {
            // Define non-default options
            var options = new RedactorOptions
            {
                ComplexTypeHandling = ComplexTypeHandling.RedactValue,
                IfIsRedacts         = new[]
                {
                    new IfIsRedact("GHI", "3", "JKL"),
                    new IfIsRedact("MNO", "5", "PQR"),
                    null,
                },
                Mask          = Guid.NewGuid().ToString("n"),
                OnErrorRedact = OnErrorRedact.None,
                Redacts       = new[]
                {
                    "ABC",
                    "DEF",
                    null
                },
                StringComparison = StringComparison.CurrentCulture
            };

            // Ensure not the defaults
            Assert.NotEqual(ComplexTypeHandling.RedactDescendants, options.ComplexTypeHandling);
            Assert.NotNull(options.IfIsRedacts);
            Assert.NotEqual(RedactorOptions.DefaultMask, options.Mask);
            Assert.NotEqual(OnErrorRedact.All, options.OnErrorRedact);
            Assert.NotNull(options.Redacts);
            Assert.NotEqual(StringComparison.OrdinalIgnoreCase, options.StringComparison);

            // create redactor
            var redactor = new ExposedOptionsRedactor(options);

            // assert options
            Assert.Equal(options.ComplexTypeHandling, redactor.Options.ComplexTypeHandling);

            var expectedIfIsRedacts = options.IfIsRedacts.Where(i => i != null);

            Assert.NotNull(redactor.Options.IfIsRedacts);
            Assert.Equal(expectedIfIsRedacts.Count(), redactor.Options.IfIsRedacts.Count());
            foreach (var ifisredact in expectedIfIsRedacts)
            {
                Assert.DoesNotContain(ifisredact, redactor.Options.IfIsRedacts);
                Assert.Contains(redactor.Options.IfIsRedacts, i => i.If == ifisredact.If && i.Is == ifisredact.Is && i.Redact == ifisredact.Redact);
            }

            Assert.Equal(options.Mask, redactor.Options.Mask);

            Assert.Equal(options.OnErrorRedact, redactor.Options.OnErrorRedact);

            var expectedRedacts = options.Redacts.Where(i => i != null);

            Assert.NotNull(redactor.Options.Redacts);
            Assert.Equal(expectedRedacts.Count(), redactor.Options.Redacts.Count());
            foreach (var redact in expectedRedacts)
            {
                Assert.Contains(redact, redactor.Options.Redacts);
            }

            Assert.Equal(options.StringComparison, redactor.Options.StringComparison);
        }
Esempio n. 4
0
 public ExposedOptionsRedactor(RedactorOptions options) : base(options)
 {
 }
Esempio n. 5
0
 public JsonRedactor(RedactorOptions options) : base(options)
 {
 }