start branch ENGINE-322 ENGINE-322
authorRoker <roker@pep-project.org>
Tue, 26 Dec 2017 22:55:32 +0100
branchENGINE-322
changeset 233223ed7bbd53f4
parent 2331 71c86f7d4c77
child 2333 10a26f0f071d
start branch ENGINE-322
test/message_api_test.cc
     1.1 --- a/test/message_api_test.cc	Wed Dec 13 15:35:12 2017 +0100
     1.2 +++ b/test/message_api_test.cc	Tue Dec 26 22:55:32 2017 +0100
     1.3 @@ -12,8 +12,89 @@
     1.4  
     1.5  using namespace std;
     1.6  
     1.7 +void test_MIME_decrypt_message()
     1.8 +{
     1.9 +	const std::string mimetext =
    1.10 +		"Return-Path: <roker@pep-project.org>\r\n"
    1.11 +		"X-Original-To: roker@pep-project.org\r\n"
    1.12 +		"Delivered-To: roker@pep-project.org\r\n"
    1.13 +		"Received: from localhost (localhost [127.0.0.1])\r\n"
    1.14 +		"	by dragon.pibit.ch (Postfix) with ESMTP id C4FF8171C055\r\n"
    1.15 +		"	for <roker@pep-project.org>; Tue, 26 Dec 2017 17:14:42 +0100 (CET)\r\n"
    1.16 +		"Received: from dragon.pibit.ch ([127.0.0.1])\r\n"
    1.17 +		"	by localhost (dragon.pibit.ch [127.0.0.1]) (amavisd-new, port 10024)\r\n"
    1.18 +		"	with ESMTP id GojZqayOfeAq for <roker@pep-project.org>;\r\n"
    1.19 +		"	Tue, 26 Dec 2017 17:14:39 +0100 (CET)\r\n"
    1.20 +		"To: Lars Rohwedder <roker@pep-project.org>\r\n"
    1.21 +		"From: Lars Rohwedder <roker@pep-project.org>\r\n"
    1.22 +		"Subject: Test mail PGP/INLINE\r\n"
    1.23 +		"Message-ID: <8fff4ca8-a8aa-f016-a7fd-39c98a9a4f43@pep-project.org>\r\n"
    1.24 +		"Date: Tue, 26 Dec 2017 17:14:38 +0100\r\n"
    1.25 +		"User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:52.0)\r\n"
    1.26 +		" Gecko/20100101 Thunderbird/52.5.0\r\n"
    1.27 +		"MIME-Version: 1.0\r\n"
    1.28 +		"Content-Type: text/plain; charset=utf-8\r\n"
    1.29 +		"Content-Language: en-US\r\n"
    1.30 +		"Content-Transfer-Encoding: 8bit\r\n"
    1.31 +		"\r\n"
    1.32 +		"-----BEGIN PGP MESSAGE-----\r\n"
    1.33 +		"Charset: utf-8\r\n"
    1.34 +		"\r\n"
    1.35 +		"hQIMA+NkSS2yiGkeARAAgtW5xzq/ksfUIRxPZIDwGIANH0iLKhbnFbg/GssuyQOE\r\n"
    1.36 +		"+7rdevKX9UcxwBcRGJYs/aSMvY9zQE4tJy3ohf6+jnRzh3RH055A6+bsUWS/cex3\r\n"
    1.37 +		"fL7PtmQUT2PRXcXfrrk+oiCPXdJPVyRJXKGkKzwmpy7+U8mSSPoR3SIciFy/9CKs\r\n"
    1.38 +		"zhiTuQm8momz5gP/FpNyIU6E0xOdvyv9G90Y0qLzQyWFCY9fo3uRvKtvQmp2A0vj\r\n"
    1.39 +		"nI0rMBBnblLWLkLhTgEhsBSxi5/Emu2kzYXdhezb+IxuMrl7LhrZkFCSNnPWozJ7\r\n"
    1.40 +		"gyEcxK9tPOyK/SCYY+s9vg6D3F8mdJIT8Vi/87v1hQjvehc+xtiY/nNadaSDPWOh\r\n"
    1.41 +		"eWZ8FWVNRU3xowT5gyC75F8K+5IkhxsdmFGNznMzX9m+09fI515oVbDPe493JPNq\r\n"
    1.42 +		"TjKOVq406EFGIJ5+DGd1IDStUZuZBl4Z79bz9uF/vKCnvFzskTW69NypoDOe3+XL\r\n"
    1.43 +		"mP86vm3dUB3kWStHyWvH2RFbHnrbyHjZhQihsu8NdGBa3ZYatwlPhwVGaucSkrYM\r\n"
    1.44 +		"vSEgKyN+7XqQQIQSv6ncxzoNlZ7Cgoyh0BeaTIjDVH/0H6oUrljGO8UwcNhEOxGH\r\n"
    1.45 +		"WRBRI/emArMa8ro/tJ08jbFkRB1qiLSdfh0bufD0hWGGG16gXvvND4UgnVZ3VnzS\r\n"
    1.46 +		"6QGNwgYI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GSt4R0+nKhrCuYkQ\r\n"
    1.60 +		"Vo5t3qUtVAo2ic/ktisa4rNPND0XQAcCi58=\r\n"
    1.61 +		"=vf0v\r\n"
    1.62 +		"-----END PGP MESSAGE-----\r\n"
    1.63 +		"\r\n";
    1.64 +	
    1.65 +	PEP_SESSION session;
    1.66 +	PEP_STATUS status1 = init(&session);
    1.67 +	assert(status1 == PEP_STATUS_OK);
    1.68 +	assert(session);
    1.69 +
    1.70 +	char* plaintext = nullptr;
    1.71 +	stringlist_t* keys_used = nullptr;
    1.72 +	PEP_rating rating;
    1.73 +	PEP_decrypt_flags_t dec_flags;
    1.74 +	
    1.75 +	PEP_STATUS status2 = MIME_decrypt_message(session, mimetext.c_str(), mimetext.length(),
    1.76 +		&plaintext, &keys_used, &rating, &dec_flags);
    1.77 +	
    1.78 +	std::cout << "MIME_decrypt_message returned " << status2 << std::hex << " (0x" << status2 << ")" << endl;
    1.79 +	
    1.80 +	assert(status2 == PEP_STATUS_OK);
    1.81 +	assert(plaintext);
    1.82 +	
    1.83 +	pEp_free(plaintext);
    1.84 +}
    1.85 +
    1.86 +
    1.87  int main() {
    1.88      cout << "\n*** message_api_test ***\n\n";
    1.89 +    test_MIME_decrypt_message();
    1.90  
    1.91      PEP_SESSION session;
    1.92