added revocation unittest, fixed test/Makefile so that unuttest can be run individually
authorEdouard Tisserant
Mon, 30 May 2016 12:25:14 +0200
changeset 6995665c57e9965
parent 698 870bbc6ea19c
child 700 5d543921a9c6
added revocation unittest, fixed test/Makefile so that unuttest can be run individually
test/Makefile
test/revoke_regen_attach_test.cc
     1.1 --- a/test/Makefile	Sun May 29 21:28:33 2016 +0200
     1.2 +++ b/test/Makefile	Mon May 30 12:25:14 2016 +0200
     1.3 @@ -16,6 +16,7 @@
     1.4  
     1.5  UNIT_TESTS_SOURCE=$(wildcard *_test.cc)
     1.6  UNIT_TESTS=$(subst .cc,,$(UNIT_TESTS_SOURCE))
     1.7 +UNIT_TESTS_RUN=$(subst .cc,_run,$(UNIT_TESTS_SOURCE))
     1.8  
     1.9  all: $(TARGET) $(UNIT_TESTS)
    1.10  
    1.11 @@ -28,10 +29,10 @@
    1.12  test: pEpEngineTest
    1.13  	LD_LIBRARY_PATH=~/lib:../src ./pEpEngineTest
    1.14  
    1.15 -unit_tests: $(UNIT_TESTS)
    1.16 -	for t in ./*_test ; do \
    1.17 -		if LD_LIBRARY_PATH=~/lib:../src $$t ; then true; else break; fi \
    1.18 -	done
    1.19 +%_test_run : %_test
    1.20 +	LD_LIBRARY_PATH=~/lib:../src ./$<
    1.21 +
    1.22 +unit_tests: $(UNIT_TESTS) $(UNIT_TESTS_RUN)
    1.23  
    1.24  install:
    1.25  	make -C .. install
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/test/revoke_regen_attach_test.cc	Mon May 30 12:25:14 2016 +0200
     2.3 @@ -0,0 +1,50 @@
     2.4 +#include <stdlib.h>
     2.5 +#include <string.h>
     2.6 +#include "platform.h"
     2.7 +#include <iostream>
     2.8 +#include <fstream>
     2.9 +#include <assert.h>
    2.10 +#include "mime.h"
    2.11 +#include "message_api.h"
    2.12 +
    2.13 +using namespace std;
    2.14 +
    2.15 +int main() {
    2.16 +    cout << "\n*** revoke_regen_attach_test ***\n\n";
    2.17 +
    2.18 +    PEP_SESSION session;
    2.19 +    
    2.20 +    cout << "calling init()\n";
    2.21 +    PEP_STATUS status1 = init(&session);   
    2.22 +    assert(status1 == PEP_STATUS_OK);
    2.23 +    assert(session);
    2.24 +    cout << "init() completed.\n";
    2.25 +
    2.26 +    cout << "creating own id for : ";
    2.27 +    char *uniqname = strdup("AAAAtestuser@testdomain.org");
    2.28 +    for(int i=0; i < 4;i++)
    2.29 +        uniqname[i] += random() & 0xf;
    2.30 +    
    2.31 +    cout << uniqname << "\n";
    2.32 +    pEp_identity * me = new_identity(uniqname, NULL, PEP_OWN_USERID, "Test User");
    2.33 +    free(uniqname);
    2.34 +    myself(session, me);
    2.35 +
    2.36 +    cout << "generated fingerprint \n";
    2.37 +    cout << me->fpr << "\n";
    2.38 +
    2.39 +    const char *prev_fpr = strdup(me->fpr);
    2.40 +    
    2.41 +    key_compromized(session, me);
    2.42 +
    2.43 +    cout << "re-generated fingerprint \n";
    2.44 +    cout << me->fpr << "\n";
    2.45 +    
    2.46 +    assert(strcmp(me->fpr, prev_fpr));
    2.47 +
    2.48 +
    2.49 +    // TODO test that revocation is attached to message for some time...
    2.50 +
    2.51 +    return 0;
    2.52 +}
    2.53 +