コード例 #1
0
        public void BodyKeySanitizerRegexReplace()
        {
            var session     = TestHelpers.LoadRecordSession("Test.RecordEntries/post_delete_get_content.json");
            var targetEntry = session.Session.Entries[0];

            var bodyKeySanitizer = new BodyKeySanitizer(jsonPath: "$.TableName", value: "TABLE_ID_IS_SANITIZED", regex: @"(?<=listtable)(?<tableid>[a-z0-9]+)", groupForReplace: "tableid");

            session.Session.Sanitize(bodyKeySanitizer);

            Assert.Contains("listtableTABLE_ID_IS_SANITIZED", Encoding.UTF8.GetString(targetEntry.Response.Body));
        }
コード例 #2
0
        public void BodyKeySanitizerHandlesNonJSON()
        {
            var session          = TestHelpers.LoadRecordSession("Test.RecordEntries/oauth_request.json");
            var targetEntry      = session.Session.Entries[0];
            var replacementValue = "sanitized.tablename";

            var bodyKeySanitizer = new BodyKeySanitizer(jsonPath: "$.TableName", value: replacementValue);

            session.Session.Sanitize(bodyKeySanitizer);

            Assert.DoesNotContain(replacementValue, Encoding.UTF8.GetString(targetEntry.Request.Body));
        }
コード例 #3
0
        public void BodyKeySanitizerQuietlyExits()
        {
            var session          = TestHelpers.LoadRecordSession("Test.RecordEntries/post_delete_get_content.json");
            var targetEntry      = session.Session.Entries[0];
            var replacementValue = "BodyIsSanitized";

            var bodyKeySanitizer = new BodyKeySanitizer(jsonPath: "$.Location", value: replacementValue);

            session.Session.Sanitize(bodyKeySanitizer);

            Assert.DoesNotContain(replacementValue, Encoding.UTF8.GetString(targetEntry.Request.Body));
        }
コード例 #4
0
        public void BodyKeySanitizerKeyReplace()
        {
            var session          = TestHelpers.LoadRecordSession("Test.RecordEntries/post_delete_get_content.json");
            var targetEntry      = session.Session.Entries[0];
            var replacementValue = "sanitized.tablename";

            var bodyKeySanitizer = new BodyKeySanitizer(jsonPath: "$.TableName", value: replacementValue);

            session.Session.Sanitize(bodyKeySanitizer);

            Assert.Contains(replacementValue, Encoding.UTF8.GetString(targetEntry.Request.Body));
        }
コード例 #5
0
        public void BodyKeySanitizerIgnoresNulls()
        {
            var session          = TestHelpers.LoadRecordSession("Test.RecordEntries/response_with_null_secrets.json");
            var targetEntry      = session.Session.Entries[0];
            var replacementValue = "sanitized.tablename";
            var originalBody     = Encoding.UTF8.GetString(targetEntry.Request.Body);
            var bodyKeySanitizer = new BodyKeySanitizer(jsonPath: "$.connectionString", value: replacementValue);

            session.Session.Sanitize(bodyKeySanitizer);

            var newBody = Encoding.UTF8.GetString(targetEntry.Request.Body);

            Assert.Equal(originalBody, newBody);
        }