Added memoryhole_test file ENGINE-118
authorKrista Grothoff <krista@pep-project.org>
Wed, 19 Oct 2016 13:09:48 +0200
branchENGINE-118
changeset 13234501141bf217
parent 1322 517692958c78
child 1324 5c604329c0bf
Added memoryhole_test file
test/memoryhole_test.cc
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/test/memoryhole_test.cc	Wed Oct 19 13:09:48 2016 +0200
     1.3 @@ -0,0 +1,81 @@
     1.4 +#include <stdlib.h>
     1.5 +#include <string.h>
     1.6 +#include "platform.h"
     1.7 +#include <iostream>
     1.8 +#include <fstream>
     1.9 +#include <assert.h>
    1.10 +#include "mime.h"
    1.11 +#include "message_api.h"
    1.12 +
    1.13 +using namespace std;
    1.14 +
    1.15 +
    1.16 +int main(int argc, char** argv) {
    1.17 +    
    1.18 +        const char* filename = "test_mails/memoryhole_B.eml";
    1.19 +        
    1.20 +        PEP_SESSION session;
    1.21 +
    1.22 +        cout << "calling init()\n";
    1.23 +        PEP_STATUS status1 = init(&session);
    1.24 +        assert(status1 == PEP_STATUS_OK);
    1.25 +        assert(session);
    1.26 +        cout << "init() completed.\n";
    1.27 +
    1.28 +        // message_api test code
    1.29 +
    1.30 +        // pEp_identity * me2 = new_identity("pep.test.alice@pep-project.org", NULL, PEP_OWN_USERID, "Alice Test");
    1.31 +        // pEp_identity * me2 = new_identity("test@nokey.plop", NULL, PEP_OWN_USERID, "Test no key");
    1.32 +
    1.33 +        // FIXME: Ugh. Maybe identities have to be args. But this is a kludge.
    1.34 +        pEp_identity* me2 = new_identity("krista@kgrothoff.org", "62D4932086185C15917B72D30571AFBCA5493553", PEP_OWN_USERID, "Krista Grothoff");
    1.35 +        me2->me = true;
    1.36 +
    1.37 +        ifstream inFile3(filename);
    1.38 +        assert(inFile3.is_open());
    1.39 +
    1.40 +        string text3;
    1.41 +
    1.42 +        while (!inFile3.eof()) {
    1.43 +            static string line;
    1.44 +            getline(inFile3, line);
    1.45 +            text3 += line + "\r\n";
    1.46 +        }
    1.47 +        inFile3.close();
    1.48 +
    1.49 +        message* msg;
    1.50 +        const char* text3_str = text3.c_str();
    1.51 +
    1.52 +        //cout << text3.c_str();
    1.53 +//        parse_mailmessage(text3_str, &msg);
    1.54 +        
    1.55 +         message *msg5 = nullptr;
    1.56 +         PEP_STATUS status5 = mime_decode_message(text3.c_str(), text3.length(), &msg5);
    1.57 +         assert(status5 == PEP_STATUS_OK);
    1.58 +//         //    cout << msg5->longmsg;
    1.59 +// 
    1.60 +//             message *msg6 = nullptr;
    1.61 +//             stringlist_t *keylist5 = nullptr;
    1.62 +//             PEP_color color2;
    1.63 +//             PEP_decrypt_flags_t flags2;
    1.64 +//             PEP_STATUS status6 = decrypt_message(session, msg5, &msg6, &keylist5, &color2, &flags2);
    1.65 +        //     assert(status6 == PEP_DECRYPT_NO_KEY);
    1.66 +        //     assert(msg6 == NULL);
    1.67 +        //     assert(keylist5 == NULL);
    1.68 +        //     assert(color2 == PEP_rating_have_no_key);
    1.69 +        //     cout << "color :" << color2 << "\n";
    1.70 +        //     free_stringlist(keylist5);
    1.71 +        // 
    1.72 +        //     cout << "freeing messages…\n";
    1.73 +        //     free_message(msg4);
    1.74 +        //     free_message(msg3);
    1.75 +        //     free_message(msg2);
    1.76 +        //     free_message(enc_msg2);
    1.77 +        //     free_message(msg6);
    1.78 +        //     free_message(msg5);
    1.79 +        //     cout << "done.\n";
    1.80 +        cout << "calling release()\n";
    1.81 +        release(session);
    1.82 +    //}
    1.83 +    return 0;
    1.84 +}