rest of test files for the color test
authorKrista Grothoff <krista@pep-project.org>
Mon, 13 Feb 2017 22:13:01 +0100
changeset 15818a645cc075a0
parent 1580 b2b599902703
child 1584 d21b3f92542d
child 1589 c6dbfcea6e5a
rest of test files for the color test
test/least_common_denom_color_test.cc
test/test_mails/Test_Message_JSON-21_Color_Problems.eml
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/test/least_common_denom_color_test.cc	Mon Feb 13 22:13:01 2017 +0100
     1.3 @@ -0,0 +1,158 @@
     1.4 +#include <iostream>
     1.5 +#include <iostream>
     1.6 +#include <fstream>
     1.7 +#include <string>
     1.8 +#include <cstring> // for strcmp()
     1.9 +#include <assert.h>
    1.10 +#include "blacklist.h"
    1.11 +#include "keymanagement.h"
    1.12 +#include "message_api.h"
    1.13 +#include "mime.h"
    1.14 +
    1.15 +using namespace std;
    1.16 +
    1.17 +int main(int argc, char** argv) {
    1.18 +        
    1.19 +    const char* mailfile = "test_mails/Test_Message_JSON-21_Color_Problems.eml";
    1.20 +    
    1.21 +    PEP_SESSION session;
    1.22 +    
    1.23 +    cout << "calling init()\n";
    1.24 +    PEP_STATUS status1 = init(&session);   
    1.25 +    assert(status1 == PEP_STATUS_OK);
    1.26 +    assert(session);
    1.27 +    cout << "init() completed.\n";
    1.28 +    
    1.29 +    // import keys
    1.30 +
    1.31 +    ifstream infilekey1("test_keys/pub/banmeonce-0x07B29090_pub.asc");
    1.32 +    string keytextkey1;
    1.33 +    while (!infilekey1.eof()) {
    1.34 +        static string line;
    1.35 +        getline(infilekey1, line);
    1.36 +        keytextkey1 += line + "\n";
    1.37 +    }
    1.38 +    infilekey1.close(); 
    1.39 +    
    1.40 +    ifstream infilekey2("test_keys/pub/banmetwice-0x4080C3E7_pub.asc");
    1.41 +    string keytextkey2;
    1.42 +    while (!infilekey2.eof()) {
    1.43 +        static string line;
    1.44 +        getline(infilekey2, line);
    1.45 +        keytextkey2 += line + "\n";
    1.46 +    }
    1.47 +    infilekey2.close(); 
    1.48 +
    1.49 +    ifstream infilekey3("test_keys/pub/pep.never.me.test-0x79C11D1D_pub.asc");
    1.50 +    string keytextkey3;
    1.51 +    while (!infilekey3.eof()) {
    1.52 +        static string line;
    1.53 +        getline(infilekey3, line);
    1.54 +        keytextkey3 += line + "\n";
    1.55 +    }
    1.56 +    infilekey3.close(); 
    1.57 +    
    1.58 +    ifstream infilekey4("test_keys/priv/pep.never.me.test-0x79C11D1D_priv.asc");
    1.59 +    string keytextkey4;
    1.60 +    while (!infilekey4.eof()) {
    1.61 +        static string line;
    1.62 +        getline(infilekey4, line);
    1.63 +        keytextkey4 += line + "\n";
    1.64 +    }
    1.65 +    infilekey4.close(); 
    1.66 +
    1.67 +    PEP_STATUS statuskey1 = import_key(session, keytextkey1.c_str(), keytextkey1.length(), NULL);
    1.68 +    PEP_STATUS statuskey2 = import_key(session, keytextkey2.c_str(), keytextkey2.length(), NULL);
    1.69 +    PEP_STATUS statuskey3 = import_key(session, keytextkey3.c_str(), keytextkey3.length(), NULL);
    1.70 +    PEP_STATUS statuskey4 = import_key(session, keytextkey4.c_str(), keytextkey4.length(), NULL);
    1.71 +
    1.72 +    pEp_identity * sender = new_identity("pep.never.me.test@kgrothoff.org", NULL, "TOFU_pep.never.me.test@kgrothoff.org", "pEp Never Me Test");    
    1.73 +    sender->me = false;    
    1.74 +    PEP_STATUS status = update_identity(session, sender);
    1.75 +        
    1.76 +    // reset the trust on both keys before we start
    1.77 +    pEp_identity * recip1 = new_identity("banmeonce@kgrothoff.org", NULL, "TOFU_banemeonce@kgrothoff.org", "Ban Me Once");    
    1.78 +    recip1->me = false;    
    1.79 +    status = update_identity(session, recip1);
    1.80 +    
    1.81 +    pEp_identity * recip2 = new_identity("banmetwice@kgrothoff.org", NULL, "TOFU_banemetwice@kgrothoff.org", "Ban Me Twice");    
    1.82 +    recip2->me = false;    
    1.83 +    status = update_identity(session, recip2);
    1.84 +        
    1.85 +    ifstream infile(mailfile);
    1.86 +    string mailtext;
    1.87 +    while (!infile.eof()) {
    1.88 +        static string line;
    1.89 +        getline(infile, line);
    1.90 +        mailtext += line + "\n";
    1.91 +    }
    1.92 +    infile.close(); 
    1.93 +
    1.94 +    // trust_personal_key(session, you);
    1.95 +    // 
    1.96 +    // status = update_identity(session, you);
    1.97 +    
    1.98 +    message* msg_ptr = nullptr;
    1.99 +    message* dest_msg = nullptr;
   1.100 +    message* final_ptr = nullptr;
   1.101 +    stringlist_t* keylist = nullptr;
   1.102 +    PEP_rating rating;
   1.103 +    PEP_decrypt_flags_t flags;
   1.104 +    
   1.105 +    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr);
   1.106 +    assert(status == PEP_STATUS_OK);
   1.107 +    assert(msg_ptr);
   1.108 +    final_ptr = msg_ptr;
   1.109 +    status = decrypt_message(session, msg_ptr, &dest_msg, &keylist, &rating, &flags);
   1.110 +    final_ptr = dest_msg ? dest_msg : msg_ptr;
   1.111 +  
   1.112 +    cout << "shortmsg: " << final_ptr->shortmsg << endl << endl;
   1.113 +    cout << "longmsg: " << final_ptr->longmsg << endl << endl;
   1.114 +    cout << "longmsg_formatted: " << (final_ptr->longmsg_formatted ? final_ptr->longmsg_formatted : "(empty)") << endl << endl;
   1.115 +
   1.116 +    /* message is signed and no recip is mistrusted... */
   1.117 +    assert(color_from_rating(rating) == PEP_color_yellow);
   1.118 +
   1.119 +    if (final_ptr == dest_msg)
   1.120 +    	free_message(dest_msg);
   1.121 +    free_message(msg_ptr);
   1.122 +    free_stringlist(keylist);
   1.123 +
   1.124 +    /* Ok, now mistrust one recip */
   1.125 +    key_mistrusted(session, recip2);
   1.126 +    
   1.127 +    msg_ptr = nullptr;
   1.128 +    dest_msg = nullptr;
   1.129 +    final_ptr = nullptr;
   1.130 +    keylist = nullptr;
   1.131 +    rating = PEP_rating_unreliable;
   1.132 +
   1.133 +    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr);
   1.134 +    assert(status == PEP_STATUS_OK);
   1.135 +    assert(msg_ptr);
   1.136 +    final_ptr = msg_ptr;
   1.137 +    status = decrypt_message(session, msg_ptr, &dest_msg, &keylist, &rating, &flags);
   1.138 +    final_ptr = dest_msg ? dest_msg : msg_ptr;
   1.139 +  
   1.140 +    cout << "shortmsg: " << final_ptr->shortmsg << endl << endl;
   1.141 +    cout << "longmsg: " << final_ptr->longmsg << endl << endl;
   1.142 +    cout << "longmsg_formatted: " << (final_ptr->longmsg_formatted ? final_ptr->longmsg_formatted : "(empty)") << endl << endl;
   1.143 +
   1.144 +    /* message is signed and no recip is mistrusted... */
   1.145 +    assert(color_from_rating(rating) == PEP_color_red);
   1.146 +
   1.147 +    if (final_ptr == dest_msg)
   1.148 +    	free_message(dest_msg);
   1.149 +    free_message(msg_ptr);
   1.150 +    free_stringlist(keylist);
   1.151 +
   1.152 +    msg_ptr = nullptr;
   1.153 +    dest_msg = nullptr;
   1.154 +    final_ptr = nullptr;
   1.155 +    keylist = nullptr;
   1.156 +    rating = PEP_rating_unreliable;
   1.157 +        
   1.158 +    cout << "calling release()\n";
   1.159 +    release(session);
   1.160 +    return 0;
   1.161 +}
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/test/test_mails/Test_Message_JSON-21_Color_Problems.eml	Mon Feb 13 22:13:01 2017 +0100
     2.3 @@ -0,0 +1,124 @@
     2.4 +Return-Path: <pep.never.me.test@kgrothoff.org>
     2.5 +X-Original-To: krista@gnunet.org
     2.6 +Delivered-To: krista@gnunet.org
     2.7 +Received: from vmmailrelay1.informatik.tu-muenchen.de (mailrelay1.informatik.tu-muenchen.de [131.159.254.14])
     2.8 +	by sam.net.in.tum.de (Postfix) with ESMTP id 192BE1C00BD
     2.9 +	for <krista@gnunet.org>; Thu,  9 Feb 2017 13:07:56 +0100 (CET)
    2.10 +Received: by vmmailrelay1.informatik.tu-muenchen.de (Postfix, from userid 109)
    2.11 +	id 117001C0394; Thu,  9 Feb 2017 13:07:56 +0100 (CET)
    2.12 +Received: from vmmailrelay1.informatik.tu-muenchen.de (localhost [127.0.0.1])
    2.13 +	by vmmailrelay1.informatik.tu-muenchen.de (Postfix) with ESMTP id D6D6E1C0393
    2.14 +	for <krista@gnunet.org>; Thu,  9 Feb 2017 13:07:55 +0100 (CET)
    2.15 +Received: from vmmaildmz2.informatik.tu-muenchen.de (vmmaildmz2.informatik.tu-muenchen.de [131.159.0.88])
    2.16 +	by vmmailrelay1.informatik.tu-muenchen.de (Postfix) with ESMTP id C1FFE1C0381
    2.17 +	for <krista@gnunet.org>; Thu,  9 Feb 2017 13:07:55 +0100 (CET)
    2.18 +Received: by vmmaildmz2.informatik.tu-muenchen.de (Postfix, from userid 109)
    2.19 +	id C01861C2AE2; Thu,  9 Feb 2017 13:07:55 +0100 (CET)
    2.20 +X-Spam-Checker-Version: SpamAssassin 3.4.0-tuminfo_1 (2014-02-07) on
    2.21 +	vmmaildmz2.informatik.tu-muenchen.de
    2.22 +X-Spam-Level: 
    2.23 +X-Spam-Status: No, score=-3.6 required=7.0 tests=BAYES_00,ENCRYPTED_MESSAGE,
    2.24 +	RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,TVD_RCVD_SPACE_BRACKET,
    2.25 +	UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.0-tuminfo_1
    2.26 +Received: from vmmaildmz2.informatik.tu-muenchen.de (localhost [127.0.0.1])
    2.27 +	by vmmaildmz2.informatik.tu-muenchen.de (Postfix) with ESMTP id 3A9C01C2AE4
    2.28 +	for <krista@gnunet.org>; Thu,  9 Feb 2017 13:07:54 +0100 (CET)
    2.29 +Received: from mi4-p00-ob.smtp.rzone.de (mi4-p00-ob.smtp.rzone.de [81.169.146.149])
    2.30 +	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
    2.31 +	(No client certificate requested)
    2.32 +	by vmmaildmz2.informatik.tu-muenchen.de (Postfix) with ESMTPS id 2A4C31C2AE0
    2.33 +	for <krista@gnunet.org>; Thu,  9 Feb 2017 13:07:54 +0100 (CET)
    2.34 +X-RZG-FWD-BY: banmeonce@kgrothoff.org
    2.35 +Received: from mailin.rzone.de ([unix socket])
    2.36 +	by mailin.rzone.de (RZmta 39.12) with LMTPA;
    2.37 +	Thu, 9 Feb 2017 13:07:34 +0100 (CET)
    2.38 +Authentication-Results: strato.com 1;
    2.39 +	spf=none
    2.40 +		smtp.mailfrom="pep.never.me.test@kgrothoff.org";
    2.41 +	dkim=none;
    2.42 +	domainkeys=none;
    2.43 +	dkim-adsp=none
    2.44 +		header.from="pep.never.me.test@kgrothoff.org"
    2.45 +X-Strato-MessageType: email
    2.46 +X-RZG-CLASS-ID: mi00
    2.47 +Received-SPF: none
    2.48 +	client-ip=131.159.0.8;
    2.49 +	helo="mail-out1.informatik.tu-muenchen.de";
    2.50 +	envelope-from="pep.never.me.test@kgrothoff.org";
    2.51 +	receiver=smtpin.rzone.de;
    2.52 +	identity=mailfrom;
    2.53 +Received: from mail-out1.informatik.tu-muenchen.de ([131.159.0.8])
    2.54 +	by smtpin.rzone.de (RZmta 39.12 OK)
    2.55 +	with ESMTPS id E072a0t19C7Y4k3
    2.56 +	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA))
    2.57 +	(Client did not present a certificate);
    2.58 +	Thu, 9 Feb 2017 13:07:34 +0100 (CET)
    2.59 +Received: from [192.168.1.62] (pD9E1CAE7.dip0.t-ipconnect.de [217.225.202.231])
    2.60 +	by services.sec.in.tum.de (Postfix) with ESMTPSA id DC477100C6BAA;
    2.61 +	Thu,  9 Feb 2017 13:07:28 +0100 (CET)
    2.62 +From: pEp Never Me Test <pep.never.me.test@kgrothoff.org>
    2.63 +Subject: Test Message JSON-21 Color Problems
    2.64 +To: banmeonce@kgrothoff.org, banmetwice@kgrothoff.org
    2.65 +Message-ID: <6c9adfb3-ecb1-88d7-12b8-0eb45d6a50da@kgrothoff.org>
    2.66 +Date: Thu, 9 Feb 2017 13:07:28 +0100
    2.67 +User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
    2.68 + Thunderbird/45.3.0
    2.69 +MIME-Version: 1.0
    2.70 +Content-Type: multipart/encrypted;
    2.71 + protocol="application/pgp-encrypted";
    2.72 + boundary="GSoHAlkS5XP2GksjNlk53fF0miL4HLkCA"
    2.73 +
    2.74 +This is an OpenPGP/MIME encrypted message (RFC 4880 and 3156)
    2.75 +--GSoHAlkS5XP2GksjNlk53fF0miL4HLkCA
    2.76 +Content-Type: application/pgp-encrypted
    2.77 +Content-Description: PGP/MIME version identification
    2.78 +
    2.79 +Version: 1
    2.80 +
    2.81 +--GSoHAlkS5XP2GksjNlk53fF0miL4HLkCA
    2.82 +Content-Type: application/octet-stream; name="encrypted.asc"
    2.83 +Content-Description: OpenPGP encrypted message
    2.84 +Content-Disposition: inline; filename="encrypted.asc"
    2.85 +
    2.86 +-----BEGIN PGP MESSAGE-----
    2.87 +
    2.88 +hQEMAwZ0wOLHTv3PAQgAuXmaVos2SgkwX9VOzPCPQxxIAVuAsS35yTG7v2fuqp1C
    2.89 +w7pNEGhmocX0ui/71hQr+n+/P4zCcp75CjzfJIHuEhF2oWInrkncv6rZ/TtZRlrS
    2.90 +21DoFLEflEv4hUVqoijD3uWqbYXEijUxWh7taQLUWH4lQ/oETrdXBgXRCrYlxIV2
    2.91 +njHkebiDLkYcdQAGP2iAU1j5/gOQN7sy+4w2QWwuCMiGJ0COzY7db8UWewlJFvp3
    2.92 +jHcQJ8AMt3oKoCuR4FbEoD3d2C0qV2YTu82SVsRb0fuk/l2HAjoqmM5a1rh3M56Q
    2.93 +iHyUnA00gchfNKYspFvunvl1hi5gVe/7YfzBY/kSdYUBDAPj7u5EGGtxogEH/jf6
    2.94 +f7nV2B4mAtE1IxriTslhMU0H5+PZvs/O3YeLzWEkQ3PUziFfkxS7pjcM4qUxIoN2
    2.95 +EHuZyddYSl/jQmEAZAGTQTfvJ2BobEWKAm/ITqShnPKBkNvIReOBQ2u76hwbRHB8
    2.96 +1M9F8gCf6OiamqugF4siWfccpTSKSMbYuW6wAIw+L1j8aIR8/iWPa7frqjXWIFLc
    2.97 +fy+ChFrmUSBgOLJJQwolHrsv0E9AxE0IFqYtvueQROqbocblVHxxzRLGGcSgfb2e
    2.98 +PQk1S3Q63/clLCtJhouE6BFY8KfuGB31JVsbMgoJN9JoBpt1g6ll/PfRjUFxipJm
    2.99 +nIRu5y8MB3Eqwen6GNGFAQwD67tRzhpQo58BB/91PbsJTrEaxg7ww005u12JnEAS
   2.100 +Kd5CclhNCf8rhxGnPIWpbJX54i6r3DfruAsEAy4ONxidmjw6EiuH3omjR+rNPqr0
   2.101 +b70tFzaZH7a27L5KbRorc7ph/jr+OwrBCvd+bO+4cpXuFH03KTRxgxzwGbu1KmTE
   2.102 +yg6zQAjH9nUvJTZpS5VRjy4tVXhWEJhJTq4H1+RV9N2VnzirlIMDce/TL0//Az71
   2.103 +17E0XNwF85woKzFtkX1UxyvsQ/Q9W/84rxFUSZ6jCagXescN12ylQ53wdYM0W+KX
   2.104 +PDUpg8zMjoX7uoUCZU9hiSmp8j2BivuinolWYMPIEYan+Xx2RSZj/AbsJoiX0ukB
   2.105 +30sPhzcixwicCniTAwWCAndCq4+1EGNT3+l+GgV5DOg/JjKjStaGfMXFVPfa9kqV
   2.106 +NDzM9b6ar++Bt2/zDwCW9ib4zJ9baplUHCgBVOxw/HcU6BgtMAiHG6WwUsULUrDJ
   2.107 +ow+XsI1R78y7mncVQyjEA9mKZteVmojYVA3RBidMr8r6a7rw8QINYXSrm85lkuur
   2.108 +q1pRuYP5z8o8YySGTTqZQe0rC4rD0O7QgGGkowDUEaHp11UJ8JYnw7fl2j5vMAKQ
   2.109 +FX9uyOev/fx/PQRrTr+b+fRHCxfu/wwH09s7asB74fpq9Ik8WNpQv7yejpBZoZn9
   2.110 +hzY3NTMDs8fsn5/L24/O8knbus2B00ZAFPUv+ffAqnQURJDKm52T+J2jABSvRDI2
   2.111 +BwWu+0JuPbqH4rCZJBl6nc1w18ndBEynx0ygsVUbs6a9q5FxGrkjXDJVKdiuMFbs
   2.112 +pPMskGk9TkqBCTWqNzTOFGgI+J0IIqpsDrs8RmpsSl4Q12kmhDU9cGijvQC/ztEh
   2.113 +3bGGbUjChnORulF77ExUz7IIAMg9BTViqpMDfPi6g2aihIi8Uqakfmb/bkkiaw2U
   2.114 +qfCZs9JKkFAyN0FUkFgZeAiswuHoxbDkz8Ne0ZErl+UwfLVwvenUeI+68L7vzJ3r
   2.115 +fij4XErClmAJrrSv0A/uuNmo/GQRpdOaAdU8isCRCcCo3CXRr6QjM85Cudn//Sdc
   2.116 +MVZ4/WoH96Q/PNSlr9lRAfcvdMeVWn9rgMA52EZZCY3Wo2ePH5jAeMg6CX7IbBIX
   2.117 +7aReLEIUIDTf7LcxfA0/WAvn21U1ifZGaJuh6JxOnFb7Fea4st7bCkYDOQ0I00EO
   2.118 +HvNoWV8iQIYLqxT4NG6fndcn12IKt5lRR1F+CEGb4habh9bI2LC2VbkbIddP83Z3
   2.119 +FXZM/QjPiItZQlHC04d85rxjUw01XLE3n9bQqTZHtbVw53Vlguy3Hro3XHQZMMEh
   2.120 +HHJ1wnOWVenx6VKeHEhO9i4V3P+htnEtmKQsw8aGQKGIwmoMXfNf7Amzy1gKqZQH
   2.121 +m7e6sDGZYGWd+WPfv6Yula3YIMIyOCqZdyXwxuEq8xALwrg5bemfJc7LqCvGWlv1
   2.122 +o0Lbj/zxPiQ6gKxIL4zupr5xhtllPSKKG8gCXIobvvmd5w3fZWSclBN7KwdNez53
   2.123 +Ov+jisztuR6H
   2.124 +=uGrR
   2.125 +-----END PGP MESSAGE-----
   2.126 +
   2.127 +--GSoHAlkS5XP2GksjNlk53fF0miL4HLkCA--