stowing changes
authorKrista Grothoff <krista@pep-project.org>
Fri, 11 Nov 2016 12:00:56 +0100
changeset 1375903b67db9d42
parent 1374 95d36885f5a7
child 1376 0404bdfa9beb
stowing changes
test/encrypt_missing_private_key_test.c
test/encrypt_missing_private_key_test.cc
     1.1 --- a/test/encrypt_missing_private_key_test.cc	Fri Nov 11 12:00:19 2016 +0100
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,101 +0,0 @@
     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() {
    1.18 -    cout << "\n*** blacklist_test ***\n\n";
    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 -    // blacklist test code
    1.29 -
    1.30 -    cout << "blacklist only key for identity / add key / check which key is used" << endl;
    1.31 -    
    1.32 -    // 2797 65A2 FEB5 B7C7 31B8  61D9 3E4C EFD9 F7AF 4684 - this is the blacklisted key in blacklisted_pub.asc
    1.33 -
    1.34 -    /* read the key into memory */
    1.35 -    ifstream infile("blacklisted_pub.asc");
    1.36 -    string keytext;
    1.37 -    while (!infile.eof()) {
    1.38 -        static string line;
    1.39 -        getline(infile, line);
    1.40 -        keytext += line + "\n";
    1.41 -    }
    1.42 -    infile.close(); 
    1.43 -    
    1.44 -    /* import it into pep */
    1.45 -    PEP_STATUS status7 = import_key(session, keytext.c_str(), keytext.length(), NULL);
    1.46 -    
    1.47 -    const char* bl_fpr_1 = "279765A2FEB5B7C731B861D93E4CEFD9F7AF4684";
    1.48 -    bool is_blacklisted = false;
    1.49 -    
    1.50 -    pEp_identity* blacklisted_identity = new_identity("blacklistedkeys@kgrothoff.org",
    1.51 -                                                      bl_fpr_1,
    1.52 -                                                      NULL,
    1.53 -                                                      "Blacklist Keypair");
    1.54 -    PEP_STATUS status8 = update_identity(session, blacklisted_identity);
    1.55 -    PEP_STATUS status9 = blacklist_add(session, bl_fpr_1);
    1.56 -    PEP_STATUS status10 = blacklist_is_listed(session, bl_fpr_1, &is_blacklisted);
    1.57 -    PEP_STATUS status11 = update_identity(session, blacklisted_identity);
    1.58 -
    1.59 -    /* identity is blacklisted. Now let's try to encrypt a message. */
    1.60 -    
    1.61 -    const char* new_key = NULL;    
    1.62 -    
    1.63 -    ifstream infile2("test_mails/blacklist_no_key.eml");
    1.64 -    string mailtext;
    1.65 -    while (!infile2.eof()) {
    1.66 -        static string line;
    1.67 -        getline(infile2, line);
    1.68 -        mailtext += line + "\n";
    1.69 -    }     infile2.close(); 
    1.70 -
    1.71 -    message* enc_msg = NULL;
    1.72 -    
    1.73 -    PEP_STATUS status69 = MIME_encrypt_message(session, mailtext.c_str(), mailtext.length(), NULL, &enc_msg, PEP_enc_PGP_MIME, 0);
    1.74 -//    pEp_identity * me1 = new_identity("blacklist_test@kgrothoff.org", NULL, PEP_OWN_USERID, "Blacklisted Key Message Recipient");    
    1.75 -
    1.76 -    new_key = enc_msg->from->fpr;
    1.77 -    cout << "Encrypted with key " << new_key << endl;
    1.78 -//     PEP_STATUS status = update_identity(session, me1);
    1.79 -//     message* msg_ptr = nullptr;
    1.80 -//     message* dest_msg = nullptr;
    1.81 -//     stringlist_t* keylist = nullptr;
    1.82 -//     PEP_rating rating;
    1.83 -//     PEP_decrypt_flags_t flags;
    1.84 -//     
    1.85 -//     status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr);
    1.86 -//     assert(status == PEP_STATUS_OK);
    1.87 -//     status = decrypt_message(session, msg_ptr, &dest_msg, &keylist, &rating, &flags);
    1.88 -// 
    1.89 -//     PEP_STATUS status12 = update_identity(session, blacklisted_identity);
    1.90 -// 
    1.91 -//     assert(strcasecmp(blacklisted_identity->fpr, new_key) == 0);
    1.92 -    
    1.93 -    PEP_STATUS status = delete_keypair(session, new_key);
    1.94 -    PEP_STATUS status13 = blacklist_delete(session, bl_fpr_1);
    1.95 -    PEP_STATUS status14 = update_identity(session, blacklisted_identity);
    1.96 -
    1.97 -    
    1.98 -    free_message(enc_msg);
    1.99 -    
   1.100 -    cout << "calling release()\n";
   1.101 -    release(session);
   1.102 -    return 0;
   1.103 -}
   1.104 -