Merged in new test framework. Note: it's not yet documented and will fail without libcpptest installed. So install it (preferably from source, see README in test)
authorKrista Bennett <krista@pep-project.org>
Fri, 11 May 2018 08:58:04 +0200
changeset 267241b8d284de9f
parent 2665 574f882fe6a0
parent 2671 9c3eff7e7b54
child 2673 7e09a0b166c9
Merged in new test framework. Note: it's not yet documented and will fail without libcpptest installed. So install it (preferably from source, see README in test)
test/_test_template_cc
test/apple_mail_test.cc
test/blacklist_accept_new_key_test.cc
test/blacklist_test.cc
test/bloblist_test.cc
test/case_and_dot_address_test.cc
test/crashdump_test.cc
test/decorate_test.cc
test/decrypt_attach_private_key_trusted_test.cc
test/decrypt_attach_private_key_untrusted_test.cc
test/encrypt_attach_private_key_test.cc
test/encrypt_for_identity_test.cc
test/encrypt_missing_private_key_test.cc
test/external_revoke_test.cc
test/i18n_test.cc
test/identity_list_test.cc
test/keyedit_test.cc
test/least_color_group_test.cc
test/least_common_denom_color_test.cc
test/map_asn1_test.cc
test/message_2.0_test.cc
test/message_api_test.cc
test/mime_test.cc
test/mistrust_undo_test.cc
test/msg_2.0.asc
test/new_update_id_and_myself_test.cc
test/pEpEngine_test.h
test/pEp_subject_received_test.cc
test/pgp_binary_test.cc
test/pgp_list_keys_test.cc
test/reencrypt_plus_extra_keys_test.cc
test/revoke_regen_attach_test.cc
test/sequence_test.cc
test/stringlist_test.cc
test/stringpair_list_test.cc
test/test_util.cc
test/test_util.h
test/trust_manipulation_test.cc
test/trustwords_test.cc
test/userid_alias_test.cc
     1.1 --- a/.hgignore	Wed May 09 09:51:05 2018 +0200
     1.2 +++ b/.hgignore	Fri May 11 08:58:04 2018 +0200
     1.3 @@ -61,4 +61,9 @@
     1.4  __pycache__
     1.5  *.pyc
     1.6  test/python_tests/test?
     1.7 -
     1.8 +test/pEp_test_home
     1.9 +test/TestDriver
    1.10 +test/local
    1.11 +.tags
    1.12 +*/.tags
    1.13 +*/*/.tags
     2.1 --- a/test/Makefile	Wed May 09 09:51:05 2018 +0200
     2.2 +++ b/test/Makefile	Fri May 11 08:58:04 2018 +0200
     2.3 @@ -1,120 +1,114 @@
     2.4 +
     2.5  # Copyright 2017, pEp Foundation
     2.6  # This file is part of pEpEngine
     2.7  # This file may be used under the terms of the GNU General Public License version 3
     2.8  # see LICENSE.txt
     2.9  
    2.10 -HERE:=$(CURDIR)
    2.11 -
    2.12  include ../default.conf
    2.13  
    2.14 -TARGET=pEpEngineTest
    2.15 +PY_ENV := $(shell command -v python3 2> /dev/null)
    2.16  
    2.17 -unexport GNUPGHOME
    2.18 -TEST_HOME=$(HERE)test_home
    2.19 -TEST_GNUPGHOME=$(TEST_HOME)/gnupg
    2.20 +HERE:=$(CURDIR)
    2.21 +TEST_HOME=$(HERE)/pEp_test_home
    2.22 +
    2.23 +TARGET=TestDriver
    2.24 +
    2.25 +SRCS := $(wildcard src/*.cc) $(wildcard src/*/*.cc)
    2.26 +OBJS := $(addsuffix .o,$(basename $(SRCS)))
    2.27 +DEPS := $(OBJS:.o=.d)
    2.28 +
    2.29 +INC_DIRS := ./include /usr/local/include  
    2.30 +INC_FLAGS := $(addprefix -I,$(INC_DIRS))
    2.31 +
    2.32 +LDFLAGS += -L/usr/local/lib
    2.33 +
    2.34 +CFLAGS += -Wno-deprecated
    2.35 +CXXFLAGS += -Wno-deprecated
    2.36  
    2.37  LDFLAGS+= $(ETPAN_LIB) -L../asn.1 -L../src
    2.38  LDLIBS+= -letpan -lpEpEngine -lstdc++ -lasn1
    2.39  
    2.40  ifeq ($(BUILD_FOR),Linux)
    2.41 -    LDLIBS+= -luuid
    2.42 +	LDLIBS+= -luuid
    2.43  endif
    2.44  
    2.45  ifeq ($(OPENPGP),NETPGP)
    2.46 -    LDLIBS+= -lnetpgp
    2.47 +	LDLIBS+= -lnetpgp
    2.48  endif
    2.49  
    2.50  ifdef SQLITE3_FROM_OS
    2.51 -    LDLIBS+= -lsqlite3
    2.52 +	LDLIBS+= -lsqlite3
    2.53  endif
    2.54  
    2.55  ifeq ($(shell uname),Darwin)
    2.56 -    LIBPATH=DYLD_LIBRARY_PATH
    2.57 -    LLDB_BIN=/Applications/Xcode.app/Contents/Developer/usr/bin/lldb
    2.58 +	LIBPATH=DYLD_LIBRARY_PATH
    2.59 +	LLDB_BIN=/Applications/Xcode.app/Contents/Developer/usr/bin/lldb
    2.60  else
    2.61 -    LIBPATH=LD_LIBRARY_PATH
    2.62 -    LLDB_BIN=lldb
    2.63 +	LIBPATH=LD_LIBRARY_PATH
    2.64 +	LLDB_BIN=lldb
    2.65  endif
    2.66  
    2.67 +LDLIBS += -lcpptest
    2.68 +
    2.69 +
    2.70  # Create a list of the extra library paths for the loader. I do not assume that the engine (and its dependencies) are installed for testing.
    2.71  # Note that += can not be used here, as it changes the amount of whitespace
    2.72  EXTRA_LIB_PATHS=../src:
    2.73  ifdef ETPAN_LIB
    2.74 -    EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(ETPAN_LIB)):
    2.75 +	EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(ETPAN_LIB)):
    2.76  endif
    2.77  ifdef GPGME_LIB
    2.78 -    EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(GPGME_LIB)):
    2.79 +	EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(GPGME_LIB)):
    2.80  endif
    2.81  ifdef NETPGP_LIB
    2.82 -    EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(NETPGP_LIB)):
    2.83 +	EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS)$(patsubst -L%,%,$(NETPGP_LIB)):
    2.84  endif
    2.85 +
    2.86  # Remove trailing ':'
    2.87  EXTRA_LIB_PATHS:=$(EXTRA_LIB_PATHS::=)
    2.88  
    2.89 -TEST_CMD_PFX=$(LIBPATH)=$(EXTRA_LIB_PATHS) HOME=$(TEST_HOME) GNUPGHOME=$(TEST_GNUPGHOME)
    2.90 -
    2.91 -UNIT_TESTS_SOURCE=$(wildcard *_test.cc) 
    2.92 -UNIT_TESTS=$(subst .cc,,$(UNIT_TESTS_SOURCE))
    2.93 -UNIT_TESTS_RUN=$(subst .cc,_run,$(UNIT_TESTS_SOURCE))
    2.94 -
    2.95  CFLAGS:=$(filter-out -DNDEBUG,$(CFLAGS))
    2.96  ifneq ($(MAKECMDGOALS),clean)
    2.97 -    ifneq (,$(findstring -DNDEBUG,$(CFLAGS)))
    2.98 -        $(error The macro NDEBUG must not be defined for test compilation.)
    2.99 -    endif
   2.100 +	ifneq (,$(findstring -DNDEBUG,$(CFLAGS)))
   2.101 +		$(error The macro NDEBUG must not be defined for test compilation.)
   2.102 +	endif
   2.103  endif
   2.104  
   2.105  CXXFLAGS:=$(filter-out -DNDEBUG,$(CXXFLAGS))
   2.106  ifneq ($(MAKECMDGOALS),clean)
   2.107 -    ifneq (,$(findstring -DNDEBUG,$(CXXFLAGS)))
   2.108 -        $(error The macro NDEBUG must not be defined for test compilation.)
   2.109 -    endif
   2.110 +	ifneq (,$(findstring -DNDEBUG,$(CXXFLAGS)))
   2.111 +		$(error The macro NDEBUG must not be defined for test compilation.)
   2.112 +	endif
   2.113  endif
   2.114  
   2.115 -.PHONY: all
   2.116 -all: $(TARGET) $(UNIT_TESTS)
   2.117 +CPPFLAGS += $(INC_FLAGS) -MMD -MP
   2.118  
   2.119 -# don't delete .o files!
   2.120 -.PRECIOUS: %.o
   2.121 +all: suitemaker $(TARGET) test_home_
   2.122 +	
   2.123 +$(TARGET): $(OBJS)
   2.124 +	$(CXX) $(CPPFLAGS) $(LDFLAGS) $(OBJS) $(LDFLAGS) $(LDLIBS) -o $@
   2.125  
   2.126 +.PHONY: suitemaker
   2.127 +suitemaker:
   2.128 +ifndef PY_ENV
   2.129 +	@echo "WARNING: Can't find python3 - this is fine unless you're adding test suites. If so, please install python3."
   2.130 +else
   2.131 +	$(PY_ENV) gensuitemaker.py
   2.132 +endif
   2.133 +		
   2.134  .PHONY: test_home_
   2.135  test_home_: 
   2.136 -	-GNUPGHOME=$(TEST_GNUPGHOME) gpgconf --kill gpg-agent
   2.137 -	rm -rf $(TEST_HOME)
   2.138 -	mkdir -p $(TEST_GNUPGHOME)/private-keys-v1.d
   2.139 -	$(GPG_CMD) --import --batch --homedir $(TEST_GNUPGHOME) 0x*.asc *_sec.asc
   2.140 +	mkdir -p $(TEST_HOME)
   2.141  
   2.142 +.PHONY: test
   2.143 +test: all
   2.144 +	./$(TARGET)
   2.145 +	
   2.146  .PHONY: clean
   2.147  clean:
   2.148 -	rm -f *.o $(TARGET) *.a *~ $(UNIT_TESTS) pep_Dokument_Titel.pdf msg4.asc msg_encrypt_for_self.asc
   2.149 -	rm -Rf *.dSYM $(TEST_HOME) pubring.gpg secring.gpg random_seed *.conf trustdb.gpg
   2.150 +	$(RM) $(TARGET) $(OBJS) $(DEPS)
   2.151  
   2.152 -.PHONY: test
   2.153 -test: $(TARGET) test_home_
   2.154 -	$(TEST_CMD_PFX) ./$<
   2.155  
   2.156 -%_test : %_test.o test_util.o
   2.157 -	$(CXX) $^ $(LDFLAGS) $(LDLIBS) -o $@
   2.158  
   2.159 -%_run : % test_home_
   2.160 -	$(TEST_CMD_PFX) ./$<
   2.161 -
   2.162 -%_lldb : % test_home_
   2.163 -	$(TEST_CMD_PFX) $(LLDB_BIN) ./$<
   2.164 -
   2.165 -%_valgrind : % test_home_
   2.166 -	$(TEST_CMD_PFX) valgrind --leak-check=yes ./$<
   2.167 -
   2.168 -%_gdb : % test_home_
   2.169 -	$(TEST_CMD_PFX) gdb ./$<
   2.170 -
   2.171 -.PHONY: unit_tests
   2.172 -unit_tests: $(UNIT_TESTS) $(UNIT_TESTS_RUN)
   2.173 -
   2.174 -.PHONY: compile
   2.175 -compile: $(UNIT_TESTS) $(TARGET)
   2.176 -
   2.177 -# Installs the engine, not the test binaries
   2.178 -.PHONY: install
   2.179 -install:
   2.180 -	$(MAKE) -C .. install
   2.181 +-include $(DEPS)
   2.182 + 
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/test/README	Fri May 11 08:58:04 2018 +0200
     3.3 @@ -0,0 +1,6 @@
     3.4 +DOCUMENTATION AND CLEANUP FORTHCOMING.
     3.5 +
     3.6 +Engine tests now require libcpptest - if you have compilation failures using your distribution's lib (I'm looking at you, Ubuntu), please download the source at http://cpptest.sourceforge.net/, compile, and run.
     3.7 +
     3.8 +New test creation requires python 3.x.
     3.9 +
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/test/README.txt	Fri May 11 08:58:04 2018 +0200
     4.3 @@ -0,0 +1,5 @@
     4.4 +Notes:
     4.5 +
     4.6 +- TEST_ASSERT is a macro and does not always behave 100% the way you'd expect. Note the following:
     4.7 +	* 1. If used in if/else blocks, make sure the blocks are guarded, or weird things happen.
     4.8 +        * 2. If performing comparisons, please parenthesise liberally - bitwise operations being compared to 0 should always be parenthesised before comparison  
     5.1 --- a/test/_test_template_cc	Wed May 09 09:51:05 2018 +0200
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,30 +0,0 @@
     5.4 -// This file is under GNU General Public License 3.0
     5.5 -// see LICENSE.txt
     5.6 -
     5.7 -#include <iostream>
     5.8 -#include <string>
     5.9 -#include <assert.h>
    5.10 -#include "pEpEngine_test.h"
    5.11 -#include "MODULE.h"
    5.12 -
    5.13 -using namespace std;
    5.14 -
    5.15 -int main() {
    5.16 -    cout << "\n*** MODULE_test ***\n\n";
    5.17 -
    5.18 -    PEP_SESSION session;
    5.19 -    
    5.20 -    cout << "calling init()\n";
    5.21 -    PEP_STATUS status1 = init(&session);   
    5.22 -    ASSERT_STATUS(status1);
    5.23 -    assert(session);
    5.24 -    cout << "init() completed.\n";
    5.25 -
    5.26 -    // MODULE test code
    5.27 -
    5.28 -
    5.29 -    cout << "calling release()\n";
    5.30 -    release(session);
    5.31 -    return 0;
    5.32 -}
    5.33 -
     6.1 --- a/test/apple_mail_test.cc	Wed May 09 09:51:05 2018 +0200
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,115 +0,0 @@
     6.4 -#include <iostream>
     6.5 -#include <iostream>
     6.6 -#include <fstream>
     6.7 -#include <string>
     6.8 -#include <cstring> // for strcmp()
     6.9 -#include <assert.h>
    6.10 -#include "blacklist.h"
    6.11 -#include "keymanagement.h"
    6.12 -#include "message_api.h"
    6.13 -#include "mime.h"
    6.14 -#include "test_util.h" // for slurp()
    6.15 -
    6.16 -using namespace std;
    6.17 -
    6.18 -int main(int argc, char** argv) {
    6.19 -
    6.20 -    const char* mailfile = "test_mails/apple_mail_TC_signed_encrypted.eml";
    6.21 -    
    6.22 -    PEP_SESSION session;
    6.23 -    
    6.24 -    cout << "calling init()\n";
    6.25 -    PEP_STATUS status1 = init(&session);   
    6.26 -    assert(status1 == PEP_STATUS_OK);
    6.27 -    assert(session);
    6.28 -    cout << "init() completed.\n";
    6.29 -
    6.30 -    const string keytextkey1 = slurp("test_keys/pub/pep-test-apple-0x1CCBC7D7_pub.asc");
    6.31 -    const string keytextkey2 = slurp("test_keys/priv/pep-test-recip-0x08DB0AEE_priv.asc");
    6.32 -    const string keytextkey3 = slurp("test_keys/pub/pep-test-recip-0x08DB0AEE_pub.asc");
    6.33 -
    6.34 -    PEP_STATUS statuskey1 = import_key(session, keytextkey1.c_str(), keytextkey1.length(), NULL);
    6.35 -    PEP_STATUS statuskey2 = import_key(session, keytextkey2.c_str(), keytextkey2.length(), NULL);
    6.36 -    PEP_STATUS statuskey3 = import_key(session, keytextkey3.c_str(), keytextkey3.length(), NULL);
    6.37 -        
    6.38 -    const string mailtext = slurp(mailfile);
    6.39 -    pEp_identity * me = new_identity("pep.test.recip@kgrothoff.org", "93D19F24AD6F4C4BA9134AAF84D9217908DB0AEE", PEP_OWN_USERID, "pEp Test Recipient");    
    6.40 -    me->me = true;    
    6.41 -    PEP_STATUS status = set_own_key(session, me, "93D19F24AD6F4C4BA9134AAF84D9217908DB0AEE");
    6.42 -    
    6.43 -    pEp_identity * you = new_identity("pep.test.apple@pep-project.org", NULL, "pep.test.apple@pep-project.org", "pEp Apple Test");    
    6.44 -    you->me = false;    
    6.45 -    status = update_identity(session, you);
    6.46 -
    6.47 -    trust_personal_key(session, you);
    6.48 -    
    6.49 -    status = update_identity(session, you);
    6.50 -    
    6.51 -    message* msg_ptr = nullptr;
    6.52 -    message* dest_msg = nullptr;
    6.53 -    message* final_ptr = nullptr;
    6.54 -    stringlist_t* keylist = nullptr;
    6.55 -    PEP_rating rating;
    6.56 -    PEP_decrypt_flags_t flags = 0;
    6.57 -    
    6.58 -    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr);
    6.59 -    assert(status == PEP_STATUS_OK);
    6.60 -    assert(msg_ptr);
    6.61 -    
    6.62 -    update_identity(session, msg_ptr->from);
    6.63 -    update_identity(session, msg_ptr->to->ident);
    6.64 -    
    6.65 -    final_ptr = msg_ptr;
    6.66 -    
    6.67 -    status = decrypt_message(session, msg_ptr, &dest_msg, &keylist, &rating, &flags);
    6.68 -    final_ptr = dest_msg ? dest_msg : msg_ptr;
    6.69 -  
    6.70 -    cout << "shortmsg: " << final_ptr->shortmsg << endl << endl;
    6.71 -    cout << "longmsg: " << final_ptr->longmsg << endl << endl;
    6.72 -    cout << "longmsg_formatted: " << (final_ptr->longmsg_formatted ? final_ptr->longmsg_formatted : "(empty)") << endl << endl;
    6.73 -
    6.74 -    assert(color_from_rating(rating) == PEP_color_green);
    6.75 -
    6.76 -    if (final_ptr == dest_msg)
    6.77 -    	free_message(dest_msg);
    6.78 -    free_message(msg_ptr);
    6.79 -    free_stringlist(keylist);
    6.80 -
    6.81 -    msg_ptr = nullptr;
    6.82 -    dest_msg = nullptr;
    6.83 -    final_ptr = nullptr;
    6.84 -    keylist = nullptr;
    6.85 -    rating = PEP_rating_unreliable;
    6.86 -    flags = 0;
    6.87 -    
    6.88 -    const char* mailfile2 = "test_mails/apple_mail_TC_html_signed_encrypted.eml";
    6.89 -    const string mailtext2 = slurp(mailfile2);
    6.90 -    
    6.91 -    status = mime_decode_message(mailtext2.c_str(), mailtext2.length(), &msg_ptr);
    6.92 -    assert(status == PEP_STATUS_OK);
    6.93 -    assert(msg_ptr);
    6.94 -    final_ptr = msg_ptr;
    6.95 -    status = decrypt_message(session, msg_ptr, &dest_msg, &keylist, &rating, &flags);
    6.96 -    final_ptr = dest_msg ? dest_msg : msg_ptr;
    6.97 -  
    6.98 -    cout << "shortmsg: " << final_ptr->shortmsg << endl << endl;
    6.99 -    cout << "longmsg: " << final_ptr->longmsg << endl << endl;
   6.100 -    cout << "longmsg_formatted: " << (final_ptr->longmsg_formatted ? final_ptr->longmsg_formatted : "(empty)") << endl << endl;
   6.101 -
   6.102 -    assert(color_from_rating(rating) == PEP_color_green);
   6.103 -
   6.104 -    if (final_ptr == dest_msg)
   6.105 -    	free_message(dest_msg);
   6.106 -    free_message(msg_ptr);
   6.107 -    free_stringlist(keylist);
   6.108 -
   6.109 -    msg_ptr = nullptr;
   6.110 -    dest_msg = nullptr;
   6.111 -    final_ptr = nullptr;
   6.112 -    keylist = nullptr;
   6.113 -    rating = PEP_rating_unreliable;
   6.114 -        
   6.115 -    cout << "calling release()\n";
   6.116 -    release(session);
   6.117 -    return 0;
   6.118 -}
     7.1 --- a/test/blacklist_accept_new_key_test.cc	Wed May 09 09:51:05 2018 +0200
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,105 +0,0 @@
     7.4 -// This file is under GNU General Public License 3.0
     7.5 -// see LICENSE.txt
     7.6 -
     7.7 -#include <iostream>
     7.8 -#include <iostream>
     7.9 -#include <fstream>
    7.10 -#include <string>
    7.11 -#include <cstring> // for strcmp()
    7.12 -#include <assert.h>
    7.13 -#include "blacklist.h"
    7.14 -#include "keymanagement.h"
    7.15 -#include "message_api.h"
    7.16 -#include "mime.h"
    7.17 -#include "test_util.h"
    7.18 -
    7.19 -using namespace std;
    7.20 -
    7.21 -int main() {
    7.22 -    cout << "\n*** blacklist_test ***\n\n";
    7.23 -
    7.24 -    PEP_SESSION session;
    7.25 -    
    7.26 -    cout << "calling init()\n";
    7.27 -    PEP_STATUS status1 = init(&session);   
    7.28 -    assert(status1 == PEP_STATUS_OK);
    7.29 -    assert(session);
    7.30 -    cout << "init() completed.\n";
    7.31 -
    7.32 -    // blacklist test code
    7.33 -
    7.34 -    cout << "blacklist only key for identity / add key / check which key is used" << endl;
    7.35 -    
    7.36 -    // 2797 65A2 FEB5 B7C7 31B8  61D9 3E4C EFD9 F7AF 4684 - this is the blacklisted key in blacklisted_pub.asc
    7.37 -
    7.38 -    /* read the key into memory */
    7.39 -    const string keytext = slurp("blacklisted_pub.asc");
    7.40 -    
    7.41 -    /* import it into pep */
    7.42 -    PEP_STATUS status7 = import_key(session, keytext.c_str(), keytext.length(), NULL);
    7.43 -    
    7.44 -    const char* bl_fpr_1 = "279765A2FEB5B7C731B861D93E4CEFD9F7AF4684";
    7.45 -    bool is_blacklisted = false;
    7.46 -    
    7.47 -    pEp_identity* blacklisted_identity = new_identity("blacklistedkeys@kgrothoff.org",
    7.48 -                                                      bl_fpr_1,
    7.49 -                                                      NULL,
    7.50 -                                                      "Blacklist Keypair");
    7.51 -    PEP_STATUS status8 = update_identity(session, blacklisted_identity);
    7.52 -    PEP_STATUS status9 = blacklist_add(session, bl_fpr_1);
    7.53 -    PEP_STATUS status10 = blacklist_is_listed(session, bl_fpr_1, &is_blacklisted);
    7.54 -    assert(is_blacklisted);
    7.55 -    PEP_STATUS status11 = update_identity(session, blacklisted_identity);
    7.56 -    assert(status11 == PEP_STATUS_OK);
    7.57 -    assert(_streq(bl_fpr_1, blacklisted_identity->fpr));
    7.58 -    
    7.59 -    bool id_def, us_def, addr_def;
    7.60 -    status11 = get_valid_pubkey(session, blacklisted_identity,
    7.61 -                                &id_def, &us_def, &addr_def, true);
    7.62 -    assert(blacklisted_identity->comm_type == PEP_ct_unknown);
    7.63 -                        
    7.64 -    if (!(blacklisted_identity->fpr))
    7.65 -        cout << "OK! blacklisted_identity->fpr is empty. Yay!" << endl;
    7.66 -    else
    7.67 -        cout << "Not OK. blacklisted_identity->fpr is " << blacklisted_identity->fpr << "." << endl
    7.68 -             << "Expected it to be empty." << endl;
    7.69 -    assert(!(blacklisted_identity->fpr) || blacklisted_identity->fpr[0] == '\0');
    7.70 -
    7.71 -    /* identity is blacklisted. Now let's read in a message which contains a new key for that ID. */
    7.72 -    
    7.73 -    const char* new_key = "634FAC4417E9B2A5DC2BD4AAC4AEEBBE7E62701B";
    7.74 -    const string mailtext = slurp("test_mails/blacklist_new_key_attached.eml");
    7.75 -    pEp_identity * me1 = new_identity("blacklist_test@kgrothoff.org", NULL, PEP_OWN_USERID, "Blacklisted Key Message Recipient");    
    7.76 -
    7.77 -    PEP_STATUS status = update_identity(session, me1);
    7.78 -    message* msg_ptr = nullptr;
    7.79 -    message* dest_msg = nullptr;
    7.80 -    stringlist_t* keylist = nullptr;
    7.81 -    PEP_rating rating;
    7.82 -    PEP_decrypt_flags_t flags = 0;
    7.83 -    
    7.84 -    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr);
    7.85 -    assert(status == PEP_STATUS_OK);
    7.86 -    status = decrypt_message(session, msg_ptr, &dest_msg, &keylist, &rating, &flags);
    7.87 -
    7.88 -    PEP_STATUS status12 = get_valid_pubkey(session, blacklisted_identity,
    7.89 -                                           &id_def, &us_def, &addr_def, true);
    7.90 -
    7.91 -    assert(strcasecmp(blacklisted_identity->fpr, new_key) == 0);
    7.92 -
    7.93 -    PEP_STATUS status13 = blacklist_delete(session, bl_fpr_1);
    7.94 -    PEP_STATUS status14 = update_identity(session, blacklisted_identity);
    7.95 -
    7.96 -    status = delete_keypair(session, new_key);
    7.97 -    update_identity(session, blacklisted_identity);
    7.98 -    status = delete_keypair(session, bl_fpr_1);
    7.99 -    update_identity(session, blacklisted_identity);
   7.100 -    
   7.101 -    free_message(msg_ptr);
   7.102 -    free_message(dest_msg);
   7.103 -    free_stringlist(keylist);
   7.104 -    
   7.105 -    cout << "calling release()\n";
   7.106 -    release(session);
   7.107 -    return 0;
   7.108 -}
     8.1 --- a/test/blacklist_test.cc	Wed May 09 09:51:05 2018 +0200
     8.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.3 @@ -1,171 +0,0 @@
     8.4 -// This file is under GNU General Public License 3.0
     8.5 -// see LICENSE.txt
     8.6 -
     8.7 -#include <iostream>
     8.8 -#include <iostream>
     8.9 -#include <fstream>
    8.10 -#include <string>
    8.11 -#include <cstring> // for strcmp()
    8.12 -#include <assert.h>
    8.13 -#include "blacklist.h"
    8.14 -#include "keymanagement.h"
    8.15 -#include "test_util.h"
    8.16 -
    8.17 -using namespace std;
    8.18 -
    8.19 -int main() {
    8.20 -    cout << "\n*** blacklist_test ***\n\n";
    8.21 -
    8.22 -    PEP_SESSION session;
    8.23 -    
    8.24 -    cout << "calling init()\n";
    8.25 -    PEP_STATUS status1 = init(&session);   
    8.26 -    assert(status1 == PEP_STATUS_OK);
    8.27 -    assert(session);
    8.28 -    cout << "init() completed.\n";
    8.29 -
    8.30 -    // blacklist test code
    8.31 -
    8.32 -    cout << "adding 23 to blacklist\n";
    8.33 -    PEP_STATUS status2 = blacklist_add(session, "23");
    8.34 -    assert(status2 == PEP_STATUS_OK);
    8.35 -    cout << "added.\n";
    8.36 -
    8.37 -    bool listed;
    8.38 -    PEP_STATUS status3 = blacklist_is_listed(session, "23", &listed);
    8.39 -    assert(status3 == PEP_STATUS_OK);
    8.40 -    assert(listed);
    8.41 -    cout << "23 is listed.\n";
    8.42 -
    8.43 -    stringlist_t *blacklist;
    8.44 -    PEP_STATUS status6 = blacklist_retrieve(session, &blacklist);
    8.45 -    assert(status6 == PEP_STATUS_OK);
    8.46 -    assert(blacklist);
    8.47 -
    8.48 -    bool in23 = false;
    8.49 -    cout << "the blacklist contains now: ";
    8.50 -    for (stringlist_t *bl = blacklist; bl && bl->value; bl = bl->next) {
    8.51 -        cout << bl->value << ", ";
    8.52 -        if (std::strcmp(bl->value, "23") == 0)
    8.53 -            in23 = true;
    8.54 -    }
    8.55 -    cout << "END\n";
    8.56 -    assert(in23);
    8.57 -    free_stringlist(blacklist);
    8.58 -
    8.59 -    cout << "deleting 23 from blacklist\n";
    8.60 -    PEP_STATUS status4 = blacklist_delete(session, "23");
    8.61 -    assert(status4 == PEP_STATUS_OK);
    8.62 -    cout << "deleted.\n";
    8.63 -    
    8.64 -    PEP_STATUS status5 = blacklist_is_listed(session, "23", &listed);
    8.65 -    assert(status5 == PEP_STATUS_OK);
    8.66 -    assert(!listed);
    8.67 -    cout << "23 is not listed any more.\n";
    8.68 -
    8.69 -    cout << "blacklist only key for identity / unblacklist key / add key" << endl;
    8.70 -
    8.71 -    
    8.72 -    // 2797 65A2 FEB5 B7C7 31B8  61D9 3E4C EFD9 F7AF 4684 - this is the blacklisted key in blacklisted_pub.asc
    8.73 -
    8.74 -    const string keytext = slurp("blacklisted_pub.asc");
    8.75 -    
    8.76 -    /* FIXME: put in automated test stuff (N.B. only gdb mem examination to this point to get
    8.77 -     *        fix in */
    8.78 -    /* import it into pep */
    8.79 -    PEP_STATUS status7 = import_key(session, keytext.c_str(), keytext.length(), NULL);
    8.80 -    
    8.81 -    const char* bl_fpr_1 = "279765A2FEB5B7C731B861D93E4CEFD9F7AF4684";
    8.82 -    const char* bl_fpr_2 = "634FAC4417E9B2A5DC2BD4AAC4AEEBBE7E62701B"; 
    8.83 -    bool is_blacklisted = false;
    8.84 -
    8.85 -    // Clean up from previous runs
    8.86 -    PEP_STATUS status10 = blacklist_is_listed(session, bl_fpr_1, &is_blacklisted);
    8.87 -    if (is_blacklisted) {
    8.88 -        is_blacklisted = false;
    8.89 -        blacklist_delete(session, bl_fpr_1);
    8.90 -    }
    8.91 -    
    8.92 -    pEp_identity* blacklisted_identity = new_identity("blacklistedkeys@kgrothoff.org",
    8.93 -                                                      bl_fpr_1,
    8.94 -                                                      NULL,
    8.95 -                                                      "Blacklist Keypair");
    8.96 -
    8.97 -    PEP_STATUS status8 = update_identity(session, blacklisted_identity);
    8.98 -        
    8.99 -    // THERE IS NO BLACKLISTING OF PEP KEYS
   8.100 -    //blacklisted_identity->comm_type = PEP_ct_pEp;
   8.101 -    blacklisted_identity->comm_type = PEP_ct_OpenPGP_unconfirmed;
   8.102 -
   8.103 -    PEP_STATUS status99 = set_identity(session, blacklisted_identity);
   8.104 -    
   8.105 -    trust_personal_key(session, blacklisted_identity);
   8.106 -
   8.107 -    PEP_STATUS status999 = update_identity(session, blacklisted_identity);
   8.108 -
   8.109 -    assert(blacklisted_identity->comm_type == PEP_ct_OpenPGP);
   8.110 -
   8.111 -    PEP_STATUS status9 = blacklist_add(session, bl_fpr_1);
   8.112 -    status10 = blacklist_is_listed(session, bl_fpr_1, &is_blacklisted);
   8.113 -    PEP_STATUS status11 = update_identity(session, blacklisted_identity);
   8.114 -    /* new!!! */
   8.115 -    assert(is_blacklisted);
   8.116 -    assert(status11 == PEP_STATUS_OK);
   8.117 -    assert(_streq(bl_fpr_1, blacklisted_identity->fpr));
   8.118 -    
   8.119 -    bool id_def, us_def, addr_def;
   8.120 -    status11 = get_valid_pubkey(session, blacklisted_identity,
   8.121 -                                &id_def, &us_def, &addr_def, true);
   8.122 -    
   8.123 -    if (!(blacklisted_identity->fpr))
   8.124 -        cout << "OK! blacklisted_identity->fpr is empty. Yay!" << endl;
   8.125 -    else if (strcmp(blacklisted_identity->fpr, bl_fpr_2) == 0)
   8.126 -        cout << "OK! While this should be empty, you are probably running " << 
   8.127 -                "this in your home directory instead of the test environment " << 
   8.128 -                "and have leftover keys. This is an acceptable result here then. But you " <<
   8.129 -                "should probably clean up after yourself :)" << endl;
   8.130 -    else
   8.131 -        cout << "Not OK. blacklisted_identity->fpr is " << blacklisted_identity->fpr << "." << endl
   8.132 -             << "Expected it to be empty or (possibly) " << bl_fpr_2 << endl;
   8.133 -    assert(!(blacklisted_identity->fpr) || blacklisted_identity->fpr[0] == '\0'|| (strcmp(blacklisted_identity->fpr, bl_fpr_2) == 0));
   8.134 -
   8.135 -    const string keytext2 = slurp("blacklisted_pub2.asc");
   8.136 -    PEP_STATUS status14 = import_key(session, keytext2.c_str(), keytext2.length(), NULL);
   8.137 -    
   8.138 -    pEp_identity* blacklisted_identity2 = new_identity("blacklistedkeys@kgrothoff.org",
   8.139 -                                                       bl_fpr_2,
   8.140 -                                                        NULL,
   8.141 -                                                       "Blacklist Keypair");
   8.142 -    PEP_STATUS status15 = update_identity(session, blacklisted_identity2);
   8.143 -    // 
   8.144 -    // assert(blacklisted_identity2->fpr && strcmp(blacklisted_identity2->fpr, bl_fpr_2) == 0);
   8.145 -    // if (blacklisted_identity2->fpr && strcmp(blacklisted_identity2->fpr, bl_fpr_2) == 0)
   8.146 -    //     cout << "blacklisted identity's fpr successfully replaced by the unblacklisted one" << endl;
   8.147 -    // // else
   8.148 -    // //     cout << "blacklisted_identity->fpr should be " << bl_fpr_2 << " but is " << blacklisted_identity->fpr << endl;
   8.149 -    // 
   8.150 -    // PEP_STATUS status12 = blacklist_delete(session, bl_fpr_1);
   8.151 -    // PEP_STATUS status13 = update_identity(session, blacklisted_identity);
   8.152 -    //     
   8.153 -    // pEp_identity* stored_identity = new_identity("blacklistedkeys@kgrothoff.org",
   8.154 -    //                                               NULL,
   8.155 -    //                                               blacklisted_identity->user_id,
   8.156 -    //                                               "Blacklist Keypair");
   8.157 -    //  
   8.158 -    // PEP_STATUS status00 = update_identity(session, stored_identity);
   8.159 -    // 
   8.160 -    // // FIXME
   8.161 -    // // assert(stored_identity->comm_type == PEP_ct_pEp);    
   8.162 -    
   8.163 -    PEP_STATUS status16 = delete_keypair(session, bl_fpr_1);
   8.164 -    update_identity(session, blacklisted_identity);
   8.165 -    PEP_STATUS status17 = delete_keypair(session, bl_fpr_2);
   8.166 -    update_identity(session, blacklisted_identity2);
   8.167 -        
   8.168 -    free_identity(blacklisted_identity);
   8.169 -    free_identity(blacklisted_identity2);
   8.170 -    
   8.171 -    cout << "calling release()\n";
   8.172 -    release(session);
   8.173 -    return 0;
   8.174 -}
     9.1 --- a/test/bloblist_test.cc	Wed May 09 09:51:05 2018 +0200
     9.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.3 @@ -1,134 +0,0 @@
     9.4 -// This file is under GNU General Public License 3.0
     9.5 -// see LICENSE.txt
     9.6 -
     9.7 -#include <stdlib.h>
     9.8 -#include <string.h>
     9.9 -#include "platform.h"
    9.10 -#include <iostream>
    9.11 -#include <fstream>
    9.12 -#include <assert.h>
    9.13 -
    9.14 -#include "bloblist.h"
    9.15 -
    9.16 -using namespace std;
    9.17 -
    9.18 -/*
    9.19 - *     char *address;              // C string with address UTF-8 encoded
    9.20 -    char *fpr;                  // C string with fingerprint UTF-8 encoded
    9.21 -    char *user_id;              // C string with user ID UTF-8 encoded
    9.22 -    char *username;             // C string with user name UTF-8 encoded
    9.23 -    PEP_comm_type comm_type;    // type of communication with this ID
    9.24 -    char lang[3];               // language of conversation
    9.25 -                                // ISO 639-1 ALPHA-2, last byte is 0
    9.26 -    bool me;                    // if this is the local user herself/himself
    9.27 -    */
    9.28 -
    9.29 -bool test_blob_equals(size_t size1, char* blob1, size_t size2, char* blob2) {
    9.30 -    if (size1 != size2)
    9.31 -        return false;
    9.32 -    size_t i;
    9.33 -    for (i = 0; i < size1; i++) {
    9.34 -        if (blob1[i] != blob2[i])
    9.35 -            return false;
    9.36 -    }
    9.37 -    return true;
    9.38 -}
    9.39 -
    9.40 -bool test_bloblist_node_equals(bloblist_t* val1, bloblist_t* val2) {
    9.41 -    assert(val1);
    9.42 -    assert(val2);
    9.43 -    assert(val1->size == val2->size);
    9.44 -    assert(test_blob_equals(val1->size, val1->value, val2->size, val2->value));
    9.45 -    return( ((!val1->mime_type && !val2->mime_type) || (strcmp(val1->mime_type, val2->mime_type) == 0))
    9.46 -        && ((!val1->filename && !val2->filename) || (strcmp(val1->filename, val2->filename) == 0)));
    9.47 -}
    9.48 -
    9.49 -int main() {
    9.50 -    cout << "\n*** data structures: bloblist_test ***\n\n";
    9.51 -    char* text1 = strdup("This is just some text.");
    9.52 -    char* text2 = strdup("More text.");
    9.53 -    char* text3 = strdup("Unpleasant news and witty one-liners.");
    9.54 -    char* text4 = strdup("I AM URDNOT WREX AND THIS IS MY PLANET!");
    9.55 -    bloblist_t* bl1 = new_bloblist(text1, strlen(text1) + 1, "text/plain", NULL);
    9.56 -    bloblist_t* bl2 = new_bloblist(text2, strlen(text2) + 1, "text/richtext", "bob.rtf");
    9.57 -    bloblist_t* bl3 = new_bloblist(text3, strlen(text3) + 1, NULL, "dummy.bin");
    9.58 -    bloblist_t* bl4 = new_bloblist(text4, strlen(text4) + 1, NULL, NULL);
    9.59 -    
    9.60 -    bloblist_t* bl_arr[4] = {bl1, bl2, bl3, bl4};
    9.61 -        
    9.62 -    int i;
    9.63 -        
    9.64 -    cout << "duping one-element bloblist...\n";
    9.65 -    
    9.66 -    bloblist_t* new_bl = bloblist_dup(bl1);
    9.67 -    assert(new_bl);
    9.68 -    assert(test_bloblist_node_equals(bl1, new_bl));
    9.69 -    assert(new_bl->next == NULL);
    9.70 -    assert(bl1->value != new_bl->value);
    9.71 -    assert(bl1->mime_type != new_bl->mime_type || !(bl1->mime_type || new_bl->mime_type));
    9.72 -    assert(bl1->filename != new_bl->filename || !(bl1->filename || new_bl->filename));
    9.73 -    cout << "one-element bloblist duplicated.\n\n";
    9.74 -    
    9.75 -    cout << "freeing bloblist...\n";
    9.76 -    free_bloblist(new_bl);
    9.77 -    new_bl = NULL;
    9.78 -    
    9.79 -    bloblist_t* p;
    9.80 -    cout << "\ncreating four-element list...\n";
    9.81 -    bloblist_t* to_copy = bl_arr[0];
    9.82 -    new_bl = bloblist_add(new_bl, strdup(to_copy->value), to_copy->size, to_copy->mime_type, to_copy->filename);
    9.83 -    for (i = 1; i < 4; i++) {
    9.84 -        to_copy = bl_arr[i];
    9.85 -        p = bloblist_add(new_bl, strdup(to_copy->value), to_copy->size, to_copy->mime_type, to_copy->filename);
    9.86 -
    9.87 -        assert(p);
    9.88 -    }
    9.89 -    
    9.90 -    p = new_bl;
    9.91 -    
    9.92 -    for (i = 0; i < 4; i++) {
    9.93 -        assert(p);
    9.94 -        
    9.95 -        assert(test_bloblist_node_equals(p, bl_arr[i]));
    9.96 -        assert(p->value != bl_arr[i]->value);
    9.97 -        assert(p->mime_type != bl_arr[i]->mime_type || !(p->mime_type || bl_arr[i]->mime_type));
    9.98 -        assert(p->filename != bl_arr[i]->filename || !(p->filename || bl_arr[i]->filename));
    9.99 -        
   9.100 -        p = p->next;
   9.101 -    }
   9.102 -    assert(p == NULL);
   9.103 -    
   9.104 -    cout << "\nduplicating four-element list...\n\n";
   9.105 -    bloblist_t* duplist = bloblist_dup(new_bl);
   9.106 -    
   9.107 -    p = new_bl;
   9.108 -    bloblist_t* dup_p = duplist;
   9.109 -    
   9.110 -    while (dup_p) {
   9.111 -        assert(test_bloblist_node_equals(p, dup_p));
   9.112 -        assert(p != dup_p);
   9.113 -        assert(p->value != dup_p->value);
   9.114 -        assert(p->mime_type != dup_p->mime_type || !(p->mime_type || dup_p->mime_type));
   9.115 -        assert(p->filename != dup_p->filename || !(p->filename || dup_p->filename));
   9.116 -
   9.117 -        dup_p = dup_p->next;
   9.118 -        p = p->next;
   9.119 -        assert((p == NULL) == (dup_p == NULL));
   9.120 -    }
   9.121 -    cout << "\nfour-element bloblist successfully duplicated.\n\n";
   9.122 -
   9.123 -    cout << "freeing bloblists...\n";
   9.124 -    free_bloblist(new_bl);
   9.125 -    free_bloblist(duplist);
   9.126 -    new_bl = NULL;
   9.127 -    duplist = NULL;
   9.128 -    free(text1);
   9.129 -    free(text2);
   9.130 -    free(text3);
   9.131 -    free(text4);    
   9.132 -    cout << "done.\n";
   9.133 -        
   9.134 -    
   9.135 -    return 0;
   9.136 -}
   9.137 -
    10.1 --- a/test/case_and_dot_address_test.cc	Wed May 09 09:51:05 2018 +0200
    10.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.3 @@ -1,88 +0,0 @@
    10.4 -// This file is under GNU General Public License 3.0
    10.5 -// see LICENSE.txt
    10.6 -
    10.7 -#include <stdlib.h>
    10.8 -#include <string.h>
    10.9 -#include <time.h>
   10.10 -#include "platform.h"
   10.11 -#include <iostream>
   10.12 -#include <fstream>
   10.13 -#include <assert.h>
   10.14 -#include "mime.h"
   10.15 -#include "message_api.h"
   10.16 -#include "test_util.h"
   10.17 -
   10.18 -using namespace std;
   10.19 -
   10.20 -int main() {
   10.21 -    cout << "\n*** case_and_dot_address_test.cc ***\n\n";
   10.22 -
   10.23 -    PEP_SESSION session;
   10.24 -    
   10.25 -    cout << "calling init()\n";
   10.26 -    PEP_STATUS status = init(&session);   
   10.27 -    assert(status == PEP_STATUS_OK);
   10.28 -    assert(session);
   10.29 -    cout << "init() completed.\n";
   10.30 -    
   10.31 -    char* user_id = get_new_uuid();
   10.32 -    
   10.33 -    const string alice_pub_key = slurp("test_keys/pub/pep-test-alice-0x6FF00E97_pub.asc");
   10.34 -
   10.35 -    const char* alice_email_case = "pEp.teST.AlICe@pEP-pRoJeCt.ORG";
   10.36 -    const char* alice_email_dot = "pe.p.te.st.a.l.i.ce@pep-project.org";
   10.37 -    const char* alice_email_dotless = "peptestalice@pep-project.org";
   10.38 -    const char* alice_email_case_and_dot = "PE.p.teS.t.ALICE@pep-project.OrG";
   10.39 -
   10.40 -    PEP_STATUS statuspub = import_key(session, alice_pub_key.c_str(), alice_pub_key.length(), NULL);
   10.41 -    assert(statuspub == PEP_STATUS_OK);
   10.42 -
   10.43 -    pEp_identity * alice_id = new_identity("pep.test.alice@pep-project.org", "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97", user_id, "Alice Test");
   10.44 -
   10.45 -    status = trust_personal_key(session, alice_id);
   10.46 -
   10.47 -    pEp_identity * new_alice_id = new_identity("pep.test.alice@pep-project.org", "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97", user_id, "Alice Test");
   10.48 -    status = update_identity(session, new_alice_id);
   10.49 -    assert(new_alice_id->fpr);
   10.50 -    assert(strcmp(new_alice_id->fpr, "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97") == 0);
   10.51 -    free_identity(new_alice_id);
   10.52 -    free_identity(alice_id);
   10.53 -    alice_id = NULL;
   10.54 -    new_alice_id = NULL;
   10.55 -
   10.56 -    alice_id = new_identity(alice_email_case, NULL, user_id, "Alice Test");
   10.57 -    status = update_identity(session, alice_id);
   10.58 -    assert(alice_id->fpr);
   10.59 -    cout << "Alice email: " << alice_email_case << " Alice fpr (should be 4ABE3AAF59AC32CFE4F86500A9411D176FF00E97): " << alice_id->fpr << endl;
   10.60 -    assert(strcmp(alice_id->fpr, "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97") == 0);
   10.61 -    free_identity(alice_id);
   10.62 -    alice_id = NULL;
   10.63 -
   10.64 -    alice_id = new_identity(alice_email_dot, NULL, user_id, "Alice Test");
   10.65 -    status = update_identity(session, alice_id);
   10.66 -    assert(alice_id->fpr);
   10.67 -    cout << "Alice email: " << alice_email_dot << " Alice fpr (should be 4ABE3AAF59AC32CFE4F86500A9411D176FF00E97): " << alice_id->fpr << endl;
   10.68 -    assert(strcmp(alice_id->fpr, "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97") == 0);
   10.69 -    free_identity(alice_id);
   10.70 -    alice_id = NULL;
   10.71 -
   10.72 -    alice_id = new_identity(alice_email_dotless, NULL, user_id, "Alice Test");
   10.73 -    status = update_identity(session, alice_id);
   10.74 -    assert(alice_id->fpr);
   10.75 -    cout << "Alice email: " << alice_email_dotless << " Alice fpr (should be 4ABE3AAF59AC32CFE4F86500A9411D176FF00E97): " << alice_id->fpr << endl;
   10.76 -    assert(strcmp(alice_id->fpr, "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97") == 0);
   10.77 -    free_identity(alice_id);
   10.78 -    alice_id = NULL;
   10.79 -
   10.80 -    alice_id = new_identity(alice_email_case_and_dot, NULL, user_id, "Alice Test");
   10.81 -    status = update_identity(session, alice_id);
   10.82 -    assert(alice_id->fpr);
   10.83 -    cout << "Alice email: " << alice_email_case_and_dot << " Alice fpr (should be 4ABE3AAF59AC32CFE4F86500A9411D176FF00E97): " << alice_id->fpr << endl;
   10.84 -    assert(strcmp(alice_id->fpr, "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97") == 0);
   10.85 -    free_identity(alice_id);
   10.86 -    alice_id = NULL;
   10.87 -    
   10.88 -    release(session);
   10.89 -
   10.90 -    return 0;
   10.91 -}
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/test/convenience_scripts/README	Fri May 11 08:58:04 2018 +0200
    11.3 @@ -0,0 +1,1 @@
    11.4 +This is just a collection of scripts and source files I've used to convert things and make the test environment behave from time to time. USE AT YOUR OWN RISK.
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/test/convenience_scripts/compile_it.sh	Fri May 11 08:58:04 2018 +0200
    12.3 @@ -0,0 +1,6 @@
    12.4 +#!/bin/bash
    12.5 +g++ -std=gnu++11 -pthread -fdiagnostics-color=always -I../src -I../asn.1 -I/home/krista/include -I./include -g -ggdb   -c -o $1.o $1.cc
    12.6 +#g++ -std=gnu++11 -pthread -fdiagnostics-color=always -I../src -I../asn.1 -I/home/krista/include -I./include -g -ggdb   -c -o test_util.o src/util/test_util.cc
    12.7 +g++ -std=gnu++11 -pthread -fdiagnostics-color=always -I../src -I../asn.1 -I/home/krista/include -I./include -g -ggdb   -c -o test_util.o test_util.cc
    12.8 +g++ -std=gnu++11 -pthread $1.o test_util.o  -L/home/krista/lib -L../asn.1 -L../src  -letpan -lpEpEngine -lstdc++ -lasn1 -luuid -lsqlite3 -o $1
    12.9 +
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/test/convenience_scripts/convert_test_assert.py	Fri May 11 08:58:04 2018 +0200
    13.3 @@ -0,0 +1,74 @@
    13.4 +import sys
    13.5 +import argparse
    13.6 +import re
    13.7 +
    13.8 +def get_closing_parenthesis(paren_start):
    13.9 +    paren_level = 0
   13.10 +    index = 0
   13.11 +    
   13.12 +    for c in paren_start:
   13.13 +        if c == '(':
   13.14 +            paren_level += 1
   13.15 +        elif c == ')':
   13.16 +            paren_level -= 1
   13.17 +        
   13.18 +        if paren_level == 0:
   13.19 +            break;
   13.20 +        
   13.21 +        index += 1
   13.22 +        
   13.23 +    return index
   13.24 +
   13.25 +# TEST_ASSERT(assertion blah blah)
   13.26 +# want: TEST_ASSERT_MSG(assertion blah blah, "AUTOMSG: assertion blah blah")
   13.27 +
   13.28 +parser = argparse.ArgumentParser()
   13.29 +parser.add_argument('files', nargs = '*', help = 'files to convert')
   13.30 +args = parser.parse_args()
   13.31 +
   13.32 +# if not args.files:
   13.33 +#     print("ERROR: Can't make something from nothing. See: first law of thermodynamics.")
   13.34 +#     sys.exit(1)
   13.35 +
   13.36 +for f in args.files:
   13.37 +    infile = open(f, "r");
   13.38 +    lines = infile.readlines();
   13.39 +
   13.40 +    output = ""
   13.41 +    
   13.42 +    # For each line in file - too lazy for regex this morning
   13.43 +    for l in lines:
   13.44 +        output_line = l
   13.45 +        old_assert = "TEST_ASSERT("
   13.46 +        old_assert_len = len(old_assert)
   13.47 +        
   13.48 +        l_index = l.find(old_assert)
   13.49 +        
   13.50 +        # if this line contains "TEST_ASSERT("
   13.51 +        if (l_index >= 0):
   13.52 +            # 1. get replaceable string (TEST_ASSERT(assertion blah blah)) 
   13.53 +            old_r_index = l.find(")", l_index)
   13.54 +            paren_start = l_index + old_assert_len - 1
   13.55 +            r_index = paren_start + get_closing_parenthesis(l[paren_start:])
   13.56 +                
   13.57 +            #print("l is " + str(l_index) + " and r is " + str(not_r_index))
   13.58 +            
   13.59 +            # 2. filter to get assertion
   13.60 +            assertion = l[l_index + old_assert_len:r_index]
   13.61 +#            print("Assertion is " + assertion)
   13.62 +            # 3. create replacement
   13.63 +            new_assert = "TEST_ASSERT_MSG((" + assertion + "), \"" + assertion.replace('"','\\"') + "\")"
   13.64 +#            print("New assertion is " + new_assert)
   13.65 +            # 4. replace
   13.66 +            output_line = l[0:l_index] + new_assert + l[r_index + 1:]
   13.67 +            
   13.68 +        output += (output_line)
   13.69 +        l_index = 0
   13.70 +
   13.71 +    print(output)
   13.72 +    
   13.73 +    infile.close()
   13.74 +    
   13.75 +    outfile = open(f, "w")
   13.76 +    outfile.write(output)
   13.77 +    outfile.close()
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/test/convenience_scripts/mime_decrypt.cc	Fri May 11 08:58:04 2018 +0200
    14.3 @@ -0,0 +1,52 @@
    14.4 +// This file is under GNU General Public License 3.0
    14.5 +// see LICENSE.txt
    14.6 +
    14.7 +#include <stdlib.h>
    14.8 +#include <string.h>
    14.9 +#include "platform.h"
   14.10 +#include <iostream>
   14.11 +#include <fstream>
   14.12 +#include <assert.h>
   14.13 +#include "mime.h"
   14.14 +#include "message_api.h"
   14.15 +#include "keymanagement.h"
   14.16 +#include "test_util.h"
   14.17 +
   14.18 +using namespace std;
   14.19 +
   14.20 +int main(int argc, char* argv[]) {
   14.21 +    cout << "\n*** MIME encrypt and decrypt testing program ***\n\n";
   14.22 +
   14.23 +    PEP_SESSION session;
   14.24 +    
   14.25 +    cout << "calling init()\n";
   14.26 +    PEP_STATUS status = init(&session);
   14.27 +    assert(status == PEP_STATUS_OK);
   14.28 +    assert(session);
   14.29 +    cout << "init() completed.\n";
   14.30 +
   14.31 +    if (argc < 2) {
   14.32 +        cout << "ERROR: filename required." << endl;
   14.33 +        return -1;
   14.34 +    }
   14.35 +        
   14.36 +    const string mailfile = slurp(argv[1]);
   14.37 +    char* dec_msg = NULL;
   14.38 +    
   14.39 +    stringlist_t* keylist = NULL;
   14.40 +    
   14.41 +    PEP_rating rating;
   14.42 +    PEP_decrypt_flags_t flags;
   14.43 +    
   14.44 +    flags = 0;
   14.45 +    char* modified_src = NULL;
   14.46 +    status = MIME_decrypt_message(session, mailfile.c_str(), mailfile.size(), &dec_msg, &keylist, &rating, &flags, &modified_src);
   14.47 +
   14.48 +    cout << dec_msg << endl << endl;
   14.49 +
   14.50 +    cout << "Rating is " << tl_rating_string(rating) << endl;
   14.51 +    
   14.52 +    release(session);
   14.53 +    return 0;
   14.54 +}
   14.55 +    
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/test/convenience_scripts/mime_encrypt.cc	Fri May 11 08:58:04 2018 +0200
    15.3 @@ -0,0 +1,43 @@
    15.4 +// This file is under GNU General Public License 3.0
    15.5 +// see LICENSE.txt
    15.6 +
    15.7 +#include <stdlib.h>
    15.8 +#include <string.h>
    15.9 +#include "platform.h"
   15.10 +#include <iostream>
   15.11 +#include <fstream>
   15.12 +#include <assert.h>
   15.13 +#include "mime.h"
   15.14 +#include "message_api.h"
   15.15 +#include "keymanagement.h"
   15.16 +#include "test_util.h"
   15.17 +
   15.18 +using namespace std;
   15.19 +
   15.20 +int main(int argc, char* argv[]) {
   15.21 +    cout << "\n*** MIME encrypt and decrypt testing program ***\n\n";
   15.22 +
   15.23 +    PEP_SESSION session;
   15.24 +    
   15.25 +    cout << "calling init()\n";
   15.26 +    PEP_STATUS status = init(&session);
   15.27 +    assert(status == PEP_STATUS_OK);
   15.28 +    assert(session);
   15.29 +    cout << "init() completed.\n";
   15.30 +
   15.31 +    if (argc < 2) {
   15.32 +        cout << "ERROR: filename required." << endl;
   15.33 +        return -1;
   15.34 +    }
   15.35 +        
   15.36 +    const string mailfile = slurp(argv[1]);
   15.37 +    char* enc_msg = NULL;
   15.38 +    
   15.39 +    status = MIME_encrypt_message(session, mailfile.c_str(), mailfile.size(), NULL, &enc_msg, PEP_enc_PGP_MIME, 0);
   15.40 +    
   15.41 +    cout << enc_msg << endl << endl;
   15.42 +
   15.43 +    release(session);
   15.44 +    return 0;
   15.45 +}
   15.46 +    
    16.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.2 +++ b/test/convenience_scripts/mime_encrypt_decrypt.cc	Fri May 11 08:58:04 2018 +0200
    16.3 @@ -0,0 +1,55 @@
    16.4 +// This file is under GNU General Public License 3.0
    16.5 +// see LICENSE.txt
    16.6 +
    16.7 +#include <stdlib.h>
    16.8 +#include <string.h>
    16.9 +#include "platform.h"
   16.10 +#include <iostream>
   16.11 +#include <fstream>
   16.12 +#include <assert.h>
   16.13 +#include "mime.h"
   16.14 +#include "message_api.h"
   16.15 +#include "keymanagement.h"
   16.16 +#include "test_util.h"
   16.17 +
   16.18 +using namespace std;
   16.19 +
   16.20 +int main(int argc, char* argv[]) {
   16.21 +    cout << "\n*** MIME encrypt and decrypt testing program ***\n\n";
   16.22 +
   16.23 +    PEP_SESSION session;
   16.24 +    
   16.25 +    cout << "calling init()\n";
   16.26 +    PEP_STATUS status = init(&session);
   16.27 +    assert(status == PEP_STATUS_OK);
   16.28 +    assert(session);
   16.29 +    cout << "init() completed.\n";
   16.30 +
   16.31 +    if (argc < 2) {
   16.32 +        cout << "ERROR: filename required." << endl;
   16.33 +        return -1;
   16.34 +    }
   16.35 +        
   16.36 +    const string mailfile = slurp(argv[1]);
   16.37 +    char* enc_msg = NULL;
   16.38 +    char* dec_msg = NULL;
   16.39 +    
   16.40 +    status = MIME_encrypt_message(session, mailfile.c_str(), mailfile.size(), NULL, &enc_msg, PEP_enc_PGP_MIME, 0);
   16.41 +    
   16.42 +    cout << enc_msg << endl << endl;
   16.43 +
   16.44 +    stringlist_t* keylist = NULL;
   16.45 +    
   16.46 +    PEP_rating rating;
   16.47 +    PEP_decrypt_flags_t flags;
   16.48 +    char* modified_src = NULL;
   16.49 +    
   16.50 +    flags = 0;
   16.51 +    status = MIME_decrypt_message(session, enc_msg, strlen(enc_msg), &dec_msg, &keylist, &rating, &flags, &modified_src);
   16.52 +
   16.53 +    cout << dec_msg << endl << endl;
   16.54 +    
   16.55 +    release(session);
   16.56 +    return 0;
   16.57 +}
   16.58 +    
    17.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.2 +++ b/test/convenience_scripts/temp_convert_script.py	Fri May 11 08:58:04 2018 +0200
    17.3 @@ -0,0 +1,23 @@
    17.4 +# This file is under GNU General Public License 3.0
    17.5 +# see LICENSE.txt
    17.6 +
    17.7 +from os import listdir, getcwd
    17.8 +from os.path import isfile, join
    17.9 +import re
   17.10 +import string
   17.11 +import subprocess
   17.12 +
   17.13 +srcpath = getcwd()
   17.14 +
   17.15 +ls = listdir(srcpath)
   17.16 +
   17.17 +files = []
   17.18 +
   17.19 +for f in ls:
   17.20 +    if isfile(join(srcpath, f)):
   17.21 +        if (f.endswith("_test.cc")):
   17.22 +            testname = re.sub('_test.cc$', r'', f)
   17.23 +            testname = (string.capwords(testname,'_')).replace("_", "")
   17.24 +            CMD_STR = "python3 ./gentestshell.py -c -s " + testname
   17.25 +            print(CMD_STR)
   17.26 +            subprocess.run(CMD_STR.split(' '))
    18.1 --- a/test/crashdump_test.cc	Wed May 09 09:51:05 2018 +0200
    18.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.3 @@ -1,33 +0,0 @@
    18.4 -// This file is under GNU General Public License 3.0
    18.5 -// see LICENSE.txt
    18.6 -
    18.7 -#include <iostream>
    18.8 -#include <string>
    18.9 -#include <assert.h>
   18.10 -#include "pEpEngine.h"
   18.11 -
   18.12 -using namespace std;
   18.13 -
   18.14 -int main() {
   18.15 -    cout << "\n*** crashdump_test ***\n\n";
   18.16 -
   18.17 -    PEP_SESSION session;
   18.18 -    
   18.19 -    cout << "calling init()\n";
   18.20 -    PEP_STATUS status1 = init(&session);   
   18.21 -    assert(status1 == PEP_STATUS_OK);
   18.22 -    assert(session);
   18.23 -    cout << "init() completed.\n";
   18.24 -
   18.25 -    // MODULE test code
   18.26 -
   18.27 -    char *text;
   18.28 -    PEP_STATUS status2 = get_crashdump_log(session, 0, &text);
   18.29 -    assert(status2 == PEP_STATUS_OK);
   18.30 -    cout << text;
   18.31 -
   18.32 -    cout << "calling release()\n";
   18.33 -    release(session);
   18.34 -    return 0;
   18.35 -}
   18.36 -
    19.1 --- a/test/decorate_test.cc	Wed May 09 09:51:05 2018 +0200
    19.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.3 @@ -1,91 +0,0 @@
    19.4 -// This file is under GNU General Public License 3.0
    19.5 -// see LICENSE.txt
    19.6 -
    19.7 -#include <stdlib.h>
    19.8 -#include <string.h>
    19.9 -#include "platform.h"
   19.10 -#include <iostream>
   19.11 -#include <fstream>
   19.12 -#include <assert.h>
   19.13 -#include <sstream>
   19.14 -#include "mime.h"
   19.15 -#include "message_api.h"
   19.16 -#include "test_util.h"
   19.17 -
   19.18 -using namespace std;
   19.19 -
   19.20 -int main() {
   19.21 -    cout << "\n*** check that X-pEp-Version is added to decorated text ***\n\n";
   19.22 -
   19.23 -    PEP_SESSION session;
   19.24 -    
   19.25 -    cout << "calling init()\n";
   19.26 -    PEP_STATUS status1 = init(&session);
   19.27 -    assert(status1 == PEP_STATUS_OK);
   19.28 -    assert(session);
   19.29 -    cout << "init() completed.\n";
   19.30 -
   19.31 -    const string alice_pub_key = slurp("test_keys/pub/pep-test-alice-0x6FF00E97_pub.asc");
   19.32 -    const string alice_priv_key = slurp("test_keys/priv/pep-test-alice-0x6FF00E97_priv.asc");
   19.33 -    const string bob_pub_key = slurp("test_keys/pub/pep-test-bob-0xC9C2EE39_pub.asc");
   19.34 -    PEP_STATUS statuspub = import_key(session, alice_pub_key.c_str(), alice_pub_key.length(), NULL);
   19.35 -    PEP_STATUS statuspriv = import_key(session, alice_priv_key.c_str(), alice_priv_key.length(), NULL);
   19.36 -    PEP_STATUS statusbob = import_key(session, bob_pub_key.c_str(), bob_pub_key.length(), NULL);
   19.37 -    assert(statuspub == PEP_STATUS_OK);
   19.38 -    assert(statuspriv == PEP_STATUS_OK);
   19.39 -    assert(statusbob == PEP_STATUS_OK);
   19.40 -
   19.41 -    cout << "creating message…\n";
   19.42 -    pEp_identity* alice = new_identity("pep.test.alice@pep-project.org", NULL, PEP_OWN_USERID, "Alice Test");
   19.43 -    pEp_identity* bob = new_identity("pep.test.bob@pep-project.org", NULL, "42", "Bob Test");
   19.44 -    alice->me = true;
   19.45 -    identity_list* to_list = new_identity_list(bob); // to bob
   19.46 -    message* outgoing_message = new_message(PEP_dir_outgoing);
   19.47 -    assert(outgoing_message);
   19.48 -    outgoing_message->from = alice;
   19.49 -    outgoing_message->to = to_list;
   19.50 -    outgoing_message->shortmsg = strdup("Greetings, humans!");
   19.51 -    outgoing_message->attachments = new_bloblist(NULL, 0, "application/octet-stream", NULL);
   19.52 -    outgoing_message->longmsg = strdup("This is a dumb message.\nBut it's done.\n");
   19.53 -    assert(outgoing_message->longmsg);
   19.54 -    cout << "message created.\n";
   19.55 -
   19.56 -    char* encoded_text = nullptr;
   19.57 -
   19.58 -    message* encrypted_msg = nullptr;
   19.59 -    cout << "calling encrypt_message\n";
   19.60 -    PEP_STATUS status = encrypt_message (session, outgoing_message, NULL, &encrypted_msg, PEP_enc_PGP_MIME, 0);
   19.61 -    cout << "encrypt_message() returns " << tl_status_string(status) << '.' << endl;
   19.62 -    assert(status == PEP_STATUS_OK);
   19.63 -    assert(encrypted_msg);
   19.64 -    cout << "message encrypted.\n";
   19.65 -    
   19.66 -    status = mime_encode_message(encrypted_msg, false, &encoded_text);
   19.67 -    assert(status == PEP_STATUS_OK);
   19.68 -    assert(encoded_text);
   19.69 -    
   19.70 -    bool contains_version = false;
   19.71 -    
   19.72 -    const char* version_str = "X-pEp-Version: ";
   19.73 -    size_t version_prefix_len = strlen(version_str);
   19.74 -    
   19.75 -    istringstream f(encoded_text);
   19.76 -    string enc_string;
   19.77 -    while (getline(f, enc_string)) {
   19.78 -        if (strncmp(enc_string.c_str(), version_str, version_prefix_len) == 0)
   19.79 -            contains_version = true;
   19.80 -    }
   19.81 -    assert(contains_version);
   19.82 -    
   19.83 -    if (contains_version)
   19.84 -        cout << "Version string in encrypted message, as it should be." << endl;
   19.85 -    
   19.86 -    cout << "freeing messages…\n";
   19.87 -    free_message(encrypted_msg);
   19.88 -    free_message(outgoing_message);
   19.89 -    cout << "done.\n";
   19.90 -
   19.91 -    cout << "calling release()\n";
   19.92 -    release(session);
   19.93 -    return 0;
   19.94 -}
    20.1 --- a/test/decrypt_attach_private_key_trusted_test.cc	Wed May 09 09:51:05 2018 +0200
    20.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.3 @@ -1,151 +0,0 @@
    20.4 -// This file is under GNU General Public License 3.0
    20.5 -// see LICENSE.txt
    20.6 -
    20.7 -#include <stdlib.h>
    20.8 -#include <string.h>
    20.9 -#include "platform.h"
   20.10 -#include <iostream>
   20.11 -#include <fstream>
   20.12 -#include <assert.h>
   20.13 -#include "mime.h"
   20.14 -#include "message_api.h"
   20.15 -#include "keymanagement.h"
   20.16 -#include "test_util.h"
   20.17 -
   20.18 -using namespace std;
   20.19 -
   20.20 -int main() {
   20.21 -    cout << "\n*** decrypt_attach_private_key_trusted_test ***\n\n";
   20.22 -
   20.23 -    PEP_SESSION session;
   20.24 -    
   20.25 -    cout << "calling init()\n";
   20.26 -    PEP_STATUS status1 = init(&session);
   20.27 -    assert(status1 == PEP_STATUS_OK);
   20.28 -    assert(session);
   20.29 -    cout << "init() completed.\n";
   20.30 -
   20.31 -    const char* own_uid = PEP_OWN_USERID;
   20.32 -
   20.33 -    cout << "Importing keys..." << endl;
   20.34 -    
   20.35 -    string input_key;
   20.36 -    const char* main_addr = "priv-key-import-test-main@darthmama.cool";
   20.37 -    pEp_identity* main_me = NULL;
   20.38 -    const char* fpr_main_me = "13A9F97964A2B52520CAA40E51BCA783C065A213";    
   20.39 -    pEp_identity* same_addr_same_uid = NULL;
   20.40 -    const char* fpr_same_addr_same_uid = "8AB616A3BD51DEF714B5E688EFFB540C3276D2E5";
   20.41 -        
   20.42 -    PEP_STATUS status = PEP_STATUS_OK;
   20.43 -
   20.44 -    // key for main own user
   20.45 -    // 
   20.46 -    // 13A9F97964A2B52520CAA40E51BCA783C065A213    
   20.47 -    input_key = slurp("test_keys/pub/priv-key-import-test-main_0-0xC065A213_pub.asc");
   20.48 -    status = import_key(session, input_key.c_str(), input_key.length(), NULL);
   20.49 -    assert(status == PEP_STATUS_OK);
   20.50 -
   20.51 -    input_key = slurp("test_keys/priv/priv-key-import-test-main_0-0xC065A213_priv.asc");
   20.52 -    status = import_key(session, input_key.c_str(), input_key.length(), NULL);
   20.53 -    assert(status == PEP_STATUS_OK);
   20.54 -
   20.55 -    // ensure there's no private key - doesn't work in automated tests, sadly. Uncommon when running script manually.
   20.56 -    bool has_priv = false;
   20.57 -    // status = contains_priv_key(session, fpr_same_addr_same_uid, &has_priv);
   20.58 -    // if (status == PEP_STATUS_OK && has_priv) {
   20.59 -    //     cout << "SORRY, have to delete keys here to run test correctly..." << endl;
   20.60 -    //     status = delete_keypair(session, fpr_same_addr_same_uid);
   20.61 -    //     if (status == PEP_STATUS_OK) {
   20.62 -    //         has_priv = false;
   20.63 -    //         status = contains_priv_key(session, fpr_same_addr_same_uid, &has_priv);
   20.64 -    //         assert(has_priv == false);
   20.65 -    //         cout << "Successfully deleted keypair for " << fpr_same_addr_same_uid << " - will now import the public key only" << endl;
   20.66 -    //     }
   20.67 -    //     else
   20.68 -    //         cout << "Warning - delete keypair returned status " << tl_status_string(status) << ". This may or may not be an error, depending on what you expect." << endl;            
   20.69 -    // }
   20.70 -        
   20.71 -    // key with same address and user_id
   20.72 -    // 8AB616A3BD51DEF714B5E688EFFB540C3276D2E5
   20.73 -    input_key = slurp("test_keys/pub/priv-key-import-test-main_0-0x3276D2E5_pub.asc");
   20.74 -    status = import_key(session, input_key.c_str(), input_key.length(), NULL);
   20.75 -    assert(status == PEP_STATUS_OK);
   20.76 -
   20.77 -    
   20.78 -    cout << "Setting up own identity with default key " << fpr_main_me << endl;
   20.79 -    // Own identity with default key etc
   20.80 -    main_me = new_identity(main_addr, fpr_main_me, own_uid, "PrivateKey Import Test");
   20.81 -    status = set_own_key(session, main_me, fpr_main_me);
   20.82 -    assert(status == PEP_STATUS_OK);
   20.83 -
   20.84 -    assert(strcmp(main_me->fpr, fpr_main_me) == 0);
   20.85 -    cout << "Done!" << endl << endl;
   20.86 -    
   20.87 -    cout << "Setting up sender identities and resetting key trust." << endl;
   20.88 -    cout << "Same address, same user_id - address: " << main_addr << ", user_id: " << own_uid << ", fpr: " << fpr_same_addr_same_uid << endl;  
   20.89 -    same_addr_same_uid = new_identity(main_addr, fpr_same_addr_same_uid, own_uid, "PrivateKey Import Test");
   20.90 -    assert(status == PEP_STATUS_OK || status == PEP_CANNOT_FIND_IDENTITY);
   20.91 -    assert((same_addr_same_uid->comm_type & PEP_ct_confirmed) != PEP_ct_confirmed);
   20.92 -
   20.93 -    status = key_reset_trust(session, same_addr_same_uid);
   20.94 -    
   20.95 -    cout << "Done!" << endl << endl;
   20.96 -
   20.97 -    cout << "Reading in message..." << endl;
   20.98 -    
   20.99 -    string encoded_text = slurp("test_mails/priv_key_attach.eml");
  20.100 -
  20.101 -    cout << "Starting test..." << endl;
  20.102 -    // Case 1:
  20.103 -    // Same address, same user_id, untrusted
  20.104 -    cout << "decrypt with attached private key: Same address, same user_id, trusted" << endl;
  20.105 -    char* decrypted_text = NULL;
  20.106 -    stringlist_t* keylist_used = NULL;
  20.107 -    PEP_rating rating;
  20.108 -    PEP_decrypt_flags_t flags = 0;
  20.109 -    char* modified_src = NULL;
  20.110 -    
  20.111 -    cout << "Trusting personal key for " << same_addr_same_uid->user_id << " and " << same_addr_same_uid->fpr << endl;
  20.112 -    status = trust_personal_key(session, same_addr_same_uid);
  20.113 -    cout << "Status is " << tl_status_string(status) << endl;  
  20.114 -    assert(status == PEP_STATUS_OK);
  20.115 -    free(decrypted_text);
  20.116 -    decrypted_text = NULL;
  20.117 -
  20.118 -    status = get_trust(session, same_addr_same_uid);
  20.119 -    cout << tl_ct_string(same_addr_same_uid->comm_type) << endl;
  20.120 -    
  20.121 -    assert(same_addr_same_uid->comm_type == PEP_ct_pEp);
  20.122 -    
  20.123 -    flags = 0;
  20.124 -    status = MIME_decrypt_message(session, encoded_text.c_str(), 
  20.125 -                                  encoded_text.size(), &decrypted_text, 
  20.126 -                                  &keylist_used, &rating, &flags,
  20.127 -                                  &modified_src);
  20.128 -
  20.129 -    status = get_trust(session, same_addr_same_uid);
  20.130 -    assert(same_addr_same_uid->comm_type == PEP_ct_pEp);
  20.131 -    
  20.132 -    flags = 0;
  20.133 -    status = MIME_decrypt_message(session, encoded_text.c_str(), 
  20.134 -                                  encoded_text.size(), &decrypted_text, 
  20.135 -                                  &keylist_used, &rating, &flags,
  20.136 -                                  &modified_src);
  20.137 -    
  20.138 -    cout << "Status: " << tl_status_string(status) << endl;
  20.139 -    assert(status == PEP_STATUS_OK);
  20.140 -
  20.141 -    cout << decrypted_text << endl;
  20.142 -    
  20.143 -    has_priv = false;
  20.144 -    status = contains_priv_key(session, fpr_same_addr_same_uid, &has_priv);
  20.145 -    assert(has_priv == true);
  20.146 -    cout << "Private key was also imported." << endl;
  20.147 -    
  20.148 -    cout << "PASS!" << endl;
  20.149 -    status = key_reset_trust(session, main_me);      
  20.150 -    status = key_reset_trust(session, same_addr_same_uid);      
  20.151 -    release(session);
  20.152 -    
  20.153 -    return 0;
  20.154 -}
    21.1 --- a/test/decrypt_attach_private_key_untrusted_test.cc	Wed May 09 09:51:05 2018 +0200
    21.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.3 @@ -1,128 +0,0 @@
    21.4 -// This file is under GNU General Public License 3.0
    21.5 -// see LICENSE.txt
    21.6 -
    21.7 -#include <stdlib.h>
    21.8 -#include <string.h>
    21.9 -#include "platform.h"
   21.10 -#include <iostream>
   21.11 -#include <fstream>
   21.12 -#include <assert.h>
   21.13 -#include "mime.h"
   21.14 -#include "message_api.h"
   21.15 -#include "keymanagement.h"
   21.16 -#include "test_util.h"
   21.17 -
   21.18 -using namespace std;
   21.19 -
   21.20 -int main() {
   21.21 -    cout << "\n*** decrypt_attach_private_key_untrusted_test ***\n\n";
   21.22 -
   21.23 -    PEP_SESSION session;
   21.24 -    
   21.25 -    cout << "calling init()\n";
   21.26 -    PEP_STATUS status1 = init(&session);
   21.27 -    assert(status1 == PEP_STATUS_OK);
   21.28 -    assert(session);
   21.29 -    cout << "init() completed.\n";
   21.30 -
   21.31 -    const char* own_uid = PEP_OWN_USERID;
   21.32 -
   21.33 -    cout << "Importing keys..." << endl;
   21.34 -    
   21.35 -    string input_key;
   21.36 -    const char* main_addr = "priv-key-import-test-main@darthmama.cool";
   21.37 -    pEp_identity* main_me = NULL;
   21.38 -    const char* fpr_main_me = "13A9F97964A2B52520CAA40E51BCA783C065A213";    
   21.39 -    pEp_identity* same_addr_same_uid = NULL;
   21.40 -    const char* fpr_same_addr_same_uid = "8AB616A3BD51DEF714B5E688EFFB540C3276D2E5";
   21.41 -        
   21.42 -    PEP_STATUS status = PEP_STATUS_OK;
   21.43 -
   21.44 -    // key for main own user
   21.45 -    // 
   21.46 -    // 13A9F97964A2B52520CAA40E51BCA783C065A213    
   21.47 -    input_key = slurp("test_keys/pub/priv-key-import-test-main_0-0xC065A213_pub.asc");
   21.48 -    status = import_key(session, input_key.c_str(), input_key.length(), NULL);
   21.49 -    assert(status == PEP_STATUS_OK);
   21.50 -
   21.51 -    input_key = slurp("test_keys/priv/priv-key-import-test-main_0-0xC065A213_priv.asc");
   21.52 -    status = import_key(session, input_key.c_str(), input_key.length(), NULL);
   21.53 -    assert(status == PEP_STATUS_OK);
   21.54 -
   21.55 -    // ensure there's no private key - doesn't work in automated tests, sadly. Uncommon when running script manually.
   21.56 -    bool has_priv = false;
   21.57 -    // status = contains_priv_key(session, fpr_same_addr_same_uid, &has_priv);
   21.58 -    // if (status == PEP_STATUS_OK && has_priv) {
   21.59 -    //     cout << "SORRY, have to delete keys here to run test correctly..." << endl;
   21.60 -    //     status = delete_keypair(session, fpr_same_addr_same_uid);
   21.61 -    //     if (status == PEP_STATUS_OK)
   21.62 -    //         cout << "Successfully deleted keypair for " << fpr_same_addr_same_uid << " - will now import the public key only" << endl;
   21.63 -    // }
   21.64 -        
   21.65 -    // key with same address and user_id
   21.66 -    // 8AB616A3BD51DEF714B5E688EFFB540C3276D2E5
   21.67 -    input_key = slurp("test_keys/pub/priv-key-import-test-main_0-0x3276D2E5_pub.asc");
   21.68 -    status = import_key(session, input_key.c_str(), input_key.length(), NULL);
   21.69 -    assert(status == PEP_STATUS_OK);
   21.70 -
   21.71 -    
   21.72 -    cout << "Setting up own identity with default key " << fpr_main_me << endl;
   21.73 -    // Own identity with default key etc
   21.74 -    main_me = new_identity(main_addr, fpr_main_me, own_uid, "PrivateKey Import Test");
   21.75 -    status = set_own_key(session, main_me, fpr_main_me);
   21.76 -    assert(status == PEP_STATUS_OK);
   21.77 -
   21.78 -    assert(strcmp(main_me->fpr, fpr_main_me) == 0);
   21.79 -    cout << "Done!" << endl << endl;
   21.80 -    
   21.81 -    cout << "Setting up sender identities and resetting key trust." << endl;
   21.82 -    cout << "Same address, same user_id - address: " << main_addr << ", user_id: " << own_uid << ", fpr: " << fpr_same_addr_same_uid << endl;  
   21.83 -    same_addr_same_uid = new_identity(main_addr, fpr_same_addr_same_uid, own_uid, "PrivateKey Import Test");
   21.84 -    assert(status == PEP_STATUS_OK || status == PEP_CANNOT_FIND_IDENTITY);
   21.85 -    assert((same_addr_same_uid->comm_type & PEP_ct_confirmed) != PEP_ct_confirmed);
   21.86 -
   21.87 -    status = key_reset_trust(session, same_addr_same_uid);
   21.88 -    
   21.89 -    cout << "Done!" << endl << endl;
   21.90 -
   21.91 -    cout << "Reading in message..." << endl;
   21.92 -    
   21.93 -    string encoded_text = slurp("test_mails/priv_key_attach.eml");
   21.94 -
   21.95 -    cout << "Starting tests..." << endl;
   21.96 -    // Case 1:
   21.97 -    // Same address, same user_id, untrusted
   21.98 -    cout << "Same address, same user_id, untrusted" << endl;
   21.99 -    char* decrypted_text = NULL;
  21.100 -    stringlist_t* keylist_used = NULL;
  21.101 -    PEP_rating rating;
  21.102 -    PEP_decrypt_flags_t flags;
  21.103 -    char* modified_src = NULL;
  21.104 -    
  21.105 -    status = get_trust(session, same_addr_same_uid);
  21.106 -    cout << tl_ct_string(same_addr_same_uid->comm_type) << endl;
  21.107 -    
  21.108 -    assert((same_addr_same_uid->comm_type & PEP_ct_confirmed) != PEP_ct_confirmed);
  21.109 -    
  21.110 -    flags = 0;
  21.111 -    status = MIME_decrypt_message(session, encoded_text.c_str(), 
  21.112 -                                  encoded_text.size(), &decrypted_text, 
  21.113 -                                  &keylist_used, &rating, &flags,
  21.114 -				  &modified_src);
  21.115 -
  21.116 -    status = get_trust(session, same_addr_same_uid);
  21.117 -    assert(same_addr_same_uid->comm_type == PEP_ct_pEp_unconfirmed);
  21.118 -
  21.119 -    cout << "Case 1 Status: " << tl_status_string(status) << endl; 
  21.120 -    cout << "Private key is not trusted for " << same_addr_same_uid->fpr << ", as desired, as the public key was not trusted." << endl;
  21.121 -    cout << "PASS!" << endl;
  21.122 -
  21.123 -    // Case 2:
  21.124 -    cout << decrypted_text << endl;
  21.125 -    
  21.126 -    status = key_reset_trust(session, main_me);      
  21.127 -    status = key_reset_trust(session, same_addr_same_uid);      
  21.128 -    release(session);
  21.129 -    
  21.130 -    return 0;
  21.131 -}
    22.1 --- a/test/encrypt_attach_private_key_test.cc	Wed May 09 09:51:05 2018 +0200
    22.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.3 @@ -1,293 +0,0 @@
    22.4 -// This file is under GNU General Public License 3.0
    22.5 -// see LICENSE.txt
    22.6 -
    22.7 -#include <stdlib.h>
    22.8 -#include <string.h>
    22.9 -#include "platform.h"
   22.10 -#include <iostream>
   22.11 -#include <fstream>
   22.12 -#include <assert.h>
   22.13 -#include "mime.h"
   22.14 -#include "message_api.h"
   22.15 -#include "keymanagement.h"
   22.16 -#include "test_util.h"
   22.17 -
   22.18 -using namespace std;
   22.19 -
   22.20 -int main() {
   22.21 -    cout << "\n*** encrypt_attach_private_key_test ***\n\n";
   22.22 -
   22.23 -    PEP_SESSION session;
   22.24 -    
   22.25 -    cout << "calling init()\n";
   22.26 -    PEP_STATUS status1 = init(&session);
   22.27 -    assert(status1 == PEP_STATUS_OK);
   22.28 -    assert(session);
   22.29 -    cout << "init() completed.\n";
   22.30 -
   22.31 -    const char* own_uid = PEP_OWN_USERID;
   22.32 -    const char* diff_uid_0 = "TASTY_TEST_UID_0";
   22.33 -    const char* diff_uid_1 = "TASTY_TEST_UID_1";
   22.34 -
   22.35 -    cout << "Importing keys..." << endl;
   22.36 -    
   22.37 -    string input_key;
   22.38 -    const char* main_addr = "priv-key-import-test-main@darthmama.cool";
   22.39 -    pEp_identity* main_me = NULL;
   22.40 -    const char* fpr_main_me = "8AB616A3BD51DEF714B5E688EFFB540C3276D2E5";
   22.41 -    pEp_identity* same_addr_same_uid = NULL;
   22.42 -    const char* fpr_same_addr_same_uid = "359DD8AC87D1F5E4304D08338D7185F180C8CD87";
   22.43 -    
   22.44 -    pEp_identity* same_addr_diff_uid = NULL;
   22.45 -    const char* fpr_same_addr_diff_uid = "B044B83639E292283A3F6E14C2E64B520B74809C";
   22.46 -
   22.47 -    const char* diff_addr_0 = "priv-key-import-test-other_0@darthmama.cool";
   22.48 -    pEp_identity* diff_addr_same_uid = NULL;
   22.49 -    const char* fpr_diff_addr_same_uid = "C52911EBA0D34B0F549594A15A7A363BD11252C9";
   22.50 -    
   22.51 -    const char* diff_addr_1 = "priv-key-import-test-other_1@darthmama.cool";
   22.52 -    pEp_identity* diff_addr_diff_uid = NULL;
   22.53 -    const char* fpr_diff_addr_diff_uid = "567212EFB8A3A76B1D32B9565F45BEA9C785F20A";
   22.54 -    
   22.55 -    PEP_STATUS status = PEP_STATUS_OK;
   22.56 -
   22.57 -    // key for main own user
   22.58 -    // 8AB616A3BD51DEF714B5E688EFFB540C3276D2E5
   22.59 -    input_key = slurp("test_keys/pub/priv-key-import-test-main_0-0x3276D2E5_pub.asc");
   22.60 -    status = import_key(session, input_key.c_str(), input_key.length(), NULL);
   22.61 -    assert(status == PEP_STATUS_OK);
   22.62 -
   22.63 -    input_key = slurp("test_keys/priv/priv-key-import-test-main_0-0x3276D2E5_priv.asc");
   22.64 -    status = import_key(session, input_key.c_str(), input_key.length(), NULL);
   22.65 -    assert(status == PEP_STATUS_OK);
   22.66 -        
   22.67 -    // key with same address and user_id (initially untrusted, then trusted)
   22.68 -    // 359DD8AC87D1F5E4304D08338D7185F180C8CD87
   22.69 -    input_key = slurp("test_keys/pub/priv-key-import-test-main_1-0x80C8CD87_pub.asc");
   22.70 -    status = import_key(session, input_key.c_str(), input_key.length(), NULL);
   22.71 -    assert(status == PEP_STATUS_OK);
   22.72 -
   22.73 -    // key with same address and to have different (non-aliased) user_id (initially untrusted, then trusted)
   22.74 -    // B044B83639E292283A3F6E14C2E64B520B74809C
   22.75 -    input_key = slurp("test_keys/pub/priv-key-import-test-main_2-0x0B74809C_pub.asc");
   22.76 -    status = import_key(session, input_key.c_str(), input_key.length(), NULL);
   22.77 -    assert(status == PEP_STATUS_OK);
   22.78 -
   22.79 -    // key with different address to have same user_id (initially untrusted, then trusted)
   22.80 -    // C52911EBA0D34B0F549594A15A7A363BD11252C9
   22.81 -    input_key = slurp("test_keys/pub/priv-key-import-test-other_0-0xD11252C9_pub.asc");
   22.82 -    status = import_key(session, input_key.c_str(), input_key.length(), NULL);
   22.83 -    assert(status == PEP_STATUS_OK);
   22.84 -        
   22.85 -    // key with different address to have different user_id (initially untrusted, then trusted)
   22.86 -    // 567212EFB8A3A76B1D32B9565F45BEA9C785F20A
   22.87 -    input_key = slurp("test_keys/pub/priv-key-import-test-other_1-0xC785F20A_pub.asc");
   22.88 -    status = import_key(session, input_key.c_str(), input_key.length(), NULL);
   22.89 -    assert(status == PEP_STATUS_OK);
   22.90 -    cout << "Done!" << endl << endl;
   22.91 -    
   22.92 -    cout << "Setting up own identity with default key " << fpr_main_me << endl;
   22.93 -    // Own identity with default key etc
   22.94 -    main_me = new_identity(main_addr, fpr_main_me, own_uid, "PrivateKey Import Test");
   22.95 -    status = set_own_key(session, main_me, fpr_main_me);
   22.96 -    assert(status == PEP_STATUS_OK);
   22.97 -
   22.98 -    assert(strcmp(main_me->fpr, fpr_main_me) == 0);
   22.99 -    cout << "Done!" << endl << endl;
  22.100 -    
  22.101 -    cout << "Setting up recipient identities and resetting key trust." << endl;
  22.102 -    cout << "#1: same address, same user_id - address: " << main_addr << ", user_id: " << own_uid << ", fpr: " << fpr_same_addr_same_uid << endl;  
  22.103 -    // Identity with same address and user_id - the fpr here will be ignored in update_identity and friends.
  22.104 -    same_addr_same_uid = new_identity(main_addr, fpr_same_addr_same_uid, own_uid, "PrivateKey Import Test");
  22.105 -    status = key_reset_trust(session, same_addr_same_uid);
  22.106 -    assert(status == PEP_STATUS_OK || status == PEP_CANNOT_FIND_IDENTITY);
  22.107 -    assert(strcmp(same_addr_same_uid->fpr, fpr_same_addr_same_uid) == 0);
  22.108 -    
  22.109 -    // Identity with same address and different user_id
  22.110 -    cout << "#2: same address, different user_id - address: " << main_addr << ", user_id: " << diff_uid_0 << ", fpr: " << fpr_same_addr_diff_uid << endl;  
  22.111 -    same_addr_diff_uid = new_identity(main_addr, fpr_same_addr_diff_uid, diff_uid_0, "PrivateKey Import Test");
  22.112 -    assert(same_addr_diff_uid);
  22.113 -    status = key_reset_trust(session, same_addr_diff_uid);
  22.114 -    assert(status == PEP_STATUS_OK || status == PEP_CANNOT_FIND_IDENTITY);
  22.115 -    assert(strcmp(same_addr_diff_uid->fpr, fpr_same_addr_diff_uid) == 0);
  22.116 -    
  22.117 -    // Identity with diff address and same user_id
  22.118 -    cout << "#3: different address, same user_id - address: " << diff_addr_0 << ", user_id: " << own_uid << ", fpr: " << fpr_diff_addr_same_uid << endl;      
  22.119 -    diff_addr_same_uid = new_identity(diff_addr_0, fpr_diff_addr_same_uid, own_uid, "PrivateKey Import Test");
  22.120 -    assert(diff_addr_same_uid);
  22.121 -    status = key_reset_trust(session, diff_addr_same_uid);
  22.122 -    assert(status == PEP_STATUS_OK || status == PEP_CANNOT_FIND_IDENTITY);
  22.123 -    assert(strcmp(diff_addr_same_uid->fpr, fpr_diff_addr_same_uid) == 0);
  22.124 -
  22.125 -    // Identity with different address and different user_id
  22.126 -    cout << "#4: different address, different user_id - address: " << diff_addr_1 << ", user_id: " << diff_uid_1 << ", fpr: " << fpr_diff_addr_diff_uid << endl;      
  22.127 -    diff_addr_diff_uid = new_identity(diff_addr_1, fpr_diff_addr_diff_uid, diff_uid_1, "PrivateKey Import Test");
  22.128 -    assert(diff_addr_diff_uid);
  22.129 -    status = key_reset_trust(session, diff_addr_diff_uid);
  22.130 -    assert(status == PEP_STATUS_OK || status == PEP_CANNOT_FIND_IDENTITY);
  22.131 -    assert(strcmp(diff_addr_diff_uid->fpr, fpr_diff_addr_diff_uid) == 0);
  22.132 -    cout << "Done!" << endl << endl;
  22.133 -
  22.134 -    message* msg_same_addr_same_uid = new_message(PEP_dir_outgoing);
  22.135 -    msg_same_addr_same_uid->from = main_me;
  22.136 -    msg_same_addr_same_uid->shortmsg = strdup("Greetings, humans!");
  22.137 -    msg_same_addr_same_uid->longmsg = strdup("This is a test of the emergency message system. This is only a test. BEEP.");
  22.138 -    msg_same_addr_same_uid->attachments = new_bloblist(NULL, 0, "application/octet-stream", NULL);
  22.139 -
  22.140 -    message* msg_same_addr_diff_uid = message_dup(msg_same_addr_same_uid);
  22.141 -    message* msg_diff_addr_same_uid = message_dup(msg_same_addr_same_uid);       
  22.142 -    message* msg_diff_addr_diff_uid = message_dup(msg_same_addr_same_uid);       
  22.143 -
  22.144 -    cout << "Starting tests..." << endl;
  22.145 -    // Case 1:
  22.146 -    // Same address, same user_id, untrusted
  22.147 -    cout << "Case 1: Same address, same user_id, untrusted" << endl;
  22.148 -    assert(msg_same_addr_same_uid);        
  22.149 -    identity_list* to_list = new_identity_list(same_addr_same_uid);
  22.150 -    msg_same_addr_same_uid->to = to_list;
  22.151 -    message* enc_same_addr_same_uid_untrusted = NULL;
  22.152 -    status = encrypt_message_and_add_priv_key(session,
  22.153 -                                              msg_same_addr_same_uid,
  22.154 -                                              &enc_same_addr_same_uid_untrusted,
  22.155 -                                              fpr_same_addr_same_uid,
  22.156 -                                              PEP_enc_PGP_MIME,
  22.157 -                                              0);
  22.158 -
  22.159 -    cout << "Case 1 Status: " << tl_status_string(status) << endl;
  22.160 -    assert(status == PEP_ILLEGAL_VALUE);
  22.161 -    cout << "PASS!" << endl;
  22.162 -    
  22.163 -    // Case 2:
  22.164 -    // Same address, same_user_id, trusted
  22.165 -    cout << "Case 2: Same address, same user_id, trusted" << endl;
  22.166 -    status = trust_personal_key(session, same_addr_same_uid);
  22.167 -    cout << "Trust personal key for " << same_addr_same_uid << " gives status " << tl_status_string(status) << " (" << status << ")" << endl;
  22.168 -    assert(status == PEP_STATUS_OK);
  22.169 -    message* enc_same_addr_same_uid_trusted = NULL;
  22.170 -    status = encrypt_message_and_add_priv_key(session,
  22.171 -                                              msg_same_addr_same_uid,
  22.172 -                                              &enc_same_addr_same_uid_trusted,
  22.173 -                                              fpr_same_addr_same_uid,
  22.174 -                                              PEP_enc_PGP_MIME,
  22.175 -                                              0);
  22.176 -
  22.177 -    cout << "Case 2 Status: " << tl_status_string(status) << endl;
  22.178 -    assert(status == PEP_STATUS_OK);
  22.179 -    cout << "PASS!" << endl;
  22.180 -
  22.181 -    // Case 3:
  22.182 -    // Different address, same user_id, untrusted
  22.183 -    cout << "Case 3: Different address, same user_id, untrusted" << endl;
  22.184 -    assert(msg_diff_addr_same_uid);        
  22.185 -    identity_list* to_list_1 = new_identity_list(diff_addr_same_uid);
  22.186 -    msg_diff_addr_same_uid->to = to_list_1;
  22.187 -    message* enc_diff_addr_same_uid_untrusted = NULL;
  22.188 -    status = encrypt_message_and_add_priv_key(session,
  22.189 -                                              msg_diff_addr_same_uid,
  22.190 -                                              &enc_diff_addr_same_uid_untrusted,
  22.191 -                                              fpr_diff_addr_same_uid,
  22.192 -                                              PEP_enc_PGP_MIME,
  22.193 -                                              0);
  22.194 -    
  22.195 -    cout << "Case 3 Status: " << tl_status_string(status) << endl;
  22.196 -    assert(status == PEP_ILLEGAL_VALUE);
  22.197 -    cout << "PASS!" << endl;
  22.198 -
  22.199 -    // Case 4:
  22.200 -    // Different address, same user_id, trusted
  22.201 -    cout << "Case 4: Different address, same user_id, trusted" << endl;
  22.202 -    status = trust_personal_key(session, diff_addr_same_uid);
  22.203 -    assert(status == PEP_STATUS_OK);
  22.204 -    message* enc_diff_addr_same_uid_trusted = NULL;
  22.205 -    status = encrypt_message_and_add_priv_key(session,
  22.206 -                                              msg_diff_addr_same_uid,
  22.207 -                                              &enc_diff_addr_same_uid_trusted,
  22.208 -                                              fpr_diff_addr_same_uid,
  22.209 -                                              PEP_enc_PGP_MIME,
  22.210 -                                              0);
  22.211 -                                              
  22.212 -    cout << "Case 4 Status: " << tl_status_string(status) << endl;
  22.213 -    assert(status == PEP_ILLEGAL_VALUE);
  22.214 -    cout << "PASS!" << endl;
  22.215 -
  22.216 -    // Case 5:
  22.217 -    // Same address, different user_id, untrusted
  22.218 -    cout << "Case 5: Same address, different user_id, untrusted" << endl;    
  22.219 -    assert(msg_same_addr_diff_uid);        
  22.220 -    identity_list* to_list_2 = new_identity_list(same_addr_diff_uid);
  22.221 -    msg_same_addr_diff_uid->to = to_list_2;
  22.222 -    message* enc_same_addr_diff_uid_untrusted = NULL;
  22.223 -    status = encrypt_message_and_add_priv_key(session,
  22.224 -                                              msg_same_addr_diff_uid,
  22.225 -                                              &enc_same_addr_diff_uid_untrusted,
  22.226 -                                              fpr_same_addr_diff_uid,
  22.227 -                                              PEP_enc_PGP_MIME,
  22.228 -                                              0);
  22.229 -
  22.230 -    cout << "Case 5 Status: " << tl_status_string(status) << endl;
  22.231 -    assert(status == PEP_ILLEGAL_VALUE);    
  22.232 -    cout << "PASS!" << endl;
  22.233 -    
  22.234 -    // Case 6:
  22.235 -    // Same address, different user_id, trusted
  22.236 -    cout << "Case 6: Same address, different user_id, trusted" << endl;        
  22.237 -    status = trust_personal_key(session, same_addr_diff_uid);
  22.238 -    assert(status == PEP_STATUS_OK);
  22.239 -    message* enc_same_addr_diff_uid_trusted = NULL;
  22.240 -    status = encrypt_message_and_add_priv_key(session,
  22.241 -                                              msg_same_addr_diff_uid,
  22.242 -                                              &enc_same_addr_diff_uid_untrusted,
  22.243 -                                              fpr_same_addr_diff_uid,
  22.244 -                                              PEP_enc_PGP_MIME,
  22.245 -                                              0);
  22.246 -
  22.247 -    cout << "Case 6 Status: " << tl_status_string(status) << endl;
  22.248 -    assert(status == PEP_ILLEGAL_VALUE);    
  22.249 -    cout << "PASS!" << endl;
  22.250 -
  22.251 -    // Case 7:
  22.252 -    // Different address, different user_id, untrusted
  22.253 -    cout << "Case 7: Different address, different user_id, untrusted" << endl;    
  22.254 -    assert(msg_diff_addr_diff_uid);        
  22.255 -    identity_list* to_list_3 = new_identity_list(diff_addr_diff_uid);
  22.256 -    msg_diff_addr_diff_uid->to = to_list_3;
  22.257 -    message* enc_diff_addr_diff_uid_untrusted = NULL;
  22.258 -    status = encrypt_message_and_add_priv_key(session,
  22.259 -                                              msg_diff_addr_diff_uid,
  22.260 -                                              &enc_diff_addr_diff_uid_untrusted,
  22.261 -                                              fpr_diff_addr_diff_uid,
  22.262 -                                              PEP_enc_PGP_MIME,
  22.263 -                                              0);
  22.264 -
  22.265 -    cout << "Case 7 Status: " << tl_status_string(status) << endl;
  22.266 -    assert(status == PEP_ILLEGAL_VALUE);
  22.267 -    cout << "PASS!" << endl;
  22.268 -
  22.269 -    // Case 8:
  22.270 -    // Different address, different user_id, trusted
  22.271 -    cout << "Case 8: Different address, different user_id, trusted" << endl;    
  22.272 -    status = trust_personal_key(session, diff_addr_diff_uid);
  22.273 -    assert(status == PEP_STATUS_OK);
  22.274 -    message* enc_diff_addr_diff_uid_trusted = NULL;
  22.275 -    status = encrypt_message_and_add_priv_key(session,
  22.276 -                                              msg_diff_addr_diff_uid,
  22.277 -                                              &enc_diff_addr_diff_uid_trusted,
  22.278 -                                              fpr_diff_addr_diff_uid,
  22.279 -                                              PEP_enc_PGP_MIME,
  22.280 -                                              0);
  22.281 -
  22.282 -    cout << "Case 8 Status: " << tl_status_string(status) << endl;
  22.283 -    assert(status == PEP_ILLEGAL_VALUE);
  22.284 -    cout << "PASS!" << endl;
  22.285 -    
  22.286 -    cout << "Correctly encrypted message:" << endl << endl;                
  22.287 -    char* encrypted_msg_text = NULL;
  22.288 -    mime_encode_message(enc_same_addr_same_uid_trusted, false, &encrypted_msg_text);                                    
  22.289 -    cout << encrypted_msg_text << endl << endl;
  22.290 -    
  22.291 -    // FIXME: Free all the damned things
  22.292 -      
  22.293 -    release(session);
  22.294 -    
  22.295 -    return 0;
  22.296 -}
    23.1 --- a/test/encrypt_for_identity_test.cc	Wed May 09 09:51:05 2018 +0200
    23.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    23.3 @@ -1,291 +0,0 @@
    23.4 -// This file is under GNU General Public License 3.0
    23.5 -// see LICENSE.txt
    23.6 -
    23.7 -#include <stdlib.h>
    23.8 -#include <string.h>
    23.9 -#include "platform.h"
   23.10 -#include <iostream>
   23.11 -#include <fstream>
   23.12 -#include <assert.h>
   23.13 -#include "mime.h"
   23.14 -#include "message_api.h"
   23.15 -#include "keymanagement.h"
   23.16 -#include "test_util.h"
   23.17 -
   23.18 -using namespace std;
   23.19 -
   23.20 -int main() {
   23.21 -    cout << "\n*** encrypt_for_identity_test ***\n\n";
   23.22 -
   23.23 -    PEP_SESSION session;
   23.24 -    
   23.25 -    cout << "calling init()\n";
   23.26 -    PEP_STATUS status1 = init(&session);
   23.27 -    assert(status1 == PEP_STATUS_OK);
   23.28 -    assert(session);
   23.29 -    cout << "init() completed.\n";
   23.30 -
   23.31 -    // message_api test code
   23.32 -
   23.33 -    const string alice_pub_key = slurp("test_keys/pub/pep-test-alice-0x6FF00E97_pub.asc");
   23.34 -    const string alice_priv_key = slurp("test_keys/priv/pep-test-alice-0x6FF00E97_priv.asc");
   23.35 -    const string gabrielle_pub_key = slurp("test_keys/pub/pep-test-gabrielle-0xE203586C_pub.asc");
   23.36 -    const string bella_pub_key = slurp("test_keys/pub/pep.test.bella-0xAF516AAE_pub.asc");    
   23.37 -
   23.38 -    PEP_STATUS statuspub = import_key(session, alice_pub_key.c_str(), alice_pub_key.length(), NULL);
   23.39 -    PEP_STATUS statuspriv = import_key(session, alice_priv_key.c_str(), alice_priv_key.length(), NULL);
   23.40 -    assert(statuspub == PEP_STATUS_OK);
   23.41 -    assert(statuspriv == PEP_STATUS_OK);
   23.42 -    
   23.43 -    statuspub = import_key(session, gabrielle_pub_key.c_str(), gabrielle_pub_key.length(), NULL);
   23.44 -    assert(statuspub == PEP_STATUS_OK);
   23.45 -    statuspub = import_key(session, bella_pub_key.c_str(), bella_pub_key.length(), NULL);
   23.46 -    assert(statuspub == PEP_STATUS_OK);
   23.47 -
   23.48 -    const char* alice_fpr = "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97";
   23.49 -    const char* gabrielle_fpr = "906C9B8349954E82C5623C3C8C541BD4E203586C";
   23.50 -    const char* bella_fpr = "5631BF1357326A02AA470EEEB815EF7FA4516AAE";
   23.51 -    const char* nobody_fpr = "1111111111111111111111111111111111111111";
   23.52 -
   23.53 -    cout << "creating message…\n";
   23.54 -    pEp_identity* alice = new_identity("pep.test.alice@pep-project.org", alice_fpr, PEP_OWN_USERID, "Alice Test");
   23.55 -    pEp_identity* bob = new_identity("pep.test.bob@pep-project.org", NULL, "42", "Bob Test");
   23.56 -    
   23.57 -    alice->me = true;
   23.58 -
   23.59 -    PEP_STATUS mystatus = set_own_key(session, alice, alice_fpr);
   23.60 -    assert(mystatus == PEP_STATUS_OK);
   23.61 -
   23.62 -    identity_list* to_list = new_identity_list(bob); // to bob
   23.63 -    message* outgoing_message = new_message(PEP_dir_outgoing);
   23.64 -    assert(outgoing_message);
   23.65 -    outgoing_message->from = alice;
   23.66 -    outgoing_message->to = to_list;
   23.67 -    outgoing_message->shortmsg = strdup("Greetings, humans!");
   23.68 -    outgoing_message->longmsg = strdup("This is a test of the emergency message system. This is only a test. BEEP.");
   23.69 -    outgoing_message->attachments = new_bloblist(NULL, 0, "application/octet-stream", NULL);
   23.70 -    cout << "message created.\n";
   23.71 -
   23.72 -    char* encoded_text = nullptr;
   23.73 -    PEP_STATUS status = mime_encode_message(outgoing_message, false, &encoded_text);
   23.74 -    assert(status == PEP_STATUS_OK);
   23.75 -    assert(encoded_text);
   23.76 -
   23.77 -    cout << "decrypted:\n\n";
   23.78 -    cout << encoded_text << "\n";
   23.79 -
   23.80 -    free(encoded_text);
   23.81 -
   23.82 -    message* encrypted_msg = nullptr;
   23.83 -    cout << "calling encrypt_message_for_identity()\n";
   23.84 -    status = encrypt_message_for_self(session, alice, outgoing_message, NULL, &encrypted_msg, PEP_enc_PGP_MIME, PEP_encrypt_flag_force_unsigned | PEP_encrypt_flag_force_no_attached_key);
   23.85 -    cout << "encrypt_message() returns " << std::hex << status << '.' << endl;
   23.86 -    assert(status == PEP_STATUS_OK);
   23.87 -    assert(encrypted_msg);
   23.88 -    cout << "message encrypted.\n";
   23.89 -    
   23.90 -    status = mime_encode_message(encrypted_msg, false, &encoded_text);
   23.91 -    assert(status == PEP_STATUS_OK);
   23.92 -    assert(encoded_text);
   23.93 -
   23.94 -    cout << "encrypted:\n\n";
   23.95 -    cout << encoded_text << "\n";
   23.96 -
   23.97 -    message* decoded_msg = nullptr;
   23.98 -    status = mime_decode_message(encoded_text, strlen(encoded_text), &decoded_msg);
   23.99 -    assert(status == PEP_STATUS_OK);
  23.100 -    const string string3 = encoded_text;
  23.101 -
  23.102 -    unlink("msg_encrypt_for_self.asc");
  23.103 -    ofstream outFile3("msg_encrypt_for_self.asc");
  23.104 -    outFile3.write(string3.c_str(), string3.size());
  23.105 -    outFile3.close();
  23.106 -
  23.107 -    message* decrypted_msg = nullptr;
  23.108 -    stringlist_t* keylist_used = nullptr;
  23.109 -
  23.110 -    PEP_rating rating;
  23.111 -    PEP_decrypt_flags_t flags;
  23.112 -
  23.113 -    flags = 0;
  23.114 -    status = decrypt_message(session, encrypted_msg, &decrypted_msg, &keylist_used, &rating, &flags);
  23.115 -    assert(decrypted_msg);
  23.116 -    assert(keylist_used);
  23.117 -    assert(rating);
  23.118 -    assert(status == PEP_DECRYPTED && rating == PEP_rating_unreliable);
  23.119 -    PEP_comm_type ct = encrypted_msg->from->comm_type;
  23.120 -    assert(ct == PEP_ct_pEp || ct == PEP_ct_pEp_unconfirmed || ct == PEP_ct_OpenPGP || ct == PEP_ct_OpenPGP_unconfirmed );
  23.121 -
  23.122 -    cout << "keys used:\n";
  23.123 -
  23.124 -    int i = 0;
  23.125 -
  23.126 -    for (stringlist_t* kl4 = keylist_used; kl4 && kl4->value; kl4 = kl4->next, i++)
  23.127 -    {
  23.128 -        if (i == 0)
  23.129 -            assert(strcasecmp("",kl4->value) == 0);
  23.130 -        else {
  23.131 -            cout << "\t " << kl4->value << endl;
  23.132 -            assert(strcasecmp("4ABE3AAF59AC32CFE4F86500A9411D176FF00E97", kl4->value) == 0);
  23.133 -            cout << "Encrypted for Alice! Yay! It worked!" << endl;
  23.134 -        }
  23.135 -        assert(i < 2);
  23.136 -    }
  23.137 -    cout << "Encrypted ONLY for Alice! Test passed. Move along. These are not the bugs you are looking for." << endl;
  23.138 - 
  23.139 -    cout << "freeing messages…\n";
  23.140 -    free_message(encrypted_msg);
  23.141 -    free_message(decrypted_msg);
  23.142 -    free_stringlist (keylist_used);
  23.143 -    cout << "done.\n";
  23.144 -
  23.145 -    cout << "Now encrypt for self with extra keys." << endl;
  23.146 -    stringlist_t* extra_keys = new_stringlist(gabrielle_fpr);
  23.147 -    stringlist_add(extra_keys, bella_fpr);
  23.148 -    encrypted_msg = NULL;
  23.149 -    decrypted_msg = NULL;
  23.150 -    keylist_used = NULL;
  23.151 -
  23.152 -    cout << "calling encrypt_message_for_identity()\n";
  23.153 -    status = encrypt_message_for_self(session, alice, outgoing_message, extra_keys, &encrypted_msg, PEP_enc_PGP_MIME, PEP_encrypt_flag_force_unsigned | PEP_encrypt_flag_force_no_attached_key);
  23.154 -    cout << "encrypt_message() returns " << std::hex << status << '.' << endl;
  23.155 -    assert(status == PEP_STATUS_OK);
  23.156 -    assert(encrypted_msg);
  23.157 -    cout << "message encrypted.\n";
  23.158 -    
  23.159 -    flags = 0;
  23.160 -    status = decrypt_message(session, encrypted_msg, &decrypted_msg, &keylist_used, &rating, &flags);
  23.161 -    assert(decrypted_msg);
  23.162 -    assert(keylist_used);
  23.163 -    assert(rating);
  23.164 -    assert(status == PEP_DECRYPTED && rating == PEP_rating_unreliable);
  23.165 -    ct = encrypted_msg->from->comm_type;
  23.166 -    assert(ct == PEP_ct_pEp || ct == PEP_ct_pEp_unconfirmed || ct == PEP_ct_OpenPGP || ct == PEP_ct_OpenPGP_unconfirmed );
  23.167 -
  23.168 -    cout << "keys used:\n";
  23.169 -
  23.170 -    for (stringlist_t* incoming_kl = extra_keys; incoming_kl && incoming_kl->value; incoming_kl = incoming_kl->next) {
  23.171 -        bool found = false;
  23.172 -        cout << "Encrypted for: ";
  23.173 -        for (stringlist_t* kl4 = keylist_used; kl4 && kl4->value; kl4 = kl4->next, i++) {
  23.174 -            if (strcasecmp(incoming_kl->value, kl4->value) == 0) {
  23.175 -                cout << "\t " << kl4->value;
  23.176 -                found = true;
  23.177 -                break;
  23.178 -            }
  23.179 -        }
  23.180 -        cout << endl;
  23.181 -        assert(found);
  23.182 -    }
  23.183 -    cout << "Encrypted for all the extra keys!" << endl;
  23.184 -
  23.185 -    bool found = false;
  23.186 -    for (stringlist_t* kl4 = keylist_used; kl4 && kl4->value; kl4 = kl4->next)
  23.187 -    {
  23.188 -        if (strcasecmp(alice_fpr, kl4->value) == 0) {
  23.189 -            found = true;
  23.190 -            cout << "Encrypted also for Alice! Yay!" << endl;
  23.191 -            break;
  23.192 -        }
  23.193 -    }
  23.194 -    assert(found);
  23.195 -
  23.196 -    free_message(encrypted_msg);
  23.197 -    encrypted_msg = NULL;
  23.198 -    free_message(decrypted_msg);
  23.199 -    decrypted_msg = NULL;
  23.200 -    free_stringlist(keylist_used);
  23.201 -    keylist_used = NULL;
  23.202 -
  23.203 -    cout << "Now add a bad fpr." << endl;
  23.204 -    
  23.205 -    stringlist_add(extra_keys, nobody_fpr);
  23.206 -    
  23.207 -    cout << "calling encrypt_message_for_identity()\n";
  23.208 -    status = encrypt_message_for_self(session, alice, outgoing_message, extra_keys, &encrypted_msg, PEP_enc_PGP_MIME, PEP_encrypt_flag_force_unsigned | PEP_encrypt_flag_force_no_attached_key);
  23.209 -    cout << "encrypt_message() returns " << std::hex << status << '.' << endl;
  23.210 -    assert(status != PEP_STATUS_OK);
  23.211 -
  23.212 -    free_message(outgoing_message);
  23.213 -    outgoing_message = NULL;
  23.214 -    free_message(encrypted_msg);
  23.215 -    encrypted_msg = NULL;
  23.216 -    free_message(decrypted_msg);
  23.217 -    decrypted_msg = NULL;
  23.218 -    free_stringlist(keylist_used);
  23.219 -    keylist_used = NULL;
  23.220 -
  23.221 -
  23.222 -    cout << "*** Now testing MIME_encrypt_for_self ***" << endl;
  23.223 -
  23.224 -    alice = new_identity("pep.test.alice@pep-project.org", NULL, PEP_OWN_USERID, "Alice Test");
  23.225 -    bob = new_identity("pep.test.bob@pep-project.org", NULL, "42", "Bob Test");
  23.226 -
  23.227 -    cout << "Reading in alice_bob_encrypt_test_plaintext_mime.eml..." << endl;
  23.228 -    
  23.229 -    const string mimetext = slurp("test_mails/alice_bob_encrypt_test_plaintext_mime.eml");
  23.230 -
  23.231 -    cout << "Text read:" << endl;
  23.232 -    cout << mimetext.c_str() << endl;
  23.233 -    char* encrypted_mimetext = nullptr;
  23.234 -    
  23.235 -    cout << "Calling MIME_encrypt_message_for_self" << endl;
  23.236 -    status = MIME_encrypt_message_for_self(session, alice, mimetext.c_str(),
  23.237 -                                           mimetext.size(), 
  23.238 -                                           NULL,
  23.239 -                                           &encrypted_mimetext, 
  23.240 -                                           PEP_enc_PGP_MIME, 
  23.241 -                                           PEP_encrypt_flag_force_unsigned | PEP_encrypt_flag_force_no_attached_key);
  23.242 -    
  23.243 -    cout << "Encrypted message:" << endl;
  23.244 -    cout << encrypted_mimetext << endl;
  23.245 -
  23.246 -    cout << "Calling MIME_decrypt_message" << endl;
  23.247 -    
  23.248 -    char* decrypted_mimetext = nullptr;
  23.249 -    free_stringlist(keylist_used);
  23.250 -    keylist_used = nullptr;
  23.251 -    PEP_decrypt_flags_t mimeflags;
  23.252 -    PEP_rating mimerating;
  23.253 -    char* modified_src = NULL;
  23.254 -
  23.255 -    mimeflags = 0;
  23.256 -    status = MIME_decrypt_message(session,
  23.257 -                                  encrypted_mimetext,
  23.258 -                                  strlen(encrypted_mimetext),
  23.259 -                                  &decrypted_mimetext,
  23.260 -                                  &keylist_used,
  23.261 -                                  &mimerating,
  23.262 -                                  &mimeflags,
  23.263 -				  &modified_src);
  23.264 -
  23.265 -    assert(decrypted_mimetext);
  23.266 -    assert(keylist_used);
  23.267 -    assert(mimerating);
  23.268 -                             
  23.269 -    assert(status == PEP_DECRYPTED && mimerating == PEP_rating_unreliable);
  23.270 -
  23.271 -    cout << "Decrypted message:" << endl;
  23.272 -    cout << decrypted_mimetext << endl;
  23.273 -
  23.274 -    cout << "keys used:\n";
  23.275 -
  23.276 -    i = 0;
  23.277 -
  23.278 -    for (stringlist_t* kl4 = keylist_used; kl4 && kl4->value; kl4 = kl4->next, i++)
  23.279 -    {
  23.280 -        if (i == 0)
  23.281 -            assert(strcasecmp("",kl4->value) == 0);
  23.282 -        else {
  23.283 -            cout << "\t " << kl4->value << endl;
  23.284 -            assert(strcasecmp("4ABE3AAF59AC32CFE4F86500A9411D176FF00E97", kl4->value) == 0);
  23.285 -            cout << "Encrypted for Alice! Yay! It worked!" << endl;
  23.286 -        }
  23.287 -        assert(i < 2);
  23.288 -    }
  23.289 -    cout << "Encrypted ONLY for Alice! Test passed. Move along. These are not the bugs you are looking for." << endl;
  23.290 -    
  23.291 -    cout << "calling release()\n";
  23.292 -    release(session);
  23.293 -    return 0;
  23.294 -}
    24.1 --- a/test/encrypt_missing_private_key_test.cc	Wed May 09 09:51:05 2018 +0200
    24.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.3 @@ -1,79 +0,0 @@
    24.4 -// This file is under GNU General Public License 3.0
    24.5 -// see LICENSE.txt
    24.6 -
    24.7 -#include <iostream>
    24.8 -#include <iostream>
    24.9 -#include <fstream>
   24.10 -#include <string>
   24.11 -#include <cstring> // for strcmp()
   24.12 -#include <assert.h>
   24.13 -#include "blacklist.h"
   24.14 -#include "keymanagement.h"
   24.15 -#include "message_api.h"
   24.16 -#include "mime.h"
   24.17 -#include "test_util.h"
   24.18 -
   24.19 -using namespace std;
   24.20 -
   24.21 -int main() {
   24.22 -    cout << "\n*** encrypt_missing_private_key_test ***\n\n";
   24.23 -
   24.24 -    PEP_SESSION session;
   24.25 -    
   24.26 -    cout << "calling init()\n";
   24.27 -    PEP_STATUS status1 = init(&session);   
   24.28 -    assert(status1 == PEP_STATUS_OK);
   24.29 -    assert(session);
   24.30 -    cout << "init() completed.\n";
   24.31 -    
   24.32 -    pEp_identity* no_key_identity = new_identity("blacklistself@kgrothoff.org",
   24.33 -                                                      NULL,
   24.34 -                                                      PEP_OWN_USERID,
   24.35 -                                                      "Blacklist Self");
   24.36 -    no_key_identity->me = true;
   24.37 -    PEP_STATUS status8 = myself(session, no_key_identity);
   24.38 -    assert (status8 == PEP_STATUS_OK);
   24.39 -
   24.40 -    /* Now let's try to encrypt a message. */
   24.41 -        
   24.42 -    message* tmp_msg = NULL;
   24.43 -    message* enc_msg = NULL;
   24.44 -    
   24.45 -    const string mailtext = slurp("test_mails/blacklist_no_key.eml");
   24.46 -
   24.47 -    PEP_STATUS status = mime_decode_message(mailtext.c_str(), mailtext.length(), &tmp_msg);
   24.48 -    assert(status == PEP_STATUS_OK);
   24.49 -    
   24.50 -    status = update_identity(session, tmp_msg->from);
   24.51 -    identity_list* to_list = tmp_msg->to;
   24.52 -
   24.53 -    while (to_list) {
   24.54 -        if (to_list->ident)
   24.55 -            update_identity(session, to_list->ident);
   24.56 -        to_list = to_list->next;
   24.57 -    }
   24.58 -    
   24.59 -    // This isn't incoming, though... so we need to reverse the direction
   24.60 -    tmp_msg->dir = PEP_dir_outgoing;
   24.61 -    status = encrypt_message(session,
   24.62 -                             tmp_msg,
   24.63 -                             NULL,
   24.64 -                             &enc_msg,
   24.65 -                             PEP_enc_PGP_MIME,
   24.66 -                             0);
   24.67 -    assert(status == PEP_STATUS_OK);
   24.68 -    
   24.69 -
   24.70 -    char* new_key = enc_msg->from->fpr;
   24.71 -    cout << "Encrypted with key " << new_key << endl;
   24.72 -    
   24.73 -    status = delete_keypair(session, new_key);
   24.74 -    PEP_STATUS status14 = myself(session, no_key_identity);
   24.75 -
   24.76 -    free_message(tmp_msg);    
   24.77 -    free_message(enc_msg);
   24.78 -    
   24.79 -    cout << "calling release()\n";
   24.80 -    release(session);
   24.81 -    return 0;
   24.82 -}
    25.1 --- a/test/external_revoke_test.cc	Wed May 09 09:51:05 2018 +0200
    25.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    25.3 @@ -1,310 +0,0 @@
    25.4 -// This file is under GNU General Public License 3.0
    25.5 -// see LICENSE.txt
    25.6 -
    25.7 -#include <stdlib.h>
    25.8 -#include <string.h>
    25.9 -#include <time.h>
   25.10 -#include "platform.h"
   25.11 -#include <iostream>
   25.12 -#include <fstream>
   25.13 -#include <assert.h>
   25.14 -#include "mime.h"
   25.15 -#include "message_api.h"
   25.16 -#include "test_util.h"
   25.17 -
   25.18 -using namespace std;
   25.19 -
   25.20 -int main() {
   25.21 -    cout << "\n*** external_revoke_test.cc ***\n\n";
   25.22 -
   25.23 -    PEP_SESSION session;
   25.24 -    
   25.25 -    cout << "calling init()\n";
   25.26 -    PEP_STATUS status = init(&session);   
   25.27 -    assert(status == PEP_STATUS_OK);
   25.28 -    assert(session);
   25.29 -    cout << "init() completed.\n";
   25.30 -
   25.31 -#ifndef NETPGP
   25.32 -    char* fprs[2];
   25.33 -
   25.34 -    const string fenris_pub_key = slurp("test_keys/pub/pep.test.fenris-0x4F3D2900_pub.asc");
   25.35 -    const string fenris_priv_key = slurp("test_keys/priv/pep.test.fenris-0x4F3D2900_priv.asc");
   25.36 -
   25.37 -    assert(fenris_pub_key.length() != 0);
   25.38 -    assert(fenris_priv_key.length() != 0);
   25.39 -    
   25.40 -    PEP_STATUS statuspub = import_key(session, fenris_pub_key.c_str(), fenris_pub_key.length(), NULL);
   25.41 -    PEP_STATUS statuspriv = import_key(session, fenris_priv_key.c_str(), fenris_priv_key.length(), NULL);
   25.42 -    assert(statuspub == PEP_STATUS_OK);
   25.43 -    assert(statuspriv == PEP_STATUS_OK);
   25.44 -
   25.45 -    // Create sender ID
   25.46 -    
   25.47 -    pEp_identity * me = new_identity("pep.test.fenris@thisstilldoesntwork.lu", "0969FA229DF21C832A64A04711B1B9804F3D2900", PEP_OWN_USERID, "Fenris Hawke");
   25.48 -    status = myself(session, me);
   25.49 -    
   25.50 -    // Create key
   25.51 -    cout << "Creating new id for : ";
   25.52 -    char *uniqname = strdup("AAAAtestuser@testdomain.org");
   25.53 -    srandom(time(NULL));
   25.54 -    for(int i=0; i < 4;i++)
   25.55 -        uniqname[i] += random() & 0xf;
   25.56 -    
   25.57 -    cout << uniqname << "\n";
   25.58 -    pEp_identity * recip1 = new_identity(uniqname, NULL, NULL, "Test User");
   25.59 -
   25.60 -    status = generate_keypair(session, recip1);
   25.61 -    
   25.62 -    cout << "Generated fingerprint ";
   25.63 -    cout << recip1->fpr << "\n";
   25.64 -
   25.65 -    fprs[0] = strdup(recip1->fpr);
   25.66 -    
   25.67 -    cout << endl << "*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*" << endl;
   25.68 -    cout << "Trust and revoke single key, ensure trust changes, then generate new key and ensure rating is correct." << endl;
   25.69 -    cout << "*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*" << endl << endl;
   25.70 -    
   25.71 -    cout << endl << "---------------------------------------------------------" << endl;
   25.72 -    cout << "1a. Encrypt message for trusted partner." << endl;
   25.73 -    cout << "---------------------------------------------------------" << endl << endl;
   25.74 -
   25.75 -    cout << "Trusting personal key for " << uniqname << endl;
   25.76 -    recip1->me = false;
   25.77 -    // Trust it
   25.78 -    status = update_identity(session, recip1);
   25.79 -    status = trust_personal_key(session, recip1);
   25.80 -    status = update_identity(session, recip1);
   25.81 -    
   25.82 -    // TODO: Check trust?
   25.83 -    cout << "Done! Trusted personal key with fpr " << recip1->fpr << " for " << uniqname << endl;
   25.84 -
   25.85 -    const char* r1_userid = (recip1->user_id ? strdup(recip1->user_id) : NULL);
   25.86 -
   25.87 -    
   25.88 -    // encrypt something to the key
   25.89 -    cout << "Creating message…\n";
   25.90 -    identity_list* to_list = new_identity_list(identity_dup(recip1)); // to bob
   25.91 -    message* outgoing_msg = new_message(PEP_dir_outgoing);
   25.92 -    assert(outgoing_msg);
   25.93 -    outgoing_msg->from = identity_dup(me);
   25.94 -    outgoing_msg->to = to_list;
   25.95 -    outgoing_msg->shortmsg = strdup("Greetings, humans!");
   25.96 -    outgoing_msg->longmsg = strdup("This is a test of the emergency message system. This is only a test. BEEP.");
   25.97 -    outgoing_msg->attachments = new_bloblist(NULL, 0, "application/octet-stream", NULL);
   25.98 -    cout << "Message created.\n";
   25.99 -
  25.100 -    message* encrypted_outgoing_msg = NULL;
  25.101 -
  25.102 -    cout << "Encrypting message to " << uniqname << "…\n";    
  25.103 -    status = encrypt_message(session, outgoing_msg, NULL, &encrypted_outgoing_msg, PEP_enc_PGP_MIME, 0);
  25.104 -    cout << "Encrypted message with status " << tl_status_string(status) << endl;
  25.105 -    // check status
  25.106 -    assert(status == PEP_STATUS_OK);
  25.107 -    assert(encrypted_outgoing_msg);
  25.108 -
  25.109 -    cout << "Checking message recipient comm_type from message." << endl;
  25.110 -    // check comm_type
  25.111 -    cout << "comm_type: " << tl_ct_string(encrypted_outgoing_msg->to->ident->comm_type) << endl;
  25.112 -    assert(encrypted_outgoing_msg->to->ident->comm_type == PEP_ct_OpenPGP);
  25.113 -    
  25.114 -    status = get_trust(session, recip1);
  25.115 -    
  25.116 -    cout << "Recip's trust DB comm_type = " << hex << tl_ct_string(recip1->comm_type) << endl;
  25.117 -    assert(recip1->comm_type == PEP_ct_OpenPGP); // FIXME: PEP_ct_pEp???
  25.118 -
  25.119 -    // decrypt message
  25.120 -    free_message(outgoing_msg);
  25.121 -    outgoing_msg = NULL;
  25.122 -
  25.123 -    stringlist_t* keylist = nullptr;
  25.124 -    PEP_rating rating;
  25.125 -    PEP_decrypt_flags_t flags;
  25.126 -
  25.127 -    cout << endl << "---------------------------------------------------------" << endl;
  25.128 -    cout << "1b. Decrypt message that was encrypted for trusted partner." << endl;
  25.129 -    cout << "---------------------------------------------------------" << endl << endl;
  25.130 -
  25.131 -    flags = 0;
  25.132 -    cout << "Decrypting message." << endl;
  25.133 -    status = decrypt_message(session, encrypted_outgoing_msg, &outgoing_msg, &keylist, &rating, &flags);
  25.134 -    cout << "Decrypted message with status " << tl_status_string(status) << endl;
  25.135 -    assert(status == PEP_STATUS_OK);
  25.136 -    assert(rating == PEP_rating_trusted);
  25.137 -
  25.138 -    // check rating
  25.139 -    cout << "Rating of decrypted message to trusted recip: " << tl_rating_string(rating) << endl;
  25.140 -    assert(rating == PEP_rating_trusted); // FIXME: trusted and anonymised?
  25.141 -    
  25.142 -    // check comm_type
  25.143 -    status = get_trust(session, recip1);
  25.144 -
  25.145 -    cout << "Recip's trust DB comm_type = " << tl_ct_string(recip1->comm_type) << endl;
  25.146 -    assert(recip1->comm_type == PEP_ct_OpenPGP); // FIXME: PEP_ct_pEp???
  25.147 -
  25.148 -    cout << endl << "---------------------------------------------------------" << endl;
  25.149 -    cout << "2a. Revoke key for (currently) trusted partner." << endl;
  25.150 -    cout << "---------------------------------------------------------" << endl << endl;
  25.151 -    // externally revoke key
  25.152 -    // (note - as of 23.5.17, revoke_key() doesn't touch the trust db, just the keyring, so we can do this)
  25.153 -
  25.154 -    cout << "Revoking key." << endl;
  25.155 -    status = update_identity(session, recip1);    
  25.156 -    status = revoke_key(session, recip1->fpr, "encrypt_for_identity_test");
  25.157 -    cout << "Status of revocation call for " << recip1->fpr << " is "<< tl_status_string(status) << endl;
  25.158 -
  25.159 -    // free messages
  25.160 -    free_message(outgoing_msg);
  25.161 -    free_message(encrypted_outgoing_msg);
  25.162 -    outgoing_msg = NULL;
  25.163 -    encrypted_outgoing_msg = NULL;
  25.164 -    
  25.165 -    // encrypt something to the key
  25.166 -    cout << "creating message…\n";
  25.167 -    to_list = new_identity_list(identity_dup(recip1)); // to bob
  25.168 -    outgoing_msg = new_message(PEP_dir_outgoing);
  25.169 -    assert(outgoing_msg);
  25.170 -    outgoing_msg->from = identity_dup(me);
  25.171 -    outgoing_msg->to = to_list;
  25.172 -    outgoing_msg->shortmsg = strdup("Greetings, humans!");
  25.173 -    outgoing_msg->longmsg = strdup("This is a test of the emergency message system. This is only a test. BEEP.");
  25.174 -    outgoing_msg->attachments = new_bloblist(NULL, 0, "application/octet-stream", NULL);
  25.175 -    cout << "message created.\n";
  25.176 -
  25.177 -    encrypted_outgoing_msg = NULL;
  25.178 -    message* decrypted_msg = NULL;
  25.179 -
  25.180 -    cout << endl << "---------------------------------------------------------" << endl;
  25.181 -    cout << "2b. Encrypt message for recip whose key has been externally revoked in the keyring, not the app." << endl;
  25.182 -    cout << "---------------------------------------------------------" << endl << endl;
  25.183 -
  25.184 -
  25.185 -    status = encrypt_message(session, outgoing_msg, NULL, &encrypted_outgoing_msg, PEP_enc_PGP_MIME, 0);
  25.186 -    cout << "Encryption returns with status " << tl_status_string(status) << endl;
  25.187 -    assert (status == PEP_UNENCRYPTED);
  25.188 -    assert (encrypted_outgoing_msg == NULL);
  25.189 -    status = update_identity(session, recip1);
  25.190 -    assert(recip1->comm_type = PEP_ct_key_not_found);
  25.191 -
  25.192 -    cout << endl << "---------------------------------------------------------" << endl;
  25.193 -    cout << "2c. Check trust of recip, whose only key has been revoked, once an encryption attempt has been made." << endl;
  25.194 -    cout << "---------------------------------------------------------" << endl << endl;
  25.195 -
  25.196 -    assert(recip1->fpr == NULL);
  25.197 -    recip1->fpr = fprs[0];
  25.198 -    status = get_trust(session, recip1);
  25.199 -    recip1->fpr = NULL;
  25.200 -
  25.201 -    cout << "Recip's trust DB comm_type = " << hex << tl_ct_string(recip1->comm_type) << endl;
  25.202 -    assert(recip1->comm_type == PEP_ct_unknown || recip1->comm_type == PEP_ct_key_revoked);
  25.203 -
  25.204 -    free_message(decrypted_msg);
  25.205 -    free_message(outgoing_msg);
  25.206 -    outgoing_msg = NULL;
  25.207 -    decrypted_msg = NULL;
  25.208 -
  25.209 -    cout << endl << "---------------------------------------------------------" << endl;
  25.210 -    cout << "3a. Generate new key, but don't explicitly trust it." << endl;
  25.211 -    cout << "---------------------------------------------------------" << endl << endl;
  25.212 -
  25.213 -    // now: generate new key
  25.214 -    free(recip1->fpr);
  25.215 -    recip1->fpr = NULL;
  25.216 -    status = generate_keypair(session, recip1);
  25.217 -    
  25.218 -    cout << "Generated fingerprint \n";
  25.219 -    cout << recip1->fpr << "\n";
  25.220 -    fprs[1] = strdup(recip1->fpr);
  25.221 -
  25.222 -    // try again
  25.223 -    cout << endl << "---------------------------------------------------------" << endl;
  25.224 -    cout << "3b. Try to send something to the email address of our revoked friend, make sure a new key is used to encrypt." << endl;
  25.225 -    cout << "---------------------------------------------------------" << endl << endl;
  25.226 -    
  25.227 -    // encrypt something to the key
  25.228 -    cout << "Creating message…\n";
  25.229 -    
  25.230 -    // cout << "First, update identity though!\n";
  25.231 -    // status = update_identity(session, recip1);
  25.232 -    to_list = new_identity_list(identity_dup(recip1)); // to bob
  25.233 -    outgoing_msg = new_message(PEP_dir_outgoing);
  25.234 -    assert(outgoing_msg);
  25.235 -    outgoing_msg->from = identity_dup(me);
  25.236 -    outgoing_msg->to = to_list;
  25.237 -    outgoing_msg->shortmsg = strdup("Greetings, humans!");
  25.238 -    outgoing_msg->longmsg = strdup("This is a test of the emergency message system. This is only a test. BEEP.");
  25.239 -    outgoing_msg->attachments = new_bloblist(NULL, 0, "application/octet-stream", NULL);
  25.240 -    cout << "Message created.\n";
  25.241 -
  25.242 -    status = encrypt_message(session, outgoing_msg, NULL, &encrypted_outgoing_msg, PEP_enc_PGP_MIME, 0);
  25.243 -    PEP_comm_type ct = (encrypted_outgoing_msg ? encrypted_outgoing_msg->to->ident->comm_type : outgoing_msg->to->ident->comm_type);
  25.244 -    
  25.245 -
  25.246 -    // CHECK STATUS???
  25.247 -    cout << "Encryption returns with status " << tl_status_string(status) << endl;
  25.248 -
  25.249 -    // check comm_type
  25.250 -    cout << "comm_type: " << tl_ct_string(ct) << endl;
  25.251 -    assert(ct == PEP_ct_OpenPGP_unconfirmed);
  25.252 -    
  25.253 -    status = get_trust(session, recip1);
  25.254 -
  25.255 -    cout << "Recip's trust DB comm_type (should be unknown, as we're using a keyring-only key, not in DB) = " << hex << tl_ct_string(recip1->comm_type) << endl;
  25.256 -    assert(recip1->comm_type != PEP_ct_OpenPGP_unconfirmed);
  25.257 -
  25.258 -    // decrypt message
  25.259 -//    free_message(outgoing_msg);
  25.260 -//    outgoing_msg = NULL;
  25.261 -
  25.262 -    cout << endl << "---------------------------------------------------------" << endl;
  25.263 -    cout << "3c. Decrypt... that... message!" << endl;
  25.264 -    cout << "---------------------------------------------------------" << endl << endl;
  25.265 -
  25.266 -
  25.267 -    flags = 0;
  25.268 -    status = decrypt_message(session, encrypted_outgoing_msg, &decrypted_msg, &keylist, &rating, &flags);
  25.269 -    cout << "Decryption returns with status " << tl_status_string(status) << endl;
  25.270 -    assert(status == PEP_STATUS_OK);
  25.271 -    assert(decrypted_msg);
  25.272 -    
  25.273 -    // check rating
  25.274 -    cout << "Rating of decrypted message to trusted recip: " << tl_rating_string(rating) << endl;
  25.275 -    assert(rating == PEP_rating_reliable);
  25.276 -
  25.277 -    status = update_identity(session, decrypted_msg->to->ident);
  25.278 -    ct = (decrypted_msg ? decrypted_msg->to->ident->comm_type : outgoing_msg->to->ident->comm_type);
  25.279 -
  25.280 -    cout << "comm_type: " << tl_ct_string(ct) << endl;
  25.281 -    assert(ct == PEP_ct_OpenPGP_unconfirmed);
  25.282 -    
  25.283 -    status = get_trust(session, recip1);
  25.284 -    
  25.285 -    cout << "Recip's trust DB comm_type (should be unknown - there's nothing in the DB) = " << hex << tl_ct_string(recip1->comm_type) << endl;
  25.286 -    assert(recip1->comm_type == PEP_ct_unknown);
  25.287 -
  25.288 -    free_message(encrypted_outgoing_msg);
  25.289 -    free_message(decrypted_msg);
  25.290 -    free_message(outgoing_msg);
  25.291 -    outgoing_msg = NULL;
  25.292 -    decrypted_msg = NULL;
  25.293 -    encrypted_outgoing_msg = NULL;
  25.294 -
  25.295 -    free_identity(me);
  25.296 -    free_identity(recip1);
  25.297 -    free(uniqname);
  25.298 -    
  25.299 -    delete_keypair(session, fprs[0]);    
  25.300 -    delete_keypair(session, fprs[1]);
  25.301 -    
  25.302 -    free(fprs[0]);
  25.303 -    free(fprs[1]);
  25.304 -    
  25.305 -#else
  25.306 -    cout << "Sorry, test is not defined for NETPGP at this time." << endl;
  25.307 -    
  25.308 -#endif
  25.309 -    
  25.310 -    release(session);
  25.311 -
  25.312 -    return 0;
  25.313 -}
    26.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    26.2 +++ b/test/gensuitemaker.py	Fri May 11 08:58:04 2018 +0200
    26.3 @@ -0,0 +1,97 @@
    26.4 +# This file is under GNU General Public License 3.0
    26.5 +# see LICENSE.txt
    26.6 +
    26.7 +from os import listdir, getcwd
    26.8 +from os.path import isfile, join
    26.9 +from re import sub
   26.10 +import datetime
   26.11 +
   26.12 +srcpath = join(getcwd(), "src/engine_tests")
   26.13 +
   26.14 +ls = listdir(srcpath)
   26.15 +
   26.16 +suites = []
   26.17 +
   26.18 +indent = "    "
   26.19 +
   26.20 +for f in ls:
   26.21 +    if isfile(join(srcpath, f)):
   26.22 +        if (f.endswith(".cc")):
   26.23 +            suite = sub('\.cc$', '', f)
   26.24 +            suites.append(suite)
   26.25 +
   26.26 +license = (''
   26.27 +'// This file is under GNU General Public License 3.0\n'
   26.28 +'// see LICENSE.txt\n\n')
   26.29 +
   26.30 +
   26.31 +header = license + "//\n// src/SuiteMaker.cc generated by gensuitemaker.py - changes may be overwritten. You've been warned!\n//\n\n"
   26.32 +
   26.33 +header += (''
   26.34 +'#include <cpptest.h>\n'
   26.35 +'#include <cpptest-suite.h>\n'
   26.36 +'#include <memory>\n'
   26.37 +'#include <vector>\n'
   26.38 +'#include "SuiteMaker.h"\n')
   26.39 +
   26.40 +suiteincludes = ""
   26.41 +
   26.42 +for s in suites:
   26.43 +    suiteincludes += '#include "' + s + '.h"\n'
   26.44 +
   26.45 +output = header + "\n// Begin where we generate stuff\n" + suiteincludes + "\n"
   26.46 +
   26.47 +output += ("\n"
   26.48 +"const char* SuiteMaker::all_suites[] = {\n")
   26.49 +
   26.50 +first = True
   26.51 +
   26.52 +for s in suites:
   26.53 +    output += indent + '"' + s + '",\n'
   26.54 +
   26.55 +output += "};\n\n"
   26.56 +
   26.57 +output += (
   26.58 +'// This file is generated, so magic constants are ok.\n'
   26.59 +'int SuiteMaker::num_suites = ')
   26.60 +
   26.61 +output += str(len(suites)) + ";\n\n"
   26.62 +    
   26.63 +output += "void SuiteMaker::suitemaker_build(const char* test_class_name, const char* test_home, Test::Suite** test_suite) {\n"
   26.64 +
   26.65 +first = True
   26.66 +
   26.67 +for s in suites:
   26.68 +    output += indent
   26.69 +    
   26.70 +    if not first:
   26.71 +        output += "else "
   26.72 +    else:
   26.73 +        first = False
   26.74 +    
   26.75 +    output += ('if (strcmp(test_class_name, "' + s + '") == 0)\n' + 
   26.76 +               indent + indent + '*test_suite = new ' + s + '(test_class_name, test_home);\n')
   26.77 +        
   26.78 +output += "}\n\n"
   26.79 +
   26.80 +output += (
   26.81 +'void SuiteMaker::suitemaker_buildlist(const char** test_class_names, int num_to_run, const char* test_home, std::vector<Test::Suite*>& test_suites) {\n'
   26.82 +'    for (int i = 0; i < num_to_run; i++) {\n'
   26.83 +'        Test::Suite* suite = NULL;\n'
   26.84 +'        SuiteMaker::suitemaker_build(test_class_names[i], test_home, &suite);\n'
   26.85 +'        if (!suite)\n'
   26.86 +'            throw std::runtime_error("Could not create a test suite instance."); // FIXME, better error, cleanup, obviously\n'
   26.87 +'        test_suites.push_back(suite);\n'
   26.88 +'    }\n'    
   26.89 +'}'
   26.90 +'\n'
   26.91 +'void SuiteMaker::suitemaker_buildall(const char* test_home, std::vector<Test::Suite*>& test_suites) {\n'
   26.92 +'    SuiteMaker::suitemaker_buildlist(SuiteMaker::all_suites, SuiteMaker::num_suites, test_home, test_suites);\n'
   26.93 +'}\n\n')
   26.94 +
   26.95 +suitemaker = open("src/SuiteMaker.cc", 'w') 
   26.96 +suitemaker.write(output)
   26.97 +suitemaker.close()
   26.98 +
   26.99 +generated_at = ("src/SuiteMaker.cc" + " generated at " + datetime.datetime.now().strftime('%c'))
  26.100 +print(generated_at)
    27.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    27.2 +++ b/test/gentestshell.py	Fri May 11 08:58:04 2018 +0200
    27.3 @@ -0,0 +1,119 @@
    27.4 +import argparse
    27.5 +import os
    27.6 +import subprocess
    27.7 +import re
    27.8 +
    27.9 +def decamel(name):
   27.10 +    retval = re.sub('([A-Z])', r'_\1', name).lower()
   27.11 +    return re.sub('^_', r'', retval) 
   27.12 +
   27.13 +parser = argparse.ArgumentParser()
   27.14 +parser.add_argument("suite_name", help="(convention is <NameInUpperCamelCase>, e.g. StringpairList - suite created will then be StringpairListTests)")
   27.15 +parser.add_argument("--clobber", "-c", help="Overwrite extant files (must be explicitly indicated)", action='store_true')
   27.16 +
   27.17 +gengroup = parser.add_mutually_exclusive_group()
   27.18 +gengroup.add_argument("--no_src", help="Generate header only, no source", action='store_true')
   27.19 +gengroup.add_argument("--no_hdr", help="Generate source only, no header", action='store_true')
   27.20 +
   27.21 +typegroup = parser.add_mutually_exclusive_group()
   27.22 +typegroup.add_argument("--test", "-t", help="Just generate a generic test suite (no engine initialisation or db/gpg setup/teardown - default)", action='store_true')
   27.23 +typegroup.add_argument("--indiv", "-i", help="Generate a test suite with engine initialisation/release and gpg/db teardown between each test function", action='store_true')
   27.24 +typegroup.add_argument("--session", "-s", help="Generate a test suite with engine initialisation/release and gpg/db teardown only at the beginning and end of the test suite", action='store_true')
   27.25 +
   27.26 +args = parser.parse_args()
   27.27 +
   27.28 +suitename = args.suite_name
   27.29 +test_suite = suitename + "Tests"
   27.30 +
   27.31 +superclass = "EngineTestSuite"
   27.32 +
   27.33 +if args.indiv: 
   27.34 +    superclass = "EngineTestIndividualSuite"
   27.35 +elif args.session:
   27.36 +    superclass = "EngineTestSessionSuite"
   27.37 +
   27.38 +print("\nCreating " + test_suite + " as an " + superclass + "\n")
   27.39 +
   27.40 +uncamel = decamel(suitename)
   27.41 +print(uncamel)
   27.42 +
   27.43 +
   27.44 +nspace = "using namespace std;\n\n"
   27.45 +
   27.46 +license = ("// This file is under GNU General Public License 3.0\n"
   27.47 +           "// see LICENSE.txt\n\n")
   27.48 +
   27.49 +default_single_testname = "check_" + re.sub('_tests$', r'', uncamel) 
   27.50 +
   27.51 +if not args.no_hdr:
   27.52 +    
   27.53 +    header_def = uncamel.upper() + "_H"
   27.54 +
   27.55 +    deftxt = "#ifndef " + header_def + "\n#define " + header_def + "\n\n"
   27.56 +
   27.57 +    header_inc = ("#include <string>\n" 
   27.58 +                  "#include \"" + superclass + ".h\"\n\n")
   27.59 +
   27.60 +    header = license + deftxt + header_inc + nspace
   27.61 +
   27.62 +
   27.63 +    classdef = "class " + test_suite + " : public " + superclass + " {\n" + \
   27.64 +               "    public:\n" + \
   27.65 +               "        " + test_suite + "(string test_suite, string test_home_dir);\n" + \
   27.66 +               "    private:\n" \
   27.67 +               "        void " + default_single_testname + "();\n" + \
   27.68 +               "};\n" 
   27.69 +
   27.70 +    header_file = header + classdef + "\n#endif\n"
   27.71 +
   27.72 +    #print(header_file)
   27.73 +
   27.74 +    do_write = True
   27.75 +    hfile_name = test_suite + ".h"
   27.76 +    hfile_path = os.path.join(os.path.join(os.getcwd(), "include"), hfile_name)
   27.77 +
   27.78 +    if not args.clobber:
   27.79 +        if (os.path.isfile(hfile_path)):
   27.80 +            print(hfile_path + " exists. Not writing header file. Use --clobber to overwrite.")
   27.81 +            do_write = False
   27.82 +
   27.83 +    if do_write:
   27.84 +        header_out = open(hfile_path, 'w')
   27.85 +        header_out.write(header_file)
   27.86 +        header_out.close()
   27.87 +
   27.88 +if not args.no_src:
   27.89 +    src_inc = ('#include <stdlib.h>\n'
   27.90 +               '#include <string>\n\n'
   27.91 +               '#include "pEpEngine.h"\n\n'
   27.92 +               '#include "' + superclass +'.h"\n'
   27.93 +               '#include "' + test_suite + '.h"\n\n')
   27.94 +
   27.95 +    test_suite_prefix = test_suite + "::"
   27.96 +    fname = test_suite_prefix + default_single_testname
   27.97 +
   27.98 +    constructor = test_suite_prefix + test_suite + "(string suitename, string test_home_dir) :\n" + \
   27.99 +                  "    " + superclass + "::" + superclass + "(suitename, test_home_dir) {\n" + \
  27.100 +                  "    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string(\"" + fname + "\"),\n" + \
  27.101 +                  "                                                                      static_cast<Func>(&" + fname + ")));\n" + \
  27.102 +                  "}\n\n"
  27.103 +                  
  27.104 +    def_funct = "void " + test_suite_prefix + default_single_testname + "() {\n" + \
  27.105 +                "    TEST_ASSERT(true);\n" + \
  27.106 +                "}\n\n"
  27.107 +
  27.108 +    src_file = license + src_inc + nspace + constructor + def_funct
  27.109 +
  27.110 +    do_write = True
  27.111 +    sfile_name = test_suite + ".cc"
  27.112 +    sfile_path = os.path.join(os.path.join(os.getcwd(), "src/engine_tests"), sfile_name)
  27.113 +
  27.114 +    if not args.clobber:
  27.115 +        if (os.path.isfile(sfile_path)):
  27.116 +            print(sfile_path + " exists. Not writing source file. Use --clobber to overwrite.")
  27.117 +            do_write = False
  27.118 +
  27.119 +    if do_write:
  27.120 +        src_out = open(sfile_path, 'w')
  27.121 +        src_out.write(src_file)
  27.122 +        src_out.close()
    28.1 --- a/test/i18n_test.cc	Wed May 09 09:51:05 2018 +0200
    28.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    28.3 @@ -1,48 +0,0 @@
    28.4 -// This file is under GNU General Public License 3.0
    28.5 -// see LICENSE.txt
    28.6 -
    28.7 -#include <iostream>
    28.8 -#include <string>
    28.9 -#include <assert.h>
   28.10 -#include "pEpEngine.h"
   28.11 -
   28.12 -using namespace std;
   28.13 -
   28.14 -int main() {
   28.15 -    cout << "\n*** i18n_test ***\n\n";
   28.16 -
   28.17 -    PEP_SESSION session;
   28.18 -    
   28.19 -    cout << "calling init()\n";
   28.20 -    PEP_STATUS status1 = init(&session);   
   28.21 -    assert(status1 == PEP_STATUS_OK);
   28.22 -    assert(session);
   28.23 -    cout << "init() completed.\n";
   28.24 -
   28.25 -    // i18n test code
   28.26 -
   28.27 -    char *languages;
   28.28 -    PEP_STATUS status2 = get_languagelist(session, &languages);
   28.29 -    assert(status2 == PEP_STATUS_OK);
   28.30 -    assert(languages);
   28.31 -
   28.32 -    cout << languages;
   28.33 -    pEp_free(languages);
   28.34 -
   28.35 -    char *phrase;
   28.36 -    PEP_STATUS status3 = get_phrase(session, "de", 1000, &phrase);
   28.37 -    assert(status3 == PEP_STATUS_OK);
   28.38 -    assert(phrase);
   28.39 -
   28.40 -    cout << "\nGerman: " << phrase << "\n";
   28.41 -    pEp_free(phrase);
   28.42 -
   28.43 -    status3 = get_phrase(session, "zz", 1000, &phrase);
   28.44 -    assert(status3 == PEP_PHRASE_NOT_FOUND);
   28.45 -    assert(phrase == NULL);
   28.46 -
   28.47 -    cout << "calling release()\n";
   28.48 -    release(session);
   28.49 -    return 0;
   28.50 -}
   28.51 -
    29.1 --- a/test/identity_list_test.cc	Wed May 09 09:51:05 2018 +0200
    29.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    29.3 @@ -1,174 +0,0 @@
    29.4 -// This file is under GNU General Public License 3.0
    29.5 -// see LICENSE.txt
    29.6 -
    29.7 -#include <stdlib.h>
    29.8 -#include <string.h>
    29.9 -#include "platform.h"
   29.10 -#include <iostream>
   29.11 -#include <fstream>
   29.12 -#include <assert.h>
   29.13 -
   29.14 -#include "identity_list.h"
   29.15 -
   29.16 -using namespace std;
   29.17 -
   29.18 -/*
   29.19 - *     char *address;              // C string with address UTF-8 encoded
   29.20 -    char *fpr;                  // C string with fingerprint UTF-8 encoded
   29.21 -    char *user_id;              // C string with user ID UTF-8 encoded
   29.22 -    char *username;             // C string with user name UTF-8 encoded
   29.23 -    PEP_comm_type comm_type;    // type of communication with this ID
   29.24 -    char lang[3];               // language of conversation
   29.25 -                                // ISO 639-1 ALPHA-2, last byte is 0
   29.26 --    bool me;                    // if this is the local user herself/himself
   29.27 -    */
   29.28 -
   29.29 -int test_identity_equals(pEp_identity* val1, pEp_identity* val2) {
   29.30 -    assert(val1);
   29.31 -    assert(val2);
   29.32 -    assert(val1->address);
   29.33 -    assert(val2->address);
   29.34 -    assert(val1->fpr);
   29.35 -    assert(val2->fpr);
   29.36 -    assert(val1->username);
   29.37 -    assert(val2->username);
   29.38 -    return((strcmp(val1->address, val2->address) == 0) && (strcmp(val1->fpr, val2->fpr) == 0)
   29.39 -        && (strcmp(val1->username, val2->username) == 0) && (val1->comm_type == val2->comm_type)
   29.40 -        && (val1->lang[0] == val2->lang[0]) && (val1->lang[1] == val2->lang[1])
   29.41 -        && (val1->lang[2] == val2->lang[2]) && (val1->me == val2->me));
   29.42 -}
   29.43 -
   29.44 -int main() {
   29.45 -    cout << "\n*** data structures: identity_list_test ***\n\n";
   29.46 -
   29.47 -    pEp_identity* id1 = new_identity(
   29.48 -        "leon.schumacher@digitalekho.com",
   29.49 -        "8BD08954C74D830EEFFB5DEB2682A17F7C87F73D",
   29.50 -        "23",
   29.51 -        "Leon Schumacher"
   29.52 -    );
   29.53 -    id1->comm_type = PEP_ct_pEp;
   29.54 -    
   29.55 -    pEp_identity* id2 = new_identity(
   29.56 -        "krista@kgrothoff.org",
   29.57 -        "62D4932086185C15917B72D30571AFBCA5493553",
   29.58 -        "42",
   29.59 -        "Krista Bennett Grothoff"
   29.60 -    );
   29.61 -    
   29.62 -    id2->comm_type = PEP_ct_OpenPGP;
   29.63 -
   29.64 -    pEp_identity* id3 = new_identity(
   29.65 -        "krista@pep-project.org",
   29.66 -        "51BF42D25BB5B154D71BF6CD3CF25B776D149247",
   29.67 -        "10",
   29.68 -        "Krista Grothoff"
   29.69 -    );
   29.70 -    
   29.71 -    id3->comm_type = PEP_ct_OTR;
   29.72 -
   29.73 -    pEp_identity* id4 = new_identity(
   29.74 -        "papa@smurf.lu",
   29.75 -        "00001111222233334444555566667777DEADBEEF",
   29.76 -        "667",
   29.77 -        "Papa Smurf"
   29.78 -    );
   29.79 -    
   29.80 -    id4->comm_type = PEP_ct_key_b0rken;
   29.81 -    
   29.82 -    pEp_identity* id_arr[4] = {id1, id2, id3, id4};
   29.83 -        
   29.84 -    int i;
   29.85 -        
   29.86 -    cout << "creating one-element identity_list...\n";
   29.87 -    
   29.88 -    pEp_identity* new_id = identity_dup(id1);
   29.89 -    assert(new_id);
   29.90 -    identity_list* idlist = new_identity_list(new_id);
   29.91 -    assert(idlist->ident);
   29.92 -    assert(test_identity_equals(id1, idlist->ident));
   29.93 -    assert(idlist->next == NULL);
   29.94 -    cout << "one-element identity_list created, next element is NULL\n\n";
   29.95 -    
   29.96 -    cout << "duplicating one-element list...\n";
   29.97 -    identity_list* duplist = identity_list_dup(idlist);
   29.98 -    pEp_identity* srcid = idlist->ident;
   29.99 -    pEp_identity* dstid = duplist->ident;
  29.100 -    assert(dstid);
  29.101 -    assert(test_identity_equals(srcid, dstid));
  29.102 -    assert(srcid->address != dstid->address);   // test deep copies 
  29.103 -    assert(srcid->fpr != dstid->fpr);
  29.104 -    assert(srcid->username != dstid->username);
  29.105 -    assert(duplist->next == NULL);
  29.106 -    cout << "one-element identity_list duplicated.\n\n";
  29.107 -    
  29.108 -    cout << "freeing identity_lists...\n";
  29.109 -    free_identity_list(idlist); // will free srcid
  29.110 -    free_identity_list(duplist);
  29.111 -    idlist = NULL;
  29.112 -    duplist = NULL;
  29.113 -    srcid = NULL;
  29.114 -    
  29.115 -    identity_list* p;
  29.116 -    cout << "\ncreating four-element list...\n";
  29.117 -    idlist = identity_list_add(idlist, identity_dup(id_arr[0]));
  29.118 -    for (i = 1; i < 4; i++) {
  29.119 -        p = identity_list_add(idlist, identity_dup(id_arr[i]));
  29.120 -        assert(p);
  29.121 -    }
  29.122 -    
  29.123 -    p = idlist;
  29.124 -    
  29.125 -    for (i = 0; i < 4; i++) {
  29.126 -        assert(p);
  29.127 -        
  29.128 -        srcid = p->ident;
  29.129 -        assert(srcid);
  29.130 -        
  29.131 -        assert(test_identity_equals(srcid, id_arr[i]));
  29.132 -        assert(srcid->address != id_arr[i]->address);   // test deep copies
  29.133 -        assert(srcid->fpr != id_arr[i]->fpr);
  29.134 -        assert(srcid->username != id_arr[i]->username);
  29.135 -
  29.136 -        p = p->next;
  29.137 -    }
  29.138 -    assert(p == NULL);
  29.139 -    
  29.140 -    cout << "\nduplicating four-element list...\n\n";
  29.141 -    duplist = identity_list_dup(idlist);
  29.142 -    
  29.143 -    p = idlist;
  29.144 -    identity_list* dup_p = duplist;
  29.145 -    
  29.146 -    while (dup_p) {
  29.147 -        srcid = p->ident;
  29.148 -        dstid = dup_p->ident;
  29.149 -
  29.150 -        assert(dstid);
  29.151 -        
  29.152 -        assert(test_identity_equals(srcid, dstid));
  29.153 -
  29.154 -        assert(srcid != dstid);   // test deep copies
  29.155 -        assert(srcid->address != dstid->address);   // test deep copies
  29.156 -        assert(srcid->fpr != dstid->fpr);
  29.157 -        assert(srcid->username != dstid->username);
  29.158 -        
  29.159 -        i++;
  29.160 -        p = p->next;
  29.161 -
  29.162 -        dup_p = dup_p->next;
  29.163 -        assert((p == NULL) == (dup_p == NULL));
  29.164 -    }
  29.165 -    cout << "\nfour-element identity_list successfully duplicated.\n\n";
  29.166 -
  29.167 -    cout << "freeing identity_lists...\n";
  29.168 -    free_identity_list(idlist); // will free srcid
  29.169 -    free_identity_list(duplist);
  29.170 -    idlist = NULL;
  29.171 -    duplist = NULL;
  29.172 -    
  29.173 -    cout << "done.\n";
  29.174 -        
  29.175 -    
  29.176 -    return 0;
  29.177 -}
    30.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    30.2 +++ b/test/include/AppleMailTests.h	Fri May 11 08:58:04 2018 +0200
    30.3 @@ -0,0 +1,19 @@
    30.4 +// This file is under GNU General Public License 3.0
    30.5 +// see LICENSE.txt
    30.6 +
    30.7 +#ifndef APPLE_MAIL_TESTS_H
    30.8 +#define APPLE_MAIL_TESTS_H
    30.9 +
   30.10 +#include <string.h>
   30.11 +#include "EngineTestSessionSuite.h"
   30.12 +
   30.13 +using namespace std;
   30.14 +
   30.15 +class AppleMailTests : public EngineTestSessionSuite {
   30.16 +    public:
   30.17 +        AppleMailTests(string suitename, string test_home_dir);
   30.18 +    private:
   30.19 +        void check_apple_mail();
   30.20 +};
   30.21 +
   30.22 +#endif
    31.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    31.2 +++ b/test/include/BlacklistAcceptNewKeyTests.h	Fri May 11 08:58:04 2018 +0200
    31.3 @@ -0,0 +1,19 @@
    31.4 +// This file is under GNU General Public License 3.0
    31.5 +// see LICENSE.txt
    31.6 +
    31.7 +#ifndef BLACKLIST_ACCEPT_NEW_KEY_H
    31.8 +#define BLACKLIST_ACCEPT_NEW_KEY_H
    31.9 +
   31.10 +#include <string>
   31.11 +#include "EngineTestSessionSuite.h"
   31.12 +
   31.13 +using namespace std;
   31.14 +
   31.15 +class BlacklistAcceptNewKeyTests : public EngineTestSessionSuite {
   31.16 +    public:
   31.17 +        BlacklistAcceptNewKeyTests(string test_suite, string test_home_dir);
   31.18 +    private:
   31.19 +        void check_blacklist_accept_new_key();
   31.20 +};
   31.21 +
   31.22 +#endif
    32.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    32.2 +++ b/test/include/BlacklistTests.h	Fri May 11 08:58:04 2018 +0200
    32.3 @@ -0,0 +1,19 @@
    32.4 +// This file is under GNU General Public License 3.0
    32.5 +// see LICENSE.txt
    32.6 +
    32.7 +#ifndef BLACKLIST_H
    32.8 +#define BLACKLIST_H
    32.9 +
   32.10 +#include <string>
   32.11 +#include "EngineTestSessionSuite.h"
   32.12 +
   32.13 +using namespace std;
   32.14 +
   32.15 +class BlacklistTests : public EngineTestSessionSuite {
   32.16 +    public:
   32.17 +        BlacklistTests(string test_suite, string test_home_dir);
   32.18 +    private:
   32.19 +        void check_blacklist();
   32.20 +};
   32.21 +
   32.22 +#endif
    33.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    33.2 +++ b/test/include/BloblistTests.h	Fri May 11 08:58:04 2018 +0200
    33.3 @@ -0,0 +1,22 @@
    33.4 +// This file is under GNU General Public License 3.0
    33.5 +// see LICENSE.txt
    33.6 +
    33.7 +#ifndef BLOBLIST_TESTS_H
    33.8 +#define BLOBLIST_TESTS_H
    33.9 +
   33.10 +#include <string>
   33.11 +#include "bloblist.h"
   33.12 +#include "EngineTestSuite.h"
   33.13 +
   33.14 +using namespace std;
   33.15 +
   33.16 +class BloblistTests : public EngineTestSuite {
   33.17 +    public:
   33.18 +        BloblistTests(string suitename, string test_home_dir);
   33.19 +    private:
   33.20 +        void check_bloblists();
   33.21 +        bool test_blob_equals(size_t size1, char* blob1, size_t size2, char* blob2);
   33.22 +        bool test_bloblist_node_equals(bloblist_t* val1, bloblist_t* val2);
   33.23 +};
   33.24 +
   33.25 +#endif
    34.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    34.2 +++ b/test/include/CaseAndDotAddressTests.h	Fri May 11 08:58:04 2018 +0200
    34.3 @@ -0,0 +1,19 @@
    34.4 +// This file is under GNU General Public License 3.0
    34.5 +// see LICENSE.txt
    34.6 +
    34.7 +#ifndef CASE_AND_DOT_ADDRESS_TESTS_H
    34.8 +#define CASE_AND_DOT_ADDRESS_TESTS_H
    34.9 +
   34.10 +#include <string>
   34.11 +#include "EngineTestSessionSuite.h"
   34.12 +
   34.13 +using namespace std;
   34.14 +
   34.15 +class CaseAndDotAddressTests : public EngineTestSessionSuite {
   34.16 +    public:
   34.17 +        CaseAndDotAddressTests(string suitename, string test_home_dir);
   34.18 +    private:
   34.19 +        void check_case_and_dot_address();
   34.20 +};
   34.21 +
   34.22 +#endif
    35.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    35.2 +++ b/test/include/CrashdumpTests.h	Fri May 11 08:58:04 2018 +0200
    35.3 @@ -0,0 +1,19 @@
    35.4 +// This file is under GNU General Public License 3.0
    35.5 +// see LICENSE.txt
    35.6 +
    35.7 +#ifndef CRASHDUMP_H
    35.8 +#define CRASHDUMP_H
    35.9 +
   35.10 +#include <string>
   35.11 +#include "EngineTestSessionSuite.h"
   35.12 +
   35.13 +using namespace std;
   35.14 +
   35.15 +class CrashdumpTests : public EngineTestSessionSuite {
   35.16 +    public:
   35.17 +        CrashdumpTests(string test_suite, string test_home_dir);
   35.18 +    private:
   35.19 +        void check_crashdump();
   35.20 +};
   35.21 +
   35.22 +#endif
    36.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    36.2 +++ b/test/include/DecorateTests.h	Fri May 11 08:58:04 2018 +0200
    36.3 @@ -0,0 +1,19 @@
    36.4 +// This file is under GNU General Public License 3.0
    36.5 +// see LICENSE.txt
    36.6 +
    36.7 +#ifndef DECORATE_TESTS_H
    36.8 +#define DECORATE_TESTS_H
    36.9 +
   36.10 +#include <string>
   36.11 +#include "EngineTestSessionSuite.h"
   36.12 +
   36.13 +using namespace std;
   36.14 +
   36.15 +class DecorateTests : public EngineTestSessionSuite {
   36.16 +    public:
   36.17 +        DecorateTests(string suitename, string test_home_dir);
   36.18 +    private:
   36.19 +        void check_decorate();
   36.20 +};
   36.21 +
   36.22 +#endif
    37.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    37.2 +++ b/test/include/DecryptAttachPrivateKeyTrustedTests.h	Fri May 11 08:58:04 2018 +0200
    37.3 @@ -0,0 +1,19 @@
    37.4 +// This file is under GNU General Public License 3.0
    37.5 +// see LICENSE.txt
    37.6 +
    37.7 +#ifndef DECRYPT_ATTACH_PRIVATE_KEY_TRUSTED_H
    37.8 +#define DECRYPT_ATTACH_PRIVATE_KEY_TRUSTED_H
    37.9 +
   37.10 +#include <string>
   37.11 +#include "EngineTestSessionSuite.h"
   37.12 +
   37.13 +using namespace std;
   37.14 +
   37.15 +class DecryptAttachPrivateKeyTrustedTests : public EngineTestSessionSuite {
   37.16 +    public:
   37.17 +        DecryptAttachPrivateKeyTrustedTests(string test_suite, string test_home_dir);
   37.18 +    private:
   37.19 +        void check_decrypt_attach_private_key_trusted();
   37.20 +};
   37.21 +
   37.22 +#endif
    38.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    38.2 +++ b/test/include/DecryptAttachPrivateKeyUntrustedTests.h	Fri May 11 08:58:04 2018 +0200
    38.3 @@ -0,0 +1,19 @@
    38.4 +// This file is under GNU General Public License 3.0
    38.5 +// see LICENSE.txt
    38.6 +
    38.7 +#ifndef DECRYPT_ATTACH_PRIVATE_KEY_UNTRUSTED_H
    38.8 +#define DECRYPT_ATTACH_PRIVATE_KEY_UNTRUSTED_H
    38.9 +
   38.10 +#include <string>
   38.11 +#include "EngineTestSessionSuite.h"
   38.12 +
   38.13 +using namespace std;
   38.14 +
   38.15 +class DecryptAttachPrivateKeyUntrustedTests : public EngineTestSessionSuite {
   38.16 +    public:
   38.17 +        DecryptAttachPrivateKeyUntrustedTests(string test_suite, string test_home_dir);
   38.18 +    private:
   38.19 +        void check_decrypt_attach_private_key_untrusted();
   38.20 +};
   38.21 +
   38.22 +#endif
    39.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    39.2 +++ b/test/include/EncryptAttachPrivateKeyTests.h	Fri May 11 08:58:04 2018 +0200
    39.3 @@ -0,0 +1,19 @@
    39.4 +// This file is under GNU General Public License 3.0
    39.5 +// see LICENSE.txt
    39.6 +
    39.7 +#ifndef ENCRYPT_ATTACH_PRIVATE_KEY_H
    39.8 +#define ENCRYPT_ATTACH_PRIVATE_KEY_H
    39.9 +
   39.10 +#include <string>
   39.11 +#include "EngineTestSessionSuite.h"
   39.12 +
   39.13 +using namespace std;
   39.14 +
   39.15 +class EncryptAttachPrivateKeyTests : public EngineTestSessionSuite {
   39.16 +    public:
   39.17 +        EncryptAttachPrivateKeyTests(string test_suite, string test_home_dir);
   39.18 +    private:
   39.19 +        void check_encrypt_attach_private_key();
   39.20 +};
   39.21 +
   39.22 +#endif
    40.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    40.2 +++ b/test/include/EncryptForIdentityTests.h	Fri May 11 08:58:04 2018 +0200
    40.3 @@ -0,0 +1,19 @@
    40.4 +// This file is under GNU General Public License 3.0
    40.5 +// see LICENSE.txt
    40.6 +
    40.7 +#ifndef ENCRYPT_FOR_IDENTITY_H
    40.8 +#define ENCRYPT_FOR_IDENTITY_H
    40.9 +
   40.10 +#include <string>
   40.11 +#include "EngineTestSessionSuite.h"
   40.12 +
   40.13 +using namespace std;
   40.14 +
   40.15 +class EncryptForIdentityTests : public EngineTestSessionSuite {
   40.16 +    public:
   40.17 +        EncryptForIdentityTests(string test_suite, string test_home_dir);
   40.18 +    private:
   40.19 +        void check_encrypt_for_identity();
   40.20 +};
   40.21 +
   40.22 +#endif
    41.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    41.2 +++ b/test/include/EncryptMissingPrivateKeyTests.h	Fri May 11 08:58:04 2018 +0200
    41.3 @@ -0,0 +1,19 @@
    41.4 +// This file is under GNU General Public License 3.0
    41.5 +// see LICENSE.txt
    41.6 +
    41.7 +#ifndef ENCRYPT_MISSING_PRIVATE_KEY_H
    41.8 +#define ENCRYPT_MISSING_PRIVATE_KEY_H
    41.9 +
   41.10 +#include <string>
   41.11 +#include "EngineTestSessionSuite.h"
   41.12 +
   41.13 +using namespace std;
   41.14 +
   41.15 +class EncryptMissingPrivateKeyTests : public EngineTestSessionSuite {
   41.16 +    public:
   41.17 +        EncryptMissingPrivateKeyTests(string test_suite, string test_home_dir);
   41.18 +    private:
   41.19 +        void check_encrypt_missing_private_key();
   41.20 +};
   41.21 +
   41.22 +#endif
    42.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    42.2 +++ b/test/include/EngineTestIndividualSuite.h	Fri May 11 08:58:04 2018 +0200
    42.3 @@ -0,0 +1,21 @@
    42.4 +#ifndef ENGINE_TEST_INDIVIDUAL_SUITE_H
    42.5 +#define ENGINE_TEST_INDIVIDUAL_SUITE_H
    42.6 +
    42.7 +#include <cpptest.h>
    42.8 +#include <cpptest-suite.h>
    42.9 +#include <cpptest-textoutput.h>
   42.10 +#include <string>
   42.11 +#include "pEpEngine.h"
   42.12 +#include "EngineTestSuite.h"
   42.13 +
   42.14 +using namespace std;
   42.15 +
   42.16 +class EngineTestIndividualSuite : public EngineTestSuite {
   42.17 +    public:
   42.18 +        EngineTestIndividualSuite(string suitename, string test_home_dir);
   42.19 +        virtual ~EngineTestIndividualSuite();
   42.20 +    protected:
   42.21 +        virtual void setup();
   42.22 +        virtual void tear_down();
   42.23 +};
   42.24 +#endif
    43.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    43.2 +++ b/test/include/EngineTestSessionSuite.h	Fri May 11 08:58:04 2018 +0200
    43.3 @@ -0,0 +1,22 @@
    43.4 +#ifndef ENGINE_TEST_SESSION_SUITE_H
    43.5 +#define ENGINE_TEST_SESSION_SUITE_H
    43.6 +
    43.7 +#include <cpptest.h>
    43.8 +#include <cpptest-suite.h>
    43.9 +#include <cpptest-textoutput.h>
   43.10 +#include <string>
   43.11 +#include "pEpEngine.h"
   43.12 +
   43.13 +#include "EngineTestSuite.h"
   43.14 +
   43.15 +using namespace std;
   43.16 +
   43.17 +class EngineTestSessionSuite : public EngineTestSuite {
   43.18 +    public:
   43.19 +        EngineTestSessionSuite(string suitename, string test_home_dir);
   43.20 +        virtual ~EngineTestSessionSuite();
   43.21 +        
   43.22 +        virtual void setup();
   43.23 +        virtual void tear_down();
   43.24 +};
   43.25 +#endif
    44.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    44.2 +++ b/test/include/EngineTestSuite.h	Fri May 11 08:58:04 2018 +0200
    44.3 @@ -0,0 +1,39 @@
    44.4 +#ifndef ENGINE_TEST_SUITE_H
    44.5 +#define ENGINE_TEST_SUITE_H
    44.6 +
    44.7 +#include <cpptest.h>
    44.8 +#include <string>
    44.9 +#include <map>
   44.10 +#include "pEpEngine.h"
   44.11 +
   44.12 +using namespace std;
   44.13 +
   44.14 +class EngineTestSuite : public Test::Suite {
   44.15 +    public:
   44.16 +        EngineTestSuite(string suitename, string test_home_dir);
   44.17 +        virtual ~EngineTestSuite();
   44.18 +        
   44.19 +        void add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()> test_func);
   44.20 +        
   44.21 +    protected:
   44.22 +        PEP_SESSION session;
   44.23 +        string test_home;
   44.24 +        string prev_gpg_home;
   44.25 +        string name;
   44.26 +        
   44.27 +        string current_test_name;
   44.28 +
   44.29 +        std::map<std::string, void (Test::Suite::*)()> test_map;                
   44.30 +        
   44.31 +        unsigned int number_of_tests;
   44.32 +        unsigned int on_test_number;
   44.33 +        
   44.34 +        virtual void setup();
   44.35 +        virtual void tear_down();
   44.36 +        
   44.37 +        void set_full_env();
   44.38 +        void restore_full_env();
   44.39 +        void initialise_test_home();
   44.40 +        
   44.41 +};
   44.42 +#endif
    45.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    45.2 +++ b/test/include/ExternalRevokeTests.h	Fri May 11 08:58:04 2018 +0200
    45.3 @@ -0,0 +1,19 @@
    45.4 +// This file is under GNU General Public License 3.0
    45.5 +// see LICENSE.txt
    45.6 +
    45.7 +#ifndef EXTERNAL_REVOKE_H
    45.8 +#define EXTERNAL_REVOKE_H
    45.9 +
   45.10 +#include <string>
   45.11 +#include "EngineTestSessionSuite.h"
   45.12 +
   45.13 +using namespace std;
   45.14 +
   45.15 +class ExternalRevokeTests : public EngineTestSessionSuite {
   45.16 +    public:
   45.17 +        ExternalRevokeTests(string test_suite, string test_home_dir);
   45.18 +    private:
   45.19 +        void check_external_revoke();
   45.20 +};
   45.21 +
   45.22 +#endif
    46.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    46.2 +++ b/test/include/I18nTests.h	Fri May 11 08:58:04 2018 +0200
    46.3 @@ -0,0 +1,19 @@
    46.4 +// This file is under GNU General Public License 3.0
    46.5 +// see LICENSE.txt
    46.6 +
    46.7 +#ifndef I18N_H
    46.8 +#define I18N_H
    46.9 +
   46.10 +#include <string>
   46.11 +#include "EngineTestSessionSuite.h"
   46.12 +
   46.13 +using namespace std;
   46.14 +
   46.15 +class I18nTests : public EngineTestSessionSuite {
   46.16 +    public:
   46.17 +        I18nTests(string test_suite, string test_home_dir);
   46.18 +    private:
   46.19 +        void check_i18n();
   46.20 +};
   46.21 +
   46.22 +#endif
    47.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    47.2 +++ b/test/include/IdentityListTests.h	Fri May 11 08:58:04 2018 +0200
    47.3 @@ -0,0 +1,19 @@
    47.4 +// This file is under GNU General Public License 3.0
    47.5 +// see LICENSE.txt
    47.6 +
    47.7 +#ifndef IDENTITY_LIST_H
    47.8 +#define IDENTITY_LIST_H
    47.9 +
   47.10 +#include <string>
   47.11 +#include "EngineTestSessionSuite.h"
   47.12 +
   47.13 +using namespace std;
   47.14 +
   47.15 +class IdentityListTests : public EngineTestSessionSuite {
   47.16 +    public:
   47.17 +        IdentityListTests(string test_suite, string test_home_dir);
   47.18 +    private:
   47.19 +        void check_identity_list();
   47.20 +};
   47.21 +
   47.22 +#endif
    48.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    48.2 +++ b/test/include/KeyeditTests.h	Fri May 11 08:58:04 2018 +0200
    48.3 @@ -0,0 +1,19 @@
    48.4 +// This file is under GNU General Public License 3.0
    48.5 +// see LICENSE.txt
    48.6 +
    48.7 +#ifndef KEYEDIT_H
    48.8 +#define KEYEDIT_H
    48.9 +
   48.10 +#include <string>
   48.11 +#include "EngineTestSessionSuite.h"
   48.12 +
   48.13 +using namespace std;
   48.14 +
   48.15 +class KeyeditTests : public EngineTestSessionSuite {
   48.16 +    public:
   48.17 +        KeyeditTests(string test_suite, string test_home_dir);
   48.18 +    private:
   48.19 +        void check_keyedit();
   48.20 +};
   48.21 +
   48.22 +#endif
    49.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    49.2 +++ b/test/include/LeastColorGroupTests.h	Fri May 11 08:58:04 2018 +0200
    49.3 @@ -0,0 +1,19 @@
    49.4 +// This file is under GNU General Public License 3.0
    49.5 +// see LICENSE.txt
    49.6 +
    49.7 +#ifndef LEAST_COLOR_GROUP_H
    49.8 +#define LEAST_COLOR_GROUP_H
    49.9 +
   49.10 +#include <string>
   49.11 +#include "EngineTestSessionSuite.h"
   49.12 +
   49.13 +using namespace std;
   49.14 +
   49.15 +class LeastColorGroupTests : public EngineTestSessionSuite {
   49.16 +    public:
   49.17 +        LeastColorGroupTests(string test_suite, string test_home_dir);
   49.18 +    private:
   49.19 +        void check_least_color_group();
   49.20 +};
   49.21 +
   49.22 +#endif
    50.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    50.2 +++ b/test/include/LeastCommonDenomColorTests.h	Fri May 11 08:58:04 2018 +0200
    50.3 @@ -0,0 +1,19 @@
    50.4 +// This file is under GNU General Public License 3.0
    50.5 +// see LICENSE.txt
    50.6 +
    50.7 +#ifndef LEAST_COMMON_DENOM_COLOR_H
    50.8 +#define LEAST_COMMON_DENOM_COLOR_H
    50.9 +
   50.10 +#include <string>
   50.11 +#include "EngineTestSessionSuite.h"
   50.12 +
   50.13 +using namespace std;
   50.14 +
   50.15 +class LeastCommonDenomColorTests : public EngineTestSessionSuite {
   50.16 +    public:
   50.17 +        LeastCommonDenomColorTests(string test_suite, string test_home_dir);
   50.18 +    private:
   50.19 +        void check_least_common_denom_color();
   50.20 +};
   50.21 +
   50.22 +#endif
    51.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    51.2 +++ b/test/include/MapAsn1Tests.h	Fri May 11 08:58:04 2018 +0200
    51.3 @@ -0,0 +1,19 @@
    51.4 +// This file is under GNU General Public License 3.0
    51.5 +// see LICENSE.txt
    51.6 +
    51.7 +#ifndef MAP_ASN1_H
    51.8 +#define MAP_ASN1_H
    51.9 +
   51.10 +#include <string>
   51.11 +#include "EngineTestSessionSuite.h"
   51.12 +
   51.13 +using namespace std;
   51.14 +
   51.15 +class MapAsn1Tests : public EngineTestSessionSuite {
   51.16 +    public:
   51.17 +        MapAsn1Tests(string test_suite, string test_home_dir);
   51.18 +    private:
   51.19 +        void check_map_asn1();
   51.20 +};
   51.21 +
   51.22 +#endif
    52.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    52.2 +++ b/test/include/Message2_0Tests.h	Fri May 11 08:58:04 2018 +0200
    52.3 @@ -0,0 +1,19 @@
    52.4 +// This file is under GNU General Public License 3.0
    52.5 +// see LICENSE.txt
    52.6 +
    52.7 +#ifndef MESSAGE2_0_H
    52.8 +#define MESSAGE2_0_H
    52.9 +
   52.10 +#include <string>
   52.11 +#include "EngineTestSessionSuite.h"
   52.12 +
   52.13 +using namespace std;
   52.14 +
   52.15 +class Message2_0Tests : public EngineTestSessionSuite {
   52.16 +    public:
   52.17 +        Message2_0Tests(string test_suite, string test_home_dir);
   52.18 +    private:
   52.19 +        void check_message2_0();
   52.20 +};
   52.21 +
   52.22 +#endif
    53.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    53.2 +++ b/test/include/MessageApiTests.h	Fri May 11 08:58:04 2018 +0200
    53.3 @@ -0,0 +1,19 @@
    53.4 +// This file is under GNU General Public License 3.0
    53.5 +// see LICENSE.txt
    53.6 +
    53.7 +#ifndef MESSAGE_API_H
    53.8 +#define MESSAGE_API_H
    53.9 +
   53.10 +#include <string>
   53.11 +#include "EngineTestSessionSuite.h"
   53.12 +
   53.13 +using namespace std;
   53.14 +
   53.15 +class MessageApiTests : public EngineTestSessionSuite {
   53.16 +    public:
   53.17 +        MessageApiTests(string test_suite, string test_home_dir);
   53.18 +    private:
   53.19 +        void check_message_api();
   53.20 +};
   53.21 +
   53.22 +#endif
    54.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    54.2 +++ b/test/include/MessageTwoPointOhTests.h	Fri May 11 08:58:04 2018 +0200
    54.3 @@ -0,0 +1,19 @@
    54.4 +// This file is under GNU General Public License 3.0
    54.5 +// see LICENSE.txt
    54.6 +
    54.7 +#ifndef MESSAGE_TWO_POINT_OH_H
    54.8 +#define MESSAGE_TWO_POINT_OH_H
    54.9 +
   54.10 +#include <string>
   54.11 +#include "EngineTestSessionSuite.h"
   54.12 +
   54.13 +using namespace std;
   54.14 +
   54.15 +class MessageTwoPointOhTests : public EngineTestSessionSuite {
   54.16 +    public:
   54.17 +        MessageTwoPointOhTests(string test_suite, string test_home_dir);
   54.18 +    private:
   54.19 +        void check_message_two_point_oh();
   54.20 +};
   54.21 +
   54.22 +#endif
    55.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    55.2 +++ b/test/include/MimeTests.h	Fri May 11 08:58:04 2018 +0200
    55.3 @@ -0,0 +1,19 @@
    55.4 +// This file is under GNU General Public License 3.0
    55.5 +// see LICENSE.txt
    55.6 +
    55.7 +#ifndef MIME_H
    55.8 +#define MIME_H
    55.9 +
   55.10 +#include <string>
   55.11 +#include "EngineTestSessionSuite.h"
   55.12 +
   55.13 +using namespace std;
   55.14 +
   55.15 +class MimeTests : public EngineTestSessionSuite {
   55.16 +    public:
   55.17 +        MimeTests(string test_suite, string test_home_dir);
   55.18 +    private:
   55.19 +        void check_mime();
   55.20 +};
   55.21 +
   55.22 +#endif
    56.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    56.2 +++ b/test/include/MistrustUndoTests.h	Fri May 11 08:58:04 2018 +0200
    56.3 @@ -0,0 +1,19 @@
    56.4 +// This file is under GNU General Public License 3.0
    56.5 +// see LICENSE.txt
    56.6 +
    56.7 +#ifndef MISTRUST_UNDO_H
    56.8 +#define MISTRUST_UNDO_H
    56.9 +
   56.10 +#include <string>
   56.11 +#include "EngineTestSessionSuite.h"
   56.12 +
   56.13 +using namespace std;
   56.14 +
   56.15 +class MistrustUndoTests : public EngineTestSessionSuite {
   56.16 +    public:
   56.17 +        MistrustUndoTests(string test_suite, string test_home_dir);
   56.18 +    private:
   56.19 +        void check_mistrust_undo();
   56.20 +};
   56.21 +
   56.22 +#endif
    57.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    57.2 +++ b/test/include/NewUpdateIdAndMyselfTests.h	Fri May 11 08:58:04 2018 +0200
    57.3 @@ -0,0 +1,19 @@
    57.4 +// This file is under GNU General Public License 3.0
    57.5 +// see LICENSE.txt
    57.6 +
    57.7 +#ifndef NEW_UPDATE_ID_AND_MYSELF_H
    57.8 +#define NEW_UPDATE_ID_AND_MYSELF_H
    57.9 +
   57.10 +#include <string>
   57.11 +#include "EngineTestSessionSuite.h"
   57.12 +
   57.13 +using namespace std;
   57.14 +
   57.15 +class NewUpdateIdAndMyselfTests : public EngineTestSessionSuite {
   57.16 +    public:
   57.17 +        NewUpdateIdAndMyselfTests(string test_suite, string test_home_dir);
   57.18 +    private:
   57.19 +        void check_new_update_id_and_myself();
   57.20 +};
   57.21 +
   57.22 +#endif
    58.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    58.2 +++ b/test/include/PepSubjectReceivedTests.h	Fri May 11 08:58:04 2018 +0200
    58.3 @@ -0,0 +1,19 @@
    58.4 +// This file is under GNU General Public License 3.0
    58.5 +// see LICENSE.txt
    58.6 +
    58.7 +#ifndef PEP_SUBJECT_RECEIVED_H
    58.8 +#define PEP_SUBJECT_RECEIVED_H
    58.9 +
   58.10 +#include <string>
   58.11 +#include "EngineTestSessionSuite.h"
   58.12 +
   58.13 +using namespace std;
   58.14 +
   58.15 +class PepSubjectReceivedTests : public EngineTestSessionSuite {
   58.16 +    public:
   58.17 +        PepSubjectReceivedTests(string test_suite, string test_home_dir);
   58.18 +    private:
   58.19 +        void check_pep_subject_received();
   58.20 +};
   58.21 +
   58.22 +#endif
    59.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    59.2 +++ b/test/include/PgpBinaryTests.h	Fri May 11 08:58:04 2018 +0200
    59.3 @@ -0,0 +1,19 @@
    59.4 +// This file is under GNU General Public License 3.0
    59.5 +// see LICENSE.txt
    59.6 +
    59.7 +#ifndef PGP_BINARY_H
    59.8 +#define PGP_BINARY_H
    59.9 +
   59.10 +#include <string>
   59.11 +#include "EngineTestSessionSuite.h"
   59.12 +
   59.13 +using namespace std;
   59.14 +
   59.15 +class PgpBinaryTests : public EngineTestSessionSuite {
   59.16 +    public:
   59.17 +        PgpBinaryTests(string test_suite, string test_home_dir);
   59.18 +    private:
   59.19 +        void check_pgp_binary();
   59.20 +};
   59.21 +
   59.22 +#endif
    60.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    60.2 +++ b/test/include/PgpListKeysTests.h	Fri May 11 08:58:04 2018 +0200
    60.3 @@ -0,0 +1,19 @@
    60.4 +// This file is under GNU General Public License 3.0
    60.5 +// see LICENSE.txt
    60.6 +
    60.7 +#ifndef PGP_LIST_KEYS_H
    60.8 +#define PGP_LIST_KEYS_H
    60.9 +
   60.10 +#include <string>
   60.11 +#include "EngineTestSessionSuite.h"
   60.12 +
   60.13 +using namespace std;
   60.14 +
   60.15 +class PgpListKeysTests : public EngineTestSessionSuite {
   60.16 +    public:
   60.17 +        PgpListKeysTests(string test_suite, string test_home_dir);
   60.18 +    private:
   60.19 +        void check_pgp_list_keys();
   60.20 +};
   60.21 +
   60.22 +#endif
    61.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    61.2 +++ b/test/include/ReencryptPlusExtraKeysTests.h	Fri May 11 08:58:04 2018 +0200
    61.3 @@ -0,0 +1,19 @@
    61.4 +// This file is under GNU General Public License 3.0
    61.5 +// see LICENSE.txt
    61.6 +
    61.7 +#ifndef REENCRYPT_PLUS_EXTRA_KEYS_H
    61.8 +#define REENCRYPT_PLUS_EXTRA_KEYS_H
    61.9 +
   61.10 +#include <string>
   61.11 +#include "EngineTestSessionSuite.h"
   61.12 +
   61.13 +using namespace std;
   61.14 +
   61.15 +class ReencryptPlusExtraKeysTests : public EngineTestSessionSuite {
   61.16 +    public:
   61.17 +        ReencryptPlusExtraKeysTests(string test_suite, string test_home_dir);
   61.18 +    private:
   61.19 +        void check_reencrypt_plus_extra_keys();
   61.20 +};
   61.21 +
   61.22 +#endif
    62.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    62.2 +++ b/test/include/RevokeRegenAttachTests.h	Fri May 11 08:58:04 2018 +0200
    62.3 @@ -0,0 +1,19 @@
    62.4 +// This file is under GNU General Public License 3.0
    62.5 +// see LICENSE.txt
    62.6 +
    62.7 +#ifndef REVOKE_REGEN_ATTACH_H
    62.8 +#define REVOKE_REGEN_ATTACH_H
    62.9 +
   62.10 +#include <string>
   62.11 +#include "EngineTestSessionSuite.h"
   62.12 +
   62.13 +using namespace std;
   62.14 +
   62.15 +class RevokeRegenAttachTests : public EngineTestSessionSuite {
   62.16 +    public:
   62.17 +        RevokeRegenAttachTests(string test_suite, string test_home_dir);
   62.18 +    private:
   62.19 +        void check_revoke_regen_attach();
   62.20 +};
   62.21 +
   62.22 +#endif
    63.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    63.2 +++ b/test/include/SequenceTests.h	Fri May 11 08:58:04 2018 +0200
    63.3 @@ -0,0 +1,19 @@
    63.4 +// This file is under GNU General Public License 3.0
    63.5 +// see LICENSE.txt
    63.6 +
    63.7 +#ifndef SEQUENCE_TESTS_H
    63.8 +#define SEQUENCE_TESTS_H
    63.9 +
   63.10 +#include <string>
   63.11 +#include "EngineTestSessionSuite.h"
   63.12 +
   63.13 +using namespace std;
   63.14 +
   63.15 +class SequenceTests : public EngineTestSessionSuite {
   63.16 +    public:
   63.17 +        SequenceTests(string suitename, string test_home_dir);
   63.18 +    private:
   63.19 +        void check_sequences();
   63.20 +};
   63.21 +
   63.22 +#endif
    64.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    64.2 +++ b/test/include/StringlistTests.h	Fri May 11 08:58:04 2018 +0200
    64.3 @@ -0,0 +1,19 @@
    64.4 +// This file is under GNU General Public License 3.0
    64.5 +// see LICENSE.txt
    64.6 +
    64.7 +#ifndef STRINGLIST_TESTS_H
    64.8 +#define STRINGLIST_TESTS_H
    64.9 +
   64.10 +#include <string>
   64.11 +#include "EngineTestSuite.h"
   64.12 +
   64.13 +using namespace std;
   64.14 +
   64.15 +class StringlistTests : public EngineTestSuite {
   64.16 +    public:
   64.17 +        StringlistTests(string suitename, string test_home_dir);
   64.18 +    private:
   64.19 +        void check_stringlists();
   64.20 +};
   64.21 +
   64.22 +#endif
    65.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    65.2 +++ b/test/include/StringpairListTests.h	Fri May 11 08:58:04 2018 +0200
    65.3 @@ -0,0 +1,20 @@
    65.4 +// This file is under GNU General Public License 3.0
    65.5 +// see LICENSE.txt
    65.6 +
    65.7 +#ifndef STRINGPAIR_LIST_TESTS_H
    65.8 +#define STRINGPAIR_LIST_TESTS_H
    65.9 +
   65.10 +#include <string>
   65.11 +#include "EngineTestSuite.h"
   65.12 +
   65.13 +using namespace std;
   65.14 +
   65.15 +class StringpairListTests : public EngineTestSuite {
   65.16 +    public:
   65.17 +        StringpairListTests(string suitename, string test_home_dir);
   65.18 +    private:
   65.19 +        void check_stringpair_lists();
   65.20 +        bool test_stringpair_equals(stringpair_t* val1, stringpair_t* val2);
   65.21 +};
   65.22 +
   65.23 +#endif
    66.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    66.2 +++ b/test/include/SuiteMaker.h	Fri May 11 08:58:04 2018 +0200
    66.3 @@ -0,0 +1,25 @@
    66.4 +// This file is under GNU General Public License 3.0
    66.5 +// see LICENSE.txt
    66.6 +
    66.7 +#ifndef SUITEMAKER_H
    66.8 +#define SUITEMAKER_H
    66.9 +
   66.10 +#include <cpptest.h>
   66.11 +#include <cpptest-suite.h>
   66.12 +#include <memory>
   66.13 +#include <vector>
   66.14 +
   66.15 +#include "EngineTestSuite.h"
   66.16 +
   66.17 +class SuiteMaker {
   66.18 +    public:
   66.19 +        static void suitemaker_build(const char* test_class_name, const char* test_home, Test::Suite** test_suite);
   66.20 +        static void suitemaker_buildall(const char* test_home, std::vector<Test::Suite*>& test_suites);
   66.21 +        static void suitemaker_buildlist(const char** test_class_names, int num_to_run, const char* test_home, std::vector<Test::Suite*>& test_suites);
   66.22 +
   66.23 +    private:
   66.24 +        static int num_suites;
   66.25 +        static const char* all_suites[];
   66.26 +};
   66.27 +
   66.28 +#endif
    67.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    67.2 +++ b/test/include/TestDriver.h	Fri May 11 08:58:04 2018 +0200
    67.3 @@ -0,0 +1,19 @@
    67.4 +#ifndef PEP_TEST_DRIVER_H
    67.5 +#define PEP_TEST_DRIVER_H
    67.6 +
    67.7 +#include <cpptest.h>
    67.8 +#include <cpptest-suite.h>
    67.9 +#include <cpptest-textoutput.h>
   67.10 +#include <string>
   67.11 +#include <map>
   67.12 +#include "SuiteMaker.h"
   67.13 +#include "EngineTestSuite.h"
   67.14 +#include "EngineTestIndividualSuite.h"
   67.15 +#include "EngineTestSessionSuite.h"
   67.16 +
   67.17 +using namespace std;
   67.18 +
   67.19 +typedef map<string, EngineTestSuite> SuiteMap;
   67.20 +typedef set<string> NameSet;
   67.21 +
   67.22 +#endif
    68.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    68.2 +++ b/test/include/TrustManipulationTests.h	Fri May 11 08:58:04 2018 +0200
    68.3 @@ -0,0 +1,19 @@
    68.4 +// This file is under GNU General Public License 3.0
    68.5 +// see LICENSE.txt
    68.6 +
    68.7 +#ifndef TRUST_MANIPULATION_TESTS_H
    68.8 +#define TRUST_MANIPULATION_TESTS_H
    68.9 +
   68.10 +#include <string>
   68.11 +#include "EngineTestSessionSuite.h"
   68.12 +
   68.13 +using namespace std;
   68.14 +
   68.15 +class TrustManipulationTests : public EngineTestSessionSuite {
   68.16 +    public:
   68.17 +        TrustManipulationTests(string suitename, string test_home_dir);
   68.18 +    private:
   68.19 +        void check_trust_manipulation();
   68.20 +};
   68.21 +
   68.22 +#endif
    69.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    69.2 +++ b/test/include/TrustwordsTests.h	Fri May 11 08:58:04 2018 +0200
    69.3 @@ -0,0 +1,19 @@
    69.4 +// This file is under GNU General Public License 3.0
    69.5 +// see LICENSE.txt
    69.6 +
    69.7 +#ifndef TRUSTWORDS_TESTS_H
    69.8 +#define TRUSTWORDS_TESTS_H
    69.9 +
   69.10 +#include <string>
   69.11 +#include "EngineTestSessionSuite.h"
   69.12 +
   69.13 +using namespace std;
   69.14 +
   69.15 +class TrustwordsTests : public EngineTestSessionSuite {
   69.16 +    public:
   69.17 +        TrustwordsTests(string suitename, string test_home_dir);
   69.18 +    private:
   69.19 +        void check_trustwords();
   69.20 +};
   69.21 +
   69.22 +#endif
    70.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    70.2 +++ b/test/include/UserIDAliasTests.h	Fri May 11 08:58:04 2018 +0200
    70.3 @@ -0,0 +1,19 @@
    70.4 +// This file is under GNU General Public License 3.0
    70.5 +// see LICENSE.txt
    70.6 +
    70.7 +#ifndef USERID_ALIAS_TESTS_H
    70.8 +#define USERID_ALIAS_TESTS_H
    70.9 +
   70.10 +#include <string>
   70.11 +#include "EngineTestSessionSuite.h"
   70.12 +
   70.13 +using namespace std;
   70.14 +
   70.15 +class UserIDAliasTests : public EngineTestSessionSuite {
   70.16 +    public:
   70.17 +        UserIDAliasTests(string suitename, string test_home_dir);
   70.18 +    private:
   70.19 +        void check_userid_aliases();
   70.20 +};
   70.21 +
   70.22 +#endif
    71.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    71.2 +++ b/test/include/pEpEngine_test.h	Fri May 11 08:58:04 2018 +0200
    71.3 @@ -0,0 +1,3 @@
    71.4 +#include <iomanip>
    71.5 +
    71.6 +#define ASSERT_STATUS(status) { cout << setfill('0') << "status: 0x" << hex << setw(4) << status << "\n"; assert(status == PEP_STATUS_OK); cout << std::dec }
    72.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    72.2 +++ b/test/include/test_util.h	Fri May 11 08:58:04 2018 +0200
    72.3 @@ -0,0 +1,34 @@
    72.4 +#ifndef PEP_TEST_UTILS_H
    72.5 +#define PEP_TEST_UTILS_H
    72.6 +
    72.7 +#include <string>
    72.8 +#include "pEpEngine.h"
    72.9 +#include "message_api.h"
   72.10 +
   72.11 +void test_init();
   72.12 +
   72.13 +// string equality (case and non-case sensitive)
   72.14 +bool _streq(const char* str1, const char* str2);
   72.15 +bool _strceq(const char* str1, const char* str2);
   72.16 +
   72.17 +// reads a whole file and returns it as std::string
   72.18 +// throws std::runtime_error() if the file cannot be read. Empty file is not an error.
   72.19 +std::string slurp(const std::string& filename);
   72.20 +
   72.21 +// dumps char* to file
   72.22 +// throws std::runtime_error() if the file cannot be opened.
   72.23 +void dump_out(const char* filename, const char* outdata);
   72.24 +
   72.25 +// Returns the string value of the input rating enum value. 
   72.26 +const char* tl_rating_string(PEP_rating rating);
   72.27 +
   72.28 +// Returns the string value of the input comm_type enum value. 
   72.29 +const char* tl_ct_string(PEP_comm_type ct);
   72.30 +
   72.31 +// Returns the string value of the input status enum value. 
   72.32 +const char* tl_status_string(PEP_STATUS status);
   72.33 +
   72.34 +// Grabs a new uuid for your randomish string needs.
   72.35 +char* get_new_uuid();
   72.36 +
   72.37 +#endif
    73.1 --- a/test/keyedit_test.cc	Wed May 09 09:51:05 2018 +0200
    73.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    73.3 @@ -1,74 +0,0 @@
    73.4 -// This file is under GNU General Public License 3.0
    73.5 -// see LICENSE.txt
    73.6 -
    73.7 -#include "platform.h"
    73.8 -
    73.9 -#include <iostream>
   73.10 -#include <fstream>
   73.11 -#include <string>
   73.12 -#include <assert.h>
   73.13 -
   73.14 -#include "pEpEngine.h"
   73.15 -
   73.16 -using namespace std;
   73.17 -
   73.18 -int main() {
   73.19 -    cout << "\n*** keyedit_test ***\n\n";
   73.20 -
   73.21 -    PEP_SESSION session;
   73.22 -    
   73.23 -    cout << "calling init()\n";
   73.24 -    PEP_STATUS status1 = init(&session);   
   73.25 -    assert(status1 == PEP_STATUS_OK);
   73.26 -    assert(session);
   73.27 -    cout << "init() completed.\n";
   73.28 -
   73.29 -    // generate test key
   73.30 -
   73.31 -    cout << "\ngenerating key for keyedit test\n";
   73.32 -    pEp_identity *identity = new_identity(
   73.33 -            "expire@dingens.org",
   73.34 -            NULL,
   73.35 -            "423",
   73.36 -            "expire test key"
   73.37 -        );
   73.38 -    assert(identity);
   73.39 -    PEP_STATUS generate_status = generate_keypair(session, identity);
   73.40 -    cout << "generate_keypair() exits with " << generate_status << "\n";
   73.41 -    assert(generate_status == PEP_STATUS_OK);
   73.42 -    cout << "generated key is " << identity->fpr << "\n";
   73.43 -
   73.44 -    string key(identity->fpr);
   73.45 -    free_identity(identity);
   73.46 -
   73.47 -    // keyedit test code
   73.48 -
   73.49 -    timestamp *ts = new_timestamp(time(0));
   73.50 -    ts->tm_year += 2;
   73.51 -
   73.52 -    cout << "key shell expire on " << asctime(ts) << "\n";
   73.53 -
   73.54 -    PEP_STATUS status2 = renew_key(session, key.c_str(), ts);
   73.55 -    cout << "renew_key() exited with " << status2 << "\n";
   73.56 -    assert(status2 == PEP_STATUS_OK);
   73.57 -    free_timestamp(ts);
   73.58 -
   73.59 -    cout << "key renewed.\n";
   73.60 -
   73.61 -    cout << "key will be revoked\n";
   73.62 -    PEP_STATUS status3 = revoke_key(session, key.c_str(), "revoke test");
   73.63 -    cout << "revoke_key() exited with " << status3 << "\n";
   73.64 -    assert(status3 == PEP_STATUS_OK);
   73.65 -    
   73.66 -    cout << "key revoked.\n";
   73.67 -
   73.68 -    cout << "deleting key pair " << key.c_str() << "\n";
   73.69 -    PEP_STATUS delete_status = delete_keypair(session, key.c_str());
   73.70 -    cout << "delete_keypair() exits with " << delete_status << "\n";
   73.71 -    assert(delete_status == PEP_STATUS_OK);
   73.72 -
   73.73 -    cout << "calling release()\n";
   73.74 -    release(session);
   73.75 -    return 0;
   73.76 -}
   73.77 -
    74.1 --- a/test/least_color_group_test.cc	Wed May 09 09:51:05 2018 +0200
    74.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    74.3 @@ -1,99 +0,0 @@
    74.4 -#include <iostream>
    74.5 -#include <iostream>
    74.6 -#include <vector>
    74.7 -#include <cstring> // for strcmp()
    74.8 -#include <assert.h>
    74.9 -#include "blacklist.h"
   74.10 -#include "keymanagement.h"
   74.11 -#include "message_api.h"
   74.12 -#include "mime.h"
   74.13 -#include "test_util.h"
   74.14 -
   74.15 -using namespace std;
   74.16 -
   74.17 -int main(int argc, char** argv) {
   74.18 -    cout << "\n*** least_color_group_test.cc ***\n\n";
   74.19 -    
   74.20 -    const char* mailfile = "test_mails/color_test.eml";
   74.21 -    
   74.22 -    const std::vector<const char*> keynames = {
   74.23 -                              "test_keys/priv/pep.color.test.P-0x3EBE215C_priv.asc",
   74.24 -                              "test_keys/pub/pep.color.test.H-0xD17E598E_pub.asc",
   74.25 -                              "test_keys/pub/pep.color.test.L-0xE9CDB4CE_pub.asc",
   74.26 -                              "test_keys/pub/pep.color.test.P-0x3EBE215C_pub.asc",
   74.27 -                              "test_keys/pub/pep.color.test.V-0x71FC6D28_pub.asc"
   74.28 -                          };
   74.29 -    
   74.30 -    PEP_SESSION session;
   74.31 -    
   74.32 -    cout << "calling init()\n";
   74.33 -    PEP_STATUS status1 = init(&session);   
   74.34 -    assert(status1 == PEP_STATUS_OK);
   74.35 -    assert(session);
   74.36 -    cout << "init() completed.\n";
   74.37 -    
   74.38 -    for (auto name : keynames) {
   74.39 -        cout << "\t read keyfile \"" << name << "\"..." << std::endl;
   74.40 -        const string keytextkey = slurp(name);
   74.41 -        PEP_STATUS statuskey = import_key(session, keytextkey.c_str(), keytextkey.length(), NULL);
   74.42 -        assert(statuskey == PEP_STATUS_OK);
   74.43 -    }
   74.44 -    
   74.45 -    cout << "\t read keyfile mailfile \"" << mailfile << "\"..." << std::endl;
   74.46 -    const string mailtext = slurp(mailfile);
   74.47 -    cout << "\t All files read successfully." << std::endl;
   74.48 -
   74.49 -    pEp_identity * me1 = new_identity("pep.color.test.P@kgrothoff.org", 
   74.50 -                                      "7EE6C60C68851954E1797F81EA59715E3EBE215C", 
   74.51 -                                      PEP_OWN_USERID, "Pep Color Test P (recip)");
   74.52 -    me1->me = true;
   74.53 -    PEP_STATUS status = myself(session, me1);
   74.54 -    
   74.55 -    pEp_identity * sender1 = new_identity("pep.color.test.V@kgrothoff.org",
   74.56 -                                          NULL, "TOFU_pep.color.test.V@kgrothoff.org",
   74.57 -                                          "Pep Color Test V (sender)");
   74.58 -    
   74.59 -    status = update_identity(session, sender1);
   74.60 -    trust_personal_key(session, sender1);
   74.61 -    status = update_identity(session, sender1);
   74.62 -    
   74.63 -    message* msg_ptr = nullptr;
   74.64 -    message* dest_msg = nullptr;
   74.65 -    message* final_ptr = nullptr;
   74.66 -    stringlist_t* keylist = nullptr;
   74.67 -    PEP_rating rating;
   74.68 -    PEP_decrypt_flags_t flags;
   74.69 -    
   74.70 -    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr);
   74.71 -    assert(status == PEP_STATUS_OK);
   74.72 -    assert(msg_ptr);
   74.73 -    final_ptr = msg_ptr;
   74.74 -    flags = 0;
   74.75 -    status = decrypt_message(session, msg_ptr, &dest_msg, &keylist, &rating, &flags);
   74.76 -    final_ptr = dest_msg ? dest_msg : msg_ptr;
   74.77 -  
   74.78 -    cout << "shortmsg: " << final_ptr->shortmsg << endl << endl;
   74.79 -    cout << "longmsg: " << final_ptr->longmsg << endl << endl;
   74.80 -    cout << "longmsg_formatted: " << (final_ptr->longmsg_formatted ? final_ptr->longmsg_formatted : "(empty)") << endl << endl;
   74.81 -    cout << "rating: " << rating << endl << endl;
   74.82 -    cout << "keys used: " << endl;
   74.83 -    
   74.84 -    int i = 0;
   74.85 -    for (stringlist_t* k = keylist; k; k = k->next) {
   74.86 -        if (i == 0)
   74.87 -            cout << "\t Signer (key 0):\t" << k->value << endl;
   74.88 -        else
   74.89 -            cout << "\t #" << i << ":\t" << k->value << endl;
   74.90 -        i++;
   74.91 -    }
   74.92 -    
   74.93 -//    free_identity(me1);
   74.94 -    if (final_ptr == dest_msg)
   74.95 -    	free_message(dest_msg);
   74.96 -    free_message(msg_ptr);
   74.97 -    free_stringlist(keylist);
   74.98 -    
   74.99 -    cout << "calling release()\n";
  74.100 -    release(session);
  74.101 -    return 0;
  74.102 -}
    75.1 --- a/test/least_common_denom_color_test.cc	Wed May 09 09:51:05 2018 +0200
    75.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    75.3 @@ -1,139 +0,0 @@
    75.4 -#include <iostream>
    75.5 -#include <iostream>
    75.6 -#include <fstream>
    75.7 -#include <string>
    75.8 -#include <cstring> // for strcmp()
    75.9 -#include <assert.h>
   75.10 -#include "blacklist.h"
   75.11 -#include "keymanagement.h"
   75.12 -#include "message_api.h"
   75.13 -#include "mime.h"
   75.14 -#include "test_util.h"
   75.15 -
   75.16 -using namespace std;
   75.17 -
   75.18 -int main(int argc, char** argv) {
   75.19 -        
   75.20 -    const char* mailfile = "test_mails/Test_Message_JSON-21_Color_Problems.eml";
   75.21 -    
   75.22 -    PEP_SESSION session;
   75.23 -    
   75.24 -    cout << "calling init()\n";
   75.25 -    PEP_STATUS status1 = init(&session);   
   75.26 -    assert(status1 == PEP_STATUS_OK);
   75.27 -    assert(session);
   75.28 -    cout << "init() completed.\n";
   75.29 -    
   75.30 -    // import keys
   75.31 -    const string keytextkey1 = slurp("test_keys/pub/banmeonce-0x07B29090_pub.asc");
   75.32 -    const string keytextkey2 = slurp("test_keys/pub/banmetwice-0x4080C3E7_pub.asc");
   75.33 -    const string keytextkey3 = slurp("test_keys/pub/pep.never.me.test-0x79C11D1D_pub.asc");
   75.34 -    const string keytextkey4 = slurp("test_keys/priv/pep.never.me.test-0x79C11D1D_priv.asc");
   75.35 -
   75.36 -    PEP_STATUS statuskey1 = import_key(session, keytextkey1.c_str(), keytextkey1.length(), NULL);
   75.37 -    PEP_STATUS statuskey2 = import_key(session, keytextkey2.c_str(), keytextkey2.length(), NULL);
   75.38 -    PEP_STATUS statuskey3 = import_key(session, keytextkey3.c_str(), keytextkey3.length(), NULL);
   75.39 -    PEP_STATUS statuskey4 = import_key(session, keytextkey4.c_str(), keytextkey4.length(), NULL);
   75.40 -
   75.41 -    pEp_identity * sender = new_identity("pep.never.me.test@kgrothoff.org", NULL, "TOFU_pep.never.me.test@kgrothoff.org", "pEp Never Me Test");    
   75.42 -    sender->me = false;    
   75.43 -    PEP_STATUS status = update_identity(session, sender);
   75.44 -        
   75.45 -    // reset the trust on both keys before we start
   75.46 -    pEp_identity * recip1 = new_identity("banmeonce@kgrothoff.org", NULL, "TOFU_banmeonce@kgrothoff.org", "Ban Me Once");    
   75.47 -    recip1->me = false;    
   75.48 -    status = update_identity(session, recip1);
   75.49 -    key_reset_trust(session, recip1);
   75.50 -    
   75.51 -    pEp_identity * recip2 = new_identity("banmetwice@kgrothoff.org", NULL, "TOFU_banmetwice@kgrothoff.org", "Ban Me Twice");    
   75.52 -    recip2->me = false;    
   75.53 -    status = update_identity(session, recip2);
   75.54 -    key_reset_trust(session, recip2);
   75.55 -        
   75.56 -    const string mailtext = slurp(mailfile);
   75.57 -
   75.58 -    // trust_personal_key(session, you);
   75.59 -    // 
   75.60 -    // status = update_identity(session, you);
   75.61 -    
   75.62 -    message* msg_ptr = nullptr;
   75.63 -    message* dest_msg = nullptr;
   75.64 -    stringlist_t* keylist = nullptr;
   75.65 -    PEP_rating rating;
   75.66 -    PEP_decrypt_flags_t flags;
   75.67 -    
   75.68 -    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr);
   75.69 -    assert(status == PEP_STATUS_OK);
   75.70 -    assert(msg_ptr);
   75.71 -
   75.72 -    flags = 0;
   75.73 -    status = decrypt_message(session, msg_ptr, &dest_msg, &keylist, &rating, &flags);
   75.74 -    assert(status == PEP_STATUS_OK);
   75.75 -    assert(dest_msg);
   75.76 -    /* message is signed and no recip is mistrusted... */
   75.77 -    assert(color_from_rating(rating) == PEP_color_yellow);
   75.78 -
   75.79 -    cout << "shortmsg: " << dest_msg->shortmsg << endl << endl;
   75.80 -    cout << "longmsg: " << dest_msg->longmsg << endl << endl;
   75.81 -    cout << "longmsg_formatted: " << (dest_msg->longmsg_formatted ? dest_msg->longmsg_formatted : "(empty)") << endl << endl;
   75.82 -
   75.83 -    PEP_rating decrypt_rating = rating;
   75.84 -    
   75.85 -    /* re-evaluate rating, counting on optional fields */
   75.86 -    status = re_evaluate_message_rating(session, dest_msg, NULL, PEP_rating_undefined, &rating);
   75.87 -    assert(status == PEP_STATUS_OK);
   75.88 -    assert(color_from_rating(rating) == PEP_color_yellow);
   75.89 -
   75.90 -    /* re-evaluate rating, without optional fields */
   75.91 -    status = re_evaluate_message_rating(session, dest_msg, keylist, decrypt_rating, &rating);
   75.92 -    assert(status == PEP_STATUS_OK);
   75.93 -    assert(color_from_rating(rating) == PEP_color_yellow);
   75.94 -
   75.95 -    /* Ok, now mistrust one recip */
   75.96 -    key_mistrusted(session, recip2);
   75.97 -
   75.98 -    /* re-evaluate rating, counting on optional fields */
   75.99 -    status = re_evaluate_message_rating(session, dest_msg, NULL, PEP_rating_undefined, &rating);
  75.100 -    assert(status == PEP_STATUS_OK);
  75.101 -    assert(color_from_rating(rating) == PEP_color_red);
  75.102 -
  75.103 -    /* re-evaluate rating, without optional fields */
  75.104 -    status = re_evaluate_message_rating(session, dest_msg, keylist, decrypt_rating, &rating);
  75.105 -    assert(status == PEP_STATUS_OK);
  75.106 -    assert(color_from_rating(rating) == PEP_color_red);
  75.107 -
  75.108 -    free_message(dest_msg);
  75.109 -    free_message(msg_ptr);
  75.110 -    free_stringlist(keylist);
  75.111 -    
  75.112 -    msg_ptr = nullptr;
  75.113 -    dest_msg = nullptr;
  75.114 -    keylist = nullptr;
  75.115 -    rating = PEP_rating_unreliable;
  75.116 -
  75.117 -    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr);
  75.118 -    assert(status == PEP_STATUS_OK);
  75.119 -    assert(msg_ptr);
  75.120 -    flags = 0;
  75.121 -    status = decrypt_message(session, msg_ptr, &dest_msg, &keylist, &rating, &flags);
  75.122 -  
  75.123 -    cout << "shortmsg: " << dest_msg->shortmsg << endl << endl;
  75.124 -    cout << "longmsg: " << dest_msg->longmsg << endl << endl;
  75.125 -    cout << "longmsg_formatted: " << (dest_msg->longmsg_formatted ? dest_msg->longmsg_formatted : "(empty)") << endl << endl;
  75.126 -
  75.127 -    /* message is signed and no recip is mistrusted... */
  75.128 -    assert(color_from_rating(rating) == PEP_color_red);
  75.129 -
  75.130 -    free_message(dest_msg);
  75.131 -    free_message(msg_ptr);
  75.132 -    free_stringlist(keylist);
  75.133 -
  75.134 -    msg_ptr = nullptr;
  75.135 -    dest_msg = nullptr;
  75.136 -    keylist = nullptr;
  75.137 -    rating = PEP_rating_unreliable;
  75.138 -    
  75.139 -    cout << "calling release()\n";
  75.140 -    release(session);
  75.141 -    return 0;
  75.142 -}
    76.1 --- a/test/map_asn1_test.cc	Wed May 09 09:51:05 2018 +0200
    76.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    76.3 @@ -1,50 +0,0 @@
    76.4 -// This file is under GNU General Public License 3.0
    76.5 -// see LICENSE.txt
    76.6 -
    76.7 -#include <iostream>
    76.8 -#include <string>
    76.9 -#include <cstring>
   76.10 -#include <assert.h>
   76.11 -#include "map_asn1.h"
   76.12 -
   76.13 -using namespace std;
   76.14 -
   76.15 -int main() {
   76.16 -    cout << "\n*** map_asn1_test ***\n\n";
   76.17 -
   76.18 -    cout << "creating new identity...\n";
   76.19 -
   76.20 -    pEp_identity *ident1 = new_identity("vb@dingens.org",
   76.21 -            "DB4713183660A12ABAFA7714EBE90D44146F62F4", "42", "Volker Birk");
   76.22 -    assert(ident1);
   76.23 -    ident1->lang[0] = 'd';
   76.24 -    ident1->lang[1] = 'e';
   76.25 -    ident1->comm_type = PEP_ct_pEp;
   76.26 -
   76.27 -    cout << "converting identity to ASN.1...\n";
   76.28 -
   76.29 -    Identity_t *ident_asn1 = Identity_from_Struct(ident1, NULL);
   76.30 -    assert(ident_asn1);
   76.31 -
   76.32 -    cout << "converting identity from ASN.1...\n";
   76.33 -
   76.34 -    pEp_identity *ident2 = Identity_to_Struct(ident_asn1, NULL);
   76.35 -    assert(ident2);
   76.36 -
   76.37 -    assert(strcmp(ident1->address, ident2->address) == 0);
   76.38 -    assert(strcmp(ident1->fpr, ident2->fpr) == 0);
   76.39 -    assert(strcmp(ident1->user_id, ident2->user_id) == 0);
   76.40 -    assert(strcmp(ident1->username, ident2->username) == 0);
   76.41 -    assert(ident2->comm_type == PEP_ct_pEp);
   76.42 -    assert(strcmp(ident2->lang, "de") == 0);
   76.43 -
   76.44 -    cout << "freeing identities...\n";
   76.45 -
   76.46 -    asn_DEF_Identity.free_struct(&asn_DEF_Identity, ident_asn1, 0);
   76.47 -    free_identity(ident1);
   76.48 -    free_identity(ident2);
   76.49 -
   76.50 -
   76.51 -    return 0;
   76.52 -}
   76.53 -
    77.1 --- a/test/message_2.0_test.cc	Wed May 09 09:51:05 2018 +0200
    77.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    77.3 @@ -1,169 +0,0 @@
    77.4 -// This file is under GNU General Public License 3.0
    77.5 -// see LICENSE.txt
    77.6 -
    77.7 -#include <stdlib.h>
    77.8 -#include <string.h>
    77.9 -#include "platform.h"
   77.10 -#include <iostream>
   77.11 -#include <fstream>
   77.12 -#include <assert.h>
   77.13 -#include "mime.h"
   77.14 -#include "message_api.h"
   77.15 -#include "keymanagement.h"
   77.16 -#include "test_util.h"
   77.17 -
   77.18 -using namespace std;
   77.19 -
   77.20 -int main() {
   77.21 -    cout << "\n*** message_2.0_test ***\n\n";
   77.22 -
   77.23 -    PEP_SESSION session;
   77.24 -    
   77.25 -    cout << "calling init()\n";
   77.26 -    PEP_STATUS status1 = init(&session);
   77.27 -    assert(status1 == PEP_STATUS_OK);
   77.28 -    assert(session);
   77.29 -    cout << "init() completed.\n";
   77.30 -
   77.31 -    PEP_comm_type carol_comm_type = PEP_ct_OpenPGP_unconfirmed;
   77.32 -
   77.33 -    // message_api test code
   77.34 -
   77.35 -    const string alice_pub_key = slurp("test_keys/pub/pep-test-alice-0x6FF00E97_pub.asc");
   77.36 -    const string alice_priv_key = slurp("test_keys/priv/pep-test-alice-0x6FF00E97_priv.asc");
   77.37 -    const string carol_pub_key = slurp("test_keys/pub/pep-test-carol-0x42A85A42_pub.asc");
   77.38 -    const string carol_priv_key = slurp("test_keys/priv/pep-test-carol-0x42A85A42_priv.asc");
   77.39 -
   77.40 -    PEP_STATUS statuspub = import_key(session, alice_pub_key.c_str(), alice_pub_key.length(), NULL);
   77.41 -    PEP_STATUS statuspriv = import_key(session, alice_priv_key.c_str(), alice_priv_key.length(), NULL);
   77.42 -    assert(statuspub == PEP_STATUS_OK);
   77.43 -    assert(statuspriv == PEP_STATUS_OK);
   77.44 -    statuspub = import_key(session, carol_pub_key.c_str(), carol_pub_key.length(), NULL);
   77.45 -    statuspriv = import_key(session, carol_priv_key.c_str(), carol_priv_key.length(), NULL);
   77.46 -    assert(statuspub == PEP_STATUS_OK);
   77.47 -    assert(statuspriv == PEP_STATUS_OK);
   77.48 -
   77.49 -    cout << "creating message…\n";
   77.50 -    pEp_identity* alice = new_identity("pep.test.alice@pep-project.org", "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97", PEP_OWN_USERID, "Alice Test");
   77.51 -    pEp_identity* carol = new_identity("pep-test-carol@pep-project.org", NULL, "TOFU_pep-test-carol@pep-project.org", "Carol Test");
   77.52 -
   77.53 -    PEP_STATUS alice_status = update_identity(session, alice);
   77.54 -    PEP_STATUS carol_status = update_identity(session, carol);
   77.55 -
   77.56 -    PEP_STATUS status = update_trust_for_fpr(session, alice->fpr, PEP_ct_pEp);
   77.57 -    status = update_trust_for_fpr(session, carol->fpr, carol_comm_type);
   77.58 -    
   77.59 -    PEP_STATUS mystatus = myself(session, alice);
   77.60 -    assert(mystatus == PEP_STATUS_OK);
   77.61 -    alice_status = update_identity(session, alice);
   77.62 -    alice_status = update_identity(session, carol);
   77.63 -    assert(alice->comm_type == PEP_ct_pEp);
   77.64 -    assert(carol->comm_type == carol_comm_type);
   77.65 -    
   77.66 -    identity_list* to_list = new_identity_list(carol); // to carol
   77.67 -    message* outgoing_message = new_message(PEP_dir_outgoing);
   77.68 -    assert(outgoing_message);
   77.69 -    outgoing_message->from = alice;
   77.70 -    outgoing_message->to = to_list;
   77.71 -    outgoing_message->shortmsg = strdup("Greetings, humans!");
   77.72 -    outgoing_message->longmsg = strdup("This is a test of the emergency message system. This is only a test. BEEP.");
   77.73 -    outgoing_message->attachments = new_bloblist(NULL, 0, "application/octet-stream", NULL);
   77.74 -//    outgoing_message->id = strdup("blahblahyourmama@pep-project.org");
   77.75 -    outgoing_message->references = new_stringlist("one-839274982347239847@pep-project.org");
   77.76 -    stringlist_add(outgoing_message->references, "two-dfddffd839274982347239847@pep-project.org");
   77.77 -    stringlist_add(outgoing_message->references, "three-OMGWTFBBQ.edfddffd839274982347239847@pep-project.org");
   77.78 -    
   77.79 -    cout << "message created.\n";
   77.80 -
   77.81 -    char* encoded_text = nullptr;
   77.82 -    status = mime_encode_message(outgoing_message, false, &encoded_text);
   77.83 -    assert(status == PEP_STATUS_OK);
   77.84 -    assert(encoded_text);
   77.85 -
   77.86 -    cout << "unencrypted:\n\n";
   77.87 -    cout << encoded_text << "\n";
   77.88 -
   77.89 -    free(encoded_text);
   77.90 -
   77.91 -    cout << "encrypting message as MIME multipart…\n";
   77.92 -    message* encrypted_msg = nullptr;
   77.93 -    cout << "calling encrypt_message\n";
   77.94 -    status = encrypt_message(session, outgoing_message, NULL, 
   77.95 -        &encrypted_msg, PEP_enc_PGP_MIME, 0);
   77.96 -    cout << "encrypt_message() returns " << std::hex << status << '.' << endl;
   77.97 -    assert(status == PEP_STATUS_OK);
   77.98 -    assert(encrypted_msg);
   77.99 -    cout << "message encrypted.\n";
  77.100 -    
  77.101 -    encrypted_msg->enc_format = PEP_enc_none;
  77.102 -    status = mime_encode_message(encrypted_msg, false, &encoded_text);
  77.103 -    assert(status == PEP_STATUS_OK);
  77.104 -    assert(encoded_text);
  77.105 -     
  77.106 -    cout << "encrypted:\n\n";
  77.107 -    cout << encoded_text << "\n";
  77.108 -     
  77.109 -    char* decrypted_text;
  77.110 -    
  77.111 -    message* decrypted_msg = nullptr;
  77.112 -    stringlist_t* keylist_used = nullptr;
  77.113 -    
  77.114 -    PEP_rating rating;
  77.115 -    PEP_decrypt_flags_t flags;
  77.116 -     
  77.117 -//    MIME_decrypt_message(session, encoded_text, strlen(encoded_text), &decrypted_text, &keylist_used, &rating, &flags);
  77.118 -    
  77.119 -//    cout << "HEY!" << endl;
  77.120 -//    cout << decrypted_text << endl;
  77.121 -    
  77.122 -    message* decoded_msg = nullptr;
  77.123 -    status = mime_decode_message(encoded_text, strlen(encoded_text), &decoded_msg);
  77.124 -    assert(status == PEP_STATUS_OK);
  77.125 -    const string string3 = encoded_text;
  77.126 -      
  77.127 -    unlink("msg_2.0.asc");
  77.128 -    ofstream outFile3("msg_2.0.asc");
  77.129 -    outFile3.write(string3.c_str(), string3.size());
  77.130 -    outFile3.close();
  77.131 -    
  77.132 -    // message* decrypted_msg = nullptr;
  77.133 -    // stringlist_t* keylist_used = nullptr;
  77.134 -    // 
  77.135 -    // PEP_rating rating;
  77.136 -    // PEP_decrypt_flags_t flags;
  77.137 -    // 
  77.138 -    stringpair_t* autoconsume = new_stringpair("pEp-auto-consume", "yes");
  77.139 -    stringpair_list_add(encrypted_msg->opt_fields, autoconsume);
  77.140 -    flags = 0;
  77.141 -    status = decrypt_message(session, encrypted_msg, &decrypted_msg, &keylist_used, &rating, &flags);
  77.142 -    assert(decrypted_msg);
  77.143 -    assert(keylist_used);
  77.144 -    assert(rating);
  77.145 -    //assert(status == PEP_STATUS_OK && rating == PEP_rating_reliable);
  77.146 -    //PEP_comm_type ct = encrypted_msg->from->comm_type;
  77.147 -    //assert(ct == PEP_ct_pEp);
  77.148 -    
  77.149 -    cout << "keys used:\n";
  77.150 -    
  77.151 -    for (stringlist_t* kl4 = keylist_used; kl4 && kl4->value; kl4 = kl4->next)
  77.152 -    {
  77.153 -       cout << "\t " << kl4->value << endl;
  77.154 -    }
  77.155 -     
  77.156 -    decrypted_msg->enc_format = PEP_enc_none; 
  77.157 -    status = _mime_encode_message_internal(decrypted_msg, false, &encoded_text, false);
  77.158 -    assert(status == PEP_STATUS_OK);
  77.159 -    assert(encoded_text);
  77.160 -    cout << "Decrypted message: " << endl;
  77.161 -    cout << encoded_text << endl;
  77.162 -     
  77.163 -    cout << "freeing messages…\n";
  77.164 -    free_message(encrypted_msg);
  77.165 -    free_message(decrypted_msg);
  77.166 -    free_message(outgoing_message);
  77.167 -    cout << "done.\n";
  77.168 -    
  77.169 -    cout << "calling release()\n";
  77.170 -    release(session);
  77.171 -    return 0;
  77.172 -}
    78.1 --- a/test/message_api_test.cc	Wed May 09 09:51:05 2018 +0200
    78.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    78.3 @@ -1,225 +0,0 @@
    78.4 -// This file is under GNU General Public License 3.0
    78.5 -// see LICENSE.txt
    78.6 -
    78.7 -#include <stdlib.h>
    78.8 -#include <string.h>
    78.9 -#include "platform.h"
   78.10 -#include <iostream>
   78.11 -#include <fstream>
   78.12 -#include <assert.h>
   78.13 -#include "mime.h"
   78.14 -#include "message_api.h"
   78.15 -#include "test_util.h"
   78.16 -
   78.17 -using namespace std;
   78.18 -
   78.19 -int main() {
   78.20 -    cout << "\n*** message_api_test ***\n\n";
   78.21 -
   78.22 -    PEP_SESSION session;
   78.23 -    
   78.24 -    cout << "calling init()\n";
   78.25 -    PEP_STATUS status1 = init(&session);
   78.26 -    assert(status1 == PEP_STATUS_OK);
   78.27 -    assert(session);
   78.28 -    cout << "init() completed.\n";
   78.29 -
   78.30 -    cout << "Importing Alice's key " << endl;
   78.31 -    const string alice_pub_key = slurp("test_keys/pub/pep-test-alice-0x6FF00E97_pub.asc");
   78.32 -    const string alice_priv_key = slurp("test_keys/priv/pep-test-alice-0x6FF00E97_priv.asc");
   78.33 -    const string bob_pub_key = slurp("test_keys/pub/pep-test-bob-0xC9C2EE39_pub.asc");
   78.34 -
   78.35 -    PEP_STATUS status0 = import_key(session, alice_pub_key.c_str(), alice_pub_key.size(), NULL);
   78.36 -    assert(status0 == PEP_STATUS_OK);
   78.37 -    status0 = import_key(session, alice_priv_key.c_str(), alice_priv_key.size(), NULL);
   78.38 -    assert(status0 == PEP_STATUS_OK);
   78.39 -    status0 = import_key(session, bob_pub_key.c_str(), bob_pub_key.size(), NULL);
   78.40 -    assert(status0 == PEP_STATUS_OK);
   78.41 -    // message_api test code
   78.42 -
   78.43 -    cout << "creating message…\n";
   78.44 -    pEp_identity * me2 = new_identity("pep.test.alice@pep-project.org", NULL, PEP_OWN_USERID, "Alice Test");
   78.45 -    // pEp_identity * me2 = new_identity("test@nokey.plop", NULL, PEP_OWN_USERID, "Test no key");
   78.46 -    me2->me = true;
   78.47 -    identity_list *to2 = new_identity_list(new_identity("pep.test.bob@pep-project.org", NULL, "42", "Bob Test"));
   78.48 -    // identity_list *to2 = new_identity_list(new_identity("still@nokey.blup", NULL, "42", "Still no key"));
   78.49 -    message *msg2 = new_message(PEP_dir_outgoing);
   78.50 -    assert(msg2);
   78.51 -    msg2->from = me2;
   78.52 -    msg2->to = to2;
   78.53 -    msg2->shortmsg = strdup("hello, world");
   78.54 -    msg2->attachments = new_bloblist(NULL, 0, "application/octet-stream", NULL);
   78.55 -    cout << "message created.\n";
   78.56 -
   78.57 -    char *text2 = nullptr;
   78.58 -    PEP_STATUS status2 = mime_encode_message(msg2, false, &text2);
   78.59 -    assert(status2 == PEP_STATUS_OK);
   78.60 -    assert(text2);
   78.61 -
   78.62 -    cout << "decrypted:\n\n";
   78.63 -    cout << text2 << "\n";
   78.64 -
   78.65 -    free(text2);
   78.66 -
   78.67 -    cout << "encrypting message as MIME multipart…\n";
   78.68 -    message *enc_msg2 = nullptr;
   78.69 -    cout << "calling encrypt_message()\n";
   78.70 -    status2 = encrypt_message(session, msg2, NULL, &enc_msg2, PEP_enc_PGP_MIME, 0);
   78.71 -    cout << "encrypt_message() returns " << status2 << '.' << endl;
   78.72 -    assert(status2 == PEP_STATUS_OK);
   78.73 -    assert(enc_msg2);
   78.74 -    cout << "message encrypted.\n";
   78.75 -    
   78.76 -    status2 = mime_encode_message(enc_msg2, false, &text2);
   78.77 -    assert(status2 == PEP_STATUS_OK);
   78.78 -    assert(text2);
   78.79 -
   78.80 -    cout << "encrypted:\n\n";
   78.81 -    cout << text2 << "\n";
   78.82 -
   78.83 -    message *msg3 = nullptr;
   78.84 -    PEP_STATUS status3 = mime_decode_message(text2, strlen(text2), &msg3);
   78.85 -    assert(status3 == PEP_STATUS_OK);
   78.86 -    const string string3 = text2;
   78.87 -    //free(text2);
   78.88 -
   78.89 -    unlink("msg4.asc");
   78.90 -    ofstream outFile3("msg4.asc");
   78.91 -    outFile3.write(string3.c_str(), string3.size());
   78.92 -    outFile3.close();
   78.93 -
   78.94 -    message *msg4 = nullptr;
   78.95 -    stringlist_t *keylist4 = nullptr;
   78.96 -    PEP_rating rating;
   78.97 -    PEP_decrypt_flags_t flags;
   78.98 -    
   78.99 -    flags = 0;
  78.100 -    PEP_STATUS status4 = decrypt_message(session, enc_msg2, &msg4, &keylist4, &rating, &flags);
  78.101 -    assert(status4 == PEP_STATUS_OK);
  78.102 -    assert(msg4);
  78.103 -    assert(keylist4);
  78.104 -    assert(rating);
  78.105 -    PEP_comm_type ct = enc_msg2->from->comm_type;
  78.106 -    assert(ct == PEP_ct_pEp || ct == PEP_ct_pEp_unconfirmed || ct == PEP_ct_OpenPGP || ct == PEP_ct_OpenPGP_unconfirmed );
  78.107 -
  78.108 -    free_stringpair_list(enc_msg2->opt_fields);
  78.109 -    enc_msg2->opt_fields = NULL;
  78.110 -
  78.111 -    cout << "keys used:";
  78.112 -
  78.113 -    for (stringlist_t* kl4 = keylist4; kl4 && kl4->value; kl4 = kl4->next)
  78.114 -    {
  78.115 -        cout << " " << kl4->value;
  78.116 -    }
  78.117 -    cout << "\n\n";
  78.118 -
  78.119 -    free_stringlist(keylist4);
  78.120 -
  78.121 -    cout << "opening msg_no_key.asc for reading\n";
  78.122 -    ifstream inFile3 ("msg_no_key.asc");
  78.123 -    assert(inFile3.is_open());
  78.124 -
  78.125 -    string text3;
  78.126 -
  78.127 -    cout << "reading msg_no_key.asc sample\n";
  78.128 -    while (!inFile3.eof()) {
  78.129 -        static string line;
  78.130 -        getline(inFile3, line);
  78.131 -        text3 += line + "\r\n";
  78.132 -    }
  78.133 -    inFile3.close();
  78.134 -
  78.135 -    message *msg5 = nullptr;
  78.136 -    PEP_STATUS status5 = mime_decode_message(text3.c_str(), text3.length(), &msg5);
  78.137 -    assert(status5 == PEP_STATUS_OK);
  78.138 -
  78.139 -    message *msg6 = nullptr;
  78.140 -    stringlist_t *keylist5 = nullptr;
  78.141 -    PEP_rating rating2;
  78.142 -    PEP_decrypt_flags_t flags2;
  78.143 -    flags2 = 0;
  78.144 -    PEP_STATUS status6 = decrypt_message(session, msg5, &msg6, &keylist5, &rating2, &flags2);
  78.145 -    assert(status6 == PEP_DECRYPT_NO_KEY);
  78.146 -    assert(msg6 == NULL);
  78.147 -    assert(keylist5 == NULL);
  78.148 -    assert(rating2 == PEP_rating_have_no_key);
  78.149 -    cout << "rating :" << rating2 << "\n";
  78.150 -    free_stringlist(keylist5);
  78.151 -
  78.152 -    cout << "\nTesting MIME_encrypt_message / MIME_decrypt_message...\n\n";
  78.153 -
  78.154 -    cout << "opening alice_bob_encrypt_test_plaintext_mime.eml for reading\n";
  78.155 -    ifstream inFile4 ("test_mails/alice_bob_encrypt_test_plaintext_mime.eml");
  78.156 -    assert(inFile4.is_open());
  78.157 -    
  78.158 -    string text4;
  78.159 -    
  78.160 -    cout << "reading alice_bob_encrypt_test_plaintext_mime.eml sample\n";
  78.161 -    while (!inFile4.eof()) {
  78.162 -        static string line;
  78.163 -        getline(inFile4, line);
  78.164 -        text4 += line + "\r\n";
  78.165 -    }
  78.166 -    inFile4.close();
  78.167 -    
  78.168 -    const char* out_msg_plain = text4.c_str();
  78.169 -    
  78.170 -//    const char* out_msg_plain = "From: krista@kgrothoff.org\nTo: Volker <vb@pep-project.org>\nSubject: Test\nContent-Type: text/plain; charset=utf-8\nContent-Language: en-US\nContent-Transfer-Encoding:quoted-printable\n\ngaga\n\n";
  78.171 -    char* enc_msg = NULL;
  78.172 -    char* dec_msg = NULL;
  78.173 -
  78.174 -    PEP_STATUS status7 = MIME_encrypt_message(session, text4.c_str(), text4.length(), NULL, &enc_msg, PEP_enc_PGP_MIME, 0);
  78.175 -//    PEP_STATUS status7 = MIME_encrypt_message(session, out_msg_plain, strlen(out_msg_plain), NULL, &enc_msg, PEP_enc_PGP_MIME, 0);
  78.176 -    assert(status7 == PEP_STATUS_OK);
  78.177 -    
  78.178 -    cout << enc_msg << endl;
  78.179 -
  78.180 -    string text5 = enc_msg;
  78.181 -    
  78.182 -    PEP_decrypt_flags_t dec_flags;
  78.183 -    stringlist_t* keys_used;
  78.184 -    
  78.185 -    dec_flags = 0;
  78.186 -    char* modified_src = NULL;
  78.187 -    PEP_STATUS status8 = MIME_decrypt_message(session, text5.c_str(), text5.length(), &dec_msg, &keys_used, &rating, &dec_flags, &modified_src);
  78.188 -    assert(status8 == PEP_STATUS_OK);
  78.189 -    
  78.190 -    cout << dec_msg << endl;
  78.191 -    
  78.192 -    cout << "\nTesting encrypt_message() with enc_format = PEP_enc_none\n\n";
  78.193 -
  78.194 -    message *msg7 = new_message(PEP_dir_outgoing);
  78.195 -    pEp_identity * me7 = new_identity("pep.test.alice@pep-project.org", NULL, PEP_OWN_USERID, "Alice Test");
  78.196 -    identity_list *to7 = new_identity_list(new_identity("pep.test.bob@pep-project.org", NULL, "42", "Bob Test"));
  78.197 -    msg7->from = me7;
  78.198 -    msg7->to = to7;
  78.199 -    msg7->shortmsg = strdup("My Subject");
  78.200 -    msg7->longmsg = strdup("This is some text.\n");
  78.201 -
  78.202 -    message *enc7 = nullptr;
  78.203 -    PEP_STATUS status9 = encrypt_message(session, msg7, NULL, &enc7, PEP_enc_none, 0);
  78.204 -	std::cout << "encrypt_message returned " << std::dec << status9 << std::hex << " (0x" << status9 << ")" << std::dec << endl;
  78.205 -    assert(status9 == PEP_UNENCRYPTED);
  78.206 -    assert(enc7 == nullptr);
  78.207 -    assert(msg7->shortmsg && msg7->longmsg);
  78.208 -    cout << msg7->shortmsg << "\n";
  78.209 -    cout << msg7->longmsg << "\n";
  78.210 -    assert(strcmp(msg7->shortmsg, "My Subject") == 0);
  78.211 -    assert(strcmp(msg7->longmsg, "This is some text.\n") == 0);
  78.212 -    
  78.213 -    cout << "\nfreeing messages…\n";
  78.214 -    free_message(msg7);
  78.215 -    free_message(msg6);
  78.216 -    free_message(msg5);
  78.217 -    free_message(msg4);
  78.218 -    free_message(msg3);
  78.219 -    free_message(msg2);
  78.220 -    free_message(enc_msg2);
  78.221 -    cout << "done.\n";
  78.222 -
  78.223 -    free(enc_msg);
  78.224 -    free(dec_msg);
  78.225 -    cout << "calling release()\n";
  78.226 -    release(session);
  78.227 -    return 0;
  78.228 -}
    79.1 --- a/test/mime_test.cc	Wed May 09 09:51:05 2018 +0200
    79.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    79.3 @@ -1,104 +0,0 @@
    79.4 -// This file is under GNU General Public License 3.0
    79.5 -// see LICENSE.txt
    79.6 -
    79.7 -#include <stdlib.h>
    79.8 -#include <string.h>
    79.9 -#include "platform.h"
   79.10 -
   79.11 -#include <iostream>
   79.12 -#include <fstream>
   79.13 -#include <string>
   79.14 -#include <assert.h>
   79.15 -
   79.16 -#include "mime.h"
   79.17 -
   79.18 -using namespace std;
   79.19 -
   79.20 -void test_mime_decoding(string filename) {
   79.21 -    cout << "opening " << filename << " for reading\n";
   79.22 -    ifstream inFile3 (filename.c_str());
   79.23 -    assert(inFile3.is_open());
   79.24 -
   79.25 -    string mimetext3;
   79.26 -
   79.27 -    cout << "reading mime sample\n";
   79.28 -    while (!inFile3.eof()) {
   79.29 -        static string line;
   79.30 -        getline(inFile3, line);
   79.31 -        mimetext3 += line + "\n";
   79.32 -    }
   79.33 -    inFile3.close();
   79.34 -
   79.35 -    cout << "decoding message…\n";
   79.36 -    message *msg3;
   79.37 -    PEP_STATUS status3 = mime_decode_message(mimetext3.c_str(), mimetext3.length(), &msg3);
   79.38 -    assert(status3 == PEP_STATUS_OK);
   79.39 -    assert(msg3);
   79.40 -    cout << "decoded.\n\n";
   79.41 -    cout << "Subject: " << msg3->shortmsg << "\n\n";
   79.42 -    if (msg3->longmsg)
   79.43 -        cout << msg3->longmsg << "\n\n";
   79.44 -    if (msg3->longmsg_formatted)
   79.45 -        cout << msg3->longmsg_formatted << "\n\n";
   79.46 -    bloblist_t *_b;
   79.47 -    for (_b = msg3->attachments; _b; _b = _b->next) {
   79.48 -        cout << "attachment of type " << _b->mime_type << "\n";
   79.49 -        if (_b->filename) {
   79.50 -            cout << "filename: " << _b->filename << "\n";
   79.51 -            unlink(_b->filename);
   79.52 -            ofstream outFile3(_b->filename);
   79.53 -            outFile3.write(_b->value, _b->size);
   79.54 -            outFile3.close();
   79.55 -        }
   79.56 -    }
   79.57 -
   79.58 -    free_message(msg3);
   79.59 -}
   79.60 -
   79.61 -int main() {
   79.62 -    cout << "\n*** mime_test ***\n\n";
   79.63 -
   79.64 -    PEP_SESSION session;
   79.65 -    
   79.66 -    cout << "calling init()\n";
   79.67 -    PEP_STATUS status1 = init(&session);   
   79.68 -    assert(status1 == PEP_STATUS_OK);
   79.69 -    assert(session);
   79.70 -    cout << "init() completed.\n";
   79.71 -
   79.72 -    // mime test code
   79.73 -
   79.74 -    // testing multipart/alternative
   79.75 -
   79.76 -    message *msg2 = new_message(PEP_dir_incoming);
   79.77 -    assert(msg2);
   79.78 -    msg2->from = new_identity("vb@dingens.org", NULL, NULL, "Volker Birk");
   79.79 -    msg2->to = new_identity_list(new_identity("trischa@dingens.org", NULL, NULL, "Patricia Bädnar")),
   79.80 -    msg2->shortmsg = strdup("my sübject");
   79.81 -
   79.82 -    string text2 = "my mèssage to yoü";
   79.83 -    msg2->longmsg = strdup(text2.c_str());
   79.84 -    string html2 = "<html><body><p>my message to you</p></body></html>";
   79.85 -    msg2->longmsg_formatted = strdup(html2.c_str());
   79.86 -    assert(msg2->longmsg_formatted);
   79.87 -
   79.88 -    cout << "encoding message…\n";
   79.89 -    char *result2;
   79.90 -    PEP_STATUS status2 = mime_encode_message(msg2, false, &result2);
   79.91 -    assert(result2);
   79.92 -    assert(status2 == PEP_STATUS_OK);
   79.93 -
   79.94 -    cout << "result:\n";
   79.95 -    cout << result2 << "\n";
   79.96 -
   79.97 -    free(result2);
   79.98 -    free_message(msg2);
   79.99 -
  79.100 -    test_mime_decoding("msg1.asc");
  79.101 -    test_mime_decoding("msg2.asc");
  79.102 -    test_mime_decoding("msg3.asc");
  79.103 -
  79.104 -    cout << "calling release()\n";
  79.105 -    release(session);
  79.106 -    return 0;
  79.107 -}
    80.1 --- a/test/mistrust_undo_test.cc	Wed May 09 09:51:05 2018 +0200
    80.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    80.3 @@ -1,83 +0,0 @@
    80.4 -// This file is under GNU General Public License 3.0
    80.5 -// see LICENSE.txt
    80.6 -
    80.7 -#include <stdlib.h>
    80.8 -#include <string.h>
    80.9 -#include <time.h>
   80.10 -#include "platform.h"
   80.11 -#include <iostream>
   80.12 -#include <fstream>
   80.13 -#include <assert.h>
   80.14 -#include "mime.h"
   80.15 -#include "message_api.h"
   80.16 -#include "test_util.h"
   80.17 -
   80.18 -using namespace std;
   80.19 -
   80.20 -int main() {
   80.21 -    cout << "\n*** mistrust_undo_test ***\n\n";
   80.22 -
   80.23 -    PEP_SESSION session;
   80.24 -    
   80.25 -    cout << "calling init()\n";
   80.26 -    PEP_STATUS status = init(&session);   
   80.27 -    assert(status == PEP_STATUS_OK);
   80.28 -    assert(session);
   80.29 -    cout << "init() completed.\n";
   80.30 -
   80.31 -    cout << "importing key 0x39E5DAB5." << endl;
   80.32 -    const string pub_key = slurp("test_keys/pub/mistrust.undo.test-0x39E5DAB5_pub.asc");
   80.33 -
   80.34 -    assert(pub_key.length() != 0);
   80.35 -    
   80.36 -    PEP_STATUS statuspub = import_key(session, pub_key.c_str(), pub_key.length(), NULL);
   80.37 -    assert(statuspub == PEP_STATUS_OK);
   80.38 -    cout << "Key imported." << endl << endl;
   80.39 -    
   80.40 -    cout << "Setting up identity for mistrust.undo.test@pep-project.org and making comm_type PEP_ct_pEp."  << endl;
   80.41 -    pEp_identity* recip1 = new_identity("mistrust.undo.test@pep-project.org", NULL, "TOFU_mistrust.undo.test@pep-project.org", "Mistrust Undo");
   80.42 -    status = update_identity(session,recip1);
   80.43 -    assert(status == PEP_STATUS_OK);
   80.44 -    assert(strcmp(recip1->fpr, "BACC7A60A88A39A25D99B4A545D7542F39E5DAB5") == 0);
   80.45 -    
   80.46 -    // First, we need the fpr to be in the DB system.
   80.47 -    status = set_identity(session,recip1);
   80.48 -    // Then we update the trust.
   80.49 -    // This is not an external function. We use it to expedite the test since we don't do a sync exchange here.
   80.50 -    status = update_trust_for_fpr(session, recip1->fpr, PEP_ct_pEp);
   80.51 -    // Then we retrieve the new trust.
   80.52 -    status = update_identity(session,recip1);
   80.53 -    assert(status == PEP_STATUS_OK);
   80.54 -    assert(recip1->comm_type == PEP_ct_pEp);
   80.55 -    assert(strcmp(recip1->fpr, "BACC7A60A88A39A25D99B4A545D7542F39E5DAB5") == 0);
   80.56 -    cout << "mistrust.undo.test@pep-project.org set up and comm_type is PEP_ct_pEp."  << endl << endl;
   80.57 -
   80.58 -    // Ok, mistrust away
   80.59 -    cout << "Mistrusting mistrust.undo.test@pep-project.org (BACC7A60A88A39A25D99B4A545D7542F39E5DAB5)."  << endl;   
   80.60 -    status = key_mistrusted(session, recip1);
   80.61 -    assert(status == PEP_STATUS_OK);
   80.62 -    status = update_identity(session,recip1);
   80.63 -    assert(status == PEP_STATUS_OK);
   80.64 -    assert(recip1->comm_type == PEP_ct_key_not_found);
   80.65 -    recip1->fpr = strdup("BACC7A60A88A39A25D99B4A545D7542F39E5DAB5");
   80.66 -    status = get_trust(session, recip1);
   80.67 -    assert(recip1->comm_type == PEP_ct_mistrusted);
   80.68 -     
   80.69 -    cout << "Mistrusted mistrust.undo.test@pep-project.org (BACC7A60A88A39A25D99B4A545D7542F39E5DAB5) and comm_type IN DB set to PEP_ct_mistrusted)." << endl  << endl;    
   80.70 -    
   80.71 -    cout << "Undo mistrust (restore identity and trust in DB)" << endl;
   80.72 -    // Undo it
   80.73 -    status = undo_last_mistrust(session);
   80.74 -    assert(status == PEP_STATUS_OK);
   80.75 -    status = update_identity(session, recip1);
   80.76 -    assert(recip1->comm_type == PEP_ct_pEp);
   80.77 -    assert(strcmp(recip1->fpr, "BACC7A60A88A39A25D99B4A545D7542F39E5DAB5") == 0);
   80.78 -    cout << "Undo mistrust (restore identity and trust in DB) - trust is now PEP_ct_pEp." << endl << endl;
   80.79 -
   80.80 -    cout << "Success!!!" << endl << endl;
   80.81 -    
   80.82 -    free_identity(recip1);
   80.83 -    release(session);
   80.84 -
   80.85 -    return 0;
   80.86 -}
    81.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    81.2 +++ b/test/msg_2.0.asc	Fri May 11 08:58:04 2018 +0200
    81.3 @@ -0,0 +1,87 @@
    81.4 +From: Alice Test <pep.test.alice@pep-project.org>
    81.5 +To: Carol Test <pep-test-carol@pep-project.org>
    81.6 +Subject: =?utf-8?Q?p=E2=89=A1p?=
    81.7 +References: <one-839274982347239847@pep-project.org>
    81.8 + <two-dfddffd839274982347239847@pep-project.org>
    81.9 + <three-OMGWTFBBQ.edfddffd839274982347239847@pep-project.org>
   81.10 +X-pEp-Version: 2.0
   81.11 +MIME-Version: 1.0
   81.12 +Content-Type: multipart/mixed; boundary="575522c015668e2f9cbd60105375cc"
   81.13 +
   81.14 +--575522c015668e2f9cbd60105375cc
   81.15 +Content-Type: text/plain; charset="utf-8"
   81.16 +Content-Transfer-Encoding: quoted-printable
   81.17 +Content-Disposition: inline; filename="msg.txt"
   81.18 +
   81.19 +this message was encrypted with p=E2=89=A1p https://pEp-project.org
   81.20 +--575522c015668e2f9cbd60105375cc
   81.21 +Content-Type: application/pgp-encrypted
   81.22 +
   81.23 +Version: 1
   81.24 +--575522c015668e2f9cbd60105375cc
   81.25 +Content-Type: application/octet-stream
   81.26 +Content-Disposition: attachment; filename="msg.asc"
   81.27 +
   81.28 +-----BEGIN PGP MESSAGE-----
   81.29 +
   81.30 +hQEMA1oCBdlzCD9NAQf+J35kigceuUv7sH8/z+fhiFkBjrDuppkEWQRE7/XrD1Br
   81.31 +YTIjoOpg4t/NrYXNIlXplnvuv+iXCpc2pKh7IySdgkROE3tDCEDkU6eAMOywsLbI
   81.32 +2T/UZ8fwr/4UOmSyfba4QkUhKUg+Qh165pGKNzMfwdSPbLl2eWexTRwRSQGrNoq6
   81.33 +WxfqwjIknXEGzb+O1duxbTszZooJC78c1vwwiZhU9PgjDsuQi/elkB8xkeq2cNen
   81.34 +pGDvODb2rp+lWpEIKbPiS6uOQLto2hJ3j80sWdgwwrcEOrtlfqwjWFCBJXQCGNOF
   81.35 +QlJ+X5obaSz3eWfSUFI8hyOJRCOpygsiAQVJ/FgSM4UBDAOo6/9vKSPoQgEH/jON
   81.36 +1PMlicRZU1kv2M/sdhWcO/kkz+5UNmciPglGX/KbS4TvIsulRoym3Z2HoTChTeKr
   81.37 +8bnBrLQazgqUtpP58gfLksQvbRkDW/tYPntgyvoWQst9i4NJhQv9soyfuJGkewpV
   81.38 +s4uBj//kEBPOtlBRVnFTnETBkSt3VxmMIPVnSne+X4pHIPk2lDquPI268HgLWiIZ
   81.39 +XdvsbIChLlykaMUBJDu5vULaBnNre6A7gJa2cn60BDnfE+PLahiBEssWT2SCJgOk
   81.40 +1gBuiuHD5Ld0PN8ZCPXeQ7WnugNfjS3atPGzUMKGbh4Iik4qF/iO/h6MXXJbLk2t
   81.41 +jk9A43x7jQr5V2D0SvvS6wH3z465jR/j1Qysm+YP+Ji6EMlc9nWsSI5tesrMEMUn
   81.42 +TbwjjLMJsSaufKVgd139lXiyr29NDogwfZb29qLcvGOU53MQXf6TBrcrFJDfOUaz
   81.43 +gcWvBczS89G3hfBxy3yn9ID5jdd24/gndCGv0Ps2g902tdt7sN3Y/wcGHpdvgDpR
   81.44 +MO3MkFVbevjyqcslYlr7/r8bvXXdST5eFRuq96xsT2smbanLLoIrt4j57K0d0ELx
   81.45 +DYh/Iq6JmnU0SEhElqg+VPvQVsWRIpcrjkMxvjV1v5z7Gx9YbUv5G2akW2BoMNMG
   81.46 +dq4372U1QXpvw+efpr9VGGQlTJLcXy5XJdmz/n+bt3XG7M6PA45Soj83E+84cNwM
   81.47 +lHT02edZnqQC6Tw1x5yLWby1KgKtajgNYw0qL6pZWRz5sO37Kms3gFUiMST6QANA
   81.48 +7JeBulhvBZiigcOq9vQIKg98JXuSzquIQUW8pCdf3xZ/FuAz28DdIBVep+Kaaujk
   81.49 +n5DqwyxmEBrJJEv4uuZBoWngBiyU++gJX/nItzqF40bWYts4v4tzkFlRa6kuE5Pq
   81.50 +h2vO8TvMt+IuYedy7DKNzpNYfSmC+KJyk8ffCZPVQPId/beDJLU4Aq3ONi99Len2
   81.51 +DoZFPVhENXw+wl4R0jyERr/d/E18QcF/HJz/YDJR8pfb4zUJPUIkbjt5+lSo/RB7
   81.52 +6gKzKJltvz6eB5dNkZ0LZbe2fJ7YnXQxQR1nEt+FPuoPiJ7JOXYOktSSwaAZ6cXW
   81.53 +KbXRTsTQ2A7YSCeQF+WJNLDl93OAJqRaJOrvjGiJ8+WQjFZX44GYV+3NXuuK8ufZ
   81.54 +twGVLOj6cM0rHyAi7BykQ2XK5fxFhEspK4ck7Nh7h9wCAgwEWFapTe7JjSqaJaGS
   81.55 +Si+CA5tZNIp6TsfNEt68QoCqzheEP95xI873QvCt3cMK3HXC2CbDic58RghWv2bZ
   81.56 +8QraqeHntJHhvxi5jXjBEZeqjf/WgAo5Y7hufmN2FIYeQBzy6nHkl9pIhz18JFKm
   81.57 +NJDRYXvUsTPcPjY1wTWN0MXoRVBNfgiZ+rkzGKZViqTlhLXmE8MgpqFcUQKJzn0i
   81.58 +IcvAvaG3pCXgSoJRCxqEC+cyX2KDMpcanqphddFLCYhkya5+1uzcW0vrNpfH7cs1
   81.59 +4sW4iqNrc91cHSOLs59i+dzAI73pk5YLwZhRCqOVA5EwWsJoic59iOvu+el8sgOj
   81.60 +PaYdIz8pGiDquuSye3JObp4aJblDP1LqAnUFS7mL4vpj4pc5jSaHq22lYYwA4kME
   81.61 +hUn8ES4+0RrLDOzkj4VEI43jlMBG16Zr+uxbawERrIJeOXrhBiVn4UCutr8DS8wG
   81.62 +RGD6x5t25/SXvV2FYNkO7RMpFg7dIYM2cNm3W9GUVZ5bdDzKcYONuNyfkDvgx1T8
   81.63 +2Qz57aUNasRKA9c6J8s+jihz63fii9aau7Npb2JSkpmedyQV9sLll3sycxjOcnoF
   81.64 +i5zFkDCy+sgNo7wRzkOkkjuQyjn0RoMIQJv7tUVnoBJPpZYkOStteryH3NJdvXd/
   81.65 +Yl4qb6KeE6EvTyjnf5DDdOFKPzLJBPyHS+3i4MfqvPz/KHXR7wNVy5Dvemcqjadc
   81.66 +N6zGlRVIL5DpgZXhO4lCt+VeqPFKvbO+1lU3IA5SVaeUmgpGbpoyLWsrcdbEUiaZ
   81.67 +rGTycegXOCunDrRRDR6org83shONzY3N3MUvJvH1rnSm4cJCaAja91MVRer3qs4M
   81.68 +i9FlWQjGksFNt5fezxESzvMotbfGh7MOepYZOXjbGijmqA1CSsUW9abhb9r0VeXU
   81.69 +brWlCJjNsBwvvGTvlBOcoJVXliA5Hp8gixL9XmBD51SsfNUMKupSOGEObIHvVCFG
   81.70 +9blBt+HgvaGj5XIzGLHm2BHah1bnex6zzgYZEpBwe7M2Y8IF4x61kEBy0BrFw6ID
   81.71 +rn76e8av9uF3Ps8p60mP4fBmNHQXRMRfkync5S563dHiHdkKzEy0e2CGCf8jup2q
   81.72 +3Dvur75MVsBce3FjOeUmWRhIQpsWHDzC+KpHGGkOakXbu7cK44x1KktZN37XdPGd
   81.73 +3VlBV8cgAQATeoFStPZTV9OUcKPWXDa+xF2uKZbY2P/c3KLvdlE9JRXCCvjVtkil
   81.74 +z+v15GJ69rMqjjrfEfFasWpWb0kck91GctAN1RGdVRq5mPHjcauPLONC0swG+uM6
   81.75 +WzupJFdlvlxA8LgAOa3tScTJfq7iY1yyqu4brte4479eJtys4IfqFKMo9cmGRCtv
   81.76 +Wkh65Z7zuV+MqwTyffgi9POu4HAqvfI8Xpt1I3iEx6WWIYsJYZBg6o/XqlNjvtiX
   81.77 +ejfTfxy/VqCOXT2oha5zbm0Fv8K6r3nLWNW8ZXbTvQOKoRBBTzB+b9sGaN+0mhIR
   81.78 +FCBP7D9plmeIzl7HwCBzqcaa/eIEoEkpHTnw1vFESqVbvRLUmHtBK/WPhOG6+M4h
   81.79 +4S2hLmj2jI0PJEmHQk3h1ICY9CAk9UvRRwdlcNhUDNrsYnpCNN7Oojp6LaJK5t7S
   81.80 +rBQOiE8gsGTBiyk8hZPT6hUXHA1IBbsOAI27kBhvQZztSlg1Ua2GxBBv+g9VRvxg
   81.81 +//kX1TXXLAYWJkwhrX4+aFQxFzOS6lBUb3z4bFDuRWPg+EfsISCvAWjdfqcnQpfC
   81.82 +lveWi+zqdA562WiT0MypYFSbm4S4uIo1s7aHIbziY8bIKMN9cMEf2PthM9TvPeWw
   81.83 +ryxOu63gQ3lJjtyEH+aoKOXGD7BXsHYk2Vu8l23Qt/nEQmF2ly5paET97RmjXmqU
   81.84 +ckNfjhrPn9LIIgAT2c8bwlXKQRcwA2mZCs+mPI5iXdT9eD0NLu0xMpbewATQ+/X3
   81.85 +qF17ExhcUuRnAvuNKtMG4woQVtOTO5Hv7cCQQ09seYczLT/8bvS5vj8KHfuKBktI
   81.86 +YLLGlEFMAVbSvS2sge10lcXJlg==
   81.87 +=EixP
   81.88 +-----END PGP MESSAGE-----
   81.89 +
   81.90 +--575522c015668e2f9cbd60105375cc--
    82.1 --- a/test/new_update_id_and_myself_test.cc	Wed May 09 09:51:05 2018 +0200
    82.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    82.3 @@ -1,622 +0,0 @@
    82.4 -// This file is under GNU General Public License 3.0
    82.5 -// see LICENSE.txt
    82.6 -
    82.7 -#include <iostream>
    82.8 -#include <iostream>
    82.9 -#include <fstream>
   82.10 -#include <string>
   82.11 -#include <cstring> // for strcmp()
   82.12 -#include <assert.h>
   82.13 -#include "pEpEngine.h"
   82.14 -#include "message_api.h"
   82.15 -#include "keymanagement.h"
   82.16 -#include "test_util.h"
   82.17 -
   82.18 -using namespace std;
   82.19 -
   82.20 -int main() {
   82.21 -    cout << "\n*** test update_identity and myself ***\n\n";
   82.22 -    
   82.23 -    test_init();
   82.24 -    
   82.25 -    PEP_SESSION session;
   82.26 -    
   82.27 -    cout << "calling init()\n";
   82.28 -    PEP_STATUS status = init(&session);
   82.29 -    assert(status == PEP_STATUS_OK);
   82.30 -    assert(session);
   82.31 -    cout << "init() completed.\n";
   82.32 -    cout << endl;
   82.33 -    cout << "***********************************************************************" << endl;
   82.34 -    cout << "* Section I. myself()" << endl;
   82.35 -    cout << "***********************************************************************" << endl << endl;
   82.36 -
   82.37 -    // Create id with no key
   82.38 -    cout << "Creating new own id with no key for : ";
   82.39 -    char *uniqname = strdup("AAAAtestuser@testdomain.org");
   82.40 -    srandom(time(NULL));
   82.41 -    for(int i=0; i < 4;i++)
   82.42 -        uniqname[i] += random() & 0xf;
   82.43 -    
   82.44 -    cout << uniqname << "\n";
   82.45 -    
   82.46 -    const char* own_user_id = get_new_uuid();
   82.47 -    const char* start_username = "Unser Testkandidat";
   82.48 -
   82.49 -    pEp_identity * new_me = new_identity(uniqname, NULL, own_user_id, start_username);
   82.50 -    
   82.51 -    cout << "***********************************************************************" << endl;
   82.52 -    cout << "* I: 1. myself() on id with no record in the DB and no input fpr" << endl;
   82.53 -    cout << "***********************************************************************" << endl << endl;
   82.54 -    status = myself(session, new_me);
   82.55 -    assert(status == PEP_STATUS_OK);
   82.56 -    assert(new_me->fpr);
   82.57 -    
   82.58 -    cout << "PASS: myself() generated fingerprint ";
   82.59 -    cout << new_me->fpr << endl << endl;
   82.60 -
   82.61 -    char* generated_fpr = strdup(new_me->fpr);
   82.62 -    
   82.63 -    assert(new_me->comm_type == PEP_ct_pEp);
   82.64 -    
   82.65 -    free_identity(new_me);
   82.66 -
   82.67 -    cout << "***********************************************************************" << endl;
   82.68 -    cout << "* I: 2. myself() on id with no input fpr and a record in the DB" << endl;
   82.69 -    cout << "***********************************************************************" << endl << endl;
   82.70 -
   82.71 -    new_me = new_identity(uniqname, NULL, own_user_id, NULL);
   82.72 -    status = myself(session, new_me);
   82.73 -    assert(status == PEP_STATUS_OK);
   82.74 -    
   82.75 -    assert(new_me->fpr);
   82.76 -    assert(strcmp(new_me->fpr, generated_fpr) == 0);
   82.77 -    assert(new_me->username);
   82.78 -    assert(strcmp(new_me->username, start_username) == 0);
   82.79 -    assert(new_me->user_id);
   82.80 -    assert(new_me->comm_type == PEP_ct_pEp);
   82.81 -    
   82.82 -    char* default_own_id = NULL;
   82.83 -    status = get_userid_alias_default(session, own_user_id, &default_own_id);
   82.84 -    if (status == PEP_CANNOT_FIND_ALIAS) {
   82.85 -        // Ok, we presume our own id above is the default (should be true if there was no existing DB as in test env)
   82.86 -        default_own_id = strdup(own_user_id);
   82.87 -    }
   82.88 -
   82.89 -    assert(strcmp(new_me->user_id, default_own_id) == 0);
   82.90 -    
   82.91 -    cout << "PASS: myself() retrieved the correct fpr, username and default user id" << endl << endl;
   82.92 -
   82.93 -    free_identity(new_me);
   82.94 -     
   82.95 -    cout << "****************************************************************************************" << endl;
   82.96 -    cout << "* I: 3. myself() on id with no input fpr, a different user_id, and a record in the DB" << endl;
   82.97 -    cout << "****************************************************************************************" << endl << endl;
   82.98 -
   82.99 -    const char* alias_id = "Huss Es El Mejor Presidente Del Mundo!";
  82.100 -
  82.101 -    new_me = new_identity(uniqname, NULL, alias_id, NULL);
  82.102 -    status = myself(session, new_me);
  82.103 -    assert(status == PEP_STATUS_OK);
  82.104 -    
  82.105 -    assert(new_me->fpr);
  82.106 -    assert(strcmp(new_me->fpr, generated_fpr) == 0);
  82.107 -    assert(new_me->username);
  82.108 -    assert(strcmp(new_me->username, start_username) == 0);
  82.109 -    assert(new_me->user_id);
  82.110 -    assert(strcmp(new_me->user_id, default_own_id) == 0);
  82.111 -    assert(new_me->comm_type == PEP_ct_pEp);
  82.112 -    
  82.113 -    char* tmp_def = NULL;
  82.114 -    
  82.115 -    status = get_userid_alias_default(session, alias_id, &tmp_def);
  82.116 -    assert(status == PEP_STATUS_OK);
  82.117 -    assert(strcmp(tmp_def, default_own_id) == 0);
  82.118 -
  82.119 -    cout << "PASS: myself() retrieved the correct fpr, username and default user id, and put the right alias in for the default";
  82.120 -    cout << endl << endl;
  82.121 -    
  82.122 -    free(tmp_def);
  82.123 -    free_identity(new_me);
  82.124 -
  82.125 -    cout << "****************************************************************************************" << endl;
  82.126 -    cout << "* I: 4. myself(), replace fpr" << endl;
  82.127 -    cout << "****************************************************************************************" << endl << endl;
  82.128 -
  82.129 -    new_me = new_identity(uniqname, NULL, alias_id, start_username);
  82.130 -    status = generate_keypair(session, new_me);
  82.131 -    assert(new_me->fpr);
  82.132 -    
  82.133 -    cout << "Generated fingerprint ";
  82.134 -    cout << new_me->fpr << "\n";
  82.135 -
  82.136 -    char* new_fpr = strdup(new_me->fpr);
  82.137 -
  82.138 -    status = set_own_key(session, new_me, new_fpr);
  82.139 -    assert(status == PEP_STATUS_OK);
  82.140 -    assert(new_me->fpr);
  82.141 -    assert(strcmp(new_me->fpr, generated_fpr) != 0);
  82.142 -    assert(strcmp(new_me->fpr, new_fpr) == 0);
  82.143 -    assert(new_me->username);
  82.144 -    assert(strcmp(new_me->username, start_username) == 0);
  82.145 -    assert(new_me->user_id);
  82.146 -    assert(strcmp(new_me->user_id, default_own_id) == 0);
  82.147 -    assert(new_me->me);
  82.148 -    assert(new_me->comm_type == PEP_ct_pEp);
  82.149 -
  82.150 -    cout << "PASS: myself() set and retrieved the new fpr, username and default user id, and put the right alias in for the default";
  82.151 -    cout << endl << endl;
  82.152 -
  82.153 -    // since that worked, we'll set it back as the default
  82.154 -    free(new_me->fpr);
  82.155 -    new_me->fpr = strdup(generated_fpr);
  82.156 -    new_me->comm_type = PEP_ct_unknown;
  82.157 -    status = set_own_key(session, new_me, generated_fpr);
  82.158 -    assert(status == PEP_STATUS_OK);
  82.159 -    assert(strcmp(new_me->fpr, generated_fpr) == 0);
  82.160 -    assert(new_me->comm_type == PEP_ct_pEp);
  82.161 -    
  82.162 -    cout << "****************************************************************************************" << endl;
  82.163 -    cout << "* I: 5. myself(), replace fpr, revoke key" << endl;
  82.164 -    cout << "****************************************************************************************" << endl << endl;
  82.165 -
  82.166 -    status = revoke_key(session, generated_fpr, "Because it's fun");
  82.167 -    assert (status == PEP_STATUS_OK);
  82.168 -    
  82.169 -    new_me = new_identity(uniqname, NULL, alias_id, start_username);
  82.170 -    
  82.171 -    status = set_own_key(session, new_me, new_fpr);
  82.172 -    assert(status == PEP_STATUS_OK);
  82.173 -    assert(new_me->fpr);
  82.174 -    assert(strcmp(new_me->fpr, generated_fpr) != 0);
  82.175 -    assert(new_me->username);
  82.176 -    assert(strcmp(new_me->username, start_username) == 0);
  82.177 -    assert(new_me->user_id);
  82.178 -    assert(strcmp(new_me->user_id, default_own_id) == 0);
  82.179 -    assert(new_me->me);
  82.180 -    assert(new_me->comm_type == PEP_ct_pEp);
  82.181 -    
  82.182 -    cout << "PASS: myself() retrieved the new fpr, username and default user id, and put the right alias in for the default";
  82.183 -    cout << endl << endl;
  82.184 -        
  82.185 -    cout << "***********************************************************************" << endl;
  82.186 -    cout << "* Section II. update_identity()" << endl;
  82.187 -    cout << "***********************************************************************" << endl << endl;
  82.188 -
  82.189 -    cout << "****************************************************************************************" << endl;
  82.190 -    cout << "* II: 1. update_identity() - get identity with matching address and user_id and username" << endl;
  82.191 -    cout << "****************************************************************************************" << endl << endl;    
  82.192 -    // 1. create original identity
  82.193 -    const char* alex_address = "pep.test.alexander@peptest.ch";
  82.194 -    const char* alex_fpr = "3AD9F60FAEB22675DB873A1362D6981326B54E4E";
  82.195 -    const char* alex_userid = "Alex";
  82.196 -    const char* alex_username = "SuperDuperAlex";
  82.197 -    const string alex_pub_key = slurp("test_keys/pub/pep.test.alexander-0x26B54E4E_pub.asc");
  82.198 -    
  82.199 -    PEP_STATUS statuspub = import_key(session, alex_pub_key.c_str(), alex_pub_key.length(), NULL);
  82.200 -    assert(statuspub == PEP_STATUS_OK);
  82.201 -
  82.202 -    pEp_identity* alex = new_identity(alex_address, alex_fpr, alex_userid, alex_username);
  82.203 -
  82.204 -    // 2. set identity
  82.205 -    status = set_identity(session, alex);
  82.206 -    assert(status == PEP_STATUS_OK);
  82.207 -    free_identity(alex);
  82.208 -            
  82.209 -    alex = new_identity(alex_address, NULL, alex_userid, alex_username); 
  82.210 -    status = update_identity(session, alex);
  82.211 -    assert(status == PEP_STATUS_OK);
  82.212 -    assert(alex->fpr);
  82.213 -    assert(strcmp(alex->fpr, alex_fpr) == 0);
  82.214 -    assert(alex->username);
  82.215 -    assert(strcmp(alex->username, alex_username) == 0);
  82.216 -    assert(alex->user_id);
  82.217 -    assert(strcmp(alex->user_id, alex_userid) == 0);
  82.218 -    assert(!alex->me); 
  82.219 -    assert(alex->comm_type == PEP_ct_OpenPGP_unconfirmed);
  82.220 -    assert(strcmp(alex->address, alex_address) == 0);
  82.221 -
  82.222 -    cout << "PASS: update_identity() correctly retrieved extant record with matching address, id, and username" << endl << endl;
  82.223 -    free_identity(alex);
  82.224 -
  82.225 -    cout << "****************************************************************************************" << endl;
  82.226 -    cout << "* II: 2. update_identity() - get identity with matching address and user_id and new username" << endl;
  82.227 -    cout << "****************************************************************************************" << endl << endl;    
  82.228 -
  82.229 -    const char* new_username = "Test Patchy";
  82.230 -            
  82.231 -    alex = new_identity(alex_address, NULL, alex_userid, new_username);
  82.232 -    cout << "Timing is everything" << endl; 
  82.233 -    status = update_identity(session, alex);
  82.234 -    assert(status == PEP_STATUS_OK);
  82.235 -    assert(alex->fpr);
  82.236 -    assert(strcmp(alex->fpr, alex_fpr) == 0);
  82.237 -    assert(alex->username);
  82.238 -    assert(strcmp(alex->username, new_username) == 0);
  82.239 -    assert(alex->user_id);
  82.240 -    assert(strcmp(alex->user_id, alex_userid) == 0);
  82.241 -    assert(!alex->me); 
  82.242 -    assert(alex->comm_type == PEP_ct_OpenPGP_unconfirmed);
  82.243 -    assert(strcmp(alex->address, alex_address) == 0);
  82.244 -
  82.245 -    cout << "PASS: update_identity() correctly retrieved extant record with matching address and id, and patched username" << endl << endl;
  82.246 -    free_identity(alex);
  82.247 -
  82.248 -    cout << "****************************************************************************************" << endl;
  82.249 -    cout << "* II: 3. update_identity() - get identity with matching address and user_id only" << endl;
  82.250 -    cout << "****************************************************************************************" << endl << endl;    
  82.251 -        
  82.252 -    alex = new_identity(alex_address, NULL, alex_userid, NULL); 
  82.253 -    status = update_identity(session, alex);
  82.254 -    assert(status == PEP_STATUS_OK);
  82.255 -    assert(alex->fpr);
  82.256 -    assert(strcmp(alex->fpr, alex_fpr) == 0);
  82.257 -    assert(alex->username);
  82.258 -    assert(strcmp(alex->username, new_username) == 0);
  82.259 -    assert(alex->user_id);
  82.260 -    assert(strcmp(alex->user_id, alex_userid) == 0);
  82.261 -    assert(!alex->me); 
  82.262 -    assert(alex->comm_type == PEP_ct_OpenPGP_unconfirmed);
  82.263 -    assert(strcmp(alex->address, alex_address) == 0);
  82.264 -
  82.265 -    cout << "PASS: update_identity() correctly retrieved extant record with matching address and id, and patched username" << endl << endl;
  82.266 -    free_identity(alex);
  82.267 -
  82.268 -    cout << "****************************************************************************************" << endl;
  82.269 -    cout << "* II: 4. update_identity() - get identity with just address and username" << endl;
  82.270 -    cout << "****************************************************************************************" << endl << endl;    
  82.271 -
  82.272 -    alex = new_identity(alex_address, NULL, NULL, new_username); 
  82.273 -    status = update_identity(session, alex);
  82.274 -    assert(status == PEP_STATUS_OK);
  82.275 -    assert(alex->fpr);
  82.276 -    assert(strcmp(alex->fpr, alex_fpr) == 0);
  82.277 -    assert(alex->username);
  82.278 -    assert(strcmp(alex->username, new_username) == 0);
  82.279 -    assert(alex->user_id);
  82.280 -    assert(strcmp(alex->user_id, alex_userid) == 0);
  82.281 -    assert(!alex->me); 
  82.282 -    assert(alex->comm_type == PEP_ct_OpenPGP_unconfirmed);
  82.283 -    assert(strcmp(alex->address, alex_address) == 0);
  82.284 -
  82.285 -    cout << "PASS: update_identity() correctly retrieved extant record with matching address and username" << endl << endl;
  82.286 -    free_identity(alex);
  82.287 -
  82.288 -    cout << "****************************************************************************************" << endl;
  82.289 -    cout << "* II: 5. update_identity() with just address " << endl;
  82.290 -    cout << "****************************************************************************************" << endl << endl;
  82.291 -    
  82.292 -    alex = new_identity(alex_address, NULL, NULL, NULL); 
  82.293 -    status = update_identity(session, alex);
  82.294 -    assert(status == PEP_STATUS_OK);
  82.295 -    assert(alex->fpr);
  82.296 -    assert(strcmp(alex->fpr, alex_fpr) == 0);
  82.297 -    assert(alex->username);
  82.298 -    assert(strcmp(alex->username, new_username) == 0);
  82.299 -    assert(alex->user_id);
  82.300 -    assert(strcmp(alex->user_id, alex_userid) == 0);
  82.301 -    assert(!alex->me); 
  82.302 -    assert(alex->comm_type == PEP_ct_OpenPGP_unconfirmed);
  82.303 -    assert(strcmp(alex->address, alex_address) == 0);
  82.304 -
  82.305 -    cout << "PASS: update_identity() correctly retrieved extant record with just matching address. Retrieved previously patched username." << endl << endl;
  82.306 -    free_identity(alex);
  82.307 -
  82.308 -
  82.309 -    cout << "****************************************************************************************" << endl;
  82.310 -    cout << "* II: 6. update_identity() with just address on own identity (only case where this is legal)" << endl;
  82.311 -    cout << "****************************************************************************************" << endl << endl;
  82.312 -    
  82.313 -    pEp_identity* somebody = new_identity(uniqname, NULL, NULL, NULL); 
  82.314 -    status = update_identity(session, somebody);
  82.315 -    assert(status == PEP_STATUS_OK);
  82.316 -    myself(session, somebody);
  82.317 -    assert(somebody->fpr);
  82.318 -    assert(strcmp(somebody->fpr, new_fpr) == 0);
  82.319 -    assert(somebody->username);
  82.320 -    assert(strcmp(somebody->username, start_username) == 0);
  82.321 -    assert(somebody->user_id);
  82.322 -    assert(strcmp(somebody->user_id, default_own_id) == 0);
  82.323 -    assert(somebody->me); // true in this case, as it was an own identity
  82.324 -    assert(somebody->comm_type == PEP_ct_pEp);
  82.325 -    assert(strcmp(somebody->address, uniqname) == 0);
  82.326 -    
  82.327 -    cout << "PASS: update_identity() retrieved the right identity information given just an address";
  82.328 -    cout << endl << endl;
  82.329 -
  82.330 -    free_identity(somebody);
  82.331 -
  82.332 -    cout << "****************************************************************************************" << endl;
  82.333 -    cout << "* II: 7. update_identity() for address and user_id that don't exist" << endl;
  82.334 -    cout << "****************************************************************************************" << endl << endl;
  82.335 -
  82.336 -    somebody = new_identity("nope@nope.nope", NULL, "some_user_id", NULL); 
  82.337 -    status = update_identity(session, somebody);
  82.338 -    assert(status == PEP_STATUS_OK);
  82.339 -    assert(!somebody->fpr);
  82.340 -    assert(somebody->comm_type == PEP_ct_key_not_found);
  82.341 -    
  82.342 -    cout << "PASS: update_identity() returns identity with no key and unknown comm type" << endl << endl;
  82.343 -
  82.344 -    free_identity(somebody);
  82.345 -    
  82.346 -    cout << "****************************************************************************************" << endl;
  82.347 -    cout << "* II: 8. update_identity() for address and and username, but non-matching temp user_id" << endl;
  82.348 -    cout << "****************************************************************************************" << endl << endl;
  82.349 -
  82.350 -    // 1. create identity
  82.351 -    const char* bella_address = "pep.test.bella@peptest.ch";
  82.352 -    const char* bella_fpr = "5631BF1357326A02AA470EEEB815EF7FA4516AAE";
  82.353 -    const char* bella_userid = "TOFU_pep.test.bella@peptest.ch"; // simulate temp ID
  82.354 -    const char* bella_username = "Annabella the Great";
  82.355 -    const string bella_pub_key = slurp("test_keys/pub/pep.test.bella-0xAF516AAE_pub.asc");
  82.356 -    
  82.357 -    statuspub = import_key(session, bella_pub_key.c_str(), bella_pub_key.length(), NULL);
  82.358 -    assert(statuspub == PEP_STATUS_OK);
  82.359 -
  82.360 -    pEp_identity* bella = new_identity(bella_address, bella_fpr, bella_userid, bella_username);
  82.361 -    
  82.362 -    // 2. set identity
  82.363 -    status = set_identity(session, bella);
  82.364 -    assert(status == PEP_STATUS_OK);
  82.365 -    free_identity(bella);
  82.366 -    
  82.367 -    const char* not_my_userid = "Bad Company";
  82.368 -            
  82.369 -    bella = new_identity(bella_address, NULL, not_my_userid, bella_username); 
  82.370 -    status = update_identity(session, bella);
  82.371 -    assert(status == PEP_STATUS_OK);
  82.372 -    assert(bella->fpr);
  82.373 -    assert(strcmp(bella->fpr, bella_fpr) == 0);
  82.374 -    assert(bella->username);
  82.375 -    assert(strcmp(bella->username, bella_username) == 0);
  82.376 -    assert(bella->user_id);
  82.377 -    assert(strcmp(bella->user_id, not_my_userid) == 0); // ???
  82.378 -    assert(!bella->me); 
  82.379 -    assert(bella->comm_type == PEP_ct_OpenPGP_unconfirmed);
  82.380 -    assert(strcmp(bella->address, bella_address) == 0);
  82.381 -
  82.382 -    cout << "PASS: update_identity() correctly retrieved extant record with matching address and username; temp user_id in DB patched" << endl << endl;
  82.383 -    free_identity(bella);
  82.384 -
  82.385 -    cout << "****************************************************************************************" << endl;
  82.386 -    cout << "* II: 9. update_identity() for address, username, and user_id, but no matching record" << endl;
  82.387 -    cout << "****************************************************************************************" << endl << endl;
  82.388 -    
  82.389 -    const char* rando_name = "Pickley BoofBoof";
  82.390 -    const char* rando_userid = "Boofy";
  82.391 -    const char* rando_address = "boof@pickles.org";
  82.392 -    somebody = new_identity(rando_address, NULL, rando_userid, rando_name);
  82.393 -    status = update_identity(session, somebody);
  82.394 -
  82.395 -    assert(status == PEP_STATUS_OK);
  82.396 -    assert(!somebody->fpr || somebody->fpr[0] == '\0');
  82.397 -    assert(somebody->username);
  82.398 -    assert(strcmp(somebody->username, rando_name) == 0);
  82.399 -    assert(somebody->user_id);
  82.400 -    assert(strcmp(somebody->user_id, rando_userid) == 0); // ???
  82.401 -    assert(!somebody->me); 
  82.402 -    assert(somebody->comm_type == PEP_ct_key_not_found);
  82.403 -    assert(strcmp(somebody->address, rando_address) == 0);
  82.404 -
  82.405 -    cout << "PASS: update_identity() correctly created record with no key" << endl << endl;
  82.406 -    free_identity(somebody);
  82.407 -    
  82.408 -    cout << "****************************************************************************************" << endl;
  82.409 -    cout << "* II: 10. update_identity() for address, username, but no matching record" << endl;
  82.410 -    cout << "****************************************************************************************" << endl << endl;
  82.411 -
  82.412 -    const char* rando2_name = "Pickles BoofyBoof";
  82.413 -    const char* rando2_address = "boof2@pickles.org";
  82.414 -    somebody = new_identity(rando2_address, NULL, NULL, rando2_name);
  82.415 -    status = update_identity(session, somebody);
  82.416 -    const char* expected_rando2_userid = "TOFU_boof2@pickles.org";
  82.417 -
  82.418 -    assert(status == PEP_STATUS_OK);
  82.419 -    assert(!somebody->fpr || somebody->fpr[0] == '\0');
  82.420 -    assert(somebody->username);
  82.421 -    assert(strcmp(somebody->username, rando2_name) == 0);
  82.422 -    assert(somebody->user_id);
  82.423 -    assert(strcmp(somebody->user_id, expected_rando2_userid) == 0); // ???
  82.424 -    assert(!somebody->me); 
  82.425 -    assert(somebody->comm_type == PEP_ct_key_not_found);
  82.426 -    assert(strcmp(somebody->address, rando2_address) == 0);
  82.427 -
  82.428 -    cout << "PASS: update_identity() correctly created record with no key" << endl << endl;
  82.429 -    free_identity(somebody);
  82.430 -
  82.431 -    cout << "****************************************************************************************" << endl;
  82.432 -    cout << "* II: 11. update_identity() for address only, but multiple matching records" << endl;
  82.433 -    cout << "****************************************************************************************" << endl << endl;
  82.434 -
  82.435 -    const char* bella_id_2 = "Bella2";
  82.436 -    bella = new_identity(bella_address, NULL, bella_id_2, bella_username);
  82.437 -    
  82.438 -    // 2. set identity
  82.439 -    status = set_identity(session, bella);
  82.440 -    assert(status == PEP_STATUS_OK);
  82.441 -    free_identity(bella);
  82.442 -                
  82.443 -    bella = new_identity(bella_address, NULL, NULL, NULL); 
  82.444 -    status = update_identity(session, bella);
  82.445 -    assert(status == PEP_STATUS_OK);
  82.446 -
  82.447 -//    cout << "PASS: update_identity() correctly failed with no matching records (too little info)" << endl << endl;
  82.448 -    
  82.449 -    cout << "****************************************************************************************" << endl;
  82.450 -    cout << "* III: key election " << endl;
  82.451 -    cout << "****************************************************************************************" << endl << endl;
  82.452 -
  82.453 -    cout << "****************************************************************************************" << endl;
  82.454 -    cout << "* III: 1. key election: get identity for user with expired key" << endl;
  82.455 -    cout << "****************************************************************************************" << endl << endl;
  82.456 -
  82.457 -    // 1. create identity
  82.458 -    const char* bernd_address = "bernd.das.brot@darthmama.org";
  82.459 -    const char* bernd_fpr = "F8CE0F7E24EB190A2FCBFD38D4B088A7CAFAA422";
  82.460 -    const char* bernd_userid = "BERND_ID"; // simulate temp ID
  82.461 -    const char* bernd_username = "Bernd das Brot der Ultimative Testkandidat";
  82.462 -    const string bernd_pub_key = slurp("test_keys/pub/bernd.das.brot-0xCAFAA422_pub.asc");
  82.463 -    
  82.464 -    statuspub = import_key(session, bernd_pub_key.c_str(), bernd_pub_key.length(), NULL);
  82.465 -    assert(statuspub == PEP_STATUS_OK);
  82.466 -
  82.467 -    pEp_identity* bernd = new_identity(bernd_address, bernd_fpr, bernd_userid, bernd_username);
  82.468 -    
  82.469 -    // 2. set identity
  82.470 -    status = set_identity(session, bernd);
  82.471 -    assert(status == PEP_STATUS_OK);
  82.472 -    free_identity(bernd);
  82.473 -                
  82.474 -    bernd = new_identity(bernd_address, NULL, bernd_userid, bernd_username); 
  82.475 -    status = update_identity(session, bernd);
  82.476 -    assert(status != PEP_STATUS_OK);
  82.477 -    assert(!bernd->fpr || bernd->fpr[0] == '\0');
  82.478 -    assert(bernd->username);
  82.479 -    assert(strcmp(bernd->username, bernd_username) == 0);
  82.480 -    assert(bernd->user_id);
  82.481 -    assert(strcmp(bernd->user_id, bernd_userid) == 0); // ???
  82.482 -    assert(!bernd->me); 
  82.483 -    assert(bernd->comm_type == PEP_ct_key_expired);
  82.484 -    assert(strcmp(bernd->address, bernd_address) == 0);
  82.485 -
  82.486 -    cout << "PASS: update_identity() correctly rejected expired key with PEP_KEY_UNSUITABLE and PEP_ct_key_expired" << endl << endl;
  82.487 -    free_identity(bernd);
  82.488 -
  82.489 -
  82.490 -    cout << "****************************************************************************************" << endl;
  82.491 -    cout << "* III: 2. key election: get identity for user with only revoked or mistrusted keys " << endl;
  82.492 -    cout << "****************************************************************************************" << endl << endl;
  82.493 -
  82.494 -    // Create id with no key
  82.495 -    cout << "Creating new id with no key for : ";
  82.496 -    char *uniqname_10000 = strdup("AAAAtestuser@testdomain.org");
  82.497 -    srandom(time(NULL));
  82.498 -    for(int i=0; i < 4;i++)
  82.499 -        uniqname_10000[i] += random() & 0xf;
  82.500 -    
  82.501 -    cout << uniqname_10000 << "\n";
  82.502 -
  82.503 -    char* revoke_uuid = get_new_uuid();
  82.504 -
  82.505 -    pEp_identity * revokemaster_3000 = new_identity(uniqname_10000, NULL, revoke_uuid, start_username);
  82.506 -    
  82.507 -    cout << "Generate three keys for "  << uniqname_10000 << " who has user_id " << revoke_uuid << endl; 
  82.508 -
  82.509 -    char* revoke_fpr_arr[3];
  82.510 -    
  82.511 -    status = generate_keypair(session, revokemaster_3000);
  82.512 -    assert(status == PEP_STATUS_OK && revokemaster_3000->fpr);
  82.513 -    revoke_fpr_arr[0] = strdup(revokemaster_3000->fpr);
  82.514 -    free(revokemaster_3000->fpr);
  82.515 -    revokemaster_3000->fpr = NULL;
  82.516 -    
  82.517 -    status = generate_keypair(session, revokemaster_3000);
  82.518 -    assert(status == PEP_STATUS_OK && revokemaster_3000->fpr);
  82.519 -    revoke_fpr_arr[1] = strdup(revokemaster_3000->fpr);
  82.520 -    free(revokemaster_3000->fpr);
  82.521 -    revokemaster_3000->fpr = NULL;
  82.522 -    
  82.523 -    status = generate_keypair(session, revokemaster_3000);
  82.524 -    assert(status == PEP_STATUS_OK && revokemaster_3000->fpr);
  82.525 -    revoke_fpr_arr[2] = strdup(revokemaster_3000->fpr);
  82.526 -    free(revokemaster_3000->fpr);
  82.527 -    revokemaster_3000->fpr = NULL;
  82.528 -    
  82.529 -    cout << "Trust "  << revoke_fpr_arr[2] << " (default for identity) and " << revoke_fpr_arr[0] << endl;
  82.530 -    
  82.531 -    free(revokemaster_3000->fpr);
  82.532 -    revokemaster_3000->fpr = strdup(revoke_fpr_arr[2]);
  82.533 -    status = trust_personal_key(session, revokemaster_3000);
  82.534 -    assert(status == PEP_STATUS_OK);
  82.535 -    status = get_trust(session, revokemaster_3000);
  82.536 -    assert(status == PEP_STATUS_OK);
  82.537 -    assert(revokemaster_3000->comm_type & PEP_ct_confirmed);
  82.538 -
  82.539 -    free(revokemaster_3000->fpr);
  82.540 -    revokemaster_3000->fpr = strdup(revoke_fpr_arr[0]);
  82.541 -    status = trust_personal_key(session, revokemaster_3000);
  82.542 -    assert(status == PEP_STATUS_OK);
  82.543 -    status = get_trust(session, revokemaster_3000);
  82.544 -    assert(status == PEP_STATUS_OK);
  82.545 -    assert(revokemaster_3000->comm_type & PEP_ct_confirmed);
  82.546 -    
  82.547 -    status = update_identity(session, revokemaster_3000);
  82.548 -    assert(status == PEP_STATUS_OK);
  82.549 -    assert(revokemaster_3000->fpr);
  82.550 -    assert(strcmp(revokemaster_3000->fpr, revoke_fpr_arr[2]) == 0);
  82.551 -    assert(revokemaster_3000->comm_type & PEP_ct_confirmed);
  82.552 -
  82.553 -    cout << "update_identity returns the correct identity default." << endl;
  82.554 -    
  82.555 -    cout << "Ok, now... we revoke the default..." << endl;
  82.556 -    
  82.557 -    cout << "Revoking " << revoke_fpr_arr[2] << endl;
  82.558 -
  82.559 -    status = revoke_key(session, revoke_fpr_arr[2], "This little pubkey went to market");
  82.560 -    assert (status == PEP_STATUS_OK);
  82.561 -
  82.562 -    bool is_revoked;
  82.563 -    status = key_revoked(session, revokemaster_3000->fpr, &is_revoked);    
  82.564 -    assert(status == PEP_STATUS_OK);
  82.565 -    assert(is_revoked);
  82.566 -
  82.567 -    cout << "Success revoking " << revoke_fpr_arr[2] << "!!! get_trust for this fpr gives us " << revokemaster_3000->comm_type << endl;
  82.568 -    
  82.569 -    cout << "Now see if update_identity gives us " << revoke_fpr_arr[0] << ", the only trusted key left." << endl;
  82.570 -    status = update_identity(session, revokemaster_3000);
  82.571 -    assert(status == PEP_STATUS_OK);
  82.572 -    assert(revokemaster_3000->fpr);
  82.573 -    assert(strcmp(revokemaster_3000->fpr, revoke_fpr_arr[0]) == 0);
  82.574 -    assert(revokemaster_3000->comm_type & PEP_ct_confirmed);    
  82.575 -    
  82.576 -    cout << "Success! So let's mistrust it, because seriously, that key was so uncool." << endl;
  82.577 -    
  82.578 -    status = key_mistrusted(session, revokemaster_3000);
  82.579 -    assert(status == PEP_STATUS_OK);
  82.580 -
  82.581 -    status = get_trust(session, revokemaster_3000);
  82.582 -    assert(status == PEP_STATUS_OK);
  82.583 -    assert(revokemaster_3000->comm_type == PEP_ct_mistrusted);
  82.584 -    
  82.585 -    cout << "Success! get_trust for this fpr gives us " << revokemaster_3000->comm_type << endl;
  82.586 -
  82.587 -    cout << "The only fpr left is an untrusted one - let's make sure this is what we get from update_identity." << endl;
  82.588 -
  82.589 -    status = update_identity(session, revokemaster_3000);
  82.590 -    assert(status == PEP_STATUS_OK);
  82.591 -    assert(revokemaster_3000->fpr);
  82.592 -    assert(strcmp(revokemaster_3000->fpr, revoke_fpr_arr[1]) == 0);
  82.593 -    assert(!(revokemaster_3000->comm_type & PEP_ct_confirmed));    
  82.594 -
  82.595 -    cout << "Success! We got " << revoke_fpr_arr[1] << "as the fpr with comm_type " << revokemaster_3000->comm_type << endl;
  82.596 -    
  82.597 -    cout << "But, you know... let's revoke that one too and see what update_identity gives us." << endl;
  82.598 -
  82.599 -    status = revoke_key(session, revoke_fpr_arr[1], "Because it's more fun to revoke ALL of someone's keys");
  82.600 -    assert (status == PEP_STATUS_OK);
  82.601 -
  82.602 -    status = key_revoked(session, revokemaster_3000->fpr, &is_revoked);    
  82.603 -    assert(status == PEP_STATUS_OK);
  82.604 -    assert(is_revoked);
  82.605 -    
  82.606 -    cout << "Success! get_trust for this fpr gives us " << revokemaster_3000->comm_type << endl;
  82.607 -
  82.608 -    cout << "Call update_identity - we expect nothing, plus an error comm type." << endl;
  82.609 -
  82.610 -    status = update_identity(session, revokemaster_3000);
  82.611 -    assert(status != PEP_STATUS_OK);
  82.612 -    assert(!revokemaster_3000->fpr);
  82.613 -    assert(revokemaster_3000->username);
  82.614 -    assert(strcmp(revokemaster_3000->user_id, revoke_uuid) == 0);
  82.615 -    assert(revokemaster_3000->comm_type == PEP_ct_key_not_found);
  82.616 -    cout << "Success! No key found. The comm_status error was " << revokemaster_3000->comm_type << "and the return status was " << tl_status_string(status) << endl;
  82.617 -
  82.618 -    free_identity(revokemaster_3000);
  82.619 -
  82.620 -    cout << "****************************************************************************************" << endl;
  82.621 -    cout << "* III: 100000000. key election: more to come " << endl;
  82.622 -    cout << "****************************************************************************************" << endl << endl;
  82.623 -
  82.624 -    return 0;
  82.625 -}
    83.1 --- a/test/pEpEngine_test.h	Wed May 09 09:51:05 2018 +0200
    83.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    83.3 @@ -1,3 +0,0 @@
    83.4 -#include <iomanip>
    83.5 -
    83.6 -#define ASSERT_STATUS(status) { cout << setfill('0') << "status: 0x" << hex << setw(4) << status << "\n"; assert(status == PEP_STATUS_OK); }
    84.1 --- a/test/pEp_subject_received_test.cc	Wed May 09 09:51:05 2018 +0200
    84.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    84.3 @@ -1,484 +0,0 @@
    84.4 -#include <iostream>
    84.5 -#include <iostream>
    84.6 -#include <fstream>
    84.7 -#include <string>
    84.8 -#include <cstring> // for strcmp()
    84.9 -#include <assert.h>
   84.10 -#include "blacklist.h"
   84.11 -#include "keymanagement.h"
   84.12 -#include "message_api.h"
   84.13 -#include "mime.h"
   84.14 -#include "test_util.h" // for slurp()
   84.15 -
   84.16 -using namespace std;
   84.17 -
   84.18 -int main(int argc, char** argv) {
   84.19 -
   84.20 -    cout << "\n*** check that p≡p subject is handled properly in received mails ***\n\n";
   84.21 -
   84.22 -    PEP_SESSION session;
   84.23 -    
   84.24 -    cout << "calling init()\n";
   84.25 -    PEP_STATUS status1 = init(&session);   
   84.26 -    assert(status1 == PEP_STATUS_OK);
   84.27 -    assert(session);
   84.28 -    cout << "init() completed.\n";
   84.29 -
   84.30 -    const char* keytexts[3];
   84.31 -
   84.32 -    const string keytextkey1 = slurp("test_keys/pub/pep-test-alice-0x6FF00E97_pub.asc");
   84.33 -    const string keytextkey2 = slurp("test_keys/priv/pep-test-recip-0x08DB0AEE_priv.asc");
   84.34 -    const string keytextkey3 = slurp("test_keys/pub/pep-test-recip-0x08DB0AEE_pub.asc");
   84.35 -    PEP_STATUS statuskey1 = import_key(session, keytextkey1.c_str(), keytextkey1.length(), NULL);
   84.36 -    PEP_STATUS statuskey2 = import_key(session, keytextkey2.c_str(), keytextkey2.length(), NULL);
   84.37 -    PEP_STATUS statuskey3 = import_key(session, keytextkey3.c_str(), keytextkey3.length(), NULL);
   84.38 -
   84.39 -    pEp_identity * me = new_identity("pep.test.recip@kgrothoff.org", "93D19F24AD6F4C4BA9134AAF84D9217908DB0AEE", PEP_OWN_USERID, "pEp Test Recipient");    
   84.40 -    me->me = true;
   84.41 -    PEP_STATUS status = myself(session, me);
   84.42 -    
   84.43 -    pEp_identity * you = new_identity("pep.test.alice@pep-project.org", NULL, "TOFU_pep.test.alice@pep-project.org", "Alice Test");    
   84.44 -    you->me = false;
   84.45 -
   84.46 -    status = update_identity(session, you);
   84.47 -    trust_personal_key(session, you);
   84.48 -    status = update_identity(session, you);
   84.49 -
   84.50 -    cout << "------------------------------------------------------------------------------------------" << endl;
   84.51 -    cout << "Test 1a: Normal encrypted mail, pEp as substitute subject, regular subject in crypto text." << endl;
   84.52 -    cout << "------------------------------------------------------------------------------------------" << endl;
   84.53 -        
   84.54 -    string mailtext = slurp("test_mails/pEp_subject_normal_1a.eml");
   84.55 -    
   84.56 -    message* msg_ptr = nullptr;
   84.57 -    message* dest_msg = nullptr;
   84.58 -    message* final_ptr = nullptr;
   84.59 -    stringlist_t* keylist = nullptr;
   84.60 -    PEP_rating rating;
   84.61 -    PEP_decrypt_flags_t flags;
   84.62 -    
   84.63 -    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr);
   84.64 -    assert(status == PEP_STATUS_OK);
   84.65 -    assert(msg_ptr);
   84.66 -    final_ptr = msg_ptr;
   84.67 -    flags = 0;
   84.68 -    status = decrypt_message(session, msg_ptr, &dest_msg, &keylist, &rating, &flags);
   84.69 -    final_ptr = dest_msg ? dest_msg : msg_ptr;
   84.70 -  
   84.71 -    cout << "shortmsg: " << final_ptr->shortmsg << endl << endl;
   84.72 -    cout << "longmsg: " << final_ptr->longmsg << endl << endl;
   84.73 -    cout << "longmsg_formatted: " << (final_ptr->longmsg_formatted ? final_ptr->longmsg_formatted : "(empty)") << endl << endl;
   84.74 -
   84.75 -    assert(strcmp("This is the usual pEp subject that should replace the above.", final_ptr->shortmsg) == 0);
   84.76 -
   84.77 -    cout << "Test 1a: Subject replaced as expected." << endl << endl;
   84.78 -
   84.79 -    if (final_ptr == dest_msg)
   84.80 -    	free_message(dest_msg);
   84.81 -    free_message(msg_ptr);
   84.82 -    free_stringlist(keylist);
   84.83 -
   84.84 -    cout << "------------------------------------------------------------------------------------------" << endl;
   84.85 -    cout << "Test 1b: Normal encrypted mail, p≡p as substitute subject, regular subject in crypto text." << endl;
   84.86 -    cout << "------------------------------------------------------------------------------------------" << endl;
   84.87 -        
   84.88 -    mailtext = slurp("test_mails/p3p_subject_normal_1b.eml");
   84.89 -    
   84.90 -    msg_ptr = nullptr;
   84.91 -    dest_msg = nullptr;
   84.92 -    final_ptr = nullptr;
   84.93 -    keylist = nullptr;
   84.94 -    rating = PEP_rating_unreliable;
   84.95 -    
   84.96 -    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr);
   84.97 -    assert(status == PEP_STATUS_OK);
   84.98 -    assert(msg_ptr);
   84.99 -    final_ptr = msg_ptr;
  84.100 -    flags = 0;
  84.101 -    status = decrypt_message(session, msg_ptr, &dest_msg, &keylist, &rating, &flags);
  84.102 -    final_ptr = dest_msg ? dest_msg : msg_ptr;
  84.103 -  
  84.104 -    cout << "shortmsg: " << final_ptr->shortmsg << endl << endl;
  84.105 -    cout << "longmsg: " << final_ptr->longmsg << endl << endl;
  84.106 -    cout << "longmsg_formatted: " << (final_ptr->longmsg_formatted ? final_ptr->longmsg_formatted : "(empty)") << endl << endl;
  84.107 -
  84.108 -    assert(strcmp("This is the usual pEp subject that should replace the above.", final_ptr->shortmsg) == 0);
  84.109 -
  84.110 -    cout << "Test 1b: Subject replaced as expected." << endl << endl;
  84.111 -
  84.112 -    if (final_ptr == dest_msg)
  84.113 -    	free_message(dest_msg);
  84.114 -    free_message(msg_ptr);
  84.115 -    free_stringlist(keylist);
  84.116 -
  84.117 -    cout << "-------------------------------------------------------------------------------------------------" << endl;
  84.118 -    cout << "Test 2a: Normal encrypted/signed mail, pEp as substitute subject, regular subject in crypto text." << endl;
  84.119 -    cout << "-------------------------------------------------------------------------------------------------" << endl;
  84.120 -
  84.121 -    msg_ptr = nullptr;
  84.122 -    dest_msg = nullptr;
  84.123 -    final_ptr = nullptr;
  84.124 -    keylist = nullptr;
  84.125 -    rating = PEP_rating_unreliable;
  84.126 -    
  84.127 -    mailtext = slurp("test_mails/pEp_subject_normal_signed_2a.eml");
  84.128 -    
  84.129 -    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr);
  84.130 -    assert(status == PEP_STATUS_OK);
  84.131 -    assert(msg_ptr);
  84.132 -    final_ptr = msg_ptr;
  84.133 -    flags = 0;
  84.134 -    status = decrypt_message(session, msg_ptr, &dest_msg, &keylist, &rating, &flags);
  84.135 -    final_ptr = dest_msg ? dest_msg : msg_ptr;
  84.136 -  
  84.137 -    cout << "shortmsg: " << final_ptr->shortmsg << endl << endl;
  84.138 -    cout << "longmsg: " << final_ptr->longmsg << endl << endl;
  84.139 -    cout << "longmsg_formatted: " << (final_ptr->longmsg_formatted ? final_ptr->longmsg_formatted : "(empty)") << endl << endl;
  84.140 -
  84.141 -    assert(strcmp("Now signed!", final_ptr->shortmsg) == 0);
  84.142 -
  84.143 -    cout << "Test 2a: Subject replaced as expected." << endl << endl;
  84.144 -
  84.145 -    if (final_ptr == dest_msg)
  84.146 -        free_message(dest_msg);
  84.147 -    free_message(msg_ptr);
  84.148 -    free_stringlist(keylist);
  84.149 -
  84.150 -    cout << "-------------------------------------------------------------------------------------------------" << endl;
  84.151 -    cout << "Test 2b: Normal encrypted/signed mail, p≡p as substitute subject, regular subject in crypto text." << endl;
  84.152 -    cout << "-------------------------------------------------------------------------------------------------" << endl;
  84.153 -
  84.154 -    msg_ptr = nullptr;
  84.155 -    dest_msg = nullptr;
  84.156 -    final_ptr = nullptr;
  84.157 -    keylist = nullptr;
  84.158 -    rating = PEP_rating_unreliable;
  84.159 -    
  84.160 -    mailtext = slurp("test_mails/p3p_subject_normal_signed_2b.eml");
  84.161 -    
  84.162 -    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr);
  84.163 -    assert(status == PEP_STATUS_OK);
  84.164 -    assert(msg_ptr);
  84.165 -    final_ptr = msg_ptr;
  84.166 -    flags = 0;
  84.167 -    status = decrypt_message(session, msg_ptr, &dest_msg, &keylist, &rating, &flags);
  84.168 -    final_ptr = dest_msg ? dest_msg : msg_ptr;
  84.169 -  
  84.170 -    cout << "shortmsg: " << final_ptr->shortmsg << endl << endl;
  84.171 -    cout << "longmsg: " << final_ptr->longmsg << endl << endl;
  84.172 -    cout << "longmsg_formatted: " << (final_ptr->longmsg_formatted ? final_ptr->longmsg_formatted : "(empty)") << endl << endl;
  84.173 -
  84.174 -    assert(strcmp("Now signed!", final_ptr->shortmsg) == 0);
  84.175 -
  84.176 -    cout << "Test 2b: Subject replaced as expected." << endl << endl;
  84.177 -
  84.178 -    if (final_ptr == dest_msg)
  84.179 -        free_message(dest_msg);
  84.180 -    free_message(msg_ptr);
  84.181 -    free_stringlist(keylist);
  84.182 -
  84.183 -    
  84.184 -    cout << "---------------------------------------------------------------------------" << endl;
  84.185 -    cout << "Test 3a: Encrypted mail, pEp as displayed subject, no subject in body text." << endl;
  84.186 -    cout << "---------------------------------------------------------------------------" << endl;
  84.187 -
  84.188 -    msg_ptr = nullptr;
  84.189 -    dest_msg = nullptr;
  84.190 -    final_ptr = nullptr;
  84.191 -    keylist = nullptr;
  84.192 -    rating = PEP_rating_unreliable;
  84.193 -    
  84.194 -    mailtext = slurp("test_mails/pEp_encrypted_subject_IS_pEp_3a.eml");
  84.195 -    
  84.196 -    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr);
  84.197 -    assert(status == PEP_STATUS_OK);
  84.198 -    assert(msg_ptr);
  84.199 -    final_ptr = msg_ptr;
  84.200 -    flags = 0;
  84.201 -    status = decrypt_message(session, msg_ptr, &dest_msg, &keylist, &rating, &flags);
  84.202 -    final_ptr = dest_msg ? dest_msg : msg_ptr;
  84.203 -  
  84.204 -    cout << "shortmsg: " << final_ptr->shortmsg << endl << endl;
  84.205 -    cout << "longmsg: " << final_ptr->longmsg << endl << endl;
  84.206 -    cout << "longmsg_formatted: " << (final_ptr->longmsg_formatted ? final_ptr->longmsg_formatted : "(empty)") << endl << endl;
  84.207 -
  84.208 -    assert(strcmp("pEp", final_ptr->shortmsg) == 0);
  84.209 -
  84.210 -    cout << "Test 3a: Subject remains intact as desired." << endl << endl;
  84.211 -
  84.212 -    if (final_ptr == dest_msg)
  84.213 -        free_message(dest_msg);
  84.214 -    free_message(msg_ptr);
  84.215 -    free_stringlist(keylist);
  84.216 -
  84.217 -    cout << "---------------------------------------------------------------------------" << endl;
  84.218 -    cout << "Test 3b: Encrypted mail, p≡p as displayed subject, no subject in body text." << endl;
  84.219 -    cout << "---------------------------------------------------------------------------" << endl;
  84.220 -
  84.221 -    msg_ptr = nullptr;
  84.222 -    dest_msg = nullptr;
  84.223 -    final_ptr = nullptr;
  84.224 -    keylist = nullptr;
  84.225 -    rating = PEP_rating_unreliable;
  84.226 -    
  84.227 -    mailtext = slurp("test_mails/p3p_encrypted_subject_IS_pEp_3b.eml");
  84.228 -    
  84.229 -    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr);
  84.230 -    assert(status == PEP_STATUS_OK);
  84.231 -    assert(msg_ptr);
  84.232 -    final_ptr = msg_ptr;
  84.233 -    flags = 0;
  84.234 -    status = decrypt_message(session, msg_ptr, &dest_msg, &keylist, &rating, &flags);
  84.235 -    final_ptr = dest_msg ? dest_msg : msg_ptr;
  84.236 -  
  84.237 -    cout << "shortmsg: " << final_ptr->shortmsg << endl << endl;
  84.238 -    cout << "longmsg: " << final_ptr->longmsg << endl << endl;
  84.239 -    cout << "longmsg_formatted: " << (final_ptr->longmsg_formatted ? final_ptr->longmsg_formatted : "(empty)") << endl << endl;
  84.240 -
  84.241 -    assert(strcmp("p≡p", final_ptr->shortmsg) == 0);
  84.242 -
  84.243 -    cout << "Test 3: Subject remains intact as desired." << endl << endl;
  84.244 -
  84.245 -    if (final_ptr == dest_msg)
  84.246 -        free_message(dest_msg);
  84.247 -    free_message(msg_ptr);
  84.248 -    free_stringlist(keylist);
  84.249 -
  84.250 -
  84.251 -    cout << "----------------------------------------------------------------------------" << endl;
  84.252 -    cout << "Test 4a: Encrypted mail, pEp as displayed subject, pEp subject in body text." << endl;
  84.253 -    cout << "----------------------------------------------------------------------------" << endl;
  84.254 -
  84.255 -    msg_ptr = nullptr;
  84.256 -    dest_msg = nullptr;
  84.257 -    final_ptr = nullptr;
  84.258 -    keylist = nullptr;
  84.259 -    rating = PEP_rating_unreliable;
  84.260 -    
  84.261 -    mailtext = slurp("test_mails/pEp_subject_pEp_replaced_w_pEp_4a.eml");
  84.262 -    
  84.263 -    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr);
  84.264 -    assert(status == PEP_STATUS_OK);
  84.265 -    assert(msg_ptr);
  84.266 -    final_ptr = msg_ptr;
  84.267 -    flags = 0;
  84.268 -    status = decrypt_message(session, msg_ptr, &dest_msg, &keylist, &rating, &flags);
  84.269 -    final_ptr = dest_msg ? dest_msg : msg_ptr;
  84.270 -  
  84.271 -    cout << "shortmsg: " << final_ptr->shortmsg << endl << endl;
  84.272 -    cout << "longmsg: " << final_ptr->longmsg << endl << endl;
  84.273 -    cout << "longmsg_formatted: " << (final_ptr->longmsg_formatted ? final_ptr->longmsg_formatted : "(empty)") << endl << endl;
  84.274 -
  84.275 -    assert(strcmp("pEp", final_ptr->shortmsg) == 0);
  84.276 -
  84.277 -    cout << "Test 4a: Subject correct." << endl << endl;
  84.278 -
  84.279 -    if (final_ptr == dest_msg)
  84.280 -        free_message(dest_msg);
  84.281 -    free_message(msg_ptr);
  84.282 -    free_stringlist(keylist);
  84.283 -
  84.284 -    cout << "----------------------------------------------------------------------------" << endl;
  84.285 -    cout << "Test 4b: Encrypted mail, p≡p as displayed subject, pEp subject in body text." << endl;
  84.286 -    cout << "----------------------------------------------------------------------------" << endl;
  84.287 -
  84.288 -    msg_ptr = nullptr;
  84.289 -    dest_msg = nullptr;
  84.290 -    final_ptr = nullptr;
  84.291 -    keylist = nullptr;
  84.292 -    rating = PEP_rating_unreliable;
  84.293 -    
  84.294 -    mailtext = slurp("test_mails/pEp_subject_pEp_replaced_w_p3p_4b.eml");
  84.295 -    
  84.296 -    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr);
  84.297 -    assert(status == PEP_STATUS_OK);
  84.298 -    assert(msg_ptr);
  84.299 -    final_ptr = msg_ptr;
  84.300 -    flags = 0;
  84.301 -    status = decrypt_message(session, msg_ptr, &dest_msg, &keylist, &rating, &flags);
  84.302 -    final_ptr = dest_msg ? dest_msg : msg_ptr;
  84.303 -  
  84.304 -    cout << "shortmsg: " << final_ptr->shortmsg << endl << endl;
  84.305 -    cout << "longmsg: " << final_ptr->longmsg << endl << endl;
  84.306 -    cout << "longmsg_formatted: " << (final_ptr->longmsg_formatted ? final_ptr->longmsg_formatted : "(empty)") << endl << endl;
  84.307 -
  84.308 -    assert(strcmp("pEp", final_ptr->shortmsg) == 0);
  84.309 -
  84.310 -    cout << "Test 4b: Subject correct." << endl << endl;
  84.311 -
  84.312 -    if (final_ptr == dest_msg)
  84.313 -        free_message(dest_msg);
  84.314 -    free_message(msg_ptr);
  84.315 -    free_stringlist(keylist);
  84.316 -
  84.317 -    cout << "----------------------------------------------------------------------------" << endl;
  84.318 -    cout << "Test 4c: Encrypted mail, pEp as displayed subject, p≡p subject in body text." << endl;
  84.319 -    cout << "----------------------------------------------------------------------------" << endl;
  84.320 -
  84.321 -    msg_ptr = nullptr;
  84.322 -    dest_msg = nullptr;
  84.323 -    final_ptr = nullptr;
  84.324 -    keylist = nullptr;
  84.325 -    rating = PEP_rating_unreliable;
  84.326 -    
  84.327 -    mailtext = slurp("test_mails/pEp_subject_p3p_replaced_w_pEp_4c.eml");
  84.328 -    
  84.329 -    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr);
  84.330 -    assert(status == PEP_STATUS_OK);
  84.331 -    assert(msg_ptr);
  84.332 -    final_ptr = msg_ptr;
  84.333 -    flags = 0;
  84.334 -    status = decrypt_message(session, msg_ptr, &dest_msg, &keylist, &rating, &flags);
  84.335 -    final_ptr = dest_msg ? dest_msg : msg_ptr;
  84.336 -  
  84.337 -    cout << "shortmsg: " << final_ptr->shortmsg << endl << endl;
  84.338 -    cout << "longmsg: " << final_ptr->longmsg << endl << endl;
  84.339 -    cout << "longmsg_formatted: " << (final_ptr->longmsg_formatted ? final_ptr->longmsg_formatted : "(empty)") << endl << endl;
  84.340 -
  84.341 -    assert(strcmp("p≡p", final_ptr->shortmsg) == 0);
  84.342 -
  84.343 -    cout << "Test 4c: Subject correct." << endl << endl;
  84.344 -
  84.345 -    if (final_ptr == dest_msg)
  84.346 -        free_message(dest_msg);
  84.347 -    free_message(msg_ptr);
  84.348 -    free_stringlist(keylist);
  84.349 -
  84.350 -    cout << "----------------------------------------------------------------------------" << endl;
  84.351 -    cout << "Test 4d: Encrypted mail, p≡p as displayed subject, p≡p subject in body text." << endl;
  84.352 -    cout << "----------------------------------------------------------------------------" << endl;
  84.353 -
  84.354 -    msg_ptr = nullptr;
  84.355 -    dest_msg = nullptr;
  84.356 -    final_ptr = nullptr;
  84.357 -    keylist = nullptr;
  84.358 -    rating = PEP_rating_unreliable;
  84.359 -    
  84.360 -    mailtext = slurp("test_mails/pEp_subject_p3p_replaced_w_p3p_4d.eml");
  84.361 -    
  84.362 -    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr);
  84.363 -    assert(status == PEP_STATUS_OK);
  84.364 -    assert(msg_ptr);
  84.365 -    final_ptr = msg_ptr;
  84.366 -    flags = 0;
  84.367 -    status = decrypt_message(session, msg_ptr, &dest_msg, &keylist, &rating, &flags);
  84.368 -    final_ptr = dest_msg ? dest_msg : msg_ptr;
  84.369 -  
  84.370 -    cout << "shortmsg: " << final_ptr->shortmsg << endl << endl;
  84.371 -    cout << "longmsg: " << final_ptr->longmsg << endl << endl;
  84.372 -    cout << "longmsg_formatted: " << (final_ptr->longmsg_formatted ? final_ptr->longmsg_formatted : "(empty)") << endl << endl;
  84.373 -
  84.374 -    assert(strcmp("p≡p", final_ptr->shortmsg) == 0);
  84.375 -
  84.376 -    cout << "Test 4d: Subject correct, in any event." << endl << endl;
  84.377 -
  84.378 -    if (final_ptr == dest_msg)
  84.379 -        free_message(dest_msg);
  84.380 -    free_message(msg_ptr);
  84.381 -    free_stringlist(keylist);
  84.382 -
  84.383 -
  84.384 -    cout << "-------------------------------------------------------------------------" << endl;
  84.385 -    cout << "Test 5a: Unencrypted variant where pEp in the subject line is the subject." << endl;
  84.386 -    cout << "-------------------------------------------------------------------------" << endl;
  84.387 -
  84.388 -    msg_ptr = nullptr;
  84.389 -    dest_msg = nullptr;
  84.390 -    final_ptr = nullptr;
  84.391 -    keylist = nullptr;
  84.392 -    rating = PEP_rating_unreliable;
  84.393 -    
  84.394 -    mailtext = slurp("test_mails/pEp_unencrypted_pEp_subject_5a.eml");
  84.395 -    
  84.396 -    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr);
  84.397 -    assert(status == PEP_STATUS_OK);
  84.398 -    assert(msg_ptr);
  84.399 -    final_ptr = msg_ptr;
  84.400 -    flags = 0;
  84.401 -    status = decrypt_message(session, msg_ptr, &dest_msg, &keylist, &rating, &flags);
  84.402 -    final_ptr = dest_msg ? dest_msg : msg_ptr;
  84.403 -  
  84.404 -    cout << "shortmsg: " << final_ptr->shortmsg << endl << endl;
  84.405 -    cout << "longmsg: " << final_ptr->longmsg << endl << endl;
  84.406 -    cout << "longmsg_formatted: " << (final_ptr->longmsg_formatted ? final_ptr->longmsg_formatted : "(empty)") << endl << endl;
  84.407 -
  84.408 -    assert(strcmp("pEp", final_ptr->shortmsg) == 0);
  84.409 -
  84.410 -    cout << "Test 5a: Subject remains intact." << endl << endl;
  84.411 -
  84.412 -    if (final_ptr == dest_msg)
  84.413 -        free_message(dest_msg);
  84.414 -    free_message(msg_ptr);
  84.415 -    free_stringlist(keylist);
  84.416 -
  84.417 -
  84.418 -    cout << "--------------------------------------------------------------------------" << endl;
  84.419 -    cout << "Test 5b: Unencrypted variant where p≡p in the subject line is the subject." << endl;
  84.420 -    cout << "--------------------------------------------------------------------------" << endl;
  84.421 -
  84.422 -    msg_ptr = nullptr;
  84.423 -    dest_msg = nullptr;
  84.424 -    final_ptr = nullptr;
  84.425 -    keylist = nullptr;
  84.426 -    rating = PEP_rating_unreliable;
  84.427 -    
  84.428 -    mailtext = slurp("test_mails/pEp_unencrypted_p3p_subject_5b.eml");
  84.429 -    
  84.430 -    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr);
  84.431 -    assert(status == PEP_STATUS_OK);
  84.432 -    assert(msg_ptr);
  84.433 -    final_ptr = msg_ptr;
  84.434 -    flags = 0;
  84.435 -    status = decrypt_message(session, msg_ptr, &dest_msg, &keylist, &rating, &flags);
  84.436 -    final_ptr = dest_msg ? dest_msg : msg_ptr;
  84.437 -  
  84.438 -    cout << "shortmsg: " << final_ptr->shortmsg << endl << endl;
  84.439 -    cout << "longmsg: " << final_ptr->longmsg << endl << endl;
  84.440 -    cout << "longmsg_formatted: " << (final_ptr->longmsg_formatted ? final_ptr->longmsg_formatted : "(empty)") << endl << endl;
  84.441 -
  84.442 -    assert(strcmp("p≡p", final_ptr->shortmsg) == 0);
  84.443 -
  84.444 -    cout << "Test 5b: Subject remains intact." << endl << endl;
  84.445 -
  84.446 -    if (final_ptr == dest_msg)
  84.447 -        free_message(dest_msg);
  84.448 -    free_message(msg_ptr);
  84.449 -    free_stringlist(keylist);
  84.450 -
  84.451 -    cout << "----------------------------------------------------------------------------------------------------------------------" << endl;
  84.452 -    cout << "Test 6: Normal unencrypted email where a subject line exists in the text but the subject is not a replacement subject." << endl;
  84.453 -    cout << "----------------------------------------------------------------------------------------------------------------------" << endl;
  84.454 -
  84.455 -    msg_ptr = nullptr;
  84.456 -    dest_msg = nullptr;
  84.457 -    final_ptr = nullptr;
  84.458 -    keylist = nullptr;
  84.459 -    rating = PEP_rating_unreliable;
  84.460 -    
  84.461 -    mailtext = slurp("test_mails/pEp_subject_normal_unencrypted_6.eml");
  84.462 -    
  84.463 -    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr);
  84.464 -    assert(status == PEP_STATUS_OK);
  84.465 -    assert(msg_ptr);
  84.466 -    final_ptr = msg_ptr;
  84.467 -    flags = 0;
  84.468 -    status = decrypt_message(session, msg_ptr, &dest_msg, &keylist, &rating, &flags);
  84.469 -    final_ptr = dest_msg ? dest_msg : msg_ptr;
  84.470 -  
  84.471 -    cout << "shortmsg: " << final_ptr->shortmsg << endl << endl;
  84.472 -    cout << "longmsg: " << final_ptr->longmsg << endl << endl;
  84.473 -    cout << "longmsg_formatted: " << (final_ptr->longmsg_formatted ? final_ptr->longmsg_formatted : "(empty)") << endl << endl;
  84.474 -
  84.475 -    assert(strcmp("This is just a normal subject, really", final_ptr->shortmsg) == 0);
  84.476 -
  84.477 -    cout << "Test 6: Subject remains intact." << endl << endl;
  84.478 -
  84.479 -    if (final_ptr == dest_msg)
  84.480 -        free_message(dest_msg);
  84.481 -    free_message(msg_ptr);
  84.482 -    free_stringlist(keylist);
  84.483 -        
  84.484 -    cout << "calling release()\n";
  84.485 -    release(session);
  84.486 -    return 0;
  84.487 -}
    85.1 --- a/test/pgp_binary_test.cc	Wed May 09 09:51:05 2018 +0200
    85.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    85.3 @@ -1,39 +0,0 @@
    85.4 -// This file is under GNU General Public License 3.0
    85.5 -// see LICENSE.txt
    85.6 -
    85.7 -#include <iostream>
    85.8 -#include <string>
    85.9 -#include <assert.h>
   85.10 -#include "message_api.h"
   85.11 -
   85.12 -using namespace std;
   85.13 -
   85.14 -int main() {
   85.15 -    cout << "\n*** pgp_binary_test ***\n\n";
   85.16 -
   85.17 -    PEP_SESSION session;
   85.18 -    
   85.19 -    cout << "calling init()\n";
   85.20 -    PEP_STATUS status1 = init(&session);   
   85.21 -    assert(status1 == PEP_STATUS_OK);
   85.22 -    assert(session);
   85.23 -    cout << "init() completed.\n";
   85.24 -
   85.25 -    // pgp_binary test code
   85.26 -
   85.27 -    const char *path;
   85.28 -    PEP_STATUS status2 = get_binary_path(PEP_crypt_OpenPGP, &path);
   85.29 -    assert(status2 == PEP_STATUS_OK);
   85.30 -#ifdef USE_GPG
   85.31 -    assert(path);
   85.32 -#endif
   85.33 -    if (path)
   85.34 -        cout << "PGP binary at " << path << "\n";
   85.35 -    else
   85.36 -        cout << "no PGP binary path available\n";
   85.37 -
   85.38 -    cout << "calling release()\n";
   85.39 -    release(session);
   85.40 -    return 0;
   85.41 -}
   85.42 -
    86.1 --- a/test/pgp_list_keys_test.cc	Wed May 09 09:51:05 2018 +0200
    86.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    86.3 @@ -1,74 +0,0 @@
    86.4 -// This file is under GNU General Public License 3.0
    86.5 -// see LICENSE.txt
    86.6 -
    86.7 -#include <iostream>
    86.8 -#include <string>
    86.9 -#include <assert.h>
   86.10 -#include "pEpEngine.h"
   86.11 -#include "stringpair.h"
   86.12 -#include "openpgp_compat.h"
   86.13 -
   86.14 -using namespace std;
   86.15 -
   86.16 -void print_stringpair_list(stringpair_list_t* spl) {
   86.17 -    for ( ; spl != NULL; spl = spl->next) {
   86.18 -        if (spl->value) {
   86.19 -            cout << "Key:" << endl;
   86.20 -            if (spl->value->key)
   86.21 -                cout << "\tFPR: " << spl->value->key << endl;
   86.22 -            if (spl->value->value)
   86.23 -                cout << "\tUID: " << spl->value->value << endl;
   86.24 -        }
   86.25 -    }
   86.26 -}
   86.27 -
   86.28 -int main() {
   86.29 -    cout << "\n*** openpgp_compat test ***\n\n";
   86.30 -
   86.31 -    PEP_SESSION session;
   86.32 -    
   86.33 -    cout << "calling init()\n";
   86.34 -    PEP_STATUS status1 = init(&session);   
   86.35 -    assert(status1 == PEP_STATUS_OK);
   86.36 -    assert(session);
   86.37 -    cout << "init() completed.\n";
   86.38 -
   86.39 -    cout << "Listing all the keys:" << endl;
   86.40 -    stringpair_list_t* all_the_ids = NULL;
   86.41 -    OpenPGP_list_keyinfo(session, "", &all_the_ids);
   86.42 -    print_stringpair_list(all_the_ids);
   86.43 -    free_stringpair_list(all_the_ids);
   86.44 -    
   86.45 -    cout << "**********************" << endl << endl << "Checking on Alice, Bob and John" << endl;
   86.46 -    all_the_ids = NULL;
   86.47 -    OpenPGP_list_keyinfo(session, "pEp Test", &all_the_ids);
   86.48 -    print_stringpair_list(all_the_ids);
   86.49 -    free_stringpair_list(all_the_ids);
   86.50 -
   86.51 -    cout << "**********************" << endl << endl << "Compare to find_keys for Alice, Bob and John" << endl;
   86.52 -    stringlist_t* all_the_keys;
   86.53 -    find_keys(session, "pEp Test", &all_the_keys);
   86.54 -    stringlist_t* i;
   86.55 -    for (i = all_the_keys; i; i = i->next) {
   86.56 -        cout << i->value << endl;
   86.57 -    }
   86.58 -    free_stringlist(all_the_keys);
   86.59 -
   86.60 -    
   86.61 -    cout << "**********************" << endl << endl << "Checking FPR" << endl;
   86.62 -    all_the_ids = NULL;
   86.63 -    OpenPGP_list_keyinfo(session, "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39", &all_the_ids);
   86.64 -    print_stringpair_list(all_the_ids);
   86.65 -    free_stringpair_list(all_the_ids);
   86.66 -
   86.67 -    cout << "**********************" << endl << endl << "Checking on nothing" << endl;
   86.68 -    all_the_ids = NULL;
   86.69 -    OpenPGP_list_keyinfo(session, "ekhwr89234uh4rknfjsklejfnlskjflselkflkserjs", &all_the_ids);
   86.70 -    print_stringpair_list(all_the_ids);
   86.71 -    free_stringpair_list(all_the_ids);
   86.72 -
   86.73 -    cout << "calling release()\n";
   86.74 -    release(session);
   86.75 -    return 0;
   86.76 -}
   86.77 -
    87.1 --- a/test/reencrypt_plus_extra_keys_test.cc	Wed May 09 09:51:05 2018 +0200
    87.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    87.3 @@ -1,534 +0,0 @@
    87.4 -// This file is under GNU General Public License 3.0
    87.5 -// see LICENSE.txt
    87.6 -
    87.7 -#include <stdlib.h>
    87.8 -#include <string.h>
    87.9 -#include "platform.h"
   87.10 -#include <iostream>
   87.11 -#include <fstream>
   87.12 -#include <assert.h>
   87.13 -#include "mime.h"
   87.14 -#include "message_api.h"
   87.15 -#include "keymanagement.h"
   87.16 -#include "test_util.h"
   87.17 -
   87.18 -using namespace std;
   87.19 -
   87.20 -int main() {
   87.21 -    cout << "\n*** reencrypt_plus_extra_keys_test ***\n\n";
   87.22 -
   87.23 -    PEP_SESSION session;
   87.24 -    
   87.25 -    cout << "calling init()\n";
   87.26 -    PEP_STATUS status = init(&session);
   87.27 -    assert(status == PEP_STATUS_OK);
   87.28 -    assert(session);
   87.29 -    cout << "init() completed.\n";
   87.30 -
   87.31 -    /* import all the keys */
   87.32 -    const char* fpr_own_recip_key = "85D022E0CC9BA9F6B922CA7B638E5211B1A2BE89";
   87.33 -    const char* fpr_own_recip_2_key = "7A2EEB933E6FD99207B83E397B6D3751D6E75FFF";
   87.34 -    
   87.35 -    const char* fpr_sender_pub_key = "95FE24B262A34FA5C6A8D0AAF90144FC3B508C8E";
   87.36 -    const char* fpr_recip_2_pub_key = "60701073D138EF622C8F9221B6FC86831EDBE691";
   87.37 -    const char* fpr_recip_0_pub_key = "CDF787C7C9664E02825DD416C6FBCF8D1F4A5986";
   87.38 -    // we're leaving recip_1 out for the Hell of it - D3886D0DF75113BE2799C9374D6B99FE0F8273D8
   87.39 -    const char* fpr_pub_extra_key_0 = "33BB6C92EBFB6F29641C75B5B79D916C828AA789";
   87.40 -
   87.41 -    const char* fpr_pub_extra_key_1 = "3DB93A746785FDD6110798AB3B193A9E8B026AEC";
   87.42 -    const string own_recip_pub_key = slurp("test_keys/pub/reencrypt_recip_0-0xB1A2BE89_pub.asc");
   87.43 -    const string own_recip_priv_key = slurp("test_keys/priv/reencrypt_recip_0-0xB1A2BE89_priv.asc");
   87.44 -    const string own_recip_2_pub_key = slurp("test_keys/pub/reencrypt_recip_numero_deux_test_0-0xD6E75FFF_pub.asc");
   87.45 -    const string own_recip_2_priv_key = slurp("test_keys/priv/reencrypt_recip_numero_deux_test_0-0xD6E75FFF_priv.asc");
   87.46 -    
   87.47 -    const string sender_pub_key = slurp("test_keys/pub/reencrypt_sender_0-0x3B508C8E_pub.asc");
   87.48 -    const string recip_2_pub_key = slurp("test_keys/pub/reencrypt_other_recip_2-0x1EDBE691_pub.asc");
   87.49 -    const string recip_0_pub_key = slurp("test_keys/pub/reencrypt_other_recip_0-0x1F4A5986_pub.asc");
   87.50 -    // we're leaving recip_1 out for the Hell of it
   87.51 -    const string pub_extra_key_0 = slurp("test_keys/pub/reencrypt_extra_keys_0-0x828AA789_pub.asc");
   87.52 -    const string pub_extra_key_1 = slurp("test_keys/pub/reencrypt_extra_keys_1-0x8B026AEC_pub.asc");
   87.53 -
   87.54 -    status = import_key(session, own_recip_pub_key.c_str(), own_recip_pub_key.length(), NULL);
   87.55 -    assert (status == PEP_STATUS_OK);
   87.56 -    status = import_key(session, own_recip_priv_key.c_str(), own_recip_priv_key.length(), NULL);
   87.57 -    assert (status == PEP_STATUS_OK);    
   87.58 -    status = import_key(session, own_recip_2_pub_key.c_str(), own_recip_2_pub_key.length(), NULL);
   87.59 -    assert (status == PEP_STATUS_OK);
   87.60 -    status = import_key(session, own_recip_2_priv_key.c_str(), own_recip_2_priv_key.length(), NULL);
   87.61 -    assert (status == PEP_STATUS_OK);
   87.62 -    
   87.63 -    status = import_key(session, sender_pub_key.c_str(), sender_pub_key.length(), NULL);
   87.64 -    assert (status == PEP_STATUS_OK);
   87.65 -    status = import_key(session, recip_2_pub_key.c_str(), recip_2_pub_key.length(), NULL);
   87.66 -    assert (status == PEP_STATUS_OK);
   87.67 -    status = import_key(session, recip_0_pub_key.c_str(), recip_0_pub_key.length(), NULL);
   87.68 -    assert (status == PEP_STATUS_OK);
   87.69 -    status = import_key(session, pub_extra_key_0.c_str(), pub_extra_key_0.length(), NULL);
   87.70 -    assert (status == PEP_STATUS_OK);
   87.71 -    status = import_key(session, pub_extra_key_1.c_str(), pub_extra_key_1.length(), NULL);
   87.72 -    assert (status == PEP_STATUS_OK);
   87.73 -
   87.74 -    cout << "Keys imported." << endl;
   87.75 -
   87.76 -    pEp_identity* me_recip_1 = new_identity("reencrypt_recip@darthmama.cool", fpr_own_recip_key, PEP_OWN_USERID, "Me Recipient");
   87.77 -    pEp_identity* me_recip_2 = new_identity("reencrypt_recip_numero_deux_test@darthmama.org", fpr_own_recip_2_key, PEP_OWN_USERID, "Me Recipient");
   87.78 -    
   87.79 -    cout << "Inserting own identities and keys into database." << endl;
   87.80 -    status = set_own_key(session, me_recip_2, fpr_own_recip_2_key);
   87.81 -    assert(status == PEP_STATUS_OK);
   87.82 -    cout << "Done: inserting own identities and keys into database." << endl;
   87.83 -
   87.84 -    const string to_reencrypt_from_enigmail = slurp("test_mails/reencrypt_sent_by_enigmail.eml");
   87.85 -    const string to_reencrypt_from_enigmail_BCC = slurp("test_mails/reencrypt_BCC_sent_by_enigmail.eml");
   87.86 -    const string to_reencrypt_from_pEp = slurp("test_mails/reencrypt_encrypted_through_pEp.eml");
   87.87 -
   87.88 -    cout << endl << "Case 1a: Calling MIME_decrypt_message with reencrypt flag set on message sent from enigmail for recip 2 with no extra keys." << endl;
   87.89 -    
   87.90 -    char* decrypted_text = nullptr;
   87.91 -    
   87.92 -    // In: extra keys; Out: keys that were used to encrypt this.
   87.93 -    stringlist_t* keys = NULL;
   87.94 -    PEP_decrypt_flags_t flags;
   87.95 -    PEP_rating rating;
   87.96 -
   87.97 -    flags = PEP_decrypt_flag_untrusted_server;
   87.98 -    char* modified_src = NULL;
   87.99 -    
  87.100 -    status = MIME_decrypt_message(session,
  87.101 -                                  to_reencrypt_from_enigmail.c_str(),
  87.102 -                                  to_reencrypt_from_enigmail.size(),
  87.103 -                                  &decrypted_text,
  87.104 -                                  &keys,
  87.105 -                                  &rating,
  87.106 -                                  &flags, 
  87.107 -                                  &modified_src);
  87.108 -
  87.109 -    cout << decrypted_text << endl;
  87.110 -
  87.111 -    cout << "Status is " << tl_status_string(status) << endl;
  87.112 -    assert(decrypted_text);
  87.113 -    assert(rating);
  87.114 -    assert(!(flags & PEP_decrypt_flag_src_modified));
  87.115 -    
  87.116 -    assert(!modified_src);
  87.117 -    //cout << modified_src << endl;
  87.118 -    
  87.119 -    free(decrypted_text);
  87.120 -    decrypted_text = nullptr;
  87.121 -
  87.122 -    cout << "CHECK: Decrypting to see what keys it was encrypted for." << endl;
  87.123 -
  87.124 -    free(decrypted_text);
  87.125 -    decrypted_text = nullptr;
  87.126 -    flags = 0;
  87.127 -    char* throwaway = NULL;
  87.128 -
  87.129 -    status = MIME_decrypt_message(session,
  87.130 -                                  modified_src,
  87.131 -                                  strlen(modified_src),
  87.132 -                                  &decrypted_text,
  87.133 -                                  &keys,
  87.134 -                                  &rating,
  87.135 -                                  &flags,
  87.136 -                                  &throwaway);
  87.137 -
  87.138 -    
  87.139 -    cout << "keys used:\n";
  87.140 -    
  87.141 -    int i = 0;
  87.142 -    
  87.143 -    for (stringlist_t* kl = keys; kl && kl->value; kl = kl->next, i++)
  87.144 -    {
  87.145 -        if (i == 0) {
  87.146 -              cout << "Signed by " << (strcasecmp("", kl->value) == 0 ? "NOBODY" : kl->value) << endl;
  87.147 -              assert(strcasecmp(fpr_own_recip_2_key,kl->value) == 0);
  87.148 -        }
  87.149 -        else {
  87.150 -            cout << "\t " << kl->value << endl;
  87.151 -            assert(strcasecmp(fpr_own_recip_2_key, kl->value) == 0);
  87.152 -            cout << "Encrypted only for own identity! Yay! It worked!" << endl;
  87.153 -        }
  87.154 -        assert(i < 2);
  87.155 -    }
  87.156 -    cout << "Case 1a: PASS" << endl << endl;
  87.157 -
  87.158 -    cout << "Case 1b: Calling MIME_decrypt_message with reencrypt flag set on message sent from enigmail for recip 2 extra keys." << endl;
  87.159 -        
  87.160 -    // In: extra keys; Out: keys that were used to encrypt this.
  87.161 -    free_stringlist(keys);
  87.162 -    keys = new_stringlist(fpr_pub_extra_key_0);
  87.163 -    stringlist_add(keys, fpr_pub_extra_key_1);    
  87.164 -
  87.165 -    flags = PEP_decrypt_flag_untrusted_server;
  87.166 -    
  87.167 -    status = MIME_decrypt_message(session,
  87.168 -                                  to_reencrypt_from_enigmail.c_str(),
  87.169 -                                  to_reencrypt_from_enigmail.size(),
  87.170 -                                  &decrypted_text,
  87.171 -                                  &keys,
  87.172 -                                  &rating,
  87.173 -                                  &flags,
  87.174 -                                  &modified_src);
  87.175 -
  87.176 -    cout << decrypted_text << endl;
  87.177 -    cout << "Status is " << tl_status_string(status) << endl;
  87.178 -
  87.179 -
  87.180 -    assert(decrypted_text);
  87.181 -    assert(rating);
  87.182 -
  87.183 -    free(decrypted_text);
  87.184 -    decrypted_text = nullptr;
  87.185 -
  87.186 -    cout << "CHECK: Decrypting to see what keys it was encrypted for." << endl;
  87.187 -
  87.188 -    free(decrypted_text);
  87.189 -    decrypted_text = nullptr;
  87.190 -    flags = 0;
  87.191 -    throwaway = NULL;
  87.192 -
  87.193 -    status = MIME_decrypt_message(session,
  87.194 -                                  modified_src,
  87.195 -                                  strlen(modified_src),
  87.196 -                                  &decrypted_text,
  87.197 -                                  &keys,
  87.198 -                                  &rating,
  87.199 -                                  &flags,
  87.200 -                                  &throwaway);
  87.201 -    
  87.202 -    cout << "keys used:\n";
  87.203 -    
  87.204 -    bool own_key_found = false;
  87.205 -    bool extra_key_0_found = false;
  87.206 -    bool extra_key_1_found = false;
  87.207 -    
  87.208 -    i = 0;
  87.209 -    
  87.210 -    for (stringlist_t* kl = keys; kl && kl->value; kl = kl->next, i++)
  87.211 -    {
  87.212 -        if (i == 0) {
  87.213 -              cout << "Signed by " << (strcasecmp("", kl->value) == 0 ? "NOBODY" : kl->value) << endl;
  87.214 -              assert(strcasecmp(fpr_own_recip_2_key,kl->value) == 0);
  87.215 -        }
  87.216 -        else {
  87.217 -            if (strcasecmp(fpr_own_recip_2_key, kl->value) == 0) {
  87.218 -                cout << "Encrypted for us." << endl;
  87.219 -                own_key_found = true;
  87.220 -            }
  87.221 -            else if (strcasecmp(fpr_pub_extra_key_0, kl->value) == 0) {
  87.222 -                cout << "Encrypted for extra key 0." << endl;
  87.223 -                extra_key_0_found = true;
  87.224 -            }
  87.225 -            else if (strcasecmp(fpr_pub_extra_key_1, kl->value) == 0) {
  87.226 -                cout << "Encrypted for extra key 1." << endl;
  87.227 -                extra_key_1_found = true;
  87.228 -            }
  87.229 -            else {
  87.230 -                cout << "FAIL: Encrypted for " << kl->value << ", which it should not be." << endl;
  87.231 -                assert(false);
  87.232 -            }
  87.233 -            cout << "\t " << kl->value << endl;
  87.234 -        }
  87.235 -        assert(i < 4);
  87.236 -    }
  87.237 -    assert (own_key_found && extra_key_0_found && extra_key_1_found);
  87.238 -    cout << "Message was encrypted for all the keys it should be, and none it should not!" << endl;
  87.239 -
  87.240 -    cout << "Case 1b: PASS" << endl << endl;
  87.241 -
  87.242 -    cout << "Case 2a: Calling MIME_decrypt_message with reencrypt flag set on message sent with recip 2 in BCC from enigmail with no extra keys." << endl;
  87.243 -
  87.244 -    free_stringlist(keys);
  87.245 -    keys = NULL;
  87.246 -
  87.247 -    flags = PEP_decrypt_flag_untrusted_server;
  87.248 -    
  87.249 -    status = MIME_decrypt_message(session,
  87.250 -                                  to_reencrypt_from_enigmail_BCC.c_str(),
  87.251 -                                  to_reencrypt_from_enigmail_BCC.size(),
  87.252 -                                  &decrypted_text,
  87.253 -                                  &keys,
  87.254 -                                  &rating,
  87.255 -                                  &flags,
  87.256 -                                  &modified_src);
  87.257 -
  87.258 -    cout << decrypted_text << endl;
  87.259 -    cout << "Status is " << tl_status_string(status) << endl;
  87.260 -
  87.261 -
  87.262 -    assert(decrypted_text);
  87.263 -    assert(rating);
  87.264 -
  87.265 -    free(decrypted_text);
  87.266 -    decrypted_text = nullptr;
  87.267 -
  87.268 -    cout << "CHECK: Decrypting to see what keys it was encrypted for." << endl;
  87.269 -
  87.270 -    free(decrypted_text);
  87.271 -    decrypted_text = nullptr;
  87.272 -    flags = 0;
  87.273 -    throwaway = NULL;
  87.274 -
  87.275 -    status = MIME_decrypt_message(session,
  87.276 -                                  modified_src,
  87.277 -                                  strlen(modified_src),
  87.278 -                                  &decrypted_text,
  87.279 -                                  &keys,
  87.280 -                                  &rating,
  87.281 -                                  &flags,
  87.282 -                                  &throwaway);
  87.283 -    
  87.284 -    cout << "keys used:\n";
  87.285 -        
  87.286 -    i = 0;
  87.287 -    
  87.288 -    for (stringlist_t* kl = keys; kl && kl->value; kl = kl->next, i++)
  87.289 -    {
  87.290 -        if (i == 0) {
  87.291 -              cout << "Signed by " << (strcasecmp("", kl->value) == 0 ? "NOBODY" : kl->value) << endl;
  87.292 -//              assert(strcasecmp(fpr_own_recip_2_key,kl->value) == 0);
  87.293 -        }
  87.294 -        else {
  87.295 -            cout << "\t " << kl->value << endl;
  87.296 -//            assert(strcasecmp(fpr_own_recip_2_key, kl->value) == 0);
  87.297 -            cout << "Encrypted only for own identity! Yay! It worked!" << endl;
  87.298 -        }
  87.299 -        assert(i < 2);
  87.300 -    }
  87.301 -
  87.302 -    cout << "Case 2a: PASS" << endl << endl;
  87.303 -
  87.304 -    cout << "Case 2b: Calling MIME_decrypt_message with reencrypt flag set on message sent with recip 2 in BCC from enigmail with extra keys." << endl;
  87.305 -
  87.306 -    free_stringlist(keys);
  87.307 -    keys = new_stringlist(fpr_pub_extra_key_0);
  87.308 -    stringlist_add(keys, fpr_pub_extra_key_1);    
  87.309 -
  87.310 -    flags = PEP_decrypt_flag_untrusted_server;
  87.311 -    
  87.312 -    status = MIME_decrypt_message(session,
  87.313 -                                  to_reencrypt_from_enigmail_BCC.c_str(),
  87.314 -                                  to_reencrypt_from_enigmail_BCC.size(),
  87.315 -                                  &decrypted_text,
  87.316 -                                  &keys,
  87.317 -                                  &rating,
  87.318 -                                  &flags,
  87.319 -                                  &modified_src);
  87.320 -
  87.321 -    cout << decrypted_text << endl;
  87.322 -    cout << "Status is " << tl_status_string(status) << endl;
  87.323 -
  87.324 -
  87.325 -    assert(decrypted_text);
  87.326 -    assert(rating);
  87.327 -
  87.328 -    free(decrypted_text);
  87.329 -    decrypted_text = nullptr;
  87.330 -
  87.331 -    cout << "CHECK: Decrypting to see what keys it was encrypted for." << endl;
  87.332 -
  87.333 -    free(decrypted_text);
  87.334 -    decrypted_text = nullptr;
  87.335 -    flags = 0;
  87.336 -    throwaway = NULL;
  87.337 -
  87.338 -    status = MIME_decrypt_message(session,
  87.339 -                                  modified_src,
  87.340 -                                  strlen(modified_src),
  87.341 -                                  &decrypted_text,
  87.342 -                                  &keys,
  87.343 -                                  &rating,
  87.344 -                                  &flags,
  87.345 -                                  &throwaway);
  87.346 -    
  87.347 -    cout << "keys used:\n";
  87.348 -    
  87.349 -    own_key_found = false;
  87.350 -    extra_key_0_found = false;
  87.351 -    extra_key_1_found = false;
  87.352 -    
  87.353 -    i = 0;
  87.354 -    
  87.355 -    for (stringlist_t* kl = keys; kl && kl->value; kl = kl->next, i++)
  87.356 -    {
  87.357 -        if (i == 0) {
  87.358 -              cout << "Signed by " << (strcasecmp("", kl->value) == 0 ? "NOBODY" : kl->value) << endl;
  87.359 -//              assert(strcasecmp(fpr_own_recip_2_key,kl->value) == 0);
  87.360 -        }
  87.361 -        else {
  87.362 -            if (strcasecmp(fpr_own_recip_2_key, kl->value) == 0) {
  87.363 -                cout << "Encrypted for us." << endl;
  87.364 -                own_key_found = true;
  87.365 -            }
  87.366 -            else if (strcasecmp(fpr_pub_extra_key_0, kl->value) == 0) {
  87.367 -                cout << "Encrypted for extra key 0." << endl;
  87.368 -                extra_key_0_found = true;
  87.369 -            }
  87.370 -            else if (strcasecmp(fpr_pub_extra_key_1, kl->value) == 0) {
  87.371 -                cout << "Encrypted for extra key 1." << endl;
  87.372 -                extra_key_1_found = true;
  87.373 -            }
  87.374 -            else {
  87.375 -                cout << "FAIL: Encrypted for " << kl->value << ", which it should not be." << endl;
  87.376 -//                assert(false);
  87.377 -            }
  87.378 -            cout << "\t " << kl->value << endl;
  87.379 -        }
  87.380 -        assert(i < 4);
  87.381 -    }
  87.382 -//    assert (own_key_found && extra_key_0_found && extra_key_1_found);
  87.383 -    cout << "Message was encrypted for all the keys it should be, and none it should not!" << endl;
  87.384 -
  87.385 -    cout << "Case 2b: PASS" << endl << endl;
  87.386 -
  87.387 -    cout << "Case 3a: Calling MIME_decrypt_message with reencrypt flag set on message generated by pEp (message 2.0) with no extra keys." << endl;
  87.388 -    free_stringlist(keys);
  87.389 -    keys = NULL;
  87.390 -
  87.391 -    status = set_own_key(session, me_recip_1, fpr_own_recip_key);
  87.392 -    assert(status == PEP_STATUS_OK);
  87.393 -
  87.394 -    flags = PEP_decrypt_flag_untrusted_server;
  87.395 -    
  87.396 -    status = MIME_decrypt_message(session,
  87.397 -                                  to_reencrypt_from_pEp.c_str(),
  87.398 -                                  to_reencrypt_from_pEp.size(),
  87.399 -                                  &decrypted_text,
  87.400 -                                  &keys,
  87.401 -                                  &rating,
  87.402 -                                  &flags,
  87.403 -                                  &modified_src);
  87.404 -
  87.405 -    cout << decrypted_text << endl;
  87.406 -    cout << "Status is " << tl_status_string(status) << endl;
  87.407 -
  87.408 -
  87.409 -    assert(decrypted_text);
  87.410 -    assert(rating);
  87.411 -
  87.412 -    free(decrypted_text);
  87.413 -    decrypted_text = nullptr;
  87.414 -
  87.415 -    cout << "CHECK: Decrypting to see what keys it was encrypted for." << endl;
  87.416 -
  87.417 -    free(decrypted_text);
  87.418 -    decrypted_text = nullptr;
  87.419 -    flags = 0;
  87.420 -    throwaway = NULL;
  87.421 -
  87.422 -    status = MIME_decrypt_message(session,
  87.423 -                                  modified_src,
  87.424 -                                  strlen(modified_src),
  87.425 -                                  &decrypted_text,
  87.426 -                                  &keys,
  87.427 -                                  &rating,
  87.428 -                                  &flags,
  87.429 -                                  &throwaway);
  87.430 -    
  87.431 -    cout << "keys used:\n";
  87.432 -      
  87.433 -    i = 0;
  87.434 -
  87.435 -    for (stringlist_t* kl = keys; kl && kl->value; kl = kl->next, i++)
  87.436 -    {
  87.437 -        if (i == 0) {
  87.438 -            cout << "Signed by " << (strcasecmp("", kl->value) == 0 ? "NOBODY" : kl->value) << endl;
  87.439 -//            assert(strcasecmp(fpr_own_recip_key,kl->value) == 0);
  87.440 -        }
  87.441 -        else {
  87.442 -            cout << "\t " << kl->value << endl;
  87.443 -//            assert(strcasecmp(fpr_own_recip_key, kl->value) == 0);
  87.444 -            cout << "Encrypted only for own identity! Yay! It worked!" << endl;
  87.445 -        }
  87.446 -        assert(i < 2);
  87.447 -    }
  87.448 -
  87.449 -    cout << "Case 3a: PASS" << endl << endl;
  87.450 -
  87.451 -
  87.452 -    cout << "Case 3b: Calling MIME_decrypt_message with reencrypt flag set on message generated by pEp (message 2.0) with extra keys." << endl;
  87.453 -
  87.454 -    free_stringlist(keys);
  87.455 -    keys = new_stringlist(fpr_pub_extra_key_0);
  87.456 -    stringlist_add(keys, fpr_pub_extra_key_1);    
  87.457 -
  87.458 -    flags = PEP_decrypt_flag_untrusted_server;
  87.459 -    
  87.460 -    status = MIME_decrypt_message(session,
  87.461 -                                  to_reencrypt_from_pEp.c_str(),
  87.462 -                                  to_reencrypt_from_pEp.size(),
  87.463 -                                  &decrypted_text,
  87.464 -                                  &keys,
  87.465 -                                  &rating,
  87.466 -                                  &flags,
  87.467 -                                  &modified_src);
  87.468 -
  87.469 -    cout << decrypted_text << endl;
  87.470 -    cout << "Status is " << tl_status_string(status) << endl;
  87.471 -
  87.472 -    assert(decrypted_text);
  87.473 -    assert(rating);
  87.474 -
  87.475 -    free(decrypted_text);
  87.476 -    decrypted_text = nullptr;
  87.477 -
  87.478 -    cout << "CHECK: Decrypting to see what keys it was encrypted for." << endl;
  87.479 -
  87.480 -    free(decrypted_text);
  87.481 -    decrypted_text = nullptr;
  87.482 -    flags = 0;
  87.483 -    throwaway = NULL;
  87.484 -
  87.485 -    status = MIME_decrypt_message(session,
  87.486 -                                  modified_src,
  87.487 -                                  strlen(modified_src),
  87.488 -                                  &decrypted_text,
  87.489 -                                  &keys,
  87.490 -                                  &rating,
  87.491 -                                  &flags,
  87.492 -                                  &throwaway);
  87.493 -    
  87.494 -    cout << "keys used:\n";
  87.495 -    
  87.496 -    own_key_found = false;
  87.497 -    extra_key_0_found = false;
  87.498 -    extra_key_1_found = false;
  87.499 -    
  87.500 -    i = 0;
  87.501 -    
  87.502 -    for (stringlist_t* kl = keys; kl && kl->value; kl = kl->next, i++)
  87.503 -    {
  87.504 -        if (i == 0) {
  87.505 -              cout << "Signed by " << (strcasecmp("", kl->value) == 0 ? "NOBODY" : kl->value) << endl;
  87.506 -//              assert(strcasecmp(fpr_own_recip_key,kl->value) == 0);
  87.507 -        }
  87.508 -        else {
  87.509 -            if (strcasecmp(fpr_own_recip_key, kl->value) == 0) {
  87.510 -                cout << "Encrypted for us." << endl;
  87.511 -                own_key_found = true;
  87.512 -            }
  87.513 -            else if (strcasecmp(fpr_pub_extra_key_0, kl->value) == 0) {
  87.514 -                cout << "Encrypted for extra key 0." << endl;
  87.515 -                extra_key_0_found = true;
  87.516 -            }
  87.517 -            else if (strcasecmp(fpr_pub_extra_key_1, kl->value) == 0) {
  87.518 -                cout << "Encrypted for extra key 1." << endl;
  87.519 -                extra_key_1_found = true;
  87.520 -            }
  87.521 -            else {
  87.522 -                cout << "FAIL: Encrypted for " << kl->value << ", which it should not be." << endl;
  87.523 -//                assert(false);
  87.524 -            }
  87.525 -            cout << "\t " << kl->value << endl;
  87.526 -        }
  87.527 -        assert(i < 4);
  87.528 -    }
  87.529 -//    assert (own_key_found && extra_key_0_found && extra_key_1_found);
  87.530 -    cout << "Message was encrypted for all the keys it should be, and none it should not!" << endl;
  87.531 -
  87.532 -    cout << "Case 3b: PASS" << endl << endl;
  87.533 -    
  87.534 -    cout << "calling release()\n";
  87.535 -    release(session);
  87.536 -    return 0;
  87.537 -}
    88.1 --- a/test/revoke_regen_attach_test.cc	Wed May 09 09:51:05 2018 +0200
    88.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    88.3 @@ -1,95 +0,0 @@
    88.4 -// This file is under GNU General Public License 3.0
    88.5 -// see LICENSE.txt
    88.6 -
    88.7 -#include <stdlib.h>
    88.8 -#include <string.h>
    88.9 -#include <time.h>
   88.10 -#include "platform.h"
   88.11 -#include <iostream>
   88.12 -#include <fstream>
   88.13 -#include <assert.h>
   88.14 -#include "mime.h"
   88.15 -#include "message_api.h"
   88.16 -
   88.17 -using namespace std;
   88.18 -
   88.19 -int main() {
   88.20 -    cout << "\n*** revoke_regen_attach_test ***\n\n";
   88.21 -
   88.22 -    PEP_SESSION session;
   88.23 -    
   88.24 -    cout << "calling init()\n";
   88.25 -    PEP_STATUS status = init(&session);   
   88.26 -    assert(status == PEP_STATUS_OK);
   88.27 -    assert(session);
   88.28 -    cout << "init() completed.\n";
   88.29 -
   88.30 -    cout << "creating own id for : ";
   88.31 -    char *uniqname = strdup("AAAAtestuser@testdomain.org");
   88.32 -    srandom(time(NULL));
   88.33 -    for(int i=0; i < 4;i++)
   88.34 -        uniqname[i] += random() & 0xf;
   88.35 -    
   88.36 -    cout << uniqname << "\n";
   88.37 -    pEp_identity * me = new_identity(uniqname, NULL, PEP_OWN_USERID, "Test User");
   88.38 -    free(uniqname);
   88.39 -    myself(session, me);
   88.40 -
   88.41 -    cout << "generated fingerprint \n";
   88.42 -    cout << me->fpr << "\n";
   88.43 -
   88.44 -    const char *prev_fpr = strdup(me->fpr);
   88.45 -    
   88.46 -    cout << "revoke \n";
   88.47 -    
   88.48 -    key_mistrusted(session, me);
   88.49 -
   88.50 -    cout << "re-generated fingerprint \n";
   88.51 -    free(me->fpr);
   88.52 -    me->fpr = NULL;
   88.53 -    status = myself(session, me);
   88.54 -    assert(status == PEP_STATUS_OK);
   88.55 -    cout << me->fpr << "\n";
   88.56 -    
   88.57 -    assert(me->fpr);
   88.58 -    assert(strcmp(me->fpr, prev_fpr) != 0);
   88.59 -    cout << "New fpr is: " << me->fpr;
   88.60 -    
   88.61 -    me->fpr = NULL;
   88.62 -    me->comm_type = PEP_ct_unknown;
   88.63 -    myself(session, me);
   88.64 -    
   88.65 -    identity_list *to = new_identity_list(new_identity("pep.test.alice@pep-project.org", NULL, "42", "pEp Test Alice (test key don't use)"));
   88.66 -    message *msg = new_message(PEP_dir_outgoing);
   88.67 -    assert(msg);
   88.68 -    msg->from = me;
   88.69 -    msg->to = to;
   88.70 -    msg->shortmsg = strdup("hello, world");
   88.71 -    cout << "message created.\n";
   88.72 -
   88.73 -    cout << "encrypting message as MIME multipart…\n";
   88.74 -    message *enc_msg;
   88.75 -    cout << "calling encrypt_message()\n";
   88.76 -    status = encrypt_message(session, msg, NULL, &enc_msg, PEP_enc_PGP_MIME, 0);
   88.77 -    assert(status == PEP_STATUS_OK);
   88.78 -    assert(enc_msg);
   88.79 -    cout << "message encrypted.\n";
   88.80 -
   88.81 -    // cout << msg->attachments->filename;
   88.82 -    // int bl_len = bloblist_length(msg->attachments);
   88.83 -    // cout << "Message contains " << bloblist_length(msg->attachments) << " attachments." << endl;
   88.84 -    // assert(bloblist_length(msg->attachments) == 2);
   88.85 -    // assert(strcmp(msg->attachments->filename, "file://pEpkey.asc") == 0);
   88.86 -    // assert(strcmp(msg->attachments->next->filename, "file://pEpkey.asc") == 0);
   88.87 -    // 
   88.88 -    // cout << "message contains 2 key attachments.\n";
   88.89 -
   88.90 -    free_message(msg);
   88.91 -    free_message(enc_msg);
   88.92 -   
   88.93 -    // TODO: check that revoked key isn't sent after some time.
   88.94 -
   88.95 -    release(session);
   88.96 -
   88.97 -    return 0;
   88.98 -}
    89.1 --- a/test/sequence_test.cc	Wed May 09 09:51:05 2018 +0200
    89.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    89.3 @@ -1,68 +0,0 @@
    89.4 -// This file is under GNU General Public License 3.0
    89.5 -// see LICENSE.txt
    89.6 -
    89.7 -#include <iostream>
    89.8 -#include <string>
    89.9 -#include <cstring> // for std::strdup()
   89.10 -#include <assert.h>
   89.11 -#include "pEpEngine.h"
   89.12 -
   89.13 -using namespace std;
   89.14 -
   89.15 -int main() {
   89.16 -    cout << "\n*** sequence_test ***\n\n";
   89.17 -
   89.18 -    PEP_SESSION session;
   89.19 -    
   89.20 -    cout << "calling init()\n";
   89.21 -    PEP_STATUS status1 = init(&session);   
   89.22 -    assert(status1 == PEP_STATUS_OK);
   89.23 -    assert(session);
   89.24 -    cout << "init() completed.\n";
   89.25 -
   89.26 -    // sequence test code
   89.27 -
   89.28 -    int32_t value1 = 0;
   89.29 -    char *name1 = strdup("test");
   89.30 -    assert(name1);
   89.31 -    PEP_STATUS status2 = sequence_value(session, name1, &value1);
   89.32 -    assert(status2 == PEP_STATUS_OK);
   89.33 -
   89.34 -    cout << "test sequence: " << value1 << "\n";
   89.35 -
   89.36 -    int32_t value2 = 0;
   89.37 -    PEP_STATUS status3 = sequence_value(session, name1, &value2);
   89.38 -    assert(status3 == PEP_STATUS_OK);
   89.39 -
   89.40 -    cout << "test sequence: " << value2 << "\n";
   89.41 -    assert(value2 == value1 + 1);
   89.42 -//    free(name1);
   89.43 -
   89.44 -    cout << "testing sequence violation\n";
   89.45 -    int32_t value3 = value2;
   89.46 -    PEP_STATUS status4 = sequence_value(session, name1, &value3);
   89.47 -    assert(status4 == PEP_SEQUENCE_VIOLATED);
   89.48 -
   89.49 -    cout << "testing sequence non-violation\n";
   89.50 -    int32_t value4 = value2 + 1;
   89.51 -    PEP_STATUS status5 = sequence_value(session, name1, &value4);
   89.52 -    assert(status5 == PEP_STATUS_OK);
   89.53 -
   89.54 -    cout << "testing UUID generation\n";
   89.55 -    int32_t value5 = 0;
   89.56 -    char name2[37] = { 0, };
   89.57 -    PEP_STATUS status6 = sequence_value(session, name2, &value5);
   89.58 -    assert(status6 == PEP_OWN_SEQUENCE);
   89.59 -    cout << "UUID created: " << name2 << "\n";
   89.60 -
   89.61 -    cout << "set sequence value\n";
   89.62 -    int32_t value6 = value2 + 10;
   89.63 -    PEP_STATUS status7 = sequence_value(session, name1, &value6);
   89.64 -    assert(status7 == PEP_STATUS_OK);
   89.65 -    cout << "value set to " << value6 << "\n";
   89.66 -
   89.67 -    cout << "calling release()\n";
   89.68 -    release(session);
   89.69 -    return 0;
   89.70 -}
   89.71 -
    90.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    90.2 +++ b/test/src/EngineTestIndividualSuite.cc	Fri May 11 08:58:04 2018 +0200
    90.3 @@ -0,0 +1,30 @@
    90.4 +#include <cpptest.h>
    90.5 +#include <cpptest-suite.h>
    90.6 +#include <cpptest-textoutput.h>
    90.7 +#include <stdlib.h>
    90.8 +#include <unistd.h>
    90.9 +#include <ftw.h>
   90.10 +
   90.11 +#include "EngineTestSuite.h"
   90.12 +#include "EngineTestIndividualSuite.h"
   90.13 +
   90.14 +using namespace std;
   90.15 +
   90.16 +// Constructor
   90.17 +EngineTestIndividualSuite::EngineTestIndividualSuite(string suitename, string test_home_dir) 
   90.18 +    : EngineTestSuite(suitename, test_home_dir) { 
   90.19 +}
   90.20 +
   90.21 +EngineTestIndividualSuite::~EngineTestIndividualSuite() {
   90.22 +    
   90.23 +}
   90.24 +
   90.25 +void EngineTestIndividualSuite::setup() {
   90.26 +    set_full_env(); // This will be called by default before every test
   90.27 +}
   90.28 +
   90.29 +void EngineTestIndividualSuite::tear_down() {
   90.30 +    cout << "calling release()\n";
   90.31 +    release(session);
   90.32 +    restore_full_env();
   90.33 +}
    91.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    91.2 +++ b/test/src/EngineTestSessionSuite.cc	Fri May 11 08:58:04 2018 +0200
    91.3 @@ -0,0 +1,30 @@
    91.4 +#include <cpptest.h>
    91.5 +#include <cpptest-suite.h>
    91.6 +#include <cpptest-textoutput.h>
    91.7 +#include <stdlib.h>
    91.8 +#include <unistd.h>
    91.9 +#include <ftw.h>
   91.10 +
   91.11 +#include "EngineTestSuite.h"
   91.12 +#include "EngineTestSessionSuite.h"
   91.13 +
   91.14 +using namespace std;
   91.15 +
   91.16 +// Constructor
   91.17 +EngineTestSessionSuite::EngineTestSessionSuite(string suitename, string test_home_dir) 
   91.18 +    : EngineTestSuite(suitename, test_home_dir) {}
   91.19 +
   91.20 +EngineTestSessionSuite::~EngineTestSessionSuite() {}
   91.21 +
   91.22 +void EngineTestSessionSuite::setup() {
   91.23 +    EngineTestSuite::setup();
   91.24 +    if (on_test_number == 1)
   91.25 +        set_full_env();
   91.26 +}
   91.27 +
   91.28 +void EngineTestSessionSuite::tear_down() {
   91.29 +    if (on_test_number == number_of_tests)
   91.30 +        restore_full_env();
   91.31 +        
   91.32 +    EngineTestSuite::tear_down();
   91.33 +}
    92.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    92.2 +++ b/test/src/EngineTestSuite.cc	Fri May 11 08:58:04 2018 +0200
    92.3 @@ -0,0 +1,84 @@
    92.4 +#include <stdlib.h>
    92.5 +#include <unistd.h>
    92.6 +#include <ftw.h>
    92.7 +
    92.8 +#include "EngineTestSuite.h"
    92.9 +using namespace std;
   92.10 +
   92.11 +// Constructor
   92.12 +EngineTestSuite::EngineTestSuite(string suitename, string test_home_dir) {
   92.13 +    // FIXME: deal with base
   92.14 +    test_home = test_home_dir;
   92.15 +    
   92.16 +    // TODO: This is *nix specific, which the current testing env is anyway,
   92.17 +    // but it needn't remain so forever and always
   92.18 +    char* tmp = getenv("GNUPGHOME");
   92.19 +    if (tmp)
   92.20 +        prev_gpg_home = getenv("GNUPGHOME");
   92.21 +        
   92.22 +    number_of_tests = 0;
   92.23 +    on_test_number = 0;
   92.24 +}
   92.25 +
   92.26 +EngineTestSuite::~EngineTestSuite() {}
   92.27 +
   92.28 +void EngineTestSuite::add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()> test_func) {
   92.29 +    test_map.insert(test_func);
   92.30 +    register_test(test_func.second, test_func.first);
   92.31 +    number_of_tests++;
   92.32 +}
   92.33 +
   92.34 +void EngineTestSuite::set_full_env() {
   92.35 +
   92.36 +    if (test_home.empty())
   92.37 +        throw std::runtime_error("SETUP: BAD INITIALISATION. No test home.");
   92.38 +    
   92.39 +    int success = system("gpgconf --kill all");
   92.40 +    if (success != 0)
   92.41 +        throw std::runtime_error("SETUP: Error when executing 'gpgconf --kill all'.");
   92.42 +    
   92.43 +    string home = getenv("HOME");
   92.44 +    if (test_home.compare(home) == 0 || test_home.compare(home + "/") == 0 ||
   92.45 +        test_home.compare(home + "/.gnupg") == 0 || test_home.compare(home + ".gnupg") == 0 ||
   92.46 +        test_home.compare(prev_gpg_home) == 0 || test_home.compare(prev_gpg_home + "/.gnupg") == 0 ||
   92.47 +        test_home.compare(prev_gpg_home + ".gnupg") == 0)
   92.48 +        throw std::runtime_error("SETUP: new GNUPGHOME threatens to mess up user GNUPGHOME (and delete all their keys). NO DICE.");
   92.49 +    
   92.50 +    cout << "Ok - checked if new test home will be safe. We'll try and make the directory, deleting it if it has already exists." << endl;
   92.51 +    
   92.52 +    struct stat buf;
   92.53 +    
   92.54 +    success = setenv("GNUPGHOME", (test_home + "/.gnupg").c_str(), 1);
   92.55 +    if (success != 0)
   92.56 +        throw std::runtime_error("SETUP: Error when setting GNUPGHOME.");
   92.57 +
   92.58 +    success = setenv("HOME", test_home.c_str(), 1);
   92.59 +    if (success != 0)
   92.60 +        throw std::runtime_error("SETUP: Cannot set test_home for init.");
   92.61 +    
   92.62 +    cout << "calling init()\n";
   92.63 +    PEP_STATUS status = init(&session);
   92.64 +    // assert(status == PEP_STATUS_OK);
   92.65 +    // assert(session);
   92.66 +    cout << "init() completed.\n";
   92.67 +
   92.68 +    success = setenv("HOME", home.c_str(), 1);
   92.69 +    if (success != 0)
   92.70 +        throw std::runtime_error("SETUP: Cannot reset home directory! Either set environment variable manually back to your home, or quit this session!");    
   92.71 +}
   92.72 +
   92.73 +void EngineTestSuite::restore_full_env() {
   92.74 +    int success = system("gpgconf --kill all");
   92.75 +    if (success != 0)
   92.76 +        throw std::runtime_error("RESTORE: Error when executing 'gpgconf --kill all'.");
   92.77 +
   92.78 +    success = setenv("GNUPGHOME", prev_gpg_home.c_str(), 1);
   92.79 +    if (success != 0)
   92.80 +        throw std::runtime_error("RESTORE: Warning - cannot restore GNUPGHOME. Either set environment variable manually back to your home, or quit this session!");
   92.81 +}
   92.82 +
   92.83 +void EngineTestSuite::setup() {
   92.84 +    on_test_number++;
   92.85 +}
   92.86 +
   92.87 +void EngineTestSuite::tear_down() {}
    93.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    93.2 +++ b/test/src/SuiteMaker.cc	Fri May 11 08:58:04 2018 +0200
    93.3 @@ -0,0 +1,178 @@
    93.4 +// This file is under GNU General Public License 3.0
    93.5 +// see LICENSE.txt
    93.6 +
    93.7 +//
    93.8 +// src/SuiteMaker.cc generated by gensuitemaker.py - changes may be overwritten. You've been warned!
    93.9 +//
   93.10 +
   93.11 +#include <cpptest.h>
   93.12 +#include <cpptest-suite.h>
   93.13 +#include <memory>
   93.14 +#include <vector>
   93.15 +#include "SuiteMaker.h"
   93.16 +
   93.17 +// Begin where we generate stuff
   93.18 +#include "MapAsn1Tests.h"
   93.19 +#include "DecorateTests.h"
   93.20 +#include "EncryptMissingPrivateKeyTests.h"
   93.21 +#include "KeyeditTests.h"
   93.22 +#include "BlacklistAcceptNewKeyTests.h"
   93.23 +#include "DecryptAttachPrivateKeyUntrustedTests.h"
   93.24 +#include "AppleMailTests.h"
   93.25 +#include "CaseAndDotAddressTests.h"
   93.26 +#include "SequenceTests.h"
   93.27 +#include "MessageApiTests.h"
   93.28 +#include "I18nTests.h"
   93.29 +#include "CrashdumpTests.h"
   93.30 +#include "PgpBinaryTests.h"
   93.31 +#include "RevokeRegenAttachTests.h"
   93.32 +#include "BlacklistTests.h"
   93.33 +#include "LeastCommonDenomColorTests.h"
   93.34 +#include "PepSubjectReceivedTests.h"
   93.35 +#include "MistrustUndoTests.h"
   93.36 +#include "StringpairListTests.h"
   93.37 +#include "PgpListKeysTests.h"
   93.38 +#include "ReencryptPlusExtraKeysTests.h"
   93.39 +#include "MimeTests.h"
   93.40 +#include "BloblistTests.h"
   93.41 +#include "NewUpdateIdAndMyselfTests.h"
   93.42 +#include "StringlistTests.h"
   93.43 +#include "LeastColorGroupTests.h"
   93.44 +#include "ExternalRevokeTests.h"
   93.45 +#include "EncryptForIdentityTests.h"
   93.46 +#include "TrustwordsTests.h"
   93.47 +#include "TrustManipulationTests.h"
   93.48 +#include "MessageTwoPointOhTests.h"
   93.49 +#include "EncryptAttachPrivateKeyTests.h"
   93.50 +#include "DecryptAttachPrivateKeyTrustedTests.h"
   93.51 +#include "IdentityListTests.h"
   93.52 +#include "UserIDAliasTests.h"
   93.53 +
   93.54 +
   93.55 +const char* SuiteMaker::all_suites[] = {
   93.56 +    "MapAsn1Tests",
   93.57 +    "DecorateTests",
   93.58 +    "EncryptMissingPrivateKeyTests",
   93.59 +    "KeyeditTests",
   93.60 +    "BlacklistAcceptNewKeyTests",
   93.61 +    "DecryptAttachPrivateKeyUntrustedTests",
   93.62 +    "AppleMailTests",
   93.63 +    "CaseAndDotAddressTests",
   93.64 +    "SequenceTests",
   93.65 +    "MessageApiTests",
   93.66 +    "I18nTests",
   93.67 +    "CrashdumpTests",
   93.68 +    "PgpBinaryTests",
   93.69 +    "RevokeRegenAttachTests",
   93.70 +    "BlacklistTests",
   93.71 +    "LeastCommonDenomColorTests",
   93.72 +    "PepSubjectReceivedTests",
   93.73 +    "MistrustUndoTests",
   93.74 +    "StringpairListTests",
   93.75 +    "PgpListKeysTests",
   93.76 +    "ReencryptPlusExtraKeysTests",
   93.77 +    "MimeTests",
   93.78 +    "BloblistTests",
   93.79 +    "NewUpdateIdAndMyselfTests",
   93.80 +    "StringlistTests",
   93.81 +    "LeastColorGroupTests",
   93.82 +    "ExternalRevokeTests",
   93.83 +    "EncryptForIdentityTests",
   93.84 +    "TrustwordsTests",
   93.85 +    "TrustManipulationTests",
   93.86 +    "MessageTwoPointOhTests",
   93.87 +    "EncryptAttachPrivateKeyTests",
   93.88 +    "DecryptAttachPrivateKeyTrustedTests",
   93.89 +    "IdentityListTests",
   93.90 +    "UserIDAliasTests",
   93.91 +};
   93.92 +
   93.93 +// This file is generated, so magic constants are ok.
   93.94 +int SuiteMaker::num_suites = 35;
   93.95 +
   93.96 +void SuiteMaker::suitemaker_build(const char* test_class_name, const char* test_home, Test::Suite** test_suite) {
   93.97 +    if (strcmp(test_class_name, "MapAsn1Tests") == 0)
   93.98 +        *test_suite = new MapAsn1Tests(test_class_name, test_home);
   93.99 +    else if (strcmp(test_class_name, "DecorateTests") == 0)
  93.100 +        *test_suite = new DecorateTests(test_class_name, test_home);
  93.101 +    else if (strcmp(test_class_name, "EncryptMissingPrivateKeyTests") == 0)
  93.102 +        *test_suite = new EncryptMissingPrivateKeyTests(test_class_name, test_home);
  93.103 +    else if (strcmp(test_class_name, "KeyeditTests") == 0)
  93.104 +        *test_suite = new KeyeditTests(test_class_name, test_home);
  93.105 +    else if (strcmp(test_class_name, "BlacklistAcceptNewKeyTests") == 0)
  93.106 +        *test_suite = new BlacklistAcceptNewKeyTests(test_class_name, test_home);
  93.107 +    else if (strcmp(test_class_name, "DecryptAttachPrivateKeyUntrustedTests") == 0)
  93.108 +        *test_suite = new DecryptAttachPrivateKeyUntrustedTests(test_class_name, test_home);
  93.109 +    else if (strcmp(test_class_name, "AppleMailTests") == 0)
  93.110 +        *test_suite = new AppleMailTests(test_class_name, test_home);
  93.111 +    else if (strcmp(test_class_name, "CaseAndDotAddressTests") == 0)
  93.112 +        *test_suite = new CaseAndDotAddressTests(test_class_name, test_home);
  93.113 +    else if (strcmp(test_class_name, "SequenceTests") == 0)
  93.114 +        *test_suite = new SequenceTests(test_class_name, test_home);
  93.115 +    else if (strcmp(test_class_name, "MessageApiTests") == 0)
  93.116 +        *test_suite = new MessageApiTests(test_class_name, test_home);
  93.117 +    else if (strcmp(test_class_name, "I18nTests") == 0)
  93.118 +        *test_suite = new I18nTests(test_class_name, test_home);
  93.119 +    else if (strcmp(test_class_name, "CrashdumpTests") == 0)
  93.120 +        *test_suite = new CrashdumpTests(test_class_name, test_home);
  93.121 +    else if (strcmp(test_class_name, "PgpBinaryTests") == 0)
  93.122 +        *test_suite = new PgpBinaryTests(test_class_name, test_home);
  93.123 +    else if (strcmp(test_class_name, "RevokeRegenAttachTests") == 0)
  93.124 +        *test_suite = new RevokeRegenAttachTests(test_class_name, test_home);
  93.125 +    else if (strcmp(test_class_name, "BlacklistTests") == 0)
  93.126 +        *test_suite = new BlacklistTests(test_class_name, test_home);
  93.127 +    else if (strcmp(test_class_name, "LeastCommonDenomColorTests") == 0)
  93.128 +        *test_suite = new LeastCommonDenomColorTests(test_class_name, test_home);
  93.129 +    else if (strcmp(test_class_name, "PepSubjectReceivedTests") == 0)
  93.130 +        *test_suite = new PepSubjectReceivedTests(test_class_name, test_home);
  93.131 +    else if (strcmp(test_class_name, "MistrustUndoTests") == 0)
  93.132 +        *test_suite = new MistrustUndoTests(test_class_name, test_home);
  93.133 +    else if (strcmp(test_class_name, "StringpairListTests") == 0)
  93.134 +        *test_suite = new StringpairListTests(test_class_name, test_home);
  93.135 +    else if (strcmp(test_class_name, "PgpListKeysTests") == 0)
  93.136 +        *test_suite = new PgpListKeysTests(test_class_name, test_home);
  93.137 +    else if (strcmp(test_class_name, "ReencryptPlusExtraKeysTests") == 0)
  93.138 +        *test_suite = new ReencryptPlusExtraKeysTests(test_class_name, test_home);
  93.139 +    else if (strcmp(test_class_name, "MimeTests") == 0)
  93.140 +        *test_suite = new MimeTests(test_class_name, test_home);
  93.141 +    else if (strcmp(test_class_name, "BloblistTests") == 0)
  93.142 +        *test_suite = new BloblistTests(test_class_name, test_home);
  93.143 +    else if (strcmp(test_class_name, "NewUpdateIdAndMyselfTests") == 0)
  93.144 +        *test_suite = new NewUpdateIdAndMyselfTests(test_class_name, test_home);
  93.145 +    else if (strcmp(test_class_name, "StringlistTests") == 0)
  93.146 +        *test_suite = new StringlistTests(test_class_name, test_home);
  93.147 +    else if (strcmp(test_class_name, "LeastColorGroupTests") == 0)
  93.148 +        *test_suite = new LeastColorGroupTests(test_class_name, test_home);
  93.149 +    else if (strcmp(test_class_name, "ExternalRevokeTests") == 0)
  93.150 +        *test_suite = new ExternalRevokeTests(test_class_name, test_home);
  93.151 +    else if (strcmp(test_class_name, "EncryptForIdentityTests") == 0)
  93.152 +        *test_suite = new EncryptForIdentityTests(test_class_name, test_home);
  93.153 +    else if (strcmp(test_class_name, "TrustwordsTests") == 0)
  93.154 +        *test_suite = new TrustwordsTests(test_class_name, test_home);
  93.155 +    else if (strcmp(test_class_name, "TrustManipulationTests") == 0)
  93.156 +        *test_suite = new TrustManipulationTests(test_class_name, test_home);
  93.157 +    else if (strcmp(test_class_name, "MessageTwoPointOhTests") == 0)
  93.158 +        *test_suite = new MessageTwoPointOhTests(test_class_name, test_home);
  93.159 +    else if (strcmp(test_class_name, "EncryptAttachPrivateKeyTests") == 0)
  93.160 +        *test_suite = new EncryptAttachPrivateKeyTests(test_class_name, test_home);
  93.161 +    else if (strcmp(test_class_name, "DecryptAttachPrivateKeyTrustedTests") == 0)
  93.162 +        *test_suite = new DecryptAttachPrivateKeyTrustedTests(test_class_name, test_home);
  93.163 +    else if (strcmp(test_class_name, "IdentityListTests") == 0)
  93.164 +        *test_suite = new IdentityListTests(test_class_name, test_home);
  93.165 +    else if (strcmp(test_class_name, "UserIDAliasTests") == 0)
  93.166 +        *test_suite = new UserIDAliasTests(test_class_name, test_home);
  93.167 +}
  93.168 +
  93.169 +void SuiteMaker::suitemaker_buildlist(const char** test_class_names, int num_to_run, const char* test_home, std::vector<Test::Suite*>& test_suites) {
  93.170 +    for (int i = 0; i < num_to_run; i++) {
  93.171 +        Test::Suite* suite = NULL;
  93.172 +        SuiteMaker::suitemaker_build(test_class_names[i], test_home, &suite);
  93.173 +        if (!suite)
  93.174 +            throw std::runtime_error("Could not create a test suite instance."); // FIXME, better error, cleanup, obviously
  93.175 +        test_suites.push_back(suite);
  93.176 +    }
  93.177 +}
  93.178 +void SuiteMaker::suitemaker_buildall(const char* test_home, std::vector<Test::Suite*>& test_suites) {
  93.179 +    SuiteMaker::suitemaker_buildlist(SuiteMaker::all_suites, SuiteMaker::num_suites, test_home, test_suites);
  93.180 +}
  93.181 +
    94.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    94.2 +++ b/test/src/TestDriver.cc	Fri May 11 08:58:04 2018 +0200
    94.3 @@ -0,0 +1,87 @@
    94.4 +#include <stdlib.h>
    94.5 +#include <cpptest.h>
    94.6 +#include <cpptest-suite.h>
    94.7 +#include <cpptest-textoutput.h>
    94.8 +#include <string>
    94.9 +#include <vector>
   94.10 +#include <sys/stat.h>
   94.11 +#include <errno.h>
   94.12 +#include <stdlib.h>
   94.13 +#include <unistd.h>
   94.14 +#include <ftw.h>
   94.15 +#include "EngineTestSuite.h"
   94.16 +#include "EngineTestIndividualSuite.h"
   94.17 +#include "EngineTestSessionSuite.h"
   94.18 +#include "SuiteMaker.h"
   94.19 +
   94.20 +using namespace std;
   94.21 +
   94.22 +string common_test_home = "./pEp_test_home";
   94.23 +
   94.24 +void usage() {
   94.25 +    throw std::runtime_error("Bad usage. Fix me, you loser developer.");
   94.26 +}
   94.27 +
   94.28 +int util_delete_filepath(const char *filepath, 
   94.29 +                         const struct stat *file_stat, 
   94.30 +                         int ftw_info, 
   94.31 +                         struct FTW * ftw_struct) {
   94.32 +    int retval = 0;
   94.33 +    switch (ftw_info) {
   94.34 +        case FTW_DP:
   94.35 +            retval = rmdir(filepath);
   94.36 +            break;
   94.37 +        case FTW_F:
   94.38 +        case FTW_SLN:
   94.39 +            retval = unlink(filepath);
   94.40 +            break;    
   94.41 +        default:
   94.42 +            retval = -1;
   94.43 +    }
   94.44 +    
   94.45 +    return retval;
   94.46 +}
   94.47 +
   94.48 +
   94.49 +int main(int argc, const char** argv) {
   94.50 +    const int MIN_ARGC = 1;
   94.51 +    if (argc < MIN_ARGC)
   94.52 +        usage();
   94.53 +    
   94.54 +    struct stat dirchk;
   94.55 +    if (stat(common_test_home.c_str(), &dirchk) == 0) {
   94.56 +        if (!S_ISDIR(dirchk.st_mode))
   94.57 +            throw std::runtime_error(("The test directory, " + common_test_home + "exists, but is not a directory.").c_str()); 
   94.58 +                    
   94.59 +        struct stat buf;
   94.60 +
   94.61 +        if (stat(common_test_home.c_str(), &buf) == 0) {
   94.62 +            cout << common_test_home << " exists. We'll recursively delete. We hope we're not horking your whole system..." << endl;
   94.63 +            int success = nftw((common_test_home + "/.").c_str(), util_delete_filepath, 100, FTW_DEPTH);
   94.64 +        }
   94.65 +    }
   94.66 +    else {
   94.67 +        int errchk = mkdir(common_test_home.c_str(), S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
   94.68 +        cout << errchk << endl;
   94.69 +        if (errchk != 0)
   94.70 +            throw std::runtime_error("Error creating a test directory.");
   94.71 +    }
   94.72 +                    
   94.73 +    EngineTestSuite* test_runner = new EngineTestSuite("MainTestDriver", common_test_home);
   94.74 +
   94.75 +    std::vector<Test::Suite*> suites_to_run;
   94.76 +    
   94.77 +    if (argc == MIN_ARGC)
   94.78 +        SuiteMaker::suitemaker_buildall(common_test_home.c_str(), suites_to_run);
   94.79 +    else
   94.80 +        SuiteMaker::suitemaker_buildlist(&argv[1], argc - MIN_ARGC, common_test_home.c_str(), suites_to_run);
   94.81 +        
   94.82 +    for (std::vector<Test::Suite*>::iterator it = suites_to_run.begin(); it != suites_to_run.end(); ++it) {
   94.83 +        auto_ptr<Test::Suite> suite(*it);
   94.84 +        test_runner->add(suite); 
   94.85 +    }
   94.86 +
   94.87 +    Test::TextOutput output(Test::TextOutput::Verbose);
   94.88 +    return test_runner->run(output, false) ? 1 : 0;
   94.89 +    
   94.90 +}
    95.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    95.2 +++ b/test/src/engine_tests/AppleMailTests.cc	Fri May 11 08:58:04 2018 +0200
    95.3 @@ -0,0 +1,121 @@
    95.4 +// This file is under GNU General Public License 3.0
    95.5 +// see LICENSE.txt
    95.6 +
    95.7 +#include <cpptest.h>
    95.8 +#include <cpptest-suite.h>
    95.9 +#include <cpptest-textoutput.h>
   95.10 +#include <stdlib.h>
   95.11 +#include <string.h>
   95.12 +#include <iostream>
   95.13 +#include <fstream>
   95.14 +#include <string>
   95.15 +#include <cstring> // for strcmp()
   95.16 +#include "platform.h"
   95.17 +#include <iostream>
   95.18 +#include <fstream>
   95.19 +#include <sstream>
   95.20 +#include "keymanagement.h"
   95.21 +#include "message_api.h"
   95.22 +#include "mime.h"
   95.23 +#include "test_util.h" // for slurp()
   95.24 +
   95.25 +#include "EngineTestSuite.h"
   95.26 +#include "EngineTestSessionSuite.h"
   95.27 +#include "AppleMailTests.h"
   95.28 +
   95.29 +using namespace std;
   95.30 +
   95.31 +AppleMailTests::AppleMailTests(string suitename, string test_home_dir) : 
   95.32 +    EngineTestSessionSuite::EngineTestSessionSuite(suitename, test_home_dir) {            
   95.33 +    TEST_ADD(AppleMailTests::check_apple_mail);
   95.34 +}
   95.35 +
   95.36 +void AppleMailTests::check_apple_mail() {
   95.37 +    
   95.38 +    const char* mailfile = "test_mails/apple_mail_TC_signed_encrypted.eml";
   95.39 +    
   95.40 +    const string keytextkey1 = slurp("test_keys/pub/pep-test-apple-0x1CCBC7D7_pub.asc");
   95.41 +    const string keytextkey2 = slurp("test_keys/priv/pep-test-recip-0x08DB0AEE_priv.asc");
   95.42 +    const string keytextkey3 = slurp("test_keys/pub/pep-test-recip-0x08DB0AEE_pub.asc");
   95.43 +
   95.44 +    PEP_STATUS statuskey1 = import_key(session, keytextkey1.c_str(), keytextkey1.length(), NULL);
   95.45 +    PEP_STATUS statuskey2 = import_key(session, keytextkey2.c_str(), keytextkey2.length(), NULL);
   95.46 +    PEP_STATUS statuskey3 = import_key(session, keytextkey3.c_str(), keytextkey3.length(), NULL);
   95.47 +        
   95.48 +    const string mailtext = slurp(mailfile);
   95.49 +    pEp_identity * me = new_identity("pep.test.recip@kgrothoff.org", "93D19F24AD6F4C4BA9134AAF84D9217908DB0AEE", PEP_OWN_USERID, "pEp Test Recipient");    
   95.50 +    me->me = true;    
   95.51 +    PEP_STATUS status = set_own_key(session, me, "93D19F24AD6F4C4BA9134AAF84D9217908DB0AEE");
   95.52 +    
   95.53 +    pEp_identity * you = new_identity("pep.test.apple@pep-project.org", NULL, "pep.test.apple@pep-project.org", "pEp Apple Test");    
   95.54 +    you->me = false;    
   95.55 +    status = update_identity(session, you);
   95.56 +
   95.57 +    trust_personal_key(session, you);
   95.58 +    
   95.59 +    status = update_identity(session, you);
   95.60 +    
   95.61 +    message* msg_ptr = nullptr;
   95.62 +    message* dest_msg = nullptr;
   95.63 +    message* final_ptr = nullptr;
   95.64 +    stringlist_t* keylist = nullptr;
   95.65 +    PEP_rating rating;
   95.66 +    PEP_decrypt_flags_t flags = 0;
   95.67 +    
   95.68 +    status = mime_decode_message(mailtext.c_str(), mailtext.length(), &msg_ptr);
   95.69 +    TEST_ASSERT_MSG((status == PEP_STATUS_OK), "status == PEP_STATUS_OK");
   95.70 +    TEST_ASSERT_MSG((msg_ptr), "msg_ptr");
   95.71 +    
   95.72 +    update_identity(session, msg_ptr->from);
   95.73 +    update_identity(session, msg_ptr->to->ident);
   95.74 +    
   95.75 +    final_ptr = msg_ptr;
   95.76 +    
   95.77 +    status = decrypt_message(session, msg_ptr, &dest_msg, &keylist, &rating, &flags);
   95.78 +    final_ptr = dest_msg ? dest_msg : msg_ptr;
   95.79 +  
   95.80 +    cout << "shortmsg: " << final_ptr->shortmsg << endl << endl;
   95.81 +    cout << "longmsg: " << final_ptr->longmsg << endl << endl;
   95.82 +    cout << "longmsg_formatted: " << (final_ptr->longmsg_formatted ? final_ptr->longmsg_formatted : "(empty)") << endl << endl;
   95.83 +
   95.84 +    TEST_ASSERT_MSG((color_from_rating(rating) == PEP_color_green), "color_from_rating(rating) == PEP_color_green");
   95.85 +
   95.86 +    if (final_ptr == dest_msg)
   95.87 +    	free_message(dest_msg);
   95.88 +    free_message(msg_ptr);
   95.89 +    free_stringlist(keylist);
   95.90 +
   95.91 +    msg_ptr = nullptr;
   95.92 +    dest_msg = nullptr;
   95.93 +    final_ptr = nullptr;
   95.94 +    keylist = nullptr;
   95.95 +    rating = PEP_rating_unreliable;
   95.96 +    flags = 0;
   95.97 +    
   95.98 +    const char* mailfile2 = "test_mails/apple_mail_TC_html_signed_encrypted.eml";
   95.99 +    const string mailtext2 = slurp(mailfile2);
  95.100 +    
  95.101 +    status = mime_decode_message(mailtext2.c_str(), mailtext2.length(), &msg_ptr);
  95.102 +    TEST_ASSERT_MSG((status == PEP_STATUS_OK), "status == PEP_STATUS_OK");
  95.103 +    TEST_ASSERT_MSG((msg_ptr), "msg_ptr");
  95.104 +    final_ptr = msg_ptr;
  95.105 +    status = decrypt_message(session, msg_ptr, &dest_msg, &keylist, &rating, &flags);
  95.106 +    final_ptr = dest_msg ? dest_msg : msg_ptr;
  95.107 +  
  95.108 +    cout << "shortmsg: " << final_ptr->shortmsg << endl << endl;
  95.109 +    cout << "longmsg: " << final_ptr->longmsg << endl << endl;
  95.110 +    cout << "longmsg_formatted: " << (final_ptr->longmsg_formatted ? final_ptr->longmsg_formatted : "(empty)") << endl << endl;
  95.111 +
  95.112 +    TEST_ASSERT_MSG((color_from_rating(rating) == PEP_color_green), "color_from_rating(rating) == PEP_color_green");
  95.113 +
  95.114 +    if (final_ptr == dest_msg)
  95.115 +    	free_message(dest_msg);
  95.116 +    free_message(msg_ptr);
  95.117 +    free_stringlist(keylist);
  95.118 +
  95.119 +    msg_ptr = nullptr;
  95.120 +    dest_msg = nullptr;
  95.121 +    final_ptr = nullptr;
  95.122 +    keylist = nullptr;
  95.123 +    rating = PEP_rating_unreliable;        
  95.124 +}
    96.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    96.2 +++ b/test/src/engine_tests/BlacklistAcceptNewKeyTests.cc	Fri May 11 08:58:04 2018 +0200
    96.3 @@ -0,0 +1,102 @@
    96.4 +// This file is under GNU General Public License 3.0
    96.5 +// see LICENSE.txt
    96.6 +
    96.7 +#include <stdlib.h>
    96.8 +#include <string>
    96.9 +#include <cstring> // for strcmp()
   96.10 +#include <cpptest.h>
   96.11 +
   96.12 +#include "test_util.h"
   96.13 +
   96.14 +#include "pEpEngine.h"
   96.15 +#include "blacklist.h"
   96.16 +#include "keymanagement.h"
   96.17 +#include "message_api.h"
   96.18 +#include "mime.h"
   96.19 +
   96.20 +#include "EngineTestSessionSuite.h"
   96.21 +#include "BlacklistAcceptNewKeyTests.h"
   96.22 +
   96.23 +using namespace std;
   96.24 +
   96.25 +BlacklistAcceptNewKeyTests::BlacklistAcceptNewKeyTests(string suitename, string test_home_dir) :
   96.26 +    EngineTestSessionSuite::EngineTestSessionSuite(suitename, test_home_dir) {
   96.27 +    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("BlacklistAcceptNewKeyTests::check_blacklist_accept_new_key"),
   96.28 +                                                                      static_cast<Func>(&BlacklistAcceptNewKeyTests::check_blacklist_accept_new_key)));
   96.29 +}
   96.30 +
   96.31 +void BlacklistAcceptNewKeyTests::check_blacklist_accept_new_key() {
   96.32 +
   96.33 +    // blacklist test code
   96.34 +
   96.35 +    cout << "blacklist only key for identity / add key / check which key is used" << endl;
   96.36 +    
   96.37 +    // 2797 65A2 FEB5 B7C7 31B8  61D9 3E4C EFD9 F7AF 4684 - this is the blacklisted key in blacklisted_pub.asc
   96.38 +
   96.39 +    /* read the key into memory */
   96.40 +    const string keytext = slurp("blacklisted_pub.asc");
   96.41 +    
   96.42 +    /* import it into pep */
   96.43 +    PEP_STATUS status7 = import_key(session, keytext.c_str(), keytext.length(), NULL);
   96.44 +    
   96.45 +    const char* bl_fpr_1 = "279765A2FEB5B7C731B861D93E4CEFD9F7AF4684";
   96.46 +    bool is_blacklisted = false;
   96.47 +    
   96.48 +    pEp_identity* blacklisted_identity = new_identity("blacklistedkeys@kgrothoff.org",
   96.49 +                                                      bl_fpr_1,
   96.50 +                                                      NULL,
   96.51 +                                                      "Blacklist Keypair");
   96.52 +    PEP_STATUS status8 = update_identity(session, blacklisted_identity);
   96.53 +    PEP_STATUS status9 = blacklist_add(session, bl_fpr_1);
   96.54 +    PEP_STATUS status10 = blacklist_is_listed(session, bl_fpr_1, &is_blacklisted);
   96.55 +    TEST_ASSERT_MSG((is_blacklisted), "is_blacklisted");
   96.56 +    PEP_STATUS status11 = update_identity(session, blacklisted_identity);
   96.57 +    TEST_ASSERT_MSG((status11 == PEP_STATUS_OK), "status11 == PEP_STATUS_OK");
   96.58 +    TEST_ASSERT_MSG((_streq(bl_fpr_1, blacklisted_identity->fpr)), "_streq(bl_fpr_1, blacklisted_identity->fpr)");
   96.59 +    
   96.60 +    bool id_def, us_def, addr_def;
   96.61 +    status11 = get_valid_pubkey(session, blacklisted_identity,
   96.62 +                                &id_def, &us_def, &addr_def, true);
   96.63 +    TEST_ASSERT_MSG((blacklisted_identity->comm_type == PEP_ct_unknown), "blacklisted_identity->comm_type == PEP_ct_unknown");
   96.64 +                        
   96.6