Ejemplo n.º 1
0
 static TestBase()
 {
     SerializerBuilder.ExtraSettings = settings =>
     {
         settings.ContractResolver = new CustomContractResolverEx();
     };
     StringScrubber.AddExtraDatetimeFormat("yyyy-MM-dd HH:mm:ss:ffffff Z");
 }
Ejemplo n.º 2
0
 public ScrubString(StringScrubber scrubber, int length)
 {
     if (length > 0)
     {
         this.scrubber = scrubber;
         this.length   = length;
     }
     //TODO Throw error if incorrect length?
 }
 static TestBase()
 {
     SerializerBuilder.ExtraSettings = settings =>
     {
         settings.Converters.Add(new LogEventPropertyConverter());
         settings.Converters.Add(new LogEventConverter());
         settings.Converters.Add(new ScalarValueConverter());
     };
     StringScrubber.AddExtraDatetimeFormat("yyyy-MM-dd HH:mm:ss:ffffff Z");
 }
Ejemplo n.º 4
0
        public void BasicTest()
        {
            const string scrubMask = "***";

            string[] scrubFields = new[]
            {
                "secret1",
                "data.secret2",
            };
            var scrubber = new StringScrubber(scrubMask, scrubFields);

            string inputToScrub   = "{'secret1':'aha', {'data': { 'secret2': 'aha'}}}";
            string scrubbedResult = scrubber.Scrub(inputToScrub);

            Assert.IsFalse(scrubbedResult.Contains(scrubMask));
            Assert.AreEqual("StringScrubber: Data scrubbing failed!", scrubbedResult);
        }
 static ObjectApproverTests()
 {
     StringScrubber.AddExtraDatetimeFormat("F");
     StringScrubber.AddExtraDatetimeOffsetFormat("F");
 }
Ejemplo n.º 6
0
 //Used for generating numbers as strings
 public ScrubString(StringScrubber scrubber, int minValue, int maxValue)
 {
     this.scrubber = scrubber;
     this.minValue = minValue;
     this.maxValue = maxValue;
 }
Ejemplo n.º 7
0
 public ScrubString(StringScrubber scrubber, bool IsRedacted)
 {
     this.scrubber   = scrubber;
     this.IsRedacted = IsRedacted;
 }
Ejemplo n.º 8
0
 public ScrubString(StringScrubber scrubber)
 {
     this.scrubber = scrubber;
 }
Ejemplo n.º 9
0
        /// <summary>
        /// Routes String by scrubbing types
        /// </summary>
        /// <param name="property"></param>
        /// <param name="cleanDataInstance"></param>
        /// <param name="scrubType"></param>
        /// <returns></returns>
        private object RouteStringType()
        {
            var scrubber = _currentProperty.GetCustomAttribute(typeof(ScrubString));

            if (scrubber != null)
            {
                ScrubString    atr           = scrubber as ScrubString;
                StringScrubber attrScrubType = atr.scrubber;
                bool           IsRedacted    = atr.IsRedacted;

                if (IsRedacted)
                {
                    return("*** REDACTED ***");
                }

                switch (attrScrubType)
                {
                case StringScrubber.SSN:
                    return(ScrubBasicTypes.ScrubSSN());

                case StringScrubber.Phone:
                    return(Faker.Phone.Number());

                case StringScrubber.Email:
                    return(Faker.Internet.Email());

                case StringScrubber.Address:
                    return(Faker.Address.StreetAddress());

                case StringScrubber.AddressTwo:
                    return(Faker.Address.SecondaryAddress());

                case StringScrubber.City:
                    return(Faker.Address.City());

                case StringScrubber.State:
                    return(Faker.Address.UsState());

                case StringScrubber.CountyFIPS:
                    return(ScrubCountyCode.ScrubCountyFIPS());

                case StringScrubber.CountyName:
                    return(ScrubCountyCode.ScrubCountyName());

                case StringScrubber.StateCode:
                    return(Faker.Address.UsStateAbbr());

                case StringScrubber.Zip:
                    return(Faker.Address.ZipCode());

                case StringScrubber.FullName:
                    return(Faker.Name.FullName());

                case StringScrubber.FirstName:
                    return(Faker.Name.First());

                case StringScrubber.LastName:
                    return(Faker.Name.Last());

                case StringScrubber.MiddleName:
                    //Two First Names
                    return(Faker.Name.First());

                case StringScrubber.UserName:
                    return(Faker.Internet.UserName());

                case StringScrubber.Number:
                    var minValue = atr.minValue;
                    var maxValue = atr.maxValue;
                    return(Faker.RandomNumber.Next(minValue, maxValue));

                case StringScrubber.VIN:
                    return(ScrubBasicTypes.ScrubVIN());

                default:
                    return(RouteGenericText(atr.length));
                }
            }
            else
            {
                return(Faker.Lorem.Sentence(144));
            }
        }