Removed Roker test that broke message_api_test.cc when run outside of the testing environment (this isn't a case of avoiding a bug, but rather the case would fail because the keys tested are actual keys which some of us have present in our real keyrings, and test presumes we do not.
authorKrista Bennett <krista@pep-project.org>
Thu, 08 Feb 2018 20:05:10 +0100
changeset 24891f29e7c1fb8a
parent 2488 b05d7d1f2842
child 2490 a527d621b486
Removed Roker test that broke message_api_test.cc when run outside of the testing environment (this isn't a case of avoiding a bug, but rather the case would fail because the keys tested are actual keys which some of us have present in our real keyrings, and test presumes we do not.
src/pEpEngine.c
test/lars_test_do_not_run_outside_of_test_environment.cc
test/message_api_test.cc
     1.1 --- a/src/pEpEngine.c	Wed Feb 07 19:08:11 2018 +0100
     1.2 +++ b/src/pEpEngine.c	Thu Feb 08 20:05:10 2018 +0100
     1.3 @@ -1263,7 +1263,7 @@
     1.4          // private keys have an 'unknown' trust designation in PGP).
     1.5  
     1.6          // We don't really worry about the status here.
     1.7 -        status = import_trusted_own_keys(_session);        
     1.8 +    //    status = import_trusted_own_keys(_session);        
     1.9      }
    1.10  
    1.11      // sync_session set to own session by default
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/test/lars_test_do_not_run_outside_of_test_environment.cc	Thu Feb 08 20:05:10 2018 +0100
     2.3 @@ -0,0 +1,169 @@
     2.4 +// This file is under GNU General Public License 3.0
     2.5 +// see LICENSE.txt
     2.6 +
     2.7 +#include <stdlib.h>
     2.8 +#include <string.h>
     2.9 +#include "platform.h"
    2.10 +#include <iostream>
    2.11 +#include <fstream>
    2.12 +#include <assert.h>
    2.13 +#include "mime.h"
    2.14 +#include "message_api.h"
    2.15 +
    2.16 +using namespace std;
    2.17 +
    2.18 +void test_MIME_decrypt_message()
    2.19 +{
    2.20 +	static const std::string private_key =
    2.21 +        "-----BEGIN PGP PRIVATE KEY BLOCK-----\n"
    2.22 +        "\n"
    2.23 +        "lQOmBFpCxkEBCCC8ugYsWOsv966JOl5Ahdw6YiobbU9peFLV8aMBOG+oNIPs3BQj\n"
    2.24 +        "u3FUugkVqA5In93oqVgNZ2LU6Y/RWldN+Pc4IMf6qSZnTBj/1ffBjuqAow1hPEYV\n"
    2.25 +        "354LNYoQtJXioY0X8FjRgt+NoBPphRbo+XJ0uIQckJey6uvvtukEZkMLM1ur1aID\n"
    2.26 +        "9biJZ7yXtJM7KxN5792Vo2gGp/1hlFW6SfM7E0g60L5DT8C/BsYeKtMmxKNZngo6\n"
    2.27 +        "ZBxLDAcxMcT5UpRW79B34pTINZAEsvLeT7TLajzqP/OggUrFkkwLr3KJk09aFF+6\n"
    2.28 +        "TN6CI2fDdSqdoPVEgNrZE9zFqAgVWOdhLOHRpXgt7wARAQABAAgZATpqsN4xRaIk\n"
    2.29 +        "giMdmujkGoMqB/ypoCOW0mqcp3ThESSqWR/Dh8n//k+poHj0Atf7fzie6JNsKruM\n"
    2.30 +        "Yo3mdIzyuuxHsONp6xEtNnkDgEB4WTb2btQQFrNaWXNTPzGVqiBoBShcw5xI7SiG\n"
    2.31 +        "CKaDlCePbaAHyBHO0uzBdVFo6czqkceXSJ+hNDY7xbURbkgIA5SGJ+8cssmcKKoc\n"
    2.32 +        "LDY34S3Pu0gG3+K6gSedYaHAqVVQn8dmEitvDFQ96sTNIpPiMp5Tc+/8UXziF91f\n"
    2.33 +        "XRrXYX9o3nkCvz01qtjR4LQVDztysm3/VmDcsjqhzALiiBLigyglpE5DEp0+wMUq\n"
    2.34 +        "gw5TpWZ63lf6XjEEEM+c+D3HHsEnh24+DNU2OyfFZGpp9olSaTDcXtEBuBTt/Uhy\n"
    2.35 +        "NnqF4MswQ2me4Lfr4D4sUS5jtsKkee+2IQuwtg/bBVYsL6MfV2llJco2vrOCb6y8\n"
    2.36 +        "u9CnQhRbVBd6kBMiJeE50Ijk3jP78GrkPm3rGWKCWRuXVr07+U2MsEnvSkkBfpEE\n"
    2.37 +        "EOi2NcXCCJux9xZv0xOyWogXDVLVrrhs8/PGjJO1IeaMtmrzleo3azUbWus/BYLA\n"
    2.38 +        "vJkO+PElg/MCc2ub5hFs7IqSbLmteWFiSOzTcdHNWeqETsixAc8dpbq0zhkPwdzA\n"
    2.39 +        "otLEBS3mpaB29Bpt9lzgewHoVI/o/OvUFFaP+b1Fd4wOJH8EELZPWw+85tSB1l63\n"
    2.40 +        "4B+77YoBc9wDBFg7Pt4Eo0eghFZ/159YTA1bcr3fZ8bYIgiHHNLC/Fsx+sUu00PC\n"
    2.41 +        "ctLrOxGRbuDyNy2rsezf8Bz8xpihBPuBmSbKoaZguSazgpuC1LPkVbQQVaN1h+Ir\n"
    2.42 +        "9/tJufw+hT9Eggvx5xtCo7GD1trnx0xLKbQhVGVzdCBUb25pIDxlbmdpbmUtMzIy\n"
    2.43 +        "QHBlcHRlc3QuY2g+iQE8BBMBCAAiBQJaQsZBAhsDBgsJCAcDAgYVCAIJCgsEFgID\n"
    2.44 +        "AQIeAQIXgAAKCRCvYy6fx5m31NWeCCCXgm1J7Pq4ECKaMZcp7WoWguXQW+Ellgrx\n"
    2.45 +        "B6EjZmvy1iB0RYaDz6F0HCXd0WtC2YDlkxJ47rKBHsnmcyHbFNlY0fgc5Uhs7apI\n"
    2.46 +        "bBMHHRGwl8pie05DqxQ0jBxO2esk/IPJDhLXw7gZvaY/9PUS669QWoq+L/Hhph8V\n"
    2.47 +        "5v65jnw2937bOaf6wvEUUj2cg6cUaPTZSXv26vxUrT8RD+DxbQiNjJIeGRfVj3QY\n"
    2.48 +        "9GCTcp45ZaB8kLQEVayFrC3Jougcklk5DS1zlFCHiYLa4cco/68XHL7/CFdIxxsK\n"
    2.49 +        "Rd/3FYWX6zfQZJs5U6KmGy18cXvk0OOtTru9aNHR0YiLj4Vs8K+mWA10vZ0DpgRa\n"
    2.50 +        "QsZBAQggwrnOsiJ3JNB+mTm9pZbX4mUkw7OXrar1CvOVDqrnI+H+Z9/DC1FDEupw\n"
    2.51 +        "8mD3fFV4veO6smjb9wWAXhmU88OxXziChM8WJlWz2GrZPoM2DIYu1gLycp7wo1Md\n"
    2.52 +        "mzhd/5tpBWMJ4gGS9AjvQc5ffk7JVBAnmhh4ZtdoEctHMJs7+1RhXE7KUM1QWjew\n"
    2.53 +        "2GAVAaw+KsuXvqsF8soXvlFaHe9sTHKXKUD/MN4WWPR3SIvC4yoadlUpCMfooXf8\n"
    2.54 +        "ZCFLbVirkqGy5AakF7thlaTq7bxEX5BQbP/DjVuTTd311jk4x7oT+1bT7D6iIoES\n"
    2.55 +        "DKfYijw+059CrCbjFUn3/RRg5sx/55FA2XEAEQEAAQAIHiu228SYwSeGGM2cLUt1\n"
    2.56 +        "vBxKeYDnmeb2aJFfUnia/E3NZ7f4/0fUo9qkv9th0l1asMLsU1bG/I6NcR5u3sYE\n"
    2.57 +        "iham0IIxHTdY6QluHzwN573TB8OqoLQDo2D/ATf95PhDcsWvUKIomU1ojhG3Wy+3\n"
    2.58 +        "TzIseD97O9hWhjnsaRxr1QDclghnNffz589T40wAQAkdQlfDuBABberGNR0DsCZq\n"
    2.59 +        "w1xx1+EaEt8o7sXfRMFKoBLJzya0toJNIBGdXCXVPFPtYx6RAiD1KoufgXwVCBaL\n"
    2.60 +        "CHc8QvurgyMBghc9pBcdGs60fNhWn1U4qeWzPOHO95ZWVFObBiuGqkX25revf1Dg\n"
    2.61 +        "RTY5OsBTBBDdnMElWA+l6ctlSX8vNUQBin7aPbHu1HrmUxH9EiKwUd6jdoFmssw7\n"
    2.62 +        "soohAfYJCsuTQLHPI+9W6okF4rjlvl0aS2cN4HSbLjTwdNiUgIHVKJPDq8WDgCsV\n"
    2.63 +        "bR09wsLkohmoX/qZFEQMKdr7A2ar64zQzpx6ZFB0kS71Fr6+rFUAIzePBBDg8QXr\n"
    2.64 +        "J/R6iZYnMNv/mzyNunbM3B7siwbILS1kLeS6lTYeaKORa7JFRc776rkWV//P1Soc\n"
    2.65 +        "nW2byeBxNxOmdNXlNsA6Gg8O4rn3rxEgBZlsOYUG1ZcPZZu8kNFkLTYP+mgFIP3I\n"
    2.66 +        "izn858IbnNFm0HjRMGiS+zip2r/rgbniIhLQ2l7/BBCL+2x0+Ww5I/el6A7k+y2X\n"
    2.67 +        "3xazBVOQfpPl9BgMdsuO0BBlN5RpbTfE8TVpWneeamAuRJh7ArApbAS508Thw7Sj\n"
    2.68 +        "8iLKXj5yScAEC2WO9ZsHqJ/RN3VyhCCI0u3Y75wB3qfcroZUlwvQb/WfH8/vHr2O\n"
    2.69 +        "E72YoprbNOmRFZ7LZkRX56URRn2JASMEGAEIAAkFAlpCxkECGwwACgkQr2Mun8eZ\n"
    2.70 +        "t9RozQggkb/Lb08g4w99CcXq6hV28D5bOHjiEx4XNdkeLVExhfk1zgQ9lf4rjyb2\n"
    2.71 +        "ox+e3Dc5S590NoYg/35vd/QWPsg1JiCvAu296lzOLtIiTAI1KGUJdbsLxRIduOU7\n"
    2.72 +        "6n/KVxRG4w4kJqpbu+UzBY7KtDbWzapJx8v0sdsTOVxg7kFxvYtra5TRaPfce4EX\n"
    2.73 +        "ox2V2HPhtFNSILH8Jqh/R0PV5RRbNFHZA4cKXkBJMw3BcpbpXeLCXiD6P3FNVSKh\n"
    2.74 +        "Rkd3JY0XJhwbvGPCRWkobtxkieZe0bCmKu8+gw0Zqm2QNA7J6iMT4rMZWH9k7lpp\n"
    2.75 +        "okyt7GheXlwKEtVQSAcH/NalK9Q+ckaQttA=\n"
    2.76 +        "=KACn\n"
    2.77 +        "-----END PGP PRIVATE KEY BLOCK-----\n"
    2.78 +        "\n";
    2.79 +
    2.80 +    static const std::string mimetext =
    2.81 +        "To: denden@peptest.ch\r\n"
    2.82 +        "From: Lars Rohwedder <roker@pep-project.org>\r\n"
    2.83 +        "Subject: Test for ENGINE-322\r\n"
    2.84 +        "Message-ID: <4b2d328c-b284-e359-1c2c-fe136358b8a6@pep-project.org>\r\n"
    2.85 +        "Date: Thu, 28 Dec 2017 22:00:47 +0100\r\n"
    2.86 +        "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:52.0)\r\n"
    2.87 +        " Gecko/20100101 Thunderbird/52.5.0\r\n"
    2.88 +        "MIME-Version: 1.0\r\n"
    2.89 +        "Content-Type: text/plain; charset=utf-8\r\n"
    2.90 +        "Content-Language: en-US\r\n"
    2.91 +        "Content-Transfer-Encoding: 8bit\r\n"
    2.92 +        "\r\n"
    2.93 +        "-----BEGIN PGP MESSAGE-----\r\n"
    2.94 +        "Charset: utf-8\r\n"
    2.95 +        "\r\n"
    2.96 +        "hQEQA30SSxlFRbxRAQgggvPrko4vJ988ylqdGF7/Jtw/61VddHg7rjOTG7yZiq2J\r\n"
    2.97 +        "p0lXb0N9Bz8SON/m4NWWS5ij0Bj1wMdTgLowLxMz0PfCIyyiQIfqEBAXUcAOQh2f\r\n"
    2.98 +        "Pg2iZbynrQ1T4M/D0BlIn2bfXb790Cni+o1OmWTCx4wC6AKtGvlonLAIsH1hUfs+\r\n"
    2.99 +        "yKOyCCNaNSmyAPeF3F5v7iEO5Eez1R/UrtxcYj2QmCdVt5v0AuAlm5HVPJgj7wCd\r\n"
   2.100 +        "MeRmK4a1+sM51CcCf6Tk9uZbIVrr/XkyGVPmmHTK8E4QmvmL6PGeuIitwqKe80/L\r\n"
   2.101 +        "XH4ZYPXIxVU9o5HoSo3YJ3BSKLQzCoDRCD8JlCo08K6mrpuFAgwD42RJLbKIaR4B\r\n"
   2.102 +        "EADNgisKiIku4SrBmBkryyKMYmOTW0QKnY/wfNselpzuj5cMpKA4e60x/wEQRIvC\r\n"
   2.103 +        "m1ZO7LjhbVjNf6ws2FgytnTRf+8R/R8mp6/XIDeUvaBvUku5yoRjTeznFRwpj6yT\r\n"
   2.104 +        "WfQMlLojI2fe+y5fHKIIjTpW5HOQQv7sZ4UzE+jRpRErRVq4UI49l7yTBnG0j75w\r\n"
   2.105 +        "UZTt05OnJMQrCCiD7Fu9xDw5If3x884GehKpFGm6XqZ8V7NhwGk6mf62rZEouBQh\r\n"
   2.106 +        "AhTu/irkz30PpWY3gGj2YF0PIaQmweb9u2izox1kTfq2xRfPLg/4cOgBKy1/Xeea\r\n"
   2.107 +        "IVeaACAcoNdJaYuZCSe9CMbr5s7kusE22/6fB0L1itGr09EzhwGJS/+XSt0IwcJw\r\n"
   2.108 +        "7XDUGtmYXuTy08wUKU9McxXJ8nlUkXF9ZcswVxHKG36ZRfzx5eBPjzSnDo8EZHs2\r\n"
   2.109 +        "wr7wnS8s8J+AvB7kZYFChAct4KH9OwT3/2pSdhd8/sSCkj2zGtrB+8h2QkIE4csD\r\n"
   2.110 +        "rIHtBp4oWCJq1XOKYPvdGqWBxZ/7086kksB99Eyn+sy5C0iNTbEdUN4JkIYq1C0n\r\n"
   2.111 +        "DExbr+dqip65DEJRj7TPfwTJ5D28djPYutanSRfJS/niPqztWu0R1ISucw1TMdGU\r\n"
   2.112 +        "NcqsqQLPYzTV6xTq+bgBsi8DO4tXkcOpf7eDEP+5kDOncNLpAZGc9NUnVa/jpkYO\r\n"
   2.113 +        "XE+CNJ5SYQPdsGcir9JNXNTDgKAGSTI7OAU/ZxOcMCsmctJATcAZERFgvUy8YZN1\r\n"
   2.114 +        "3X4Ii6osc8u6shJrjL/detZs8LH8wSe6NYQdtipQo4ySAYQAO9tXdoRrfktXrYus\r\n"
   2.115 +        "eLh86toD19D5R9RxHnVEMQP5CdNWgvX7X4ngK94kJq18QCDa1bZXhHBKmWOnAtyL\r\n"
   2.116 +        "zpcUNnCWo2gml6GX2kyuL+5Ji6afwKHZg+iag8wBDLGQ+hoOMnzk1iP4DFeQ7iZN\r\n"
   2.117 +        "Qvd4mWWASd2BCnf9ulKiMw1wdzN2mpYRNo+nRHx0Zu50VUyj0xMm8VSyUZis5+YH\r\n"
   2.118 +        "I3Se7UEeS6ppLsiGcyaJDCMp/38xt5SU5NY4wAAubc6MJclECcvSkM1W/20wQ4di\r\n"
   2.119 +        "z5FhKHlqZaPTXN02h0P78wKDDwJr7fFvqtB8G2LgtwbXAkOUvn8vbomQLHBkQ+GH\r\n"
   2.120 +        "AuXqBGxKrIwyIEjLZf6hDz++0fDa/ACeFynpxNl1ehmvCl5CsEMcCiM+Ic2pZ/ML\r\n"
   2.121 +        "+Hle0GWEKej4WBzXi0j4pzR4WZFt9XCv5+yYAg+UHKc2Kn0Q+bC1AZYxhQDicTP9\r\n"
   2.122 +        "qNKTLBHRAeJoQ1y4vHXYGwRGH+penfJiKsQsyOOeoQlZar8tvRYR77K8FhxBtnYK\r\n"
   2.123 +        "Xrv+rb1BT/2Ey7P4jb8PiZpbic7ACu1MjFdmlPKrExe5+MY+Pr9ms+hxJrdBH736\r\n"
   2.124 +        "K6dojmWUQKpJRzue2lWsfESLxIVeB+vmbg2zU3PflCmMIsRNh2US7vZj2WdgqSqz\r\n"
   2.125 +        "wR2eTG4MgPVy4iiGOVT2JWS5t+KXm3kwUZTy9Twi6P1ebNm/B8KQwlutssdWip2q\r\n"
   2.126 +        "hON1aFYa4L601zrHgow592PdBkRPQZGiXNHffCvHgsxBHsj4G4JWZhmIkEK/cIWl\r\n"
   2.127 +        "RanlZdQG6UPHkoUomh7hauUUgcYe4FWt4NBKdiba36Y=\r\n"
   2.128 +        "=1lFj\r\n"
   2.129 +        "-----END PGP MESSAGE-----\r\n"
   2.130 +        "\r\n";
   2.131 +
   2.132 +	PEP_SESSION session;
   2.133 +	PEP_STATUS status1 = init(&session);
   2.134 +	assert(status1 == PEP_STATUS_OK);
   2.135 +	assert(session);
   2.136 +
   2.137 +	// import secret key
   2.138 +	identity_list* pk = NULL; 
   2.139 +	status1 = import_key( session, private_key.c_str(), private_key.size(), &pk );
   2.140 +	assert(status1 == PEP_STATUS_OK);
   2.141 +	std::cout << "Imported " << identity_list_length(pk) << " private key(s)." << endl;
   2.142 +	
   2.143 +	char* plaintext = nullptr;
   2.144 +	stringlist_t* keys_used = nullptr;
   2.145 +	PEP_rating rating;
   2.146 +	PEP_decrypt_flags_t dec_flags;
   2.147 +	
   2.148 +	PEP_STATUS status2 = MIME_decrypt_message(session, mimetext.c_str(), mimetext.length(),
   2.149 +		&plaintext, &keys_used, &rating, &dec_flags);
   2.150 +	
   2.151 +	std::cout << "MIME_decrypt_message returned " << std::dec << status2 << std::hex << " (0x" << status2 << ")" << std::dec << endl;
   2.152 +	
   2.153 +    // We have no public key, so we cannot, in fact, VERIFY the message. SO cannot be PEP_STATUS_OK.
   2.154 +	assert(status2 == PEP_DECRYPTED);
   2.155 +	assert(plaintext);
   2.156 +	
   2.157 +	pEp_free(plaintext);
   2.158 +	
   2.159 +	identity_list* il = pk;
   2.160 +	while(il)
   2.161 +	{
   2.162 +		std::cout << "Delete test key \"" << il->ident->fpr << "\"" << endl;
   2.163 +		delete_keypair( session, il->ident->fpr );
   2.164 +		il = il->next;
   2.165 +	}
   2.166 +	free_identity_list(pk);
   2.167 +}
   2.168 +
   2.169 +int main() {
   2.170 +    test_MIME_decrypt_message();
   2.171 +    return 0;
   2.172 +}
     3.1 --- a/test/message_api_test.cc	Wed Feb 07 19:08:11 2018 +0100
     3.2 +++ b/test/message_api_test.cc	Thu Feb 08 20:05:10 2018 +0100
     3.3 @@ -165,7 +165,6 @@
     3.4  
     3.5  int main() {
     3.6      cout << "\n*** message_api_test ***\n\n";
     3.7 -    test_MIME_decrypt_message();
     3.8  
     3.9      PEP_SESSION session;
    3.10