test/encrypt_missing_private_key_test.cc
branchENGINE-189
changeset 1660 e153b77f3e52
parent 1513 e7f7e42385b5
child 1925 bee52dae2cb9
     1.1 --- a/test/encrypt_missing_private_key_test.cc	Mon Mar 13 20:47:49 2017 +0100
     1.2 +++ b/test/encrypt_missing_private_key_test.cc	Mon Mar 13 20:48:39 2017 +0100
     1.3 @@ -11,6 +11,7 @@
     1.4  #include "keymanagement.h"
     1.5  #include "message_api.h"
     1.6  #include "mime.h"
     1.7 +#include "test_util.h"
     1.8  
     1.9  using namespace std;
    1.10  
    1.11 @@ -31,15 +32,7 @@
    1.12      
    1.13      // B252066DE0513BECA2954F30E8E18177B28D9B9D - this is the blacklisted key in blacklisted_self.asc
    1.14  
    1.15 -    /* read the key into memory */
    1.16 -    ifstream infile("test_keys/priv/blacklist_self.asc");
    1.17 -    string keytext;
    1.18 -    while (!infile.eof()) {
    1.19 -        static string line;
    1.20 -        getline(infile, line);
    1.21 -        keytext += line + "\n";
    1.22 -    }
    1.23 -    infile.close(); 
    1.24 +    const string keytext = slurp("test_keys/priv/blacklist_self.asc");
    1.25      
    1.26      /* import it into pep */
    1.27      PEP_STATUS status7 = import_key(session, keytext.c_str(), keytext.length(), NULL);
    1.28 @@ -59,16 +52,9 @@
    1.29  
    1.30      /* identity is blacklisted. Now let's try to encrypt a message. */
    1.31      
    1.32 -    const char* new_key = NULL;    
    1.33 +    const char* new_key = NULL;
    1.34      
    1.35 -    ifstream infile2("test_mails/blacklist_no_key.eml");
    1.36 -    string mailtext;
    1.37 -    while (!infile2.eof()) {
    1.38 -        static string line;
    1.39 -        getline(infile2, line);
    1.40 -        mailtext += line + "\n";
    1.41 -    }     infile2.close(); 
    1.42 -
    1.43 +    const string mailtext = slurp("test_mails/blacklist_no_key.eml");
    1.44      
    1.45      message* tmp_msg = NULL;
    1.46      message* enc_msg = NULL;
    1.47 @@ -77,7 +63,6 @@
    1.48      assert(status == PEP_STATUS_OK);
    1.49      
    1.50      
    1.51 -    
    1.52      // This isn't incoming, though... so we need to reverse the direction
    1.53      tmp_msg->dir = PEP_dir_outgoing;
    1.54      status = encrypt_message(session,
    1.55 @@ -88,7 +73,6 @@
    1.56                               0);
    1.57      assert(status == PEP_STATUS_OK);
    1.58      
    1.59 -    
    1.60  //    PEP_STATUS status69 = MIME_encrypt_message(session, mailtext.c_str(), mailtext.length(), NULL, &enc_msg, PEP_enc_PGP_MIME, 0);
    1.61  //    pEp_identity * me1 = new_identity("blacklist_test@kgrothoff.org", NULL, PEP_OWN_USERID, "Blacklisted Key Message Recipient");    
    1.62  
    1.63 @@ -121,4 +105,3 @@
    1.64      release(session);
    1.65      return 0;
    1.66  }
    1.67 -