Skip to content

Commit d6ec50c

Browse files
committed
MB-30303: Subdoc regression tests for backtick un-escaping issue
Regression tests for how KV-Engine subdoc API uses subjson to parse backticked escaped paths. (Note: MB-30303 is the 5.1.x backport of MB-30278). Change-Id: I42a144ba3f37c38d3e4ca0f8990652cda85011c2 Reviewed-on: http://review.couchbase.org/97313 Well-Formed: Build Bot <[email protected]> Tested-by: Build Bot <[email protected]> Reviewed-by: Jim Walker <[email protected]>
1 parent bbb1bc7 commit d6ec50c

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

tests/testapp/testapp_subdoc.cc

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2206,6 +2206,34 @@ TEST_P(McdTestappTest, SubdocUTF8ValTest) {
22062206
validate_object("dict", "{ \"key1\": \"Ẇ̴̷̦͔͖͚̝̟̋̽ͪ̾ͤ̈́ͯͮͮ̀͗̌ͭ̾͜h̨̥̞͖̬̠͍͖̘̹͎͌̇̂̃ͯͣ͗̆̌̑ͨ̍̊ͪ̆̾̆̚͟͞ȧ̛̰̞̗̞̬̣̹͎̰̝͍͈̮̖̘̫̤̟͆̈́̒͗ͦ̋̓̌̊̋͝ͅţ͒ͮ͋̋̔̽ͥ̂ͭ̒̉̔̃ͫ̌̆̆҉̹͙̟̩̖̩̹̳̜͚̜̜ ͎̲͕̺̔̿̀͒̈́̏̌ͬͫ͒͂ͩͦ̀͝â̢̡̘̫̮̞̩̰̎ͨ̾ͤ̈́͑̉̈ͧ͆̃ͩ͆̚͡ ̧̢̛̙͔̰̹̲̱͔̤̝͖̥͚͓̲̪̯̟̖̏͒̽ͬ̂ͫͩͭ͋̏͊̽͗͊̀ͭ̋͘c̵̴͐̉̇͂̋ͬ̇̃͊ͨ͗̆̄̊́͏̡̡̫̦̦͉̼̙̜͉̯̮̪̫͍̩̼̘̫̻͍o̸̷͕̭̼̺̤͖͚̯̪̥̘̪̼̝̩̮͕̥̟̐͒̏ͭͦͮ̒ͧ̔̉̅̂͜͢͡o̷̢̡͕̟͓̺͚̟̱̜̻͇̘͍̤͓̲ͣͫ̾͛͗̅̐̏͑͆͌̀͜ͅͅͅl̴̡̙̹͖̈̄̌͒ͣ͒̅̏̕ ͛̐̿͋ͦ͛͌̄ͫ̒ͪ͊̀ͤ̀̿͏̶̡҉҉̤͎͖v̸̵̱͇̲͎̩͚̩͈̙̜̳̞̭̯̩̻̮̪ͯ̋̔͗̃̊ͬͮ̄̃͛̂̒̍͘͘a̦̝͇̙̬̬̰̪͙̗̟͙̝̬͛͂͑ͣ̓͑̏ͤ̑̀̚̚͘l͊̔́͋̋ͫ̈́̿̈̉̀͏̡͍͇̲̙̺̮͠uͬ̄̋̔ͪͧͥ͛ͭ̏̅ͫ͊̚͏̧͈̠̱͇͉̦̫͎͠ę̸͔̯̭̤͕̱͈̖͖̯̭̞͈͖ͨ̑̌̓̈ͮ͂̆̀͟ͅ\" }");
22072207
}
22082208

2209+
// MB-30278: Perform a DICT_ADD followed by SD_GET to a path with backticks in
2210+
// them; to verify the path caching of un-escaped components is correctly reset
2211+
// between calls.
2212+
TEST_P(McdTestappTest, MB_30278_SubdocBacktickLookup) {
2213+
// Test DICT_ADD where the element key contains a literal backtick.
2214+
store_object("doc", "{}", /*JSON*/ true, /*compress*/ false);
2215+
// Add a key with literal backtick (which we escape by passing
2216+
// double-backtick)
2217+
EXPECT_SD_OK(BinprotSubdocCommand(
2218+
PROTOCOL_BINARY_CMD_SUBDOC_DICT_ADD, "doc", "key``", "\"value\""));
2219+
EXPECT_SD_GET("doc", "key``", "\"value\"");
2220+
validate_object("doc", R"({"key`":"value"})");
2221+
}
2222+
2223+
// MB-30278: Perform two DICT_ADD calls to paths with backticks in them;
2224+
// to verify the path caching of un-escaped components is correctly reset
2225+
// between calls.
2226+
TEST_P(McdTestappTest, MB_30278_SubdocBacktickDictAdd) {
2227+
store_object("doc", "{}", /*JSON*/ true, /*compress*/ false);
2228+
EXPECT_SD_OK(BinprotSubdocCommand(
2229+
PROTOCOL_BINARY_CMD_SUBDOC_DICT_ADD, "doc", "key``", "\"value\""));
2230+
EXPECT_SD_OK(BinprotSubdocCommand(PROTOCOL_BINARY_CMD_SUBDOC_DICT_ADD,
2231+
"doc",
2232+
"key2``",
2233+
"\"value2\""));
2234+
validate_object("doc", R"({"key`":"value","key2`":"value2"})");
2235+
}
2236+
22092237
// Tests how a single worker handles multiple "concurrent" connections
22102238
// performing operations.
22112239
class WorkerConcurrencyTest : public TestappTest {

tests/testapp/testapp_subdoc_multipath.cc

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,3 +608,28 @@ TEST_P(McdTestappTest, SubdocMultiMutation_AddDocFlagInavlidCas) {
608608
"56"});
609609
expect_subdoc_cmd(mutation, PROTOCOL_BINARY_RESPONSE_EINVAL, {});
610610
}
611+
612+
// MB-30278: Perform a multi-mutation with two paths with backticks in them.
613+
TEST_P(McdTestappTest, MB_30278_SubdocBacktickMultiMutation) {
614+
store_object("dict", "{}");
615+
616+
SubdocMultiMutationCmd mutation;
617+
mutation.key = "dict";
618+
mutation.specs.push_back({PROTOCOL_BINARY_CMD_SUBDOC_DICT_ADD,
619+
SUBDOC_FLAG_NONE,
620+
"key1``",
621+
"1"});
622+
mutation.specs.push_back({PROTOCOL_BINARY_CMD_SUBDOC_DICT_ADD,
623+
SUBDOC_FLAG_NONE,
624+
"key2``",
625+
"2"});
626+
mutation.specs.push_back({PROTOCOL_BINARY_CMD_SUBDOC_DICT_ADD,
627+
SUBDOC_FLAG_NONE,
628+
"key3``",
629+
"3"});
630+
expect_subdoc_cmd(mutation, PROTOCOL_BINARY_RESPONSE_SUCCESS, {});
631+
632+
validate_object("dict", R"({"key1`":1,"key2`":2,"key3`":3})");
633+
634+
delete_object("dict");
635+
}

0 commit comments

Comments
 (0)