예제 #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);
        }