Partial test for revoked key attachement
authorEdouard Tisserant
Mon, 30 May 2016 20:11:41 +0200
changeset 7005d543921a9c6
parent 699 5665c57e9965
child 701 331a6b3aaeab
Partial test for revoked key attachement
test/revoke_regen_attach_test.cc
     1.1 --- a/test/revoke_regen_attach_test.cc	Mon May 30 12:25:14 2016 +0200
     1.2 +++ b/test/revoke_regen_attach_test.cc	Mon May 30 20:11:41 2016 +0200
     1.3 @@ -1,5 +1,6 @@
     1.4  #include <stdlib.h>
     1.5  #include <string.h>
     1.6 +#include <time.h>
     1.7  #include "platform.h"
     1.8  #include <iostream>
     1.9  #include <fstream>
    1.10 @@ -15,13 +16,14 @@
    1.11      PEP_SESSION session;
    1.12      
    1.13      cout << "calling init()\n";
    1.14 -    PEP_STATUS status1 = init(&session);   
    1.15 -    assert(status1 == PEP_STATUS_OK);
    1.16 +    PEP_STATUS status = init(&session);   
    1.17 +    assert(status == PEP_STATUS_OK);
    1.18      assert(session);
    1.19      cout << "init() completed.\n";
    1.20  
    1.21      cout << "creating own id for : ";
    1.22      char *uniqname = strdup("AAAAtestuser@testdomain.org");
    1.23 +    srandom(time(NULL));
    1.24      for(int i=0; i < 4;i++)
    1.25          uniqname[i] += random() & 0xf;
    1.26      
    1.27 @@ -35,6 +37,8 @@
    1.28  
    1.29      const char *prev_fpr = strdup(me->fpr);
    1.30      
    1.31 +    cout << "revoke \n";
    1.32 +    
    1.33      key_compromized(session, me);
    1.34  
    1.35      cout << "re-generated fingerprint \n";
    1.36 @@ -42,8 +46,36 @@
    1.37      
    1.38      assert(strcmp(me->fpr, prev_fpr));
    1.39  
    1.40 +    identity_list *to = new_identity_list(new_identity("vb@dingens.org", NULL, "42", "Volker Birk"));
    1.41 +    message *msg = new_message(PEP_dir_outgoing);
    1.42 +    assert(msg);
    1.43 +    msg->from = me;
    1.44 +    msg->to = to;
    1.45 +    msg->shortmsg = strdup("hello, world");
    1.46 +    cout << "message created.\n";
    1.47  
    1.48 -    // TODO test that revocation is attached to message for some time...
    1.49 +    cout << "encrypting message as MIME multipart…\n";
    1.50 +    message *enc_msg;
    1.51 +    cout << "calling encrypt_message()\n";
    1.52 +    status = encrypt_message(session, msg, NULL, &enc_msg, PEP_enc_PGP_MIME);
    1.53 +    cout << status;
    1.54 +    assert(status == PEP_STATUS_OK);
    1.55 +    assert(enc_msg);
    1.56 +    cout << "message encrypted.\n";
    1.57 +
    1.58 +    cout << msg->attachments->filename;
    1.59 +    assert(bloblist_length(msg->attachments) == 2);
    1.60 +    assert(strcmp(msg->attachments->filename, "pEpkey.asc") == 0);
    1.61 +    assert(strcmp(msg->attachments->next->filename, "pEpkey.asc") == 0);
    1.62 +
    1.63 +    cout << "message contains 2 key attachements.\n";
    1.64 +
    1.65 +    free_message(msg);
    1.66 +    free_message(enc_msg);
    1.67 +   
    1.68 +    // TODO: check that revoked key isn't sent after some time.
    1.69 +
    1.70 +    release(session);
    1.71  
    1.72      return 0;
    1.73  }