Skip to content

Commit

Permalink
Add test for SRedactSensitiveValues
Browse files Browse the repository at this point in the history
  • Loading branch information
marcaaron committed Sep 25, 2024
1 parent 67b55ff commit 2e7ae59
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions test/tests/LibStuffTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ struct LibStuff : tpunit::TestFixture {
TEST(LibStuff::testFirstOfMonth),
TEST(LibStuff::SREMatchTest),
TEST(LibStuff::SREReplaceTest),
TEST(LibStuff::SQResultTest)
TEST(LibStuff::SQResultTest),
TEST(LibStuff::SRedactSensitiveValuesTest)
)
{ }

Expand Down Expand Up @@ -647,7 +648,7 @@ struct LibStuff : tpunit::TestFixture {

// Case sensitive but case doesn't match.
ASSERT_FALSE(SREMatch(".*CAT.*", "this contains cat"));

// Case-insensitive.
ASSERT_TRUE(SREMatch(".*CAT.*", "this contains cat", false));
ASSERT_FALSE(SREMatch(".*CAT.*", "this does not", false));
Expand Down Expand Up @@ -744,4 +745,18 @@ struct LibStuff : tpunit::TestFixture {
db.rollback();
ASSERT_EQUAL(result[0]["coco"], "name1");
}

void SRedactSensitiveValuesTest() {
string logValue = R"({"edits":["test1", "test2", "test3"]})";
SRedactSensitiveValues(logValue);
ASSERT_EQUALS(R"({"edits":["REDACTED"]})", logValue);

logValue = R"({"authToken": "123IMANAUTHTOKEN321"})";
SRedactSensitiveValues(logValue);
ASSERT_EQUALS(R"({"authToken":<REDACTED>})", logValue);

logValue = R"({"html":"private conversation happens here"})";
SRedactSensitiveValues(logValue);
ASSERT_EQUALS(R"({"html":<REDACTED>})", logValue);
}
} __LibStuff;

0 comments on commit 2e7ae59

Please sign in to comment.