test/memoryhole_test.cc
author Krista Grothoff <krista@pep-project.org>
Wed, 19 Oct 2016 13:09:48 +0200
branchENGINE-118
changeset 1323 4501141bf217
permissions -rw-r--r--
Added memoryhole_test file
krista@1323
     1
#include <stdlib.h>
krista@1323
     2
#include <string.h>
krista@1323
     3
#include "platform.h"
krista@1323
     4
#include <iostream>
krista@1323
     5
#include <fstream>
krista@1323
     6
#include <assert.h>
krista@1323
     7
#include "mime.h"
krista@1323
     8
#include "message_api.h"
krista@1323
     9
krista@1323
    10
using namespace std;
krista@1323
    11
krista@1323
    12
krista@1323
    13
int main(int argc, char** argv) {
krista@1323
    14
    
krista@1323
    15
        const char* filename = "test_mails/memoryhole_B.eml";
krista@1323
    16
        
krista@1323
    17
        PEP_SESSION session;
krista@1323
    18
krista@1323
    19
        cout << "calling init()\n";
krista@1323
    20
        PEP_STATUS status1 = init(&session);
krista@1323
    21
        assert(status1 == PEP_STATUS_OK);
krista@1323
    22
        assert(session);
krista@1323
    23
        cout << "init() completed.\n";
krista@1323
    24
krista@1323
    25
        // message_api test code
krista@1323
    26
krista@1323
    27
        // pEp_identity * me2 = new_identity("pep.test.alice@pep-project.org", NULL, PEP_OWN_USERID, "Alice Test");
krista@1323
    28
        // pEp_identity * me2 = new_identity("test@nokey.plop", NULL, PEP_OWN_USERID, "Test no key");
krista@1323
    29
krista@1323
    30
        // FIXME: Ugh. Maybe identities have to be args. But this is a kludge.
krista@1323
    31
        pEp_identity* me2 = new_identity("krista@kgrothoff.org", "62D4932086185C15917B72D30571AFBCA5493553", PEP_OWN_USERID, "Krista Grothoff");
krista@1323
    32
        me2->me = true;
krista@1323
    33
krista@1323
    34
        ifstream inFile3(filename);
krista@1323
    35
        assert(inFile3.is_open());
krista@1323
    36
krista@1323
    37
        string text3;
krista@1323
    38
krista@1323
    39
        while (!inFile3.eof()) {
krista@1323
    40
            static string line;
krista@1323
    41
            getline(inFile3, line);
krista@1323
    42
            text3 += line + "\r\n";
krista@1323
    43
        }
krista@1323
    44
        inFile3.close();
krista@1323
    45
krista@1323
    46
        message* msg;
krista@1323
    47
        const char* text3_str = text3.c_str();
krista@1323
    48
krista@1323
    49
        //cout << text3.c_str();
krista@1323
    50
//        parse_mailmessage(text3_str, &msg);
krista@1323
    51
        
krista@1323
    52
         message *msg5 = nullptr;
krista@1323
    53
         PEP_STATUS status5 = mime_decode_message(text3.c_str(), text3.length(), &msg5);
krista@1323
    54
         assert(status5 == PEP_STATUS_OK);
krista@1323
    55
//         //    cout << msg5->longmsg;
krista@1323
    56
// 
krista@1323
    57
//             message *msg6 = nullptr;
krista@1323
    58
//             stringlist_t *keylist5 = nullptr;
krista@1323
    59
//             PEP_color color2;
krista@1323
    60
//             PEP_decrypt_flags_t flags2;
krista@1323
    61
//             PEP_STATUS status6 = decrypt_message(session, msg5, &msg6, &keylist5, &color2, &flags2);
krista@1323
    62
        //     assert(status6 == PEP_DECRYPT_NO_KEY);
krista@1323
    63
        //     assert(msg6 == NULL);
krista@1323
    64
        //     assert(keylist5 == NULL);
krista@1323
    65
        //     assert(color2 == PEP_rating_have_no_key);
krista@1323
    66
        //     cout << "color :" << color2 << "\n";
krista@1323
    67
        //     free_stringlist(keylist5);
krista@1323
    68
        // 
krista@1323
    69
        //     cout << "freeing messages…\n";
krista@1323
    70
        //     free_message(msg4);
krista@1323
    71
        //     free_message(msg3);
krista@1323
    72
        //     free_message(msg2);
krista@1323
    73
        //     free_message(enc_msg2);
krista@1323
    74
        //     free_message(msg6);
krista@1323
    75
        //     free_message(msg5);
krista@1323
    76
        //     cout << "done.\n";
krista@1323
    77
        cout << "calling release()\n";
krista@1323
    78
        release(session);
krista@1323
    79
    //}
krista@1323
    80
    return 0;
krista@1323
    81
}