コード例 #1
0
        public void HandlesEmptyInput()
        {
            var secretMasker = new SecretMasker();
            secretMasker.AddValue("abcd");

            var result = secretMasker.MaskSecrets(null);
            Assert.Equal(string.Empty, result);

            result = secretMasker.MaskSecrets(string.Empty);
            Assert.Equal(string.Empty, result);
        }
コード例 #2
0
        public void HandlesEmptyInput()
        {
            var secretMasker = new SecretMasker();

            secretMasker.AddValue("abcd");

            var result = secretMasker.MaskSecrets(null);

            Assert.Equal(string.Empty, result);

            result = secretMasker.MaskSecrets(string.Empty);
            Assert.Equal(string.Empty, result);
        }
コード例 #3
0
 public void HandlesNoMasks()
 {
     var secretMasker = new SecretMasker();
     var input = "abcdefg";
     var result = secretMasker.MaskSecrets(input);
     Assert.Equal(input, result);
 }
コード例 #4
0
        public void HandlesNoMasks()
        {
            var secretMasker = new SecretMasker();
            var input        = "abcdefg";
            var result       = secretMasker.MaskSecrets(input);

            Assert.Equal(input, result);
        }
コード例 #5
0
        public void ReplacesMultipleAdjacentInstances()
        {
            var secretMasker = new SecretMasker();
            secretMasker.AddValue("abc");

            var input = "abcabcdef";
            var result = secretMasker.MaskSecrets(input);

            Assert.Equal("********def", result);
        }
コード例 #6
0
        public void ReplacesMultipleInstances()
        {
            var secretMasker = new SecretMasker();
            secretMasker.AddValue("def");

            var input = "abcdefgdef";
            var result = secretMasker.MaskSecrets(input);

            Assert.Equal("abc********g********", result);
        }
コード例 #7
0
        public void ReplacesValue()
        {
            var secretMasker = new SecretMasker();
            secretMasker.AddValue("def");

            var input = "abcdefg";
            var result = secretMasker.MaskSecrets(input);

            Assert.Equal("abc********g", result);
        }
コード例 #8
0
        public void HandlesUrlEscapedInput()
        {
            var secretMasker = new SecretMasker();

            secretMasker.AddValue("b c");

            var result = secretMasker.MaskSecrets("ab%20cd");

            Assert.Equal("a********d", result);
        }
コード例 #9
0
        public void HandlesJsonEscapedInput()
        {
            var secretMasker = new SecretMasker();

            secretMasker.AddValue(@"b\c");

            var result = secretMasker.MaskSecrets(@"ab\\cd");

            Assert.Equal("a********d", result);
        }
コード例 #10
0
        public void ReplacesMultipleAdjacentInstances()
        {
            var secretMasker = new SecretMasker();

            secretMasker.AddValue("abc");

            var input  = "abcabcdef";
            var result = secretMasker.MaskSecrets(input);

            Assert.Equal("********def", result);
        }
コード例 #11
0
        public void ReplacesMultipleInstances()
        {
            var secretMasker = new SecretMasker();

            secretMasker.AddValue("def");

            var input  = "abcdefgdef";
            var result = secretMasker.MaskSecrets(input);

            Assert.Equal("abc********g********", result);
        }
コード例 #12
0
        public void ReplacesValue()
        {
            var secretMasker = new SecretMasker();

            secretMasker.AddValue("def");

            var input  = "abcdefg";
            var result = secretMasker.MaskSecrets(input);

            Assert.Equal("abc********g", result);
        }
コード例 #13
0
        public void ReplacesMultipleSecrets()
        {
            var secretMasker = new SecretMasker();
            secretMasker.AddValue("bcd");
            secretMasker.AddValue("fgh");

            var input = "abcdefghi";
            var result = secretMasker.MaskSecrets(input);

            Assert.Equal("a********e********i", result);
        }
コード例 #14
0
        public void ReplacesMultipleSecrets()
        {
            var secretMasker = new SecretMasker();

            secretMasker.AddValue("bcd");
            secretMasker.AddValue("fgh");

            var input  = "abcdefghi";
            var result = secretMasker.MaskSecrets(input);

            Assert.Equal("a********e********i", result);
        }
コード例 #15
0
        public void ReplacesAdjacentSecrets()
        {
            var secretMasker = new SecretMasker();

            secretMasker.AddValue("efg");
            secretMasker.AddValue("bcd");

            var input  = "abcdefgh";
            var result = secretMasker.MaskSecrets(input);

            // two adjacent secrets are basically one big secret

            Assert.Equal("a********h", result);
        }
コード例 #16
0
        public void ReplacesOverlappingSecrets()
        {
            var secretMasker = new SecretMasker();

            secretMasker.AddValue("def");
            secretMasker.AddValue("bcd");

            var input  = "abcdefg";
            var result = secretMasker.MaskSecrets(input);

            // a naive replacement would replace "def" first, and never find "bcd", resulting in "abc********g"
            // or it would replace "bcd" first, and never find "def", resulting in "a********efg"

            Assert.Equal("a********g", result);
        }
コード例 #17
0
        public void ReplacesOverlappingSecrets()
        {
            var secretMasker = new SecretMasker();
            secretMasker.AddValue("def");
            secretMasker.AddValue("bcd");

            var input = "abcdefg";
            var result = secretMasker.MaskSecrets(input);

            // a naive replacement would replace "def" first, and never find "bcd", resulting in "abc********g"
            // or it would replace "bcd" first, and never find "def", resulting in "a********efg"

            Assert.Equal("a********g", result);
        }
コード例 #18
0
        public void ReplacesAdjacentSecrets()
        {
            var secretMasker = new SecretMasker();
            secretMasker.AddValue("efg");
            secretMasker.AddValue("bcd");

            var input = "abcdefgh";
            var result = secretMasker.MaskSecrets(input);

            // two adjacent secrets are basically one big secret

            Assert.Equal("a********h", result);
        }