Esempio n. 1
0
        public void then_flattenned_correctly(object input, string expected)
        {
            Act(input);
            var actual = LogCastDocument.ToJson(Request.Route.SerializedValues);

            actual.Should().Be(expected);
        }
Esempio n. 2
0
        public void then_contract_serialized_is_as_expected()
        {
            var actualSerialized = LogCastDocument.ToJson(Request.Route);
            var expected = LogCastDocument.ToJson(new
            {
                template = "",
                controller = (string)null,
                action = (string)null,
                values = new {key = "value"}
            });

            actualSerialized.Should().Be(expected);
        }
Esempio n. 3
0
        public static string RemoveSensitiveData(string body)
        {
            if (string.IsNullOrWhiteSpace(body))
            {
                return(null);
            }

            if (SensitiveInformationKeywords.All(x => body.IndexOf(x, StringComparison.OrdinalIgnoreCase) == -1))
            {
                return(body);
            }

            try
            {
                var jsonBody = JObject.Parse(body);
                if (jsonBody == null)
                {
                    return(Property.Values.Removed);
                }

                var keys = ((IDictionary <string, JToken>)jsonBody)
                           .Where(x => SensitiveInformationKeywords.Contains(x.Key, StringComparer.OrdinalIgnoreCase))
                           .Select(x => x.Key);

                foreach (var keyValuePair in keys)
                {
                    jsonBody[keyValuePair] = Property.Values.Removed;
                }

                return(LogCastDocument.ToJson(jsonBody));
            }
            catch (Exception)
            {
                return(Property.Values.Removed);
            }
        }
Esempio n. 4
0
 private static string Json(object obj)
 {
     return(LogCastDocument.ToJson(obj));
 }