diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2020-03-21 14:28:53 +0100 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2020-03-21 14:28:53 +0100 |
commit | 4480c7b7cc25135dc401d329c8d37396d35840b8 (patch) | |
tree | bb10ec7228fc99860b043bf8a5e4714ce3503fec /tests | |
parent | bf42a1ebc59cc019c343825d2be6761b57fc5d04 (diff) | |
download | weechat-4480c7b7cc25135dc401d329c8d37396d35840b8.zip |
irc: split AUTHENTICATE message in 400-byte chunks (closes #1459)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/plugins/irc/test-irc-message.cpp | 209 |
1 files changed, 209 insertions, 0 deletions
diff --git a/tests/unit/plugins/irc/test-irc-message.cpp b/tests/unit/plugins/irc/test-irc-message.cpp index 83aaada42..716f826bc 100644 --- a/tests/unit/plugins/irc/test-irc-message.cpp +++ b/tests/unit/plugins/irc/test-irc-message.cpp @@ -106,6 +106,53 @@ extern "C" "4:jkl TEST5:mno TEST6:pqr TEST7:stu TEST8:vwx TEST9:yz ABC:1 DEF:2 GHI:" \ "3 JKL:4 MNO:5 PQR:6 STU:7 VWX:8 YT:9 :are supported by this server" +#define STRING_200 "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCD" \ + "EFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVW" \ + "XYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOP" \ + "QR" + +#define STRING_400 "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCD" \ + "EFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVW" \ + "XYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ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OPQRSTUVWXYZABCDEFGHIJK" \ + "LMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCD" \ + "EFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVW" \ + "XYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOP" \ + "QRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHI" \ + "JKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZAB" \ + "CDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTU" \ + "VWXYZABCD" + #define WEE_CHECK_PARSE(__tags, __message_without_tags, __nick, __user, \ __host, __command, __channel, __arguments, \ __text, __pos_command, __pos_arguments, \ @@ -697,6 +744,168 @@ TEST(IrcMessage, Split) (const char *)hashtable_get (hashtable, "msg1")); hashtable_free (hashtable); + /* AUTHENTICATE with small content: no split */ + hashtable = irc_message_split (server, "AUTHENTICATE +"); + CHECK(hashtable); + LONGS_EQUAL(3, hashtable->items_count); + STRCMP_EQUAL("1", + (const char *)hashtable_get (hashtable, "count")); + STRCMP_EQUAL("AUTHENTICATE +", + (const char *)hashtable_get (hashtable, "msg1")); + STRCMP_EQUAL("+", + (const char *)hashtable_get (hashtable, "args1")); + hashtable_free (hashtable); + + /* AUTHENTICATE with small content: no split */ + hashtable = irc_message_split (server, "AUTHENTICATE ABCDEFGH"); + CHECK(hashtable); + LONGS_EQUAL(3, hashtable->items_count); + STRCMP_EQUAL("1", + (const char *)hashtable_get (hashtable, "count")); + STRCMP_EQUAL("AUTHENTICATE ABCDEFGH", + (const char *)hashtable_get (hashtable, "msg1")); + STRCMP_EQUAL("ABCDEFGH", + (const char *)hashtable_get (hashtable, "args1")); + hashtable_free (hashtable); + + /* AUTHENTICATE with small content: no split */ + hashtable = irc_message_split (server, "AUTHENTICATE " STRING_200); + CHECK(hashtable); + LONGS_EQUAL(3, hashtable->items_count); + STRCMP_EQUAL("1", + (const char *)hashtable_get (hashtable, "count")); + STRCMP_EQUAL("AUTHENTICATE " STRING_200, + (const char *)hashtable_get (hashtable, "msg1")); + STRCMP_EQUAL(STRING_200, + (const char *)hashtable_get (hashtable, "args1")); + hashtable_free (hashtable); + + /* AUTHENTICATE: 1 split */ + hashtable = irc_message_split (server, "AUTHENTICATE " STRING_400); + CHECK(hashtable); + LONGS_EQUAL(5, hashtable->items_count); + STRCMP_EQUAL("2", + (const char *)hashtable_get (hashtable, "count")); + STRCMP_EQUAL("AUTHENTICATE " STRING_400, + (const char *)hashtable_get (hashtable, "msg1")); + STRCMP_EQUAL(STRING_400, + (const char *)hashtable_get (hashtable, "args1")); + STRCMP_EQUAL("AUTHENTICATE +", + (const char *)hashtable_get (hashtable, "msg2")); + STRCMP_EQUAL("+", + (const char *)hashtable_get (hashtable, "args2")); + hashtable_free (hashtable); + + /* AUTHENTICATE: 3 splits */ + hashtable = irc_message_split (server, "AUTHENTICATE " STRING_1000); + CHECK(hashtable); + LONGS_EQUAL(7, hashtable->items_count); + STRCMP_EQUAL("3", + (const char *)hashtable_get (hashtable, "count")); + STRCMP_EQUAL("AUTHENTICATE ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRST" + "UVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZA" + "BCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGH" + "IJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNO" + "PQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUV" + "WXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABC" + "DEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJ", + (const char *)hashtable_get (hashtable, "msg1")); + STRCMP_EQUAL("ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFG" + "HIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMN" + "OPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTU" + "VWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZAB" + "CDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHI" + "JKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOP" + "QRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJ", + (const char *)hashtable_get (hashtable, "args1")); + STRCMP_EQUAL("AUTHENTICATE KLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCD" + "EFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJK" + "LMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQR" + "STUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXY" + "ZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEF" + "GHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLM" + "NOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRST", + (const char *)hashtable_get (hashtable, "msg2")); + STRCMP_EQUAL("KLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQ" + "RSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWX" + "YZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDE" + "FGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL" + "MNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRS" + "TUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ" + "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRST", + (const char *)hashtable_get (hashtable, "args2")); + STRCMP_EQUAL("AUTHENTICATE UVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMN" + "OPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTU" + "VWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZAB" + "CDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL", + (const char *)hashtable_get (hashtable, "msg3")); + STRCMP_EQUAL("UVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZA" + "BCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGH" + "IJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNO" + "PQRSTUVWXYZABCDEFGHIJKL", + (const char *)hashtable_get (hashtable, "args3")); + hashtable_free (hashtable); + + /* AUTHENTICATE: 4 splits */ + hashtable = irc_message_split (server, "AUTHENTICATE " STRING_1200); + CHECK(hashtable); + LONGS_EQUAL(9, hashtable->items_count); + STRCMP_EQUAL("4", + (const char *)hashtable_get (hashtable, "count")); + STRCMP_EQUAL("AUTHENTICATE ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRST" + "UVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZA" + "BCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGH" + "IJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNO" + "PQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUV" + "WXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABC" + "DEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJ", + (const char *)hashtable_get (hashtable, "msg1")); + STRCMP_EQUAL("ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFG" + "HIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMN" + "OPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTU" + "VWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZAB" + "CDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHI" + "JKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOP" + "QRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJ", + (const char *)hashtable_get (hashtable, "args1")); + STRCMP_EQUAL("AUTHENTICATE KLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCD" + "EFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJK" + "LMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQR" + "STUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXY" + "ZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEF" + "GHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLM" + "NOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRST", + (const char *)hashtable_get (hashtable, "msg2")); + STRCMP_EQUAL("KLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQ" + "RSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWX" + "YZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDE" + "FGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL" + "MNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRS" + "TUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ" + "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRST", + (const char *)hashtable_get (hashtable, "args2")); + STRCMP_EQUAL("AUTHENTICATE UVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMN" + "OPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTU" + "VWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZAB" + "CDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHI" + "JKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOP" + "QRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVW" + "XYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCD", + (const char *)hashtable_get (hashtable, "msg3")); + STRCMP_EQUAL("UVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZA" + "BCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGH" + "IJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNO" + "PQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUV" + "WXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABC" + "DEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJ" + "KLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCD", + (const char *)hashtable_get (hashtable, "args3")); + STRCMP_EQUAL("AUTHENTICATE +", + (const char *)hashtable_get (hashtable, "msg4")); + STRCMP_EQUAL("+", + (const char *)hashtable_get (hashtable, "args4")); + hashtable_free (hashtable); + /* ISON with small content: no split */ hashtable = irc_message_split (server, "ISON :nick1 nick2"); CHECK(hashtable); |