test/revoke_regen_attach_test.cc
author Edouard Tisserant
Mon, 30 May 2016 12:25:14 +0200
changeset 699 5665c57e9965
child 700 5d543921a9c6
permissions -rw-r--r--
added revocation unittest, fixed test/Makefile so that unuttest can be run individually
     1 #include <stdlib.h>
     2 #include <string.h>
     3 #include "platform.h"
     4 #include <iostream>
     5 #include <fstream>
     6 #include <assert.h>
     7 #include "mime.h"
     8 #include "message_api.h"
     9 
    10 using namespace std;
    11 
    12 int main() {
    13     cout << "\n*** revoke_regen_attach_test ***\n\n";
    14 
    15     PEP_SESSION session;
    16     
    17     cout << "calling init()\n";
    18     PEP_STATUS status1 = init(&session);   
    19     assert(status1 == PEP_STATUS_OK);
    20     assert(session);
    21     cout << "init() completed.\n";
    22 
    23     cout << "creating own id for : ";
    24     char *uniqname = strdup("AAAAtestuser@testdomain.org");
    25     for(int i=0; i < 4;i++)
    26         uniqname[i] += random() & 0xf;
    27     
    28     cout << uniqname << "\n";
    29     pEp_identity * me = new_identity(uniqname, NULL, PEP_OWN_USERID, "Test User");
    30     free(uniqname);
    31     myself(session, me);
    32 
    33     cout << "generated fingerprint \n";
    34     cout << me->fpr << "\n";
    35 
    36     const char *prev_fpr = strdup(me->fpr);
    37     
    38     key_compromized(session, me);
    39 
    40     cout << "re-generated fingerprint \n";
    41     cout << me->fpr << "\n";
    42     
    43     assert(strcmp(me->fpr, prev_fpr));
    44 
    45 
    46     // TODO test that revocation is attached to message for some time...
    47 
    48     return 0;
    49 }
    50