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)); }
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)); }
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)); }
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)); }
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); }