コード例 #1
0
	// No Content-Disposition field
	void testIsBodyPartAnAttachment3()
	{
		vmime::string data = "Content-Type: application/octet-stream\r\n\r\nFoo\r\n";

		vmime::shared_ptr <vmime::bodyPart> p = vmime::make_shared <vmime::bodyPart>();
		p->parse(data);

		VASSERT_EQ("1", true, vmime::attachmentHelper::isBodyPartAnAttachment(p));
	}
コード例 #2
0
	// Content-Disposition: attachment
	// No other field
	void testIsBodyPartAnAttachment1()
	{
		vmime::string data = "Content-Disposition: attachment\r\n\r\nFoo\r\n";

		vmime::shared_ptr <vmime::bodyPart> p = vmime::make_shared <vmime::bodyPart>();
		p->parse(data);

		VASSERT_EQ("1", true, vmime::attachmentHelper::isBodyPartAnAttachment(p));
	}
コード例 #3
0
ファイル: md5Test.cpp プロジェクト: 0xbda2d2f8/vmime
	void testRFC1321_5()
	{
		INIT_DIGEST(algo, "md5");

		algo->update("abcdefghijklmnopqrstuvwxyz");
		algo->finalize();

		VASSERT_EQ("*", "c3fcd3d76192e4007dfb496cca67e13b", algo->getHexDigest());
	}
コード例 #4
0
ファイル: mailboxTest.cpp プロジェクト: kisli/vmime
	void testSeparatorInComment() {

		vmime::addressList addrList;
		addrList.parse("aaa(comment,comment)@vmime.org, [email protected]");

		VASSERT_EQ("count", 2, addrList.getAddressCount());

		vmime::shared_ptr <vmime::mailbox> mbox1 =
			vmime::dynamicCast <vmime::mailbox>(addrList.getAddressAt(0));
		vmime::shared_ptr <vmime::mailbox> mbox2 =
			vmime::dynamicCast <vmime::mailbox>(addrList.getAddressAt(1));

		VASSERT_EQ("name1", vmime::text(), mbox1->getName());
		VASSERT_EQ("email1", "*****@*****.**", mbox1->getEmail());

		VASSERT_EQ("name2", vmime::text(), mbox2->getName());
		VASSERT_EQ("email2", "*****@*****.**", mbox2->getEmail());
	}
コード例 #5
0
ファイル: md5Test.cpp プロジェクト: 0xbda2d2f8/vmime
	void testRFC1321_3()
	{
		INIT_DIGEST(algo, "md5");

		algo->update("abc");
		algo->finalize();

		VASSERT_EQ("*", "900150983cd24fb0d6963f7d28e17f72", algo->getHexDigest());
	}
コード例 #6
0
	void testRFC1321_7()
	{
		INIT_DIGEST(algo, "md5");

		algo->update("12345678901234567890123456789012345678901234567890123456789012345678901234567890");
		algo->finalize();

		VASSERT_EQ("*", "57edf4a22be3c955ac49da2e2107b67a", algo->getHexDigest());
	}
コード例 #7
0
ファイル: md5Test.cpp プロジェクト: 0xbda2d2f8/vmime
	void testRFC1321_4()
	{
		INIT_DIGEST(algo, "md5");

		algo->update("message digest");
		algo->finalize();

		VASSERT_EQ("*", "f96b697d7cb7938d525a2f31aaf161d0", algo->getHexDigest());
	}
コード例 #8
0
	void testForcedNonEncoding()
	{
		// Testing long unbreakable and unencodable header
		vmime::relay r;
		r.parse(" from User (Ee9GMqZQ8t7IQwftfAFHd2KyScCYRrFSJ50tKEoXv2bVCG4HcPU80GGWiFabAvG77FekpGgF1h@[127.0.0.1]) by servername.hostname.com\n\t"
				"with esmtp id 1NGTS9-2C0sqG0; Fri, 4 Dec 2009 09:23:49 +0100");

		VASSERT_EQ("received.long", "from User\r\n (Ee9GMqZQ8t7IQwftfAFHd2KyScCYRrFSJ50tKEoXv2bVCG4HcPU80GGWiFabAvG77FekpGgF1h@[127.0.0.1])\r\n by servername.hostname.com with esmtp id 1NGTS9-2C0sqG0; Fri, 4 Dec 2009\r\n 09:23:49 +0100", r.generate(78));
	}
コード例 #9
0
ファイル: md5Test.cpp プロジェクト: 0xbda2d2f8/vmime
	void testRFC1321_2()
	{
		INIT_DIGEST(algo, "md5");

		algo->update("a");
		algo->finalize();

		VASSERT_EQ("*", "0cc175b9c0f1b6a831c399e269772661", algo->getHexDigest());
	}
コード例 #10
0
ファイル: mediaTypeTest.cpp プロジェクト: 0xbda2d2f8/vmime
	void testCopy()
	{
		vmime::mediaType t1("type/sub");

		VASSERT_EQ("eq1", "type", t1.getType());
		VASSERT_EQ("eq2", "sub", t1.getSubType());

		VASSERT("operator==", t1 == t1);
		VASSERT("clone", t1 == *vmime::clone(t1));

		VASSERT_EQ("eq3", "type", vmime::clone(t1)->getType());
		VASSERT_EQ("eq4", "sub", vmime::clone(t1)->getSubType());

		vmime::mediaType t2;
		t2.copyFrom(t1);

		VASSERT("copyFrom", t1 == t2);
	}
コード例 #11
0
ファイル: sha1Test.cpp プロジェクト: cloudstrifegit/vmime
	void testFIPS180_2()
	{
		INIT_DIGEST(algo, "sha1");

		algo->update("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq");
		algo->finalize();

		VASSERT_EQ("*", "84983e441c3bd26ebaae4aa1f95129e5e54670f1", algo->getHexDigest());
	}
コード例 #12
0
ファイル: stringUtilsTest.cpp プロジェクト: burner/vmime
	void testCountASCIIChars()
	{
		vmime::string str1("foo");
		VASSERT_EQ("1", static_cast <vmime::string::size_type>(3),
			stringUtils::countASCIIchars(str1.begin(), str1.end()));

		vmime::string str2("f=?oo");
		VASSERT_EQ("2", static_cast <vmime::string::size_type>(3 + 1),
			stringUtils::countASCIIchars(str2.begin(), str2.end()));

		vmime::string str3("foo\x7f");
		VASSERT_EQ("3", static_cast <vmime::string::size_type>(4),
			stringUtils::countASCIIchars(str3.begin(), str3.end()));

		vmime::string str4("foo\x80");
		VASSERT_EQ("4", static_cast <vmime::string::size_type>(3),
			stringUtils::countASCIIchars(str4.begin(), str4.end()));
	}
コード例 #13
0
	void testUpdate1()
	{
		INIT_DIGEST(algo, "md5");

		algo->update("");
		algo->finalize();

		VASSERT_EQ("*", "d41d8cd98f00b204e9800998ecf8427e", algo->getHexDigest());
	}
コード例 #14
0
	void testRFC1321_6()
	{
		INIT_DIGEST(algo, "md5");

		algo->update("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");
		algo->finalize();

		VASSERT_EQ("*", "d174ab98d277d9f5a5611c2c9f419d9f", algo->getHexDigest());
	}
コード例 #15
0
ファイル: attachmentHelperTest.cpp プロジェクト: burner/vmime
	void testGetBodyPartAttachmentMessage()
	{
		const vmime::string data =
"Subject: Test message\r\n"
"Content-Type: multipart/mixed; boundary=\"foo\"\r\n"
"\r\n"
"--foo\r\n"
"Content-Type: message/rfc822\r\n"
"\r\n"
"Subject: Attached message\r\n"
"\r\n"
"Attached message body\r\n"
"--foo\r\n"
"Content-Type: text/plain\r\n"
"\r\n"
"FooBar\r\n"
"--foo--\r\n";

		std::shared_ptr<vmime::message> msg =
			vmime::factory<vmime::message>::create();
		msg->parse(data);

		VASSERT_EQ("0", 2, msg->getBody()->getPartCount());

		std::shared_ptr<const vmime::attachment> att = vmime::attachmentHelper::
			getBodyPartAttachment(msg->getBody()->getPartAt(0));

		VASSERT("1", att != NULL);

		std::shared_ptr<const vmime::messageAttachment> msgAtt =
			// att.dynamicCast <const vmime::messageAttachment>(); TODO shared
			std::dynamic_pointer_cast<const vmime::messageAttachment>(att);

		VASSERT("2", msgAtt != NULL);

		std::shared_ptr<vmime::message> amsg = msgAtt->getMessage();
		std::shared_ptr<vmime::header> hdr = amsg->getHeader();

		// VASSERT_EQ("3", "Attached message",
		// hdr->Subject()->getValue().dynamicCast
		// <vmime::text>()->generate()); TODO shared
		VASSERT_EQ("3", "Attached message", std::dynamic_pointer_cast<vmime::text>(hdr->Subject()->getValue())->generate());
		VASSERT_EQ("4", "Attached message body", extractBodyContents(amsg));
	}
コード例 #16
0
ファイル: SMTPResponseTest.cpp プロジェクト: burner/vmime
	VMIME_TEST_LIST_END


	void testSingleLineResponse()
	{
		std::shared_ptr<testSocket> socket =
			vmime::factory<testSocket>::create();
		std::shared_ptr<vmime::net::timeoutHandler> toh =
			vmime::factory<testTimeoutHandler>::create();

		socket->localSend("123 Response Text\r\n");

		std::shared_ptr<vmime::net::smtp::SMTPResponse> resp =
			vmime::net::smtp::SMTPResponse::readResponse(socket, toh);

		VASSERT_EQ("Code", 123, resp->getCode());
		VASSERT_EQ("Lines", 1, resp->getLineCount());
		VASSERT_EQ("Text", "Response Text", resp->getText());
	}
コード例 #17
0
	void testGenerate()
	{
		// Simple parameter/value
		parameterizedHeaderField p1;
		p1.appendParameter(vmime::create <vmime::parameter>("param1", "value1"));

		VASSERT_EQ("1", "F: X; param1=value1", p1.generate());

		// Value that needs quoting (1/2)
		parameterizedHeaderField p2a;
		p2a.appendParameter(vmime::create <vmime::parameter>("param1", "value1a;value1b"));

		VASSERT_EQ("2a", "F: X; param1=\"value1a;value1b\"", p2a.generate());

		// Value that needs quoting (2/2)
		parameterizedHeaderField p2b;
		p2b.appendParameter(vmime::create <vmime::parameter>("param1", "va\\lue\"1"));

		VASSERT_EQ("2b", "F: X; param1=\"va\\\\lue\\\"1\"", p2b.generate());

		// Extended parameter with charset specifier
		parameterizedHeaderField p3;
		p3.appendParameter(vmime::create <vmime::parameter>("param1",
			vmime::word("value 1\xe9", vmime::charset("charset"))));

		VASSERT_EQ("3", "F: X; param1=\"value 1\";param1*=charset''value%201%E9", p3.generate());

		// Value that spans on multiple lines
		parameterizedHeaderField p4;
		p4.appendParameter(vmime::create <vmime::parameter>("param1",
			vmime::word("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
				    vmime::charset("charset"))));

		VASSERT_EQ("4", "F: X; \r\n "
			"param1=abcdefghijklm;\r\n "
			"param1*0*=charset''abc;\r\n "
			"param1*1*=defghijkl;\r\n "
			"param1*2*=mnopqrstu;\r\n "
			"param1*3*=vwxyzABCD;\r\n "
			"param1*4*=EFGHIJKLM;\r\n "
			"param1*5*=NOPQRSTUV;\r\n "
			"param1*6*=WXYZ", p4.generate(25));  // max line length = 25
	}
コード例 #18
0
	/** Tests Soft Line Breaks (RFC-2047/6.7(5). */
	void testQuotedPrintable_SoftLineBreaks()
	{
		VASSERT_EQ("1", "Now's the time=\r\n"
		                " for all folk =\r\n"
		                "to come to the=\r\n"
		                " aid of their =\r\n"
		                "country.",
		                encode("quoted-printable", "Now's the time for all folk "
		                                           "to come to the aid of their country.", 15));
	}
コード例 #19
0
ファイル: wordEncoderTest.cpp プロジェクト: 0xbda2d2f8/vmime
	void testEncodeQP_RFC2047()
	{
		// When Quoted-Printable is used, it should be RFC-2047 QP encoding
		vmime::wordEncoder we(
			"buffer\xc3\xa0 foo_bar",
			vmime::charset("utf-8"),
			vmime::wordEncoder::ENCODING_AUTO);

		VASSERT_EQ("1", "buffer=C3=A0_foo=5Fbar", we.getNextChunk(100));
	}
コード例 #20
0
ファイル: SMTPResponseTest.cpp プロジェクト: burner/vmime
	void testNoResponseText()
	{
		std::shared_ptr<testSocket> socket =
			vmime::factory<testSocket>::create();
		std::shared_ptr<vmime::net::timeoutHandler> toh =
			vmime::factory<testTimeoutHandler>::create(1);

		socket->localSend
		(
			"250\r\n"
		);

		std::shared_ptr<vmime::net::smtp::SMTPResponse> resp =
			vmime::net::smtp::SMTPResponse::readResponse(socket, toh);

		VASSERT_EQ("Code", 250, resp->getCode());
		VASSERT_EQ("Lines", 1, resp->getLineCount());
		VASSERT_EQ("Text", "", resp->getText());
	}
コード例 #21
0
	void testAddAttachmentMessage1()
	{
		const vmime::string data =
"Subject: Test message\r\n"
"Content-Type: text/plain\r\n"
"\r\n"
"Message body";

		vmime::ref <vmime::message> msg = vmime::create <vmime::message>();
		msg->parse(data);

		const vmime::string attData =
"Subject: Attached message\r\n"
"Content-Type: text/plain\r\n"
"Content-Transfer-Encoding: base64\r\n"
"\r\n"
"QXR0YWNoZWQgbWVzc2FnZSBib2R5";

		vmime::ref <vmime::message> amsg = vmime::create <vmime::message>();
		amsg->parse(attData);

		vmime::attachmentHelper::addAttachment(msg, amsg);

		VASSERT_EQ("1", "multipart/mixed[text/plain,message/rfc822]", getStructure(msg));
		VASSERT_EQ("2", "Message body", extractBodyContents(msg->getBody()->getPartAt(0)));

		// Ensure message has been encoded properly
		vmime::ref <const vmime::bodyPart> attPart = msg->getBody()->getPartAt(1);
		vmime::ref <const vmime::contentHandler> attCth = attPart->getBody()->getContents();

		vmime::string attDataOut;
		vmime::utility::outputStreamStringAdapter attDataOutOs(attDataOut);

		attCth->extract(attDataOutOs);

		vmime::ref <vmime::message> amsgOut = vmime::create <vmime::message>();
		amsgOut->parse(attDataOut);

		vmime::ref <vmime::header> hdr = amsgOut->getHeader();

		VASSERT_EQ("3", "Attached message", hdr->Subject()->getValue().dynamicCast <vmime::text>()->generate());
		VASSERT_EQ("4", "Attached message body", extractBodyContents(amsgOut));
	}
コード例 #22
0
	void testDetectFormat_Courier()
	{
		createMaildir(TEST_MAILDIR_COURIER, TEST_MAILDIRFILES_COURIER);

		vmime::ref <vmime::net::maildir::maildirStore> store =
			vmime::dynamicCast <vmime::net::maildir::maildirStore>(createAndConnectStore());

		VASSERT_EQ("*", "courier", store->getFormat()->getName());

		destroyMaildir();
	}
コード例 #23
0
	void testDetectFormat_KMail()
	{
		createMaildir(TEST_MAILDIR_KMAIL, TEST_MAILDIRFILES_KMAIL);

		vmime::ref <vmime::net::maildir::maildirStore> store =
			vmime::dynamicCast <vmime::net::maildir::maildirStore>(createAndConnectStore());

		VASSERT_EQ("*", "kmail", store->getFormat()->getName());

		destroyMaildir();
	}
コード例 #24
0
	void testGetLength_Encoded()
	{
		vmime::string data("foo=12=34=56bar");
		vmime::shared_ptr <vmime::utility::inputStream> stream =
			vmime::make_shared <vmime::utility::inputStreamStringAdapter>(data);

		vmime::streamContentHandler cth(stream, data.length(), vmime::encoding("quoted-printable"));

		// Reported length should be the length of encoded data
		VASSERT_EQ("length", 15, cth.getLength());
	}
コード例 #25
0
	void testGetLength()
	{
		vmime::string data("Test Data");
		vmime::shared_ptr <vmime::utility::inputStream> stream =
			vmime::make_shared <vmime::utility::inputStreamStringAdapter>(data);

		vmime::streamContentHandler cth(stream, data.length());

		VASSERT_FALSE("empty", cth.isEmpty());
		VASSERT_EQ("length", 9, cth.getLength());
	}
コード例 #26
0
	void testAddAttachment1()
	{
		vmime::string data =
"Content-Type: text/plain\r\n"
"\r\n"
"The text\r\n"
"";

		vmime::ref <vmime::message> msg = vmime::create <vmime::message>();
		msg->parse(data);

		vmime::ref <vmime::attachment> att = vmime::create <vmime::defaultAttachment>
			(vmime::create <vmime::stringContentHandler>("test"),
				vmime::mediaType("image/jpeg"));

		vmime::attachmentHelper::addAttachment(msg, att);

		VASSERT_EQ("1", "multipart/mixed[text/plain,image/jpeg]", getStructure(msg));
		VASSERT_EQ("2", "The text\r\n", extractBodyContents(msg->getBody()->getPartAt(0)));
	}
コード例 #27
0
	VMIME_TEST_LIST_END


	void testSingleLineResponse()
	{
		vmime::ref <testSocket> socket = vmime::create <testSocket>();
		vmime::ref <vmime::net::timeoutHandler> toh =
			vmime::create <testTimeoutHandler>();

		socket->localSend("123 Response Text\r\n");

		vmime::net::smtp::SMTPResponse::state responseState;

		vmime::ref <vmime::net::smtp::SMTPResponse> resp =
			vmime::net::smtp::SMTPResponse::readResponse(socket, toh, responseState);

		VASSERT_EQ("Code", 123, resp->getCode());
		VASSERT_EQ("Lines", 1, resp->getLineCount());
		VASSERT_EQ("Text", "Response Text", resp->getText());
	}
コード例 #28
0
	void testNoResponseText()
	{
		vmime::ref <testSocket> socket = vmime::create <testSocket>();
		vmime::ref <vmime::net::timeoutHandler> toh =
			vmime::create <testTimeoutHandler>(1);

		socket->localSend
		(
			"250\r\n"
		);

		vmime::net::smtp::SMTPResponse::state responseState;

		vmime::ref <vmime::net::smtp::SMTPResponse> resp =
			vmime::net::smtp::SMTPResponse::readResponse(socket, toh, responseState);

		VASSERT_EQ("Code", 250, resp->getCode());
		VASSERT_EQ("Lines", 1, resp->getLineCount());
		VASSERT_EQ("Text", "", resp->getText());
	}
コード例 #29
0
	void testGenerate()
	{
		vmime::emptyContentHandler cth;

		std::ostringstream oss;
		vmime::utility::outputStreamAdapter osa(oss);

		cth.generate(osa, vmime::encoding("base64"));

		VASSERT_EQ("generate", "", oss.str());
	}
コード例 #30
0
	void testExtractRaw()
	{
		vmime::emptyContentHandler cth;

		std::ostringstream oss;
		vmime::utility::outputStreamAdapter osa(oss);

		cth.extractRaw(osa);

		VASSERT_EQ("extractRaw", "", oss.str());
	}