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