Mercurial > thymian
comparison 3rdparty/vmime/tests/net/imap/IMAPCommandTest.cpp @ 0:a4671277546c tip
created the repository for the thymian project
| author | ferencd |
|---|---|
| date | Tue, 17 Aug 2021 11:19:54 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:a4671277546c |
|---|---|
| 1 // | |
| 2 // VMime library (http://www.vmime.org) | |
| 3 // Copyright (C) 2002-2014 Vincent Richard <vincent@vmime.org> | |
| 4 // | |
| 5 // This program is free software; you can redistribute it and/or | |
| 6 // modify it under the terms of the GNU General Public License as | |
| 7 // published by the Free Software Foundation; either version 3 of | |
| 8 // the License, or (at your option) any later version. | |
| 9 // | |
| 10 // This program is distributed in the hope that it will be useful, | |
| 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 13 // General Public License for more details. | |
| 14 // | |
| 15 // You should have received a copy of the GNU General Public License along | |
| 16 // with this program; if not, write to the Free Software Foundation, Inc., | |
| 17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
| 18 // | |
| 19 // Linking this library statically or dynamically with other modules is making | |
| 20 // a combined work based on this library. Thus, the terms and conditions of | |
| 21 // the GNU General Public License cover the whole combination. | |
| 22 // | |
| 23 | |
| 24 #include "tests/testUtils.hpp" | |
| 25 | |
| 26 #include "vmime/net/imap/IMAPCommand.hpp" | |
| 27 #include "vmime/net/imap/IMAPStore.hpp" | |
| 28 #include "vmime/net/imap/IMAPConnection.hpp" | |
| 29 | |
| 30 | |
| 31 using namespace vmime::net::imap; | |
| 32 | |
| 33 | |
| 34 VMIME_TEST_SUITE_BEGIN(IMAPCommandTest) | |
| 35 | |
| 36 VMIME_TEST_LIST_BEGIN | |
| 37 VMIME_TEST(testCreateCommand) | |
| 38 VMIME_TEST(testCreateCommandParams) | |
| 39 VMIME_TEST(testLOGIN) | |
| 40 VMIME_TEST(testAUTHENTICATE) | |
| 41 VMIME_TEST(testAUTHENTICATE_InitialResponse) | |
| 42 VMIME_TEST(testLIST) | |
| 43 VMIME_TEST(testSELECT) | |
| 44 VMIME_TEST(testSTATUS) | |
| 45 VMIME_TEST(testCREATE) | |
| 46 VMIME_TEST(testDELETE) | |
| 47 VMIME_TEST(testRENAME) | |
| 48 VMIME_TEST(testFETCH) | |
| 49 VMIME_TEST(testSTORE) | |
| 50 VMIME_TEST(testAPPEND) | |
| 51 VMIME_TEST(testCOPY) | |
| 52 VMIME_TEST(testSEARCH) | |
| 53 VMIME_TEST(testSTARTTLS) | |
| 54 VMIME_TEST(testCAPABILITY) | |
| 55 VMIME_TEST(testNOOP) | |
| 56 VMIME_TEST(testEXPUNGE) | |
| 57 VMIME_TEST(testCLOSE) | |
| 58 VMIME_TEST(testLOGOUT) | |
| 59 VMIME_TEST(testSend) | |
| 60 VMIME_TEST_LIST_END | |
| 61 | |
| 62 | |
| 63 void testCreateCommand() | |
| 64 { | |
| 65 vmime::shared_ptr <IMAPCommand> cmd = IMAPCommand::createCommand("MY_COMMAND"); | |
| 66 | |
| 67 VASSERT_NOT_NULL("Not null", cmd); | |
| 68 VASSERT_EQ("Text", "MY_COMMAND", cmd->getText()); | |
| 69 } | |
| 70 | |
| 71 void testCreateCommandParams() | |
| 72 { | |
| 73 vmime::shared_ptr <IMAPCommand> cmd = IMAPCommand::createCommand("MY_COMMAND param1 param2"); | |
| 74 | |
| 75 VASSERT_NOT_NULL("Not null", cmd); | |
| 76 VASSERT_EQ("Text", "MY_COMMAND param1 param2", cmd->getText()); | |
| 77 } | |
| 78 | |
| 79 void testLOGIN() | |
| 80 { | |
| 81 vmime::shared_ptr <IMAPCommand> cmd = IMAPCommand::LOGIN("username", "password"); | |
| 82 | |
| 83 VASSERT_NOT_NULL("Not null", cmd); | |
| 84 VASSERT_EQ("Text", "LOGIN username password", cmd->getText()); | |
| 85 VASSERT_EQ("Trace Text", "LOGIN {username} {password}", cmd->getTraceText()); | |
| 86 } | |
| 87 | |
| 88 void testAUTHENTICATE() | |
| 89 { | |
| 90 vmime::shared_ptr <IMAPCommand> cmd = IMAPCommand::AUTHENTICATE("saslmechanism"); | |
| 91 | |
| 92 VASSERT_NOT_NULL("Not null", cmd); | |
| 93 VASSERT_EQ("Text", "AUTHENTICATE saslmechanism", cmd->getText()); | |
| 94 } | |
| 95 | |
| 96 void testAUTHENTICATE_InitialResponse() | |
| 97 { | |
| 98 vmime::shared_ptr <IMAPCommand> cmd = IMAPCommand::AUTHENTICATE("saslmechanism", "initial-response"); | |
| 99 | |
| 100 VASSERT_NOT_NULL("Not null", cmd); | |
| 101 VASSERT_EQ("Text", "AUTHENTICATE saslmechanism initial-response", cmd->getText()); | |
| 102 } | |
| 103 | |
| 104 void testLIST() | |
| 105 { | |
| 106 vmime::shared_ptr <IMAPCommand> cmd = IMAPCommand::LIST("ref-name", "mailbox-name"); | |
| 107 | |
| 108 VASSERT_NOT_NULL("Not null", cmd); | |
| 109 VASSERT_EQ("Text", "LIST ref-name mailbox-name", cmd->getText()); | |
| 110 | |
| 111 vmime::shared_ptr <IMAPCommand> cmdQuote = IMAPCommand::LIST("ref name", "mailbox-name"); | |
| 112 | |
| 113 VASSERT_NOT_NULL("Not null", cmdQuote); | |
| 114 VASSERT_EQ("Text", "LIST \"ref name\" mailbox-name", cmdQuote->getText()); | |
| 115 } | |
| 116 | |
| 117 void testSELECT() | |
| 118 { | |
| 119 std::vector <vmime::string> params; | |
| 120 params.push_back("param-1"); | |
| 121 params.push_back("param-2"); | |
| 122 | |
| 123 | |
| 124 vmime::shared_ptr <IMAPCommand> cmdRO = IMAPCommand::SELECT | |
| 125 (/* readOnly */ true, "mailbox-name", std::vector <vmime::string>()); | |
| 126 | |
| 127 VASSERT_NOT_NULL("Not null", cmdRO); | |
| 128 VASSERT_EQ("Text", "EXAMINE mailbox-name", cmdRO->getText()); | |
| 129 | |
| 130 vmime::shared_ptr <IMAPCommand> cmdROQuote = IMAPCommand::SELECT | |
| 131 (/* readOnly */ true, "mailbox name", std::vector <vmime::string>()); | |
| 132 | |
| 133 VASSERT_NOT_NULL("Not null", cmdROQuote); | |
| 134 VASSERT_EQ("Text", "EXAMINE \"mailbox name\"", cmdROQuote->getText()); | |
| 135 | |
| 136 | |
| 137 vmime::shared_ptr <IMAPCommand> cmdRW = IMAPCommand::SELECT | |
| 138 (/* readOnly */ false, "mailbox-name", std::vector <vmime::string>()); | |
| 139 | |
| 140 VASSERT_NOT_NULL("Not null", cmdRW); | |
| 141 VASSERT_EQ("Text", "SELECT mailbox-name", cmdRW->getText()); | |
| 142 | |
| 143 vmime::shared_ptr <IMAPCommand> cmdRWParams = IMAPCommand::SELECT | |
| 144 (/* readOnly */ false, "mailbox-name", params); | |
| 145 | |
| 146 VASSERT_NOT_NULL("Not null", cmdRWParams); | |
| 147 VASSERT_EQ("Text", "SELECT mailbox-name (param-1 param-2)", cmdRWParams->getText()); | |
| 148 | |
| 149 vmime::shared_ptr <IMAPCommand> cmdRWQuote = IMAPCommand::SELECT | |
| 150 (/* readOnly */ false, "mailbox name", std::vector <vmime::string>()); | |
| 151 | |
| 152 VASSERT_NOT_NULL("Not null", cmdRWQuote); | |
| 153 VASSERT_EQ("Text", "SELECT \"mailbox name\"", cmdRWQuote->getText()); | |
| 154 } | |
| 155 | |
| 156 void testSTATUS() | |
| 157 { | |
| 158 std::vector <vmime::string> attribs; | |
| 159 attribs.push_back("attrib-1"); | |
| 160 attribs.push_back("attrib-2"); | |
| 161 | |
| 162 | |
| 163 vmime::shared_ptr <IMAPCommand> cmd = | |
| 164 IMAPCommand::STATUS("mailbox-name", attribs); | |
| 165 | |
| 166 VASSERT_NOT_NULL("Not null", cmd); | |
| 167 VASSERT_EQ("Text", "STATUS mailbox-name (attrib-1 attrib-2)", cmd->getText()); | |
| 168 | |
| 169 | |
| 170 vmime::shared_ptr <IMAPCommand> cmdQuote = | |
| 171 IMAPCommand::STATUS("mailbox name", attribs); | |
| 172 | |
| 173 VASSERT_NOT_NULL("Not null", cmdQuote); | |
| 174 VASSERT_EQ("Text", "STATUS \"mailbox name\" (attrib-1 attrib-2)", cmdQuote->getText()); | |
| 175 } | |
| 176 | |
| 177 void testCREATE() | |
| 178 { | |
| 179 std::vector <vmime::string> params; | |
| 180 params.push_back("param-1"); | |
| 181 params.push_back("param-2"); | |
| 182 | |
| 183 | |
| 184 vmime::shared_ptr <IMAPCommand> cmd = | |
| 185 IMAPCommand::CREATE("mailbox-name", params); | |
| 186 | |
| 187 VASSERT_NOT_NULL("Not null", cmd); | |
| 188 VASSERT_EQ("Text", "CREATE mailbox-name (param-1 param-2)", cmd->getText()); | |
| 189 | |
| 190 | |
| 191 vmime::shared_ptr <IMAPCommand> cmdQuote = | |
| 192 IMAPCommand::CREATE("mailbox name", params); | |
| 193 | |
| 194 VASSERT_NOT_NULL("Not null", cmdQuote); | |
| 195 VASSERT_EQ("Text", "CREATE \"mailbox name\" (param-1 param-2)", cmdQuote->getText()); | |
| 196 | |
| 197 | |
| 198 vmime::shared_ptr <IMAPCommand> cmdNoParam = | |
| 199 IMAPCommand::CREATE("mailbox-name", std::vector <vmime::string>()); | |
| 200 | |
| 201 VASSERT_NOT_NULL("Not null", cmdNoParam); | |
| 202 VASSERT_EQ("Text", "CREATE mailbox-name", cmdNoParam->getText()); | |
| 203 } | |
| 204 | |
| 205 void testDELETE() | |
| 206 { | |
| 207 vmime::shared_ptr <IMAPCommand> cmd = | |
| 208 IMAPCommand::DELETE("mailbox-name"); | |
| 209 | |
| 210 VASSERT_NOT_NULL("Not null", cmd); | |
| 211 VASSERT_EQ("Text", "DELETE mailbox-name", cmd->getText()); | |
| 212 | |
| 213 | |
| 214 vmime::shared_ptr <IMAPCommand> cmdQuote = | |
| 215 IMAPCommand::DELETE("mailbox name"); | |
| 216 | |
| 217 VASSERT_NOT_NULL("Not null", cmdQuote); | |
| 218 VASSERT_EQ("Text", "DELETE \"mailbox name\"", cmdQuote->getText()); | |
| 219 } | |
| 220 | |
| 221 void testRENAME() | |
| 222 { | |
| 223 vmime::shared_ptr <IMAPCommand> cmd = | |
| 224 IMAPCommand::RENAME("mailbox-name", "new-mailbox-name"); | |
| 225 | |
| 226 VASSERT_NOT_NULL("Not null", cmd); | |
| 227 VASSERT_EQ("Text", "RENAME mailbox-name new-mailbox-name", cmd->getText()); | |
| 228 | |
| 229 | |
| 230 vmime::shared_ptr <IMAPCommand> cmdQuote = | |
| 231 IMAPCommand::RENAME("mailbox name", "new mailbox name"); | |
| 232 | |
| 233 VASSERT_NOT_NULL("Not null", cmdQuote); | |
| 234 VASSERT_EQ("Text", "RENAME \"mailbox name\" \"new mailbox name\"", cmdQuote->getText()); | |
| 235 } | |
| 236 | |
| 237 void testFETCH() | |
| 238 { | |
| 239 std::vector <vmime::string> params; | |
| 240 params.push_back("param-1"); | |
| 241 params.push_back("param-2"); | |
| 242 | |
| 243 | |
| 244 vmime::shared_ptr <IMAPCommand> cmdNum = | |
| 245 IMAPCommand::FETCH(vmime::net::messageSet::byNumber(42), params); | |
| 246 | |
| 247 VASSERT_NOT_NULL("Not null", cmdNum); | |
| 248 VASSERT_EQ("Text", "FETCH 42 (param-1 param-2)", cmdNum->getText()); | |
| 249 | |
| 250 | |
| 251 vmime::shared_ptr <IMAPCommand> cmdNums = | |
| 252 IMAPCommand::FETCH(vmime::net::messageSet::byNumber(42, 47), params); | |
| 253 | |
| 254 VASSERT_NOT_NULL("Not null", cmdNums); | |
| 255 VASSERT_EQ("Text", "FETCH 42:47 (param-1 param-2)", cmdNums->getText()); | |
| 256 | |
| 257 | |
| 258 vmime::shared_ptr <IMAPCommand> cmdUID = | |
| 259 IMAPCommand::FETCH(vmime::net::messageSet::byUID(42), params); | |
| 260 | |
| 261 VASSERT_NOT_NULL("Not null", cmdUID); | |
| 262 VASSERT_EQ("Text", "UID FETCH 42 (param-1 param-2)", cmdUID->getText()); | |
| 263 | |
| 264 | |
| 265 vmime::shared_ptr <IMAPCommand> cmdUIDs = | |
| 266 IMAPCommand::FETCH(vmime::net::messageSet::byUID(42, 47), params); | |
| 267 | |
| 268 VASSERT_NOT_NULL("Not null", cmdUIDs); | |
| 269 VASSERT_EQ("Text", "UID FETCH 42:47 (param-1 param-2)", cmdUIDs->getText()); | |
| 270 } | |
| 271 | |
| 272 void testSTORE() | |
| 273 { | |
| 274 std::vector <vmime::string> flags; | |
| 275 flags.push_back("flag-1"); | |
| 276 flags.push_back("flag-2"); | |
| 277 | |
| 278 | |
| 279 vmime::shared_ptr <IMAPCommand> cmdNum = IMAPCommand::STORE | |
| 280 (vmime::net::messageSet::byNumber(42), vmime::net::message::FLAG_MODE_SET, flags); | |
| 281 | |
| 282 VASSERT_NOT_NULL("Not null", cmdNum); | |
| 283 VASSERT_EQ("Text", "STORE 42 FLAGS (flag-1 flag-2)", cmdNum->getText()); | |
| 284 | |
| 285 | |
| 286 vmime::shared_ptr <IMAPCommand> cmdNums = IMAPCommand::STORE | |
| 287 (vmime::net::messageSet::byNumber(42, 47), vmime::net::message::FLAG_MODE_SET, flags); | |
| 288 | |
| 289 VASSERT_NOT_NULL("Not null", cmdNums); | |
| 290 VASSERT_EQ("Text", "STORE 42:47 FLAGS (flag-1 flag-2)", cmdNums->getText()); | |
| 291 | |
| 292 | |
| 293 vmime::shared_ptr <IMAPCommand> cmdUID = IMAPCommand::STORE | |
| 294 (vmime::net::messageSet::byUID(42), vmime::net::message::FLAG_MODE_SET, flags); | |
| 295 | |
| 296 VASSERT_NOT_NULL("Not null", cmdUID); | |
| 297 VASSERT_EQ("Text", "UID STORE 42 FLAGS (flag-1 flag-2)", cmdUID->getText()); | |
| 298 | |
| 299 | |
| 300 vmime::shared_ptr <IMAPCommand> cmdUIDs = IMAPCommand::STORE | |
| 301 (vmime::net::messageSet::byUID(42, 47), vmime::net::message::FLAG_MODE_SET, flags); | |
| 302 | |
| 303 VASSERT_NOT_NULL("Not null", cmdUIDs); | |
| 304 VASSERT_EQ("Text", "UID STORE 42:47 FLAGS (flag-1 flag-2)", cmdUIDs->getText()); | |
| 305 | |
| 306 | |
| 307 vmime::shared_ptr <IMAPCommand> cmdAdd = IMAPCommand::STORE | |
| 308 (vmime::net::messageSet::byUID(42, 47), vmime::net::message::FLAG_MODE_ADD, flags); | |
| 309 | |
| 310 VASSERT_NOT_NULL("Not null", cmdAdd); | |
| 311 VASSERT_EQ("Text", "UID STORE 42:47 +FLAGS (flag-1 flag-2)", cmdAdd->getText()); | |
| 312 | |
| 313 | |
| 314 vmime::shared_ptr <IMAPCommand> cmdRem = IMAPCommand::STORE | |
| 315 (vmime::net::messageSet::byUID(42, 47), vmime::net::message::FLAG_MODE_REMOVE, flags); | |
| 316 | |
| 317 VASSERT_NOT_NULL("Not null", cmdRem); | |
| 318 VASSERT_EQ("Text", "UID STORE 42:47 -FLAGS (flag-1 flag-2)", cmdRem->getText()); | |
| 319 } | |
| 320 | |
| 321 void testAPPEND() | |
| 322 { | |
| 323 std::vector <vmime::string> flags; | |
| 324 flags.push_back("flag-1"); | |
| 325 flags.push_back("flag-2"); | |
| 326 | |
| 327 | |
| 328 vmime::shared_ptr <IMAPCommand> cmd = | |
| 329 IMAPCommand::APPEND("mailbox-name", flags, /* date */ NULL, 1234); | |
| 330 | |
| 331 VASSERT_NOT_NULL("Not null", cmd); | |
| 332 VASSERT_EQ("Text", "APPEND mailbox-name (flag-1 flag-2) {1234}", cmd->getText()); | |
| 333 | |
| 334 | |
| 335 vmime::shared_ptr <IMAPCommand> cmdQuote = | |
| 336 IMAPCommand::APPEND("mailbox name", flags, /* date */ NULL, 1234); | |
| 337 | |
| 338 VASSERT_NOT_NULL("Not null", cmdQuote); | |
| 339 VASSERT_EQ("Text", "APPEND \"mailbox name\" (flag-1 flag-2) {1234}", cmdQuote->getText()); | |
| 340 | |
| 341 | |
| 342 vmime::datetime date(2014, 3, 15, 23, 11, 47, vmime::datetime::GMT2); | |
| 343 vmime::shared_ptr <IMAPCommand> cmdDate = | |
| 344 IMAPCommand::APPEND("mailbox name", flags, &date, 1234); | |
| 345 | |
| 346 VASSERT_NOT_NULL("Not null", cmdDate); | |
| 347 VASSERT_EQ("Text", "APPEND \"mailbox name\" (flag-1 flag-2) \"15-Mar-2014 23:11:47 +0200\" {1234}", cmdDate->getText()); | |
| 348 } | |
| 349 | |
| 350 void testCOPY() | |
| 351 { | |
| 352 vmime::shared_ptr <IMAPCommand> cmdNum = | |
| 353 IMAPCommand::COPY(vmime::net::messageSet::byNumber(42), "mailbox-name"); | |
| 354 | |
| 355 VASSERT_NOT_NULL("Not null", cmdNum); | |
| 356 VASSERT_EQ("Text", "COPY 42 mailbox-name", cmdNum->getText()); | |
| 357 | |
| 358 | |
| 359 vmime::shared_ptr <IMAPCommand> cmdNums = | |
| 360 IMAPCommand::COPY(vmime::net::messageSet::byNumber(42, 47), "mailbox-name"); | |
| 361 | |
| 362 VASSERT_NOT_NULL("Not null", cmdNums); | |
| 363 VASSERT_EQ("Text", "COPY 42:47 mailbox-name", cmdNums->getText()); | |
| 364 | |
| 365 | |
| 366 vmime::shared_ptr <IMAPCommand> cmdUID = | |
| 367 IMAPCommand::COPY(vmime::net::messageSet::byUID(42), "mailbox-name"); | |
| 368 | |
| 369 VASSERT_NOT_NULL("Not null", cmdUID); | |
| 370 VASSERT_EQ("Text", "UID COPY 42 mailbox-name", cmdUID->getText()); | |
| 371 | |
| 372 | |
| 373 vmime::shared_ptr <IMAPCommand> cmdUIDs = | |
| 374 IMAPCommand::COPY(vmime::net::messageSet::byUID(42, 47), "mailbox-name"); | |
| 375 | |
| 376 VASSERT_NOT_NULL("Not null", cmdUIDs); | |
| 377 VASSERT_EQ("Text", "UID COPY 42:47 mailbox-name", cmdUIDs->getText()); | |
| 378 | |
| 379 | |
| 380 vmime::shared_ptr <IMAPCommand> cmdQuote = | |
| 381 IMAPCommand::COPY(vmime::net::messageSet::byNumber(42, 47), "mailbox name"); | |
| 382 | |
| 383 VASSERT_NOT_NULL("Not null", cmdQuote); | |
| 384 VASSERT_EQ("Text", "COPY 42:47 \"mailbox name\"", cmdQuote->getText()); | |
| 385 } | |
| 386 | |
| 387 void testSEARCH() | |
| 388 { | |
| 389 std::vector <vmime::string> searchKeys; | |
| 390 searchKeys.push_back("search-key-1"); | |
| 391 searchKeys.push_back("search-key-2"); | |
| 392 | |
| 393 vmime::shared_ptr <IMAPCommand> cmd = | |
| 394 IMAPCommand::SEARCH(searchKeys, /* charset */ NULL); | |
| 395 | |
| 396 VASSERT_NOT_NULL("Not null", cmd); | |
| 397 VASSERT_EQ("Text", "SEARCH search-key-1 search-key-2", cmd->getText()); | |
| 398 | |
| 399 | |
| 400 vmime::charset cset("test-charset"); | |
| 401 | |
| 402 vmime::shared_ptr <IMAPCommand> cmdCset = | |
| 403 IMAPCommand::SEARCH(searchKeys, &cset); | |
| 404 | |
| 405 VASSERT_NOT_NULL("Not null", cmdCset); | |
| 406 VASSERT_EQ("Text", "SEARCH CHARSET test-charset search-key-1 search-key-2", cmdCset->getText()); | |
| 407 } | |
| 408 | |
| 409 void testSTARTTLS() | |
| 410 { | |
| 411 vmime::shared_ptr <IMAPCommand> cmd = IMAPCommand::STARTTLS(); | |
| 412 | |
| 413 VASSERT_NOT_NULL("Not null", cmd); | |
| 414 VASSERT_EQ("Text", "STARTTLS", cmd->getText()); | |
| 415 } | |
| 416 | |
| 417 void testCAPABILITY() | |
| 418 { | |
| 419 vmime::shared_ptr <IMAPCommand> cmd = IMAPCommand::CAPABILITY(); | |
| 420 | |
| 421 VASSERT_NOT_NULL("Not null", cmd); | |
| 422 VASSERT_EQ("Text", "CAPABILITY", cmd->getText()); | |
| 423 } | |
| 424 | |
| 425 void testNOOP() | |
| 426 { | |
| 427 vmime::shared_ptr <IMAPCommand> cmd = IMAPCommand::NOOP(); | |
| 428 | |
| 429 VASSERT_NOT_NULL("Not null", cmd); | |
| 430 VASSERT_EQ("Text", "NOOP", cmd->getText()); | |
| 431 } | |
| 432 | |
| 433 void testEXPUNGE() | |
| 434 { | |
| 435 vmime::shared_ptr <IMAPCommand> cmd = IMAPCommand::EXPUNGE(); | |
| 436 | |
| 437 VASSERT_NOT_NULL("Not null", cmd); | |
| 438 VASSERT_EQ("Text", "EXPUNGE", cmd->getText()); | |
| 439 } | |
| 440 | |
| 441 void testCLOSE() | |
| 442 { | |
| 443 vmime::shared_ptr <IMAPCommand> cmd = IMAPCommand::CLOSE(); | |
| 444 | |
| 445 VASSERT_NOT_NULL("Not null", cmd); | |
| 446 VASSERT_EQ("Text", "CLOSE", cmd->getText()); | |
| 447 } | |
| 448 | |
| 449 void testLOGOUT() | |
| 450 { | |
| 451 vmime::shared_ptr <IMAPCommand> cmd = IMAPCommand::LOGOUT(); | |
| 452 | |
| 453 VASSERT_NOT_NULL("Not null", cmd); | |
| 454 VASSERT_EQ("Text", "LOGOUT", cmd->getText()); | |
| 455 } | |
| 456 | |
| 457 void testSend() | |
| 458 { | |
| 459 vmime::shared_ptr <IMAPCommand> cmd = IMAPCommand::createCommand("MY_COMMAND param1 param2"); | |
| 460 | |
| 461 vmime::shared_ptr <vmime::net::session> sess = | |
| 462 vmime::make_shared <vmime::net::session>(); | |
| 463 | |
| 464 vmime::shared_ptr <vmime::security::authenticator> auth = | |
| 465 vmime::make_shared <vmime::security::defaultAuthenticator>(); | |
| 466 | |
| 467 vmime::shared_ptr <IMAPStore> store = | |
| 468 vmime::make_shared <IMAPStore>(sess, auth, /* secured */ false); | |
| 469 | |
| 470 vmime::shared_ptr <IMAPConnection> conn = | |
| 471 vmime::make_shared <IMAPConnection>(store, auth); | |
| 472 | |
| 473 vmime::shared_ptr <testSocket> sok = vmime::make_shared <testSocket>(); | |
| 474 conn->setSocket(sok); | |
| 475 | |
| 476 cmd->send(conn); | |
| 477 | |
| 478 vmime::string response; | |
| 479 sok->localReceive(response); | |
| 480 | |
| 481 VASSERT_EQ("Sent buffer", vmime::string(*conn->getTag()) + " MY_COMMAND param1 param2\r\n", response); | |
| 482 } | |
| 483 | |
| 484 VMIME_TEST_SUITE_END |
