Changed test_utils for reorg sync_test_refactor
authorKrista 'DarthMama' Bennett <krista@pep.foundation>
Mon, 11 Feb 2019 08:35:27 +0100
branchsync_test_refactor
changeset 3292673b8c6da681
parent 3281 676ee202da9b
child 3294 7b95c642c491
Changed test_utils for reorg
test/convenience_scripts/compile_it.sh
test/convenience_scripts/mime_decrypt.cc
test/convenience_scripts/mime_encrypt.cc
test/convenience_scripts/mime_encrypt_decrypt.cc
test/include/TestUtils.h
test/include/test_util.h
test/src/EngineTestSuite.cc
test/src/TestUtils.cc
test/src/engine_tests/AppleMailTests.cc
test/src/engine_tests/BCCTests.cc
test/src/engine_tests/BlacklistAcceptNewKeyTests.cc
test/src/engine_tests/BlacklistTests.cc
test/src/engine_tests/CaseAndDotAddressTests.cc
test/src/engine_tests/CheckRenewedExpiredKeyTrustStatusTests.cc
test/src/engine_tests/DecorateTests.cc
test/src/engine_tests/DecryptAttachPrivateKeyTrustedTests.cc
test/src/engine_tests/DecryptAttachPrivateKeyUntrustedTests.cc
test/src/engine_tests/EncryptAttachPrivateKeyTests.cc
test/src/engine_tests/EncryptForIdentityTests.cc
test/src/engine_tests/EncryptMissingPrivateKeyTests.cc
test/src/engine_tests/Engine358Tests.cc
test/src/engine_tests/Engine463Tests.cc
test/src/engine_tests/ExpiredSubkeyTests.cc
test/src/engine_tests/ExternalRevokeTests.cc
test/src/engine_tests/HeaderKeyImportTests.cc
test/src/engine_tests/IntegrityTests.do.not.run.before.ENGINE-434
test/src/engine_tests/KeyAttachmentTests.cc
test/src/engine_tests/KeyResetMessageTests.cc
test/src/engine_tests/LeastColorGroupTests.cc
test/src/engine_tests/LeastCommonDenomColorTests.cc
test/src/engine_tests/MessageApiTests.cc
test/src/engine_tests/MessageNullFromTests.cc
test/src/engine_tests/MessageTwoPointOhTests.cc
test/src/engine_tests/NewUpdateIdAndMyselfTests.cc
test/src/engine_tests/PepSubjectReceivedTests.cc
test/src/engine_tests/ReencryptPlusExtraKeysTests.cc
test/src/engine_tests/RevokeRegenAttachTests.cc
test/src/engine_tests/SignOnlyTests.cc
test/src/engine_tests/SimpleBodyNotAltTests.cc
test/src/engine_tests/SubkeyRatingEvalTests.cc
test/src/engine_tests/TrustManipulationTests.cc
test/src/engine_tests/UserIDAliasTests.cc
test/src/engine_tests/UserIdCollisionTests.cc
test/src/util/test_util.cc
     1.1 --- a/test/convenience_scripts/compile_it.sh	Wed Feb 06 19:25:40 2019 +0100
     1.2 +++ b/test/convenience_scripts/compile_it.sh	Mon Feb 11 08:35:27 2019 +0100
     1.3 @@ -1,6 +1,6 @@
     1.4  #!/bin/bash
     1.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
     1.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
     1.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
     1.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
     1.9 +#g++ -std=gnu++11 -pthread -fdiagnostics-color=always -I../src -I../asn.1 -I/home/krista/include -I./include -g -ggdb   -c -o TestUtils.o src/util/TestUtils.cc
    1.10 +g++ -std=gnu++11 -pthread -fdiagnostics-color=always -I../src -I../asn.1 -I/home/krista/include -I./include -g -ggdb   -c -o TestUtils.o TestUtils.cc
    1.11 +g++ -std=gnu++11 -pthread $1.o TestUtils.o  -L/home/krista/lib -L../asn.1 -L../src  -letpan -lpEpEngine -lstdc++ -lasn1 -luuid -lsqlite3 -o $1
    1.12  
     2.1 --- a/test/convenience_scripts/mime_decrypt.cc	Wed Feb 06 19:25:40 2019 +0100
     2.2 +++ b/test/convenience_scripts/mime_decrypt.cc	Mon Feb 11 08:35:27 2019 +0100
     2.3 @@ -10,7 +10,7 @@
     2.4  #include "mime.h"
     2.5  #include "message_api.h"
     2.6  #include "keymanagement.h"
     2.7 -#include "test_util.h"
     2.8 +#include "TestUtils.h"
     2.9  
    2.10  using namespace std;
    2.11  
     3.1 --- a/test/convenience_scripts/mime_encrypt.cc	Wed Feb 06 19:25:40 2019 +0100
     3.2 +++ b/test/convenience_scripts/mime_encrypt.cc	Mon Feb 11 08:35:27 2019 +0100
     3.3 @@ -10,7 +10,7 @@
     3.4  #include "mime.h"
     3.5  #include "message_api.h"
     3.6  #include "keymanagement.h"
     3.7 -#include "test_util.h"
     3.8 +#include "TestUtils.h"
     3.9  
    3.10  using namespace std;
    3.11  
     4.1 --- a/test/convenience_scripts/mime_encrypt_decrypt.cc	Wed Feb 06 19:25:40 2019 +0100
     4.2 +++ b/test/convenience_scripts/mime_encrypt_decrypt.cc	Mon Feb 11 08:35:27 2019 +0100
     4.3 @@ -10,7 +10,7 @@
     4.4  #include "mime.h"
     4.5  #include "message_api.h"
     4.6  #include "keymanagement.h"
     4.7 -#include "test_util.h"
     4.8 +#include "TestUtils.h"
     4.9  
    4.10  using namespace std;
    4.11  
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/test/include/TestUtils.h	Mon Feb 11 08:35:27 2019 +0100
     5.3 @@ -0,0 +1,60 @@
     5.4 +#ifndef PEP_TEST_UTILS_H
     5.5 +#define PEP_TEST_UTILS_H
     5.6 +
     5.7 +#include <string>
     5.8 +#include <stdlib.h>
     5.9 +#include <sys/stat.h>
    5.10 +#include <ftw.h>
    5.11 +
    5.12 +#include "pEpEngine.h"
    5.13 +#include "message_api.h"
    5.14 +
    5.15 +void test_init();
    5.16 +
    5.17 +bool file_exists(std::string filename);
    5.18 +
    5.19 +PEP_STATUS read_file_and_import_key(PEP_SESSION session, const char* fname);
    5.20 +PEP_STATUS set_up_ident_from_scratch(PEP_SESSION session, 
    5.21 +                                     const char* key_fname,
    5.22 +                                     const char* address,
    5.23 +                                     const char* fpr,
    5.24 +                                     const char* user_id,
    5.25 +                                     const char* username,
    5.26 +                                     pEp_identity** ret_ident,
    5.27 +                                     bool is_priv);
    5.28 +
    5.29 +// string equality (case and non-case sensitive)
    5.30 +bool _streq(const char* str1, const char* str2);
    5.31 +bool _strceq(const char* str1, const char* str2);
    5.32 +
    5.33 +// reads a whole file and returns it as std::string
    5.34 +// throws std::runtime_error() if the file cannot be read. Empty file is not an error.
    5.35 +std::string slurp(const std::string& filename);
    5.36 +
    5.37 +// dumps char* to file
    5.38 +// throws std::runtime_error() if the file cannot be opened.
    5.39 +void dump_out(const char* filename, const char* outdata);
    5.40 +
    5.41 +// Returns the string value of the input rating enum value. 
    5.42 +const char* tl_rating_string(PEP_rating rating);
    5.43 +
    5.44 +// Returns the string value of the input comm_type enum value. 
    5.45 +const char* tl_ct_string(PEP_comm_type ct);
    5.46 +
    5.47 +// Returns the string value of the input status enum value. 
    5.48 +const char* tl_status_string(PEP_STATUS status);
    5.49 +
    5.50 +// Grabs a new uuid for your randomish string needs.
    5.51 +char* get_new_uuid();
    5.52 +
    5.53 +bool slurp_and_import_key(PEP_SESSION session, const char* key_filename);
    5.54 +
    5.55 +bool slurp_message_and_import_key(PEP_SESSION session, const char* message_fname, std::string& message, const char* key_filename);
    5.56 +
    5.57 +int util_delete_filepath(const char *filepath, 
    5.58 +                         const struct stat *file_stat, 
    5.59 +                         int ftw_info, 
    5.60 +                         struct FTW * ftw_struct);
    5.61 +                         
    5.62 +        
    5.63 +#endif
     6.1 --- a/test/include/test_util.h	Wed Feb 06 19:25:40 2019 +0100
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,60 +0,0 @@
     6.4 -#ifndef PEP_TEST_UTILS_H
     6.5 -#define PEP_TEST_UTILS_H
     6.6 -
     6.7 -#include <string>
     6.8 -#include <stdlib.h>
     6.9 -#include <sys/stat.h>
    6.10 -#include <ftw.h>
    6.11 -
    6.12 -#include "pEpEngine.h"
    6.13 -#include "message_api.h"
    6.14 -
    6.15 -void test_init();
    6.16 -
    6.17 -bool file_exists(std::string filename);
    6.18 -
    6.19 -PEP_STATUS read_file_and_import_key(PEP_SESSION session, const char* fname);
    6.20 -PEP_STATUS set_up_ident_from_scratch(PEP_SESSION session, 
    6.21 -                                     const char* key_fname,
    6.22 -                                     const char* address,
    6.23 -                                     const char* fpr,
    6.24 -                                     const char* user_id,
    6.25 -                                     const char* username,
    6.26 -                                     pEp_identity** ret_ident,
    6.27 -                                     bool is_priv);
    6.28 -
    6.29 -// string equality (case and non-case sensitive)
    6.30 -bool _streq(const char* str1, const char* str2);
    6.31 -bool _strceq(const char* str1, const char* str2);
    6.32 -
    6.33 -// reads a whole file and returns it as std::string
    6.34 -// throws std::runtime_error() if the file cannot be read. Empty file is not an error.
    6.35 -std::string slurp(const std::string& filename);
    6.36 -
    6.37 -// dumps char* to file
    6.38 -// throws std::runtime_error() if the file cannot be opened.
    6.39 -void dump_out(const char* filename, const char* outdata);
    6.40 -
    6.41 -// Returns the string value of the input rating enum value. 
    6.42 -const char* tl_rating_string(PEP_rating rating);
    6.43 -
    6.44 -// Returns the string value of the input comm_type enum value. 
    6.45 -const char* tl_ct_string(PEP_comm_type ct);
    6.46 -
    6.47 -// Returns the string value of the input status enum value. 
    6.48 -const char* tl_status_string(PEP_STATUS status);
    6.49 -
    6.50 -// Grabs a new uuid for your randomish string needs.
    6.51 -char* get_new_uuid();
    6.52 -
    6.53 -bool slurp_and_import_key(PEP_SESSION session, const char* key_filename);
    6.54 -
    6.55 -bool slurp_message_and_import_key(PEP_SESSION session, const char* message_fname, std::string& message, const char* key_filename);
    6.56 -
    6.57 -int util_delete_filepath(const char *filepath, 
    6.58 -                         const struct stat *file_stat, 
    6.59 -                         int ftw_info, 
    6.60 -                         struct FTW * ftw_struct);
    6.61 -                         
    6.62 -        
    6.63 -#endif
     7.1 --- a/test/src/EngineTestSuite.cc	Wed Feb 06 19:25:40 2019 +0100
     7.2 +++ b/test/src/EngineTestSuite.cc	Mon Feb 11 08:35:27 2019 +0100
     7.3 @@ -16,7 +16,7 @@
     7.4  
     7.5  #include "platform_unix.h"
     7.6  
     7.7 -#include "test_util.h"
     7.8 +#include "TestUtils.h"
     7.9  #include "EngineTestSuite.h"
    7.10  #include "pEpTestStatic.h"
    7.11  #include <algorithm>
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/test/src/TestUtils.cc	Mon Feb 11 08:35:27 2019 +0100
     8.3 @@ -0,0 +1,419 @@
     8.4 +#include "pEpEngine_test.h"
     8.5 +#include "pEpEngine.h"
     8.6 +#include "pEp_internal.h"
     8.7 +#include "message_api.h"
     8.8 +#include "TestUtils.h"
     8.9 +#include "TestConstants.h"
    8.10 +
    8.11 +#include <fstream>
    8.12 +#include <sstream>
    8.13 +#include <stdexcept>
    8.14 +#include <stdlib.h>
    8.15 +#include <sys/stat.h>
    8.16 +#include <errno.h>
    8.17 +#include <stdlib.h>
    8.18 +#include <unistd.h>
    8.19 +#include <ftw.h>
    8.20 +
    8.21 +PEP_STATUS read_file_and_import_key(PEP_SESSION session, const char* fname) {
    8.22 +    const std::string key = slurp(fname);
    8.23 +    PEP_STATUS status = (key.empty() ? PEP_KEY_NOT_FOUND : PEP_STATUS_OK);
    8.24 +    if (status == PEP_STATUS_OK)
    8.25 +        status = import_key(session, key.c_str(), key.size(), NULL);
    8.26 +    return status;    
    8.27 +}
    8.28 +
    8.29 +PEP_STATUS set_up_ident_from_scratch(PEP_SESSION session,
    8.30 +                                     const char* key_fname,
    8.31 +                                     const char* address,
    8.32 +                                     const char* fpr,
    8.33 +                                     const char* user_id,
    8.34 +                                     const char* username,
    8.35 +                                     pEp_identity** ret_ident,
    8.36 +                                     bool is_priv) {
    8.37 +    PEP_STATUS status = read_file_and_import_key(session,key_fname);
    8.38 +    if (status != PEP_KEY_IMPORTED)
    8.39 +        return status;
    8.40 +    else
    8.41 +        status = PEP_STATUS_OK;
    8.42 +    
    8.43 +    pEp_identity* ident = new_identity(address, fpr, user_id, username);
    8.44 +    if (is_priv && fpr) {
    8.45 +        status = set_own_key(session, ident, fpr);
    8.46 +        if (status == PEP_STATUS_OK)
    8.47 +            status = myself(session, ident);
    8.48 +    }
    8.49 +    else    
    8.50 +        status = update_identity(session, ident);
    8.51 +
    8.52 +    if (status != PEP_STATUS_OK)
    8.53 +        goto pep_free;
    8.54 +        
    8.55 +    if (!ident || !ident->fpr) {
    8.56 +        status = PEP_CANNOT_FIND_IDENTITY;
    8.57 +        goto pep_free;
    8.58 +    }
    8.59 +    
    8.60 +    if (ret_ident)
    8.61 +        *ret_ident = ident;
    8.62 +        
    8.63 +pep_free:
    8.64 +    if (!ret_ident)
    8.65 +        free_identity(ident);
    8.66 +    return status;    
    8.67 +}
    8.68 +
    8.69 +
    8.70 +bool file_exists(std::string filename) {
    8.71 +    struct stat buffer;
    8.72 +    return (stat(filename.c_str(), &buffer) == 0);
    8.73 +}
    8.74 +
    8.75 +char* str_to_lower(const char* str) {
    8.76 +    if (!str)
    8.77 +        return NULL;
    8.78 +    int str_len = strlen(str);
    8.79 +    if (str_len == 0)
    8.80 +        return strdup("");
    8.81 +    int i;
    8.82 +    
    8.83 +    char* retval = (char*) calloc(1, str_len + 1);
    8.84 +    for (i = 0; i < str_len; i++) {
    8.85 +        retval[i] = tolower(str[i]);
    8.86 +    }    
    8.87 +    return retval;
    8.88 +}
    8.89 +
    8.90 +// Because annoyed
    8.91 +bool _streq(const char* str1, const char* str2) {
    8.92 +    if (!str1) {
    8.93 +        if (str2)
    8.94 +            return false;
    8.95 +        return true;
    8.96 +    }
    8.97 +    if (!str2)
    8.98 +        return false;
    8.99 +        
   8.100 +    return (strcmp(str1, str2) == 0);
   8.101 +}
   8.102 +
   8.103 +bool _strceq(const char* str1, const char* str2) {
   8.104 +    char* str1_dup = str_to_lower(str1);
   8.105 +    char* str2_dup = str_to_lower(str2);
   8.106 +
   8.107 +    bool retval = _streq(str_to_lower(str1_dup), str_to_lower(str2_dup));
   8.108 +    free(str1_dup);
   8.109 +    free(str2_dup);
   8.110 +    return retval;
   8.111 +}
   8.112 +
   8.113 +void test_init() {
   8.114 +    unlink ("../test_home/.pEp_management.db");
   8.115 +    unlink ("../test_home/.pEp_management.db-shm");
   8.116 +    unlink ("../test_home/.pEp_management.db-wal");
   8.117 +}
   8.118 +
   8.119 +std::string slurp(const std::string& filename)
   8.120 +{
   8.121 +	std::ifstream input(filename.c_str());
   8.122 +	if(!input)
   8.123 +	{
   8.124 +		throw std::runtime_error("Cannot read file \"" + filename + "\"! ");
   8.125 +	}
   8.126 +	
   8.127 +	std::stringstream sstr;
   8.128 +	sstr << input.rdbuf();
   8.129 +	return sstr.str();
   8.130 +}
   8.131 +
   8.132 +void dump_out(const char* filename, const char* outdata)
   8.133 +{
   8.134 +	std::ofstream outfile(filename);
   8.135 +	if(!outfile)
   8.136 +	{
   8.137 +		throw std::runtime_error("Cannot open output file!");
   8.138 +	}
   8.139 +	
   8.140 +	outfile << outdata;
   8.141 +    outfile.close();
   8.142 +}
   8.143 +
   8.144 +char* get_new_uuid() {
   8.145 +    char* new_uuid = (char*)calloc(37, 1);
   8.146 +    pEpUUID uuid;
   8.147 +    uuid_generate_random(uuid);
   8.148 +    uuid_unparse_upper(uuid, new_uuid);
   8.149 +    return new_uuid;
   8.150 +}
   8.151 +
   8.152 +const char* tl_status_string(PEP_STATUS status) {
   8.153 +    switch (status) {
   8.154 +        case PEP_STATUS_OK:
   8.155 +            return "PEP_STATUS_OK";
   8.156 +        case PEP_INIT_CANNOT_LOAD_GPGME:
   8.157 +            return "PEP_INIT_CANNOT_LOAD_GPGME";
   8.158 +        case PEP_INIT_GPGME_INIT_FAILED:
   8.159 +            return "PEP_INIT_GPGME_INIT_FAILED";
   8.160 +        case PEP_INIT_NO_GPG_HOME:
   8.161 +            return "PEP_INIT_NO_GPG_HOME";
   8.162 +        case PEP_INIT_NETPGP_INIT_FAILED:
   8.163 +            return "PEP_INIT_NETPGP_INIT_FAILED";
   8.164 +        case PEP_INIT_SQLITE3_WITHOUT_MUTEX:
   8.165 +            return "PEP_INIT_SQLITE3_WITHOUT_MUTEX";
   8.166 +        case PEP_INIT_CANNOT_OPEN_DB:
   8.167 +            return "PEP_INIT_CANNOT_OPEN_DB";
   8.168 +        case PEP_INIT_CANNOT_OPEN_SYSTEM_DB:
   8.169 +            return "PEP_INIT_CANNOT_OPEN_SYSTEM_DB";
   8.170 +        case PEP_KEY_NOT_FOUND:
   8.171 +            return "PEP_KEY_NOT_FOUND";
   8.172 +        case PEP_KEY_HAS_AMBIG_NAME:
   8.173 +            return "PEP_KEY_HAS_AMBIG_NAME";
   8.174 +        case PEP_GET_KEY_FAILED:
   8.175 +            return "PEP_GET_KEY_FAILED";
   8.176 +        case PEP_CANNOT_EXPORT_KEY:
   8.177 +            return "PEP_CANNOT_EXPORT_KEY";
   8.178 +        case PEP_CANNOT_EDIT_KEY:
   8.179 +            return "PEP_CANNOT_EDIT_KEY";
   8.180 +        case PEP_CANNOT_FIND_IDENTITY:
   8.181 +            return "PEP_CANNOT_FIND_IDENTITY";
   8.182 +        case PEP_CANNOT_SET_PERSON:
   8.183 +            return "PEP_CANNOT_SET_PERSON";
   8.184 +        case PEP_CANNOT_SET_PGP_KEYPAIR:
   8.185 +            return "PEP_CANNOT_SET_PGP_KEYPAIR";
   8.186 +        case PEP_CANNOT_SET_IDENTITY:
   8.187 +            return "PEP_CANNOT_SET_IDENTITY";
   8.188 +        case PEP_CANNOT_SET_TRUST:
   8.189 +            return "PEP_CANNOT_SET_TRUST";
   8.190 +        case PEP_KEY_BLACKLISTED:
   8.191 +            return "PEP_KEY_BLACKLISTED";
   8.192 +        case PEP_UNENCRYPTED:
   8.193 +            return "PEP_UNENCRYPTED";
   8.194 +        case PEP_VERIFIED:
   8.195 +            return "PEP_VERIFIED";
   8.196 +        case PEP_DECRYPTED:
   8.197 +            return "PEP_DECRYPTED";
   8.198 +        case PEP_DECRYPTED_AND_VERIFIED:
   8.199 +            return "PEP_DECRYPTED_AND_VERIFIED";
   8.200 +        case PEP_DECRYPT_WRONG_FORMAT:
   8.201 +            return "PEP_DECRYPT_WRONG_FORMAT";
   8.202 +        case PEP_DECRYPT_NO_KEY:
   8.203 +            return "PEP_DECRYPT_NO_KEY";
   8.204 +        case PEP_DECRYPT_SIGNATURE_DOES_NOT_MATCH:
   8.205 +            return "PEP_DECRYPT_SIGNATURE_DOES_NOT_MATCH";
   8.206 +//        case PEP_DECRYPTED_BUT_UNSIGNED:
   8.207 +//            return "PEP_DECRYPTED_BUT_UNSIGNED";
   8.208 +//        case PEP_DECRYPT_MODIFICATION_DETECTED:
   8.209 +//            return "PEP_DECRYPT_MODIFICATION_DETECTED";
   8.210 +//        case PEP_DECRYPT_NO_KEY_FOR_SIGNER:
   8.211 +//            return "PEP_DECRYPT_NO_KEY_FOR_SIGNER";
   8.212 +        case PEP_VERIFY_NO_KEY:
   8.213 +            return "PEP_VERIFY_NO_KEY";
   8.214 +        case PEP_VERIFIED_AND_TRUSTED:
   8.215 +            return "PEP_VERIFIED_AND_TRUSTED";
   8.216 +        case PEP_CANNOT_DECRYPT_UNKNOWN:
   8.217 +            return "PEP_CANNOT_DECRYPT_UNKNOWN";
   8.218 +        case PEP_TRUSTWORD_NOT_FOUND:
   8.219 +            return "PEP_TRUSTWORD_NOT_FOUND";
   8.220 +        case PEP_TRUSTWORDS_FPR_WRONG_LENGTH:
   8.221 +            return "PEP_TRUSTWORDS_FPR_WRONG_LENGTH";
   8.222 +        case PEP_CANNOT_CREATE_KEY:
   8.223 +            return "PEP_CANNOT_CREATE_KEY";
   8.224 +        case PEP_CANNOT_SEND_KEY:
   8.225 +            return "PEP_CANNOT_SEND_KEY";
   8.226 +        case PEP_PHRASE_NOT_FOUND:
   8.227 +            return "PEP_PHRASE_NOT_FOUND";
   8.228 +        case PEP_SEND_FUNCTION_NOT_REGISTERED:
   8.229 +            return "PEP_SEND_FUNCTION_NOT_REGISTERED";
   8.230 +        case PEP_CONTRAINTS_VIOLATED:
   8.231 +            return "PEP_CONTRAINTS_VIOLATED";
   8.232 +        case PEP_CANNOT_ENCODE:
   8.233 +            return "PEP_CANNOT_ENCODE";
   8.234 +        case PEP_SYNC_NO_NOTIFY_CALLBACK:
   8.235 +            return "PEP_SYNC_NO_NOTIFY_CALLBACK";
   8.236 +        case PEP_SYNC_ILLEGAL_MESSAGE:
   8.237 +            return "PEP_SYNC_ILLEGAL_MESSAGE";
   8.238 +        case PEP_SYNC_NO_INJECT_CALLBACK:
   8.239 +            return "PEP_SYNC_NO_INJECT_CALLBACK";
   8.240 +        case PEP_CANNOT_INCREASE_SEQUENCE:
   8.241 +            return "PEP_CANNOT_INCREASE_SEQUENCE";
   8.242 +        case PEP_STATEMACHINE_ERROR:
   8.243 +            return "PEP_STATEMACHINE_ERROR";
   8.244 +        case PEP_NO_TRUST:
   8.245 +            return "PEP_NO_TRUST";
   8.246 +        case PEP_STATEMACHINE_INVALID_STATE:
   8.247 +            return "PEP_STATEMACHINE_INVALID_STATE";
   8.248 +        case PEP_STATEMACHINE_INVALID_EVENT:
   8.249 +            return "PEP_STATEMACHINE_INVALID_EVENT";
   8.250 +        case PEP_STATEMACHINE_INVALID_CONDITION:
   8.251 +            return "PEP_STATEMACHINE_INVALID_CONDITION";
   8.252 +        case PEP_STATEMACHINE_INVALID_ACTION:
   8.253 +            return "PEP_STATEMACHINE_INVALID_ACTION";
   8.254 +        case PEP_STATEMACHINE_INHIBITED_EVENT:
   8.255 +            return "PEP_STATEMACHINE_INHIBITED_EVENT";
   8.256 +        case PEP_COMMIT_FAILED:
   8.257 +            return "PEP_COMMIT_FAILED";
   8.258 +        case PEP_MESSAGE_CONSUME:
   8.259 +            return "PEP_MESSAGE_CONSUME";
   8.260 +        case PEP_MESSAGE_IGNORE:
   8.261 +            return "PEP_MESSAGE_IGNORE";
   8.262 +        case PEP_RECORD_NOT_FOUND:
   8.263 +            return "PEP_RECORD_NOT_FOUND";
   8.264 +        case PEP_CANNOT_CREATE_TEMP_FILE:
   8.265 +            return "PEP_CANNOT_CREATE_TEMP_FILE";
   8.266 +        case PEP_ILLEGAL_VALUE:
   8.267 +            return "PEP_ILLEGAL_VALUE";
   8.268 +        case PEP_BUFFER_TOO_SMALL:
   8.269 +            return "PEP_BUFFER_TOO_SMALL";
   8.270 +        case PEP_OUT_OF_MEMORY:
   8.271 +            return "PEP_OUT_OF_MEMORY";
   8.272 +        case PEP_UNKNOWN_ERROR:
   8.273 +            return "PEP_UNKNOWN_ERROR";    
   8.274 +        default:
   8.275 + 
   8.276 +            return "PEP_STATUS_OMGWTFBBQ - This means you're using a status the test lib doesn't know about!";
   8.277 +    }
   8.278 +}
   8.279 +const char* tl_rating_string(PEP_rating rating) {
   8.280 +    switch (rating) {
   8.281 +        case PEP_rating_undefined:
   8.282 +            return "PEP_rating_undefined";
   8.283 +        case PEP_rating_cannot_decrypt:
   8.284 +            return "PEP_rating_cannot_decrypt";
   8.285 +        case PEP_rating_have_no_key:
   8.286 +            return "PEP_rating_have_no_key";
   8.287 +        case PEP_rating_unencrypted:
   8.288 +            return "PEP_rating_unencrypted";
   8.289 +        case PEP_rating_unencrypted_for_some:
   8.290 +            return "PEP_rating_unencrypted_for_some";
   8.291 +        case PEP_rating_unreliable:
   8.292 +            return "PEP_rating_unreliable";
   8.293 +        case PEP_rating_reliable:
   8.294 +            return "PEP_rating_reliable";
   8.295 +        case PEP_rating_trusted:
   8.296 +            return "PEP_rating_trusted";
   8.297 +        case PEP_rating_trusted_and_anonymized:
   8.298 +            return "PEP_rating_trusted_and_anonymized";
   8.299 +        case PEP_rating_fully_anonymous:
   8.300 +            return "PEP_rating_fully_anonymous";
   8.301 +        case PEP_rating_mistrust:
   8.302 +            return "PEP_rating_mistrust";
   8.303 +        case PEP_rating_b0rken:
   8.304 +            return "PEP_rating_b0rken";
   8.305 +        case PEP_rating_under_attack:
   8.306 +            return "PEP_rating_under_attack";
   8.307 +        default:
   8.308 +            return "PEP_rating_OMGWTFBBQ - in other words, INVALID RATING VALUE!!!\n\nSomething bad is going on here, or a new rating value has been added to the enum and not the test function.";
   8.309 +    }
   8.310 +}
   8.311 +
   8.312 +const char* tl_ct_string(PEP_comm_type ct) {
   8.313 +    switch (ct) {
   8.314 +        case PEP_ct_unknown:
   8.315 +            return "PEP_ct_unknown";
   8.316 +        case PEP_ct_no_encryption:
   8.317 +            return "PEP_ct_no_encryption";
   8.318 +        case PEP_ct_no_encrypted_channel:
   8.319 +            return "PEP_ct_no_encrypted_channel";
   8.320 +        case PEP_ct_key_not_found:
   8.321 +            return "PEP_ct_key_not_found";
   8.322 +        case PEP_ct_key_expired:
   8.323 +            return "PEP_ct_key_expired";
   8.324 +        case PEP_ct_key_revoked:
   8.325 +            return "PEP_ct_key_revoked";
   8.326 +        case PEP_ct_key_b0rken:
   8.327 +            return "PEP_ct_key_b0rken";
   8.328 +        case PEP_ct_my_key_not_included:
   8.329 +            return "PEP_ct_my_key_not_included";
   8.330 +        case PEP_ct_security_by_obscurity:
   8.331 +            return "PEP_ct_security_by_obscurity";
   8.332 +        case PEP_ct_b0rken_crypto:
   8.333 +            return "PEP_ct_b0rken_crypto";
   8.334 +        case PEP_ct_key_too_short:
   8.335 +            return "PEP_ct_key_too_short";
   8.336 +        case PEP_ct_compromised:
   8.337 +            return "PEP_ct_compromised";
   8.338 +        case PEP_ct_mistrusted:
   8.339 +            return "PEP_ct_mistrusted";
   8.340 +        case PEP_ct_unconfirmed_encryption:
   8.341 +            return "PEP_ct_unconfirmed_encryption";
   8.342 +        case PEP_ct_OpenPGP_weak_unconfirmed:
   8.343 +            return "PEP_ct_OpenPGP_weak_unconfirmed";
   8.344 +        case PEP_ct_to_be_checked:
   8.345 +            return "PEP_ct_to_be_checked";
   8.346 +        case PEP_ct_SMIME_unconfirmed:
   8.347 +            return "PEP_ct_SMIME_unconfirmed";
   8.348 +        case PEP_ct_CMS_unconfirmed:
   8.349 +            return "PEP_ct_CMS_unconfirmed";
   8.350 +        case PEP_ct_strong_but_unconfirmed:
   8.351 +            return "PEP_ct_strong_but_unconfirmed";
   8.352 +        case PEP_ct_OpenPGP_unconfirmed:
   8.353 +            return "PEP_ct_OpenPGP_unconfirmed";
   8.354 +        case PEP_ct_OTR_unconfirmed:
   8.355 +            return "PEP_ct_OTR_unconfirmed";
   8.356 +        case PEP_ct_unconfirmed_enc_anon:
   8.357 +            return "PEP_ct_unconfirmed_enc_anon";
   8.358 +        case PEP_ct_pEp_unconfirmed:
   8.359 +            return "PEP_ct_pEp_unconfirmed";
   8.360 +        case PEP_ct_confirmed:
   8.361 +            return "PEP_ct_pEp_confirmed";
   8.362 +        case PEP_ct_confirmed_encryption:
   8.363 +            return "PEP_ct_confirmed_encryption";
   8.364 +        case PEP_ct_OpenPGP_weak:
   8.365 +            return "PEP_ct_OpenPGP_weak";
   8.366 +        case PEP_ct_to_be_checked_confirmed:
   8.367 +            return "PEP_ct_to_be_checked_confirmed";
   8.368 +        case PEP_ct_SMIME:
   8.369 +            return "PEP_ct_SMIME";
   8.370 +        case PEP_ct_CMS:
   8.371 +            return "PEP_ct_CMS";
   8.372 +        case PEP_ct_strong_encryption:
   8.373 +            return "PEP_ct_strong_encryption";
   8.374 +        case PEP_ct_OpenPGP:
   8.375 +            return "PEP_ct_OpenPGP";
   8.376 +        case PEP_ct_OTR:
   8.377 +            return "PEP_ct_OTR";
   8.378 +        case PEP_ct_confirmed_enc_anon:
   8.379 +            return "PEP_ct_confirmed_enc_anon";
   8.380 +        case PEP_ct_pEp:
   8.381 +            return "PEP_ct_pEp";
   8.382 +        default:
   8.383 +            return "PEP_ct_OMGWTFBBQ\n\nIn other words, comm type is invalid. Either something's corrupt or a new ct value has been added to the enum but not to the test function.";
   8.384 +    }
   8.385 +}
   8.386 +
   8.387 +bool slurp_and_import_key(PEP_SESSION session, const char* key_filename) {
   8.388 +    std::string keyfile = slurp(key_filename);
   8.389 +    if (import_key(session, keyfile.c_str(), keyfile.size(), NULL) != PEP_TEST_KEY_IMPORT_SUCCESS)
   8.390 +        return false;
   8.391 +    return true;
   8.392 +}
   8.393 +
   8.394 +bool slurp_message_and_import_key(PEP_SESSION session, const char* message_fname, std::string& message, const char* key_filename) {
   8.395 +    bool ok = true;
   8.396 +    message = slurp(message_fname);
   8.397 +    if (key_filename)
   8.398 +        ok = slurp_and_import_key(session, key_filename);
   8.399 +    return ok;
   8.400 +}
   8.401 +
   8.402 +
   8.403 +
   8.404 +int util_delete_filepath(const char *filepath, 
   8.405 +                         const struct stat *file_stat, 
   8.406 +                         int ftw_info, 
   8.407 +                         struct FTW * ftw_struct) {
   8.408 +    int retval = 0;
   8.409 +    switch (ftw_info) {
   8.410 +        case FTW_DP:
   8.411 +            retval = rmdir(filepath);
   8.412 +            break;
   8.413 +        case FTW_F:
   8.414 +        case FTW_SLN:
   8.415 +            retval = unlink(filepath);
   8.416 +            break;    
   8.417 +        default:
   8.418 +            retval = -1;
   8.419 +    }
   8.420 +    
   8.421 +    return retval;
   8.422 +}
     9.1 --- a/test/src/engine_tests/AppleMailTests.cc	Wed Feb 06 19:25:40 2019 +0100
     9.2 +++ b/test/src/engine_tests/AppleMailTests.cc	Mon Feb 11 08:35:27 2019 +0100
     9.3 @@ -17,7 +17,7 @@
     9.4  #include "keymanagement.h"
     9.5  #include "message_api.h"
     9.6  #include "mime.h"
     9.7 -#include "test_util.h" // for slurp()
     9.8 +#include "TestUtils.h" // for slurp()
     9.9  #include "TestConstants.h"
    9.10  
    9.11  #include "EngineTestSuite.h"
    10.1 --- a/test/src/engine_tests/BCCTests.cc	Wed Feb 06 19:25:40 2019 +0100
    10.2 +++ b/test/src/engine_tests/BCCTests.cc	Mon Feb 11 08:35:27 2019 +0100
    10.3 @@ -11,7 +11,7 @@
    10.4  #include "TestConstants.h"
    10.5  
    10.6  #include <cpptest.h>
    10.7 -#include "test_util.h"
    10.8 +#include "TestUtils.h"
    10.9  #include "EngineTestIndividualSuite.h"
   10.10  #include "BCCTests.h"
   10.11  
    11.1 --- a/test/src/engine_tests/BlacklistAcceptNewKeyTests.cc	Wed Feb 06 19:25:40 2019 +0100
    11.2 +++ b/test/src/engine_tests/BlacklistAcceptNewKeyTests.cc	Mon Feb 11 08:35:27 2019 +0100
    11.3 @@ -6,7 +6,7 @@
    11.4  #include <cstring> // for strcmp()
    11.5  #include <cpptest.h>
    11.6  
    11.7 -#include "test_util.h"
    11.8 +#include "TestUtils.h"
    11.9  #include "TestConstants.h"
   11.10  
   11.11  #include "pEpEngine.h"
    12.1 --- a/test/src/engine_tests/BlacklistTests.cc	Wed Feb 06 19:25:40 2019 +0100
    12.2 +++ b/test/src/engine_tests/BlacklistTests.cc	Mon Feb 11 08:35:27 2019 +0100
    12.3 @@ -9,7 +9,7 @@
    12.4  // #include <TEST_ASSERT.h>
    12.5  // #include "blacklist.h"
    12.6  // #include "keymanagement.h"
    12.7 -// #include "test_util.h"
    12.8 +// #include "TestUtils.h"
    12.9  // 
   12.10  // // This file is under GNU General Public License 3.0
   12.11  // // see LICENSE.txt
   12.12 @@ -26,7 +26,7 @@
   12.13  
   12.14  #include "blacklist.h"
   12.15  #include "keymanagement.h"
   12.16 -#include "test_util.h"
   12.17 +#include "TestUtils.h"
   12.18  #include "TestConstants.h"
   12.19  
   12.20  #include "EngineTestSessionSuite.h"
    13.1 --- a/test/src/engine_tests/CaseAndDotAddressTests.cc	Wed Feb 06 19:25:40 2019 +0100
    13.2 +++ b/test/src/engine_tests/CaseAndDotAddressTests.cc	Mon Feb 11 08:35:27 2019 +0100
    13.3 @@ -9,7 +9,7 @@
    13.4  #include <fstream>
    13.5  #include "mime.h"
    13.6  #include "message_api.h"
    13.7 -#include "test_util.h"
    13.8 +#include "TestUtils.h"
    13.9  #include "TestConstants.h"
   13.10  
   13.11  #include "EngineTestSuite.h"
    14.1 --- a/test/src/engine_tests/CheckRenewedExpiredKeyTrustStatusTests.cc	Wed Feb 06 19:25:40 2019 +0100
    14.2 +++ b/test/src/engine_tests/CheckRenewedExpiredKeyTrustStatusTests.cc	Mon Feb 11 08:35:27 2019 +0100
    14.3 @@ -9,7 +9,7 @@
    14.4  #include "pEpEngine.h"
    14.5  
    14.6  #include <cpptest.h>
    14.7 -#include "test_util.h"
    14.8 +#include "TestUtils.h"
    14.9  #include "EngineTestIndividualSuite.h"
   14.10  #include "CheckRenewedExpiredKeyTrustStatusTests.h"
   14.11  
    15.1 --- a/test/src/engine_tests/DecorateTests.cc	Wed Feb 06 19:25:40 2019 +0100
    15.2 +++ b/test/src/engine_tests/DecorateTests.cc	Mon Feb 11 08:35:27 2019 +0100
    15.3 @@ -14,7 +14,7 @@
    15.4  #include <sstream>
    15.5  #include "mime.h"
    15.6  #include "message_api.h"
    15.7 -#include "test_util.h"
    15.8 +#include "TestUtils.h"
    15.9  
   15.10  #include "EngineTestSuite.h"
   15.11  #include "EngineTestSessionSuite.h"
    16.1 --- a/test/src/engine_tests/DecryptAttachPrivateKeyTrustedTests.cc	Wed Feb 06 19:25:40 2019 +0100
    16.2 +++ b/test/src/engine_tests/DecryptAttachPrivateKeyTrustedTests.cc	Mon Feb 11 08:35:27 2019 +0100
    16.3 @@ -13,7 +13,7 @@
    16.4  #include "mime.h"
    16.5  #include "message_api.h"
    16.6  #include "keymanagement.h"
    16.7 -#include "test_util.h"
    16.8 +#include "TestUtils.h"
    16.9  
   16.10  #include "EngineTestSessionSuite.h"
   16.11  #include "DecryptAttachPrivateKeyTrustedTests.h"
    17.1 --- a/test/src/engine_tests/DecryptAttachPrivateKeyUntrustedTests.cc	Wed Feb 06 19:25:40 2019 +0100
    17.2 +++ b/test/src/engine_tests/DecryptAttachPrivateKeyUntrustedTests.cc	Mon Feb 11 08:35:27 2019 +0100
    17.3 @@ -10,7 +10,7 @@
    17.4  #include "mime.h"
    17.5  #include "message_api.h"
    17.6  #include "keymanagement.h"
    17.7 -#include "test_util.h"
    17.8 +#include "TestUtils.h"
    17.9  
   17.10  #include "pEpEngine.h"
   17.11  
    18.1 --- a/test/src/engine_tests/EncryptAttachPrivateKeyTests.cc	Wed Feb 06 19:25:40 2019 +0100
    18.2 +++ b/test/src/engine_tests/EncryptAttachPrivateKeyTests.cc	Mon Feb 11 08:35:27 2019 +0100
    18.3 @@ -12,7 +12,7 @@
    18.4  #include "mime.h"
    18.5  #include "message_api.h"
    18.6  #include "keymanagement.h"
    18.7 -#include "test_util.h"
    18.8 +#include "TestUtils.h"
    18.9  
   18.10  #include "EngineTestSessionSuite.h"
   18.11  #include "EncryptAttachPrivateKeyTests.h"
    19.1 --- a/test/src/engine_tests/EncryptForIdentityTests.cc	Wed Feb 06 19:25:40 2019 +0100
    19.2 +++ b/test/src/engine_tests/EncryptForIdentityTests.cc	Mon Feb 11 08:35:27 2019 +0100
    19.3 @@ -13,7 +13,7 @@
    19.4  #include "mime.h"
    19.5  #include "message_api.h"
    19.6  #include "keymanagement.h"
    19.7 -#include "test_util.h"
    19.8 +#include "TestUtils.h"
    19.9  
   19.10  #include <cpptest.h>
   19.11  #include "EngineTestSessionSuite.h"
    20.1 --- a/test/src/engine_tests/EncryptMissingPrivateKeyTests.cc	Wed Feb 06 19:25:40 2019 +0100
    20.2 +++ b/test/src/engine_tests/EncryptMissingPrivateKeyTests.cc	Mon Feb 11 08:35:27 2019 +0100
    20.3 @@ -14,7 +14,7 @@
    20.4  #include "keymanagement.h"
    20.5  #include "message_api.h"
    20.6  #include "mime.h"
    20.7 -#include "test_util.h"
    20.8 +#include "TestUtils.h"
    20.9  
   20.10  #include "pEpEngine.h"
   20.11  
    21.1 --- a/test/src/engine_tests/Engine358Tests.cc	Wed Feb 06 19:25:40 2019 +0100
    21.2 +++ b/test/src/engine_tests/Engine358Tests.cc	Mon Feb 11 08:35:27 2019 +0100
    21.3 @@ -9,7 +9,7 @@
    21.4  
    21.5  #include "pEpEngine.h"
    21.6  
    21.7 -#include "test_util.h"
    21.8 +#include "TestUtils.h"
    21.9  #include "EngineTestIndividualSuite.h"
   21.10  #include "Engine358Tests.h"
   21.11  
    22.1 --- a/test/src/engine_tests/Engine463Tests.cc	Wed Feb 06 19:25:40 2019 +0100
    22.2 +++ b/test/src/engine_tests/Engine463Tests.cc	Mon Feb 11 08:35:27 2019 +0100
    22.3 @@ -7,7 +7,7 @@
    22.4  
    22.5  #include "pEpEngine.h"
    22.6  #include "pEp_internal.h"
    22.7 -#include "test_util.h"
    22.8 +#include "TestUtils.h"
    22.9  #include "message.h"
   22.10  
   22.11  #include "EngineTestIndividualSuite.h"
    23.1 --- a/test/src/engine_tests/ExpiredSubkeyTests.cc	Wed Feb 06 19:25:40 2019 +0100
    23.2 +++ b/test/src/engine_tests/ExpiredSubkeyTests.cc	Mon Feb 11 08:35:27 2019 +0100
    23.3 @@ -5,7 +5,7 @@
    23.4  #include <stdlib.h>
    23.5  #include <string>
    23.6  #include <cpptest.h>
    23.7 -#include "test_util.h"
    23.8 +#include "TestUtils.h"
    23.9  
   23.10  #include "pEpEngine.h"
   23.11  
    24.1 --- a/test/src/engine_tests/ExternalRevokeTests.cc	Wed Feb 06 19:25:40 2019 +0100
    24.2 +++ b/test/src/engine_tests/ExternalRevokeTests.cc	Mon Feb 11 08:35:27 2019 +0100
    24.3 @@ -11,7 +11,7 @@
    24.4  #include <fstream>
    24.5  #include "mime.h"
    24.6  #include "message_api.h"
    24.7 -#include "test_util.h"
    24.8 +#include "TestUtils.h"
    24.9  
   24.10  #include "pEpEngine.h"
   24.11  
    25.1 --- a/test/src/engine_tests/HeaderKeyImportTests.cc	Wed Feb 06 19:25:40 2019 +0100
    25.2 +++ b/test/src/engine_tests/HeaderKeyImportTests.cc	Mon Feb 11 08:35:27 2019 +0100
    25.3 @@ -12,7 +12,7 @@
    25.4  #include "bloblist.h"
    25.5  #include "base64.h"
    25.6  
    25.7 -#include "test_util.h"
    25.8 +#include "TestUtils.h"
    25.9  #include "EngineTestIndividualSuite.h"
   25.10  #include "HeaderKeyImportTests.h"
   25.11  
    26.1 --- a/test/src/engine_tests/IntegrityTests.do.not.run.before.ENGINE-434	Wed Feb 06 19:25:40 2019 +0100
    26.2 +++ b/test/src/engine_tests/IntegrityTests.do.not.run.before.ENGINE-434	Mon Feb 11 08:35:27 2019 +0100
    26.3 @@ -9,7 +9,7 @@
    26.4  #include "pEpEngine.h"
    26.5  #include "message_api.h"
    26.6  
    26.7 -#include "test_util.h"
    26.8 +#include "TestUtils.h"
    26.9  
   26.10  #include "EngineTestIndividualSuite.h"
   26.11  #include "IntegrityTests.h"
    27.1 --- a/test/src/engine_tests/KeyAttachmentTests.cc	Wed Feb 06 19:25:40 2019 +0100
    27.2 +++ b/test/src/engine_tests/KeyAttachmentTests.cc	Mon Feb 11 08:35:27 2019 +0100
    27.3 @@ -13,7 +13,7 @@
    27.4  #include "mime.h"
    27.5  
    27.6  #include <cpptest.h>
    27.7 -#include "test_util.h"
    27.8 +#include "TestUtils.h"
    27.9  #include "EngineTestIndividualSuite.h"
   27.10  #include "KeyAttachmentTests.h"
   27.11  
    28.1 --- a/test/src/engine_tests/KeyResetMessageTests.cc	Wed Feb 06 19:25:40 2019 +0100
    28.2 +++ b/test/src/engine_tests/KeyResetMessageTests.cc	Mon Feb 11 08:35:27 2019 +0100
    28.3 @@ -12,7 +12,7 @@
    28.4  #include "mime.h"
    28.5  #include "keymanagement.h"
    28.6  
    28.7 -#include "test_util.h"
    28.8 +#include "TestUtils.h"
    28.9  #include "EngineTestIndividualSuite.h"
   28.10  #include "KeyResetMessageTests.h"
   28.11  
    29.1 --- a/test/src/engine_tests/LeastColorGroupTests.cc	Wed Feb 06 19:25:40 2019 +0100
    29.2 +++ b/test/src/engine_tests/LeastColorGroupTests.cc	Mon Feb 11 08:35:27 2019 +0100
    29.3 @@ -10,7 +10,7 @@
    29.4  #include "keymanagement.h"
    29.5  #include "message_api.h"
    29.6  #include "mime.h"
    29.7 -#include "test_util.h"
    29.8 +#include "TestUtils.h"
    29.9  
   29.10  #include "pEpEngine.h"
   29.11  
    30.1 --- a/test/src/engine_tests/LeastCommonDenomColorTests.cc	Wed Feb 06 19:25:40 2019 +0100
    30.2 +++ b/test/src/engine_tests/LeastCommonDenomColorTests.cc	Mon Feb 11 08:35:27 2019 +0100
    30.3 @@ -12,7 +12,7 @@
    30.4  #include "keymanagement.h"
    30.5  #include "message_api.h"
    30.6  #include "mime.h"
    30.7 -#include "test_util.h"
    30.8 +#include "TestUtils.h"
    30.9  
   30.10  #include <cpptest.h>
   30.11  #include "EngineTestIndividualSuite.h"
    31.1 --- a/test/src/engine_tests/MessageApiTests.cc	Wed Feb 06 19:25:40 2019 +0100
    31.2 +++ b/test/src/engine_tests/MessageApiTests.cc	Mon Feb 11 08:35:27 2019 +0100
    31.3 @@ -12,7 +12,7 @@
    31.4  #include "platform.h"
    31.5  #include "mime.h"
    31.6  #include "message_api.h"
    31.7 -#include "test_util.h"
    31.8 +#include "TestUtils.h"
    31.9  
   31.10  #include <cpptest.h>
   31.11  #include "EngineTestSessionSuite.h"
    32.1 --- a/test/src/engine_tests/MessageNullFromTests.cc	Wed Feb 06 19:25:40 2019 +0100
    32.2 +++ b/test/src/engine_tests/MessageNullFromTests.cc	Mon Feb 11 08:35:27 2019 +0100
    32.3 @@ -8,7 +8,7 @@
    32.4  #include <assert.h>
    32.5  
    32.6  #include "pEpEngine.h"
    32.7 -#include "test_util.h"
    32.8 +#include "TestUtils.h"
    32.9  
   32.10  #include "EngineTestIndividualSuite.h"
   32.11  #include "MessageNullFromTests.h"
    33.1 --- a/test/src/engine_tests/MessageTwoPointOhTests.cc	Wed Feb 06 19:25:40 2019 +0100
    33.2 +++ b/test/src/engine_tests/MessageTwoPointOhTests.cc	Mon Feb 11 08:35:27 2019 +0100
    33.3 @@ -13,7 +13,7 @@
    33.4  #include "mime.h"
    33.5  #include "message_api.h"
    33.6  #include "keymanagement.h"
    33.7 -#include "test_util.h"
    33.8 +#include "TestUtils.h"
    33.9  
   33.10  #include <cpptest.h>
   33.11  #include "EngineTestSessionSuite.h"
    34.1 --- a/test/src/engine_tests/NewUpdateIdAndMyselfTests.cc	Wed Feb 06 19:25:40 2019 +0100
    34.2 +++ b/test/src/engine_tests/NewUpdateIdAndMyselfTests.cc	Mon Feb 11 08:35:27 2019 +0100
    34.3 @@ -11,7 +11,7 @@
    34.4  #include "pEpEngine.h"
    34.5  #include "message_api.h"
    34.6  #include "keymanagement.h"
    34.7 -#include "test_util.h"
    34.8 +#include "TestUtils.h"
    34.9  
   34.10  #include <cpptest.h>
   34.11  #include "EngineTestSessionSuite.h"
    35.1 --- a/test/src/engine_tests/PepSubjectReceivedTests.cc	Wed Feb 06 19:25:40 2019 +0100
    35.2 +++ b/test/src/engine_tests/PepSubjectReceivedTests.cc	Mon Feb 11 08:35:27 2019 +0100
    35.3 @@ -12,7 +12,7 @@
    35.4  #include "keymanagement.h"
    35.5  #include "message_api.h"
    35.6  #include "mime.h"
    35.7 -#include "test_util.h" // for slurp()
    35.8 +#include "TestUtils.h" // for slurp()
    35.9  
   35.10  #include <cpptest.h>
   35.11  #include "EngineTestSessionSuite.h"
    36.1 --- a/test/src/engine_tests/ReencryptPlusExtraKeysTests.cc	Wed Feb 06 19:25:40 2019 +0100
    36.2 +++ b/test/src/engine_tests/ReencryptPlusExtraKeysTests.cc	Mon Feb 11 08:35:27 2019 +0100
    36.3 @@ -12,7 +12,7 @@
    36.4  #include "mime.h"
    36.5  #include "message_api.h"
    36.6  #include "keymanagement.h"
    36.7 -#include "test_util.h"
    36.8 +#include "TestUtils.h"
    36.9  
   36.10  #include <cpptest.h>
   36.11  #include "EngineTestSessionSuite.h"
    37.1 --- a/test/src/engine_tests/RevokeRegenAttachTests.cc	Wed Feb 06 19:25:40 2019 +0100
    37.2 +++ b/test/src/engine_tests/RevokeRegenAttachTests.cc	Mon Feb 11 08:35:27 2019 +0100
    37.3 @@ -15,7 +15,7 @@
    37.4  #include "mime.h"
    37.5  #include "message_api.h"
    37.6  
    37.7 -#include "test_util.h"
    37.8 +#include "TestUtils.h"
    37.9  
   37.10  #include <cpptest.h>
   37.11  #include "EngineTestSessionSuite.h"
    38.1 --- a/test/src/engine_tests/SignOnlyTests.cc	Wed Feb 06 19:25:40 2019 +0100
    38.2 +++ b/test/src/engine_tests/SignOnlyTests.cc	Mon Feb 11 08:35:27 2019 +0100
    38.3 @@ -9,7 +9,7 @@
    38.4  
    38.5  #include "pEpEngine.h"
    38.6  
    38.7 -#include "test_util.h"
    38.8 +#include "TestUtils.h"
    38.9  #include "EngineTestIndividualSuite.h"
   38.10  #include "SignOnlyTests.h"
   38.11  
    39.1 --- a/test/src/engine_tests/SimpleBodyNotAltTests.cc	Wed Feb 06 19:25:40 2019 +0100
    39.2 +++ b/test/src/engine_tests/SimpleBodyNotAltTests.cc	Mon Feb 11 08:35:27 2019 +0100
    39.3 @@ -10,7 +10,7 @@
    39.4  #include "pEpEngine.h"
    39.5  #include "message.h"
    39.6  #include "mime.h"
    39.7 -#include "test_util.h"
    39.8 +#include "TestUtils.h"
    39.9  
   39.10  #include "EngineTestIndividualSuite.h"
   39.11  #include "SimpleBodyNotAltTests.h"
    40.1 --- a/test/src/engine_tests/SubkeyRatingEvalTests.cc	Wed Feb 06 19:25:40 2019 +0100
    40.2 +++ b/test/src/engine_tests/SubkeyRatingEvalTests.cc	Mon Feb 11 08:35:27 2019 +0100
    40.3 @@ -8,7 +8,7 @@
    40.4  #include "pEpEngine.h"
    40.5  
    40.6  #include <cpptest.h>
    40.7 -#include "test_util.h"
    40.8 +#include "TestUtils.h"
    40.9  
   40.10  #include "EngineTestIndividualSuite.h"
   40.11  #include "SubkeyRatingEvalTests.h"
    41.1 --- a/test/src/engine_tests/TrustManipulationTests.cc	Wed Feb 06 19:25:40 2019 +0100
    41.2 +++ b/test/src/engine_tests/TrustManipulationTests.cc	Mon Feb 11 08:35:27 2019 +0100
    41.3 @@ -10,7 +10,7 @@
    41.4  #include <fstream>
    41.5  #include "mime.h"
    41.6  #include "message_api.h"
    41.7 -#include "test_util.h"
    41.8 +#include "TestUtils.h"
    41.9  
   41.10  #include "EngineTestSuite.h"
   41.11  #include "EngineTestSessionSuite.h"
    42.1 --- a/test/src/engine_tests/UserIDAliasTests.cc	Wed Feb 06 19:25:40 2019 +0100
    42.2 +++ b/test/src/engine_tests/UserIDAliasTests.cc	Mon Feb 11 08:35:27 2019 +0100
    42.3 @@ -10,7 +10,7 @@
    42.4  #include "pEpEngine.h"
    42.5  #include "message_api.h"
    42.6  #include "keymanagement.h"
    42.7 -#include "test_util.h"
    42.8 +#include "TestUtils.h"
    42.9  
   42.10  #include "EngineTestSuite.h"
   42.11  #include "EngineTestSessionSuite.h"
    43.1 --- a/test/src/engine_tests/UserIdCollisionTests.cc	Wed Feb 06 19:25:40 2019 +0100
    43.2 +++ b/test/src/engine_tests/UserIdCollisionTests.cc	Mon Feb 11 08:35:27 2019 +0100
    43.3 @@ -8,7 +8,7 @@
    43.4  
    43.5  #include "pEpEngine.h"
    43.6  
    43.7 -#include "test_util.h"
    43.8 +#include "TestUtils.h"
    43.9  #include "EngineTestIndividualSuite.h"
   43.10  #include "UserIdCollisionTests.h"
   43.11  
    44.1 --- a/test/src/util/test_util.cc	Wed Feb 06 19:25:40 2019 +0100
    44.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    44.3 @@ -1,419 +0,0 @@
    44.4 -#include "pEpEngine_test.h"
    44.5 -#include "pEpEngine.h"
    44.6 -#include "pEp_internal.h"
    44.7 -#include "message_api.h"
    44.8 -#include "test_util.h"
    44.9 -#include "TestConstants.h"
   44.10 -
   44.11 -#include <fstream>
   44.12 -#include <sstream>
   44.13 -#include <stdexcept>
   44.14 -#include <stdlib.h>
   44.15 -#include <sys/stat.h>
   44.16 -#include <errno.h>
   44.17 -#include <stdlib.h>
   44.18 -#include <unistd.h>
   44.19 -#include <ftw.h>
   44.20 -
   44.21 -PEP_STATUS read_file_and_import_key(PEP_SESSION session, const char* fname) {
   44.22 -    const std::string key = slurp(fname);
   44.23 -    PEP_STATUS status = (key.empty() ? PEP_KEY_NOT_FOUND : PEP_STATUS_OK);
   44.24 -    if (status == PEP_STATUS_OK)
   44.25 -        status = import_key(session, key.c_str(), key.size(), NULL);
   44.26 -    return status;    
   44.27 -}
   44.28 -
   44.29 -PEP_STATUS set_up_ident_from_scratch(PEP_SESSION session,
   44.30 -                                     const char* key_fname,
   44.31 -                                     const char* address,
   44.32 -                                     const char* fpr,
   44.33 -                                     const char* user_id,
   44.34 -                                     const char* username,
   44.35 -                                     pEp_identity** ret_ident,
   44.36 -                                     bool is_priv) {
   44.37 -    PEP_STATUS status = read_file_and_import_key(session,key_fname);
   44.38 -    if (status != PEP_KEY_IMPORTED)
   44.39 -        return status;
   44.40 -    else
   44.41 -        status = PEP_STATUS_OK;
   44.42 -    
   44.43 -    pEp_identity* ident = new_identity(address, fpr, user_id, username);
   44.44 -    if (is_priv && fpr) {
   44.45 -        status = set_own_key(session, ident, fpr);
   44.46 -        if (status == PEP_STATUS_OK)
   44.47 -            status = myself(session, ident);
   44.48 -    }
   44.49 -    else    
   44.50 -        status = update_identity(session, ident);
   44.51 -
   44.52 -    if (status != PEP_STATUS_OK)
   44.53 -        goto pep_free;
   44.54 -        
   44.55 -    if (!ident || !ident->fpr) {
   44.56 -        status = PEP_CANNOT_FIND_IDENTITY;
   44.57 -        goto pep_free;
   44.58 -    }
   44.59 -    
   44.60 -    if (ret_ident)
   44.61 -        *ret_ident = ident;
   44.62 -        
   44.63 -pep_free:
   44.64 -    if (!ret_ident)
   44.65 -        free_identity(ident);
   44.66 -    return status;    
   44.67 -}
   44.68 -
   44.69 -
   44.70 -bool file_exists(std::string filename) {
   44.71 -    struct stat buffer;
   44.72 -    return (stat(filename.c_str(), &buffer) == 0);
   44.73 -}
   44.74 -
   44.75 -char* str_to_lower(const char* str) {
   44.76 -    if (!str)
   44.77 -        return NULL;
   44.78 -    int str_len = strlen(str);
   44.79 -    if (str_len == 0)
   44.80 -        return strdup("");
   44.81 -    int i;
   44.82 -    
   44.83 -    char* retval = (char*) calloc(1, str_len + 1);
   44.84 -    for (i = 0; i < str_len; i++) {
   44.85 -        retval[i] = tolower(str[i]);
   44.86 -    }    
   44.87 -    return retval;
   44.88 -}
   44.89 -
   44.90 -// Because annoyed
   44.91 -bool _streq(const char* str1, const char* str2) {
   44.92 -    if (!str1) {
   44.93 -        if (str2)
   44.94 -            return false;
   44.95 -        return true;
   44.96 -    }
   44.97 -    if (!str2)
   44.98 -        return false;
   44.99 -        
  44.100 -    return (strcmp(str1, str2) == 0);
  44.101 -}
  44.102 -
  44.103 -bool _strceq(const char* str1, const char* str2) {
  44.104 -    char* str1_dup = str_to_lower(str1);
  44.105 -    char* str2_dup = str_to_lower(str2);
  44.106 -
  44.107 -    bool retval = _streq(str_to_lower(str1_dup), str_to_lower(str2_dup));
  44.108 -    free(str1_dup);
  44.109 -    free(str2_dup);
  44.110 -    return retval;
  44.111 -}
  44.112 -
  44.113 -void test_init() {
  44.114 -    unlink ("../test_home/.pEp_management.db");
  44.115 -    unlink ("../test_home/.pEp_management.db-shm");
  44.116 -    unlink ("../test_home/.pEp_management.db-wal");
  44.117 -}
  44.118 -
  44.119 -std::string slurp(const std::string& filename)
  44.120 -{
  44.121 -	std::ifstream input(filename.c_str());
  44.122 -	if(!input)
  44.123 -	{
  44.124 -		throw std::runtime_error("Cannot read file \"" + filename + "\"! ");
  44.125 -	}
  44.126 -	
  44.127 -	std::stringstream sstr;
  44.128 -	sstr << input.rdbuf();
  44.129 -	return sstr.str();
  44.130 -}
  44.131 -
  44.132 -void dump_out(const char* filename, const char* outdata)
  44.133 -{
  44.134 -	std::ofstream outfile(filename);
  44.135 -	if(!outfile)
  44.136 -	{
  44.137 -		throw std::runtime_error("Cannot open output file!");
  44.138 -	}
  44.139 -	
  44.140 -	outfile << outdata;
  44.141 -    outfile.close();
  44.142 -}
  44.143 -
  44.144 -char* get_new_uuid() {
  44.145 -    char* new_uuid = (char*)calloc(37, 1);
  44.146 -    pEpUUID uuid;
  44.147 -    uuid_generate_random(uuid);
  44.148 -    uuid_unparse_upper(uuid, new_uuid);
  44.149 -    return new_uuid;
  44.150 -}
  44.151 -
  44.152 -const char* tl_status_string(PEP_STATUS status) {
  44.153 -    switch (status) {
  44.154 -        case PEP_STATUS_OK:
  44.155 -            return "PEP_STATUS_OK";
  44.156 -        case PEP_INIT_CANNOT_LOAD_GPGME:
  44.157 -            return "PEP_INIT_CANNOT_LOAD_GPGME";
  44.158 -        case PEP_INIT_GPGME_INIT_FAILED:
  44.159 -            return "PEP_INIT_GPGME_INIT_FAILED";
  44.160 -        case PEP_INIT_NO_GPG_HOME:
  44.161 -            return "PEP_INIT_NO_GPG_HOME";
  44.162 -        case PEP_INIT_NETPGP_INIT_FAILED:
  44.163 -            return "PEP_INIT_NETPGP_INIT_FAILED";
  44.164 -        case PEP_INIT_SQLITE3_WITHOUT_MUTEX:
  44.165 -            return "PEP_INIT_SQLITE3_WITHOUT_MUTEX";
  44.166 -        case PEP_INIT_CANNOT_OPEN_DB:
  44.167 -            return "PEP_INIT_CANNOT_OPEN_DB";
  44.168 -        case PEP_INIT_CANNOT_OPEN_SYSTEM_DB:
  44.169 -            return "PEP_INIT_CANNOT_OPEN_SYSTEM_DB";
  44.170 -        case PEP_KEY_NOT_FOUND:
  44.171 -            return "PEP_KEY_NOT_FOUND";
  44.172 -        case PEP_KEY_HAS_AMBIG_NAME:
  44.173 -            return "PEP_KEY_HAS_AMBIG_NAME";
  44.174 -        case PEP_GET_KEY_FAILED:
  44.175 -            return "PEP_GET_KEY_FAILED";
  44.176 -        case PEP_CANNOT_EXPORT_KEY:
  44.177 -            return "PEP_CANNOT_EXPORT_KEY";
  44.178 -        case PEP_CANNOT_EDIT_KEY:
  44.179 -            return "PEP_CANNOT_EDIT_KEY";
  44.180 -        case PEP_CANNOT_FIND_IDENTITY:
  44.181 -            return "PEP_CANNOT_FIND_IDENTITY";
  44.182 -        case PEP_CANNOT_SET_PERSON:
  44.183 -            return "PEP_CANNOT_SET_PERSON";
  44.184 -        case PEP_CANNOT_SET_PGP_KEYPAIR:
  44.185 -            return "PEP_CANNOT_SET_PGP_KEYPAIR";
  44.186 -        case PEP_CANNOT_SET_IDENTITY:
  44.187 -            return "PEP_CANNOT_SET_IDENTITY";
  44.188 -        case PEP_CANNOT_SET_TRUST:
  44.189 -            return "PEP_CANNOT_SET_TRUST";
  44.190 -        case PEP_KEY_BLACKLISTED:
  44.191 -            return "PEP_KEY_BLACKLISTED";
  44.192 -        case PEP_UNENCRYPTED:
  44.193 -            return "PEP_UNENCRYPTED";
  44.194 -        case PEP_VERIFIED:
  44.195 -            return "PEP_VERIFIED";
  44.196 -        case PEP_DECRYPTED:
  44.197 -            return "PEP_DECRYPTED";
  44.198 -        case PEP_DECRYPTED_AND_VERIFIED:
  44.199 -            return "PEP_DECRYPTED_AND_VERIFIED";
  44.200 -        case PEP_DECRYPT_WRONG_FORMAT:
  44.201 -            return "PEP_DECRYPT_WRONG_FORMAT";
  44.202 -        case PEP_DECRYPT_NO_KEY:
  44.203 -            return "PEP_DECRYPT_NO_KEY";
  44.204 -        case PEP_DECRYPT_SIGNATURE_DOES_NOT_MATCH:
  44.205 -            return "PEP_DECRYPT_SIGNATURE_DOES_NOT_MATCH";
  44.206 -//        case PEP_DECRYPTED_BUT_UNSIGNED:
  44.207 -//            return "PEP_DECRYPTED_BUT_UNSIGNED";
  44.208 -//        case PEP_DECRYPT_MODIFICATION_DETECTED:
  44.209 -//            return "PEP_DECRYPT_MODIFICATION_DETECTED";
  44.210 -//        case PEP_DECRYPT_NO_KEY_FOR_SIGNER:
  44.211 -//            return "PEP_DECRYPT_NO_KEY_FOR_SIGNER";
  44.212 -        case PEP_VERIFY_NO_KEY:
  44.213 -            return "PEP_VERIFY_NO_KEY";
  44.214 -        case PEP_VERIFIED_AND_TRUSTED:
  44.215 -            return "PEP_VERIFIED_AND_TRUSTED";
  44.216 -        case PEP_CANNOT_DECRYPT_UNKNOWN:
  44.217 -            return "PEP_CANNOT_DECRYPT_UNKNOWN";
  44.218 -        case PEP_TRUSTWORD_NOT_FOUND:
  44.219 -            return "PEP_TRUSTWORD_NOT_FOUND";
  44.220 -        case PEP_TRUSTWORDS_FPR_WRONG_LENGTH:
  44.221 -            return "PEP_TRUSTWORDS_FPR_WRONG_LENGTH";
  44.222 -        case PEP_CANNOT_CREATE_KEY:
  44.223 -            return "PEP_CANNOT_CREATE_KEY";
  44.224 -        case PEP_CANNOT_SEND_KEY:
  44.225 -            return "PEP_CANNOT_SEND_KEY";
  44.226 -        case PEP_PHRASE_NOT_FOUND:
  44.227 -            return "PEP_PHRASE_NOT_FOUND";
  44.228 -        case PEP_SEND_FUNCTION_NOT_REGISTERED:
  44.229 -            return "PEP_SEND_FUNCTION_NOT_REGISTERED";
  44.230 -        case PEP_CONTRAINTS_VIOLATED:
  44.231 -            return "PEP_CONTRAINTS_VIOLATED";
  44.232 -        case PEP_CANNOT_ENCODE:
  44.233 -            return "PEP_CANNOT_ENCODE";
  44.234 -        case PEP_SYNC_NO_NOTIFY_CALLBACK:
  44.235 -            return "PEP_SYNC_NO_NOTIFY_CALLBACK";
  44.236 -        case PEP_SYNC_ILLEGAL_MESSAGE:
  44.237 -            return "PEP_SYNC_ILLEGAL_MESSAGE";
  44.238 -        case PEP_SYNC_NO_INJECT_CALLBACK:
  44.239 -            return "PEP_SYNC_NO_INJECT_CALLBACK";
  44.240 -        case PEP_CANNOT_INCREASE_SEQUENCE:
  44.241 -            return "PEP_CANNOT_INCREASE_SEQUENCE";
  44.242 -        case PEP_STATEMACHINE_ERROR:
  44.243 -            return "PEP_STATEMACHINE_ERROR";
  44.244 -        case PEP_NO_TRUST:
  44.245 -            return "PEP_NO_TRUST";
  44.246 -        case PEP_STATEMACHINE_INVALID_STATE:
  44.247 -            return "PEP_STATEMACHINE_INVALID_STATE";
  44.248 -        case PEP_STATEMACHINE_INVALID_EVENT:
  44.249 -            return "PEP_STATEMACHINE_INVALID_EVENT";
  44.250 -        case PEP_STATEMACHINE_INVALID_CONDITION:
  44.251 -            return "PEP_STATEMACHINE_INVALID_CONDITION";
  44.252 -        case PEP_STATEMACHINE_INVALID_ACTION:
  44.253 -            return "PEP_STATEMACHINE_INVALID_ACTION";
  44.254 -        case PEP_STATEMACHINE_INHIBITED_EVENT:
  44.255 -            return "PEP_STATEMACHINE_INHIBITED_EVENT";
  44.256 -        case PEP_COMMIT_FAILED:
  44.257 -            return "PEP_COMMIT_FAILED";
  44.258 -        case PEP_MESSAGE_CONSUME:
  44.259 -            return "PEP_MESSAGE_CONSUME";
  44.260 -        case PEP_MESSAGE_IGNORE:
  44.261 -            return "PEP_MESSAGE_IGNORE";
  44.262 -        case PEP_RECORD_NOT_FOUND:
  44.263 -            return "PEP_RECORD_NOT_FOUND";
  44.264 -        case PEP_CANNOT_CREATE_TEMP_FILE:
  44.265 -            return "PEP_CANNOT_CREATE_TEMP_FILE";
  44.266 -        case PEP_ILLEGAL_VALUE:
  44.267 -            return "PEP_ILLEGAL_VALUE";
  44.268 -        case PEP_BUFFER_TOO_SMALL:
  44.269 -            return "PEP_BUFFER_TOO_SMALL";
  44.270 -        case PEP_OUT_OF_MEMORY:
  44.271 -            return "PEP_OUT_OF_MEMORY";
  44.272 -        case PEP_UNKNOWN_ERROR:
  44.273 -            return "PEP_UNKNOWN_ERROR";    
  44.274 -        default:
  44.275 - 
  44.276 -            return "PEP_STATUS_OMGWTFBBQ - This means you're using a status the test lib doesn't know about!";
  44.277 -    }
  44.278 -}
  44.279 -const char* tl_rating_string(PEP_rating rating) {
  44.280 -    switch (rating) {
  44.281 -        case PEP_rating_undefined:
  44.282 -            return "PEP_rating_undefined";
  44.283 -        case PEP_rating_cannot_decrypt:
  44.284 -            return "PEP_rating_cannot_decrypt";
  44.285 -        case PEP_rating_have_no_key:
  44.286 -            return "PEP_rating_have_no_key";
  44.287 -        case PEP_rating_unencrypted:
  44.288 -            return "PEP_rating_unencrypted";
  44.289 -        case PEP_rating_unencrypted_for_some:
  44.290 -            return "PEP_rating_unencrypted_for_some";
  44.291 -        case PEP_rating_unreliable:
  44.292 -            return "PEP_rating_unreliable";
  44.293 -        case PEP_rating_reliable:
  44.294 -            return "PEP_rating_reliable";
  44.295 -        case PEP_rating_trusted:
  44.296 -            return "PEP_rating_trusted";
  44.297 -        case PEP_rating_trusted_and_anonymized:
  44.298 -            return "PEP_rating_trusted_and_anonymized";
  44.299 -        case PEP_rating_fully_anonymous:
  44.300 -            return "PEP_rating_fully_anonymous";
  44.301 -        case PEP_rating_mistrust:
  44.302 -            return "PEP_rating_mistrust";
  44.303 -        case PEP_rating_b0rken:
  44.304 -            return "PEP_rating_b0rken";
  44.305 -        case PEP_rating_under_attack:
  44.306 -            return "PEP_rating_under_attack";
  44.307 -        default:
  44.308 -            return "PEP_rating_OMGWTFBBQ - in other words, INVALID RATING VALUE!!!\n\nSomething bad is going on here, or a new rating value has been added to the enum and not the test function.";
  44.309 -    }
  44.310 -}
  44.311 -
  44.312 -const char* tl_ct_string(PEP_comm_type ct) {
  44.313 -    switch (ct) {
  44.314 -        case PEP_ct_unknown:
  44.315 -            return "PEP_ct_unknown";
  44.316 -        case PEP_ct_no_encryption:
  44.317 -            return "PEP_ct_no_encryption";
  44.318 -        case PEP_ct_no_encrypted_channel:
  44.319 -            return "PEP_ct_no_encrypted_channel";
  44.320 -        case PEP_ct_key_not_found:
  44.321 -            return "PEP_ct_key_not_found";
  44.322 -        case PEP_ct_key_expired:
  44.323 -            return "PEP_ct_key_expired";
  44.324 -        case PEP_ct_key_revoked:
  44.325 -            return "PEP_ct_key_revoked";
  44.326 -        case PEP_ct_key_b0rken:
  44.327 -            return "PEP_ct_key_b0rken";
  44.328 -        case PEP_ct_my_key_not_included:
  44.329 -            return "PEP_ct_my_key_not_included";
  44.330 -        case PEP_ct_security_by_obscurity:
  44.331 -            return "PEP_ct_security_by_obscurity";
  44.332 -        case PEP_ct_b0rken_crypto:
  44.333 -            return "PEP_ct_b0rken_crypto";
  44.334 -        case PEP_ct_key_too_short:
  44.335 -            return "PEP_ct_key_too_short";
  44.336 -        case PEP_ct_compromised:
  44.337 -            return "PEP_ct_compromised";
  44.338 -        case PEP_ct_mistrusted:
  44.339 -            return "PEP_ct_mistrusted";
  44.340 -        case PEP_ct_unconfirmed_encryption:
  44.341 -            return "PEP_ct_unconfirmed_encryption";
  44.342 -        case PEP_ct_OpenPGP_weak_unconfirmed:
  44.343 -            return "PEP_ct_OpenPGP_weak_unconfirmed";
  44.344 -        case PEP_ct_to_be_checked:
  44.345 -            return "PEP_ct_to_be_checked";
  44.346 -        case PEP_ct_SMIME_unconfirmed:
  44.347 -            return "PEP_ct_SMIME_unconfirmed";
  44.348 -        case PEP_ct_CMS_unconfirmed:
  44.349 -            return "PEP_ct_CMS_unconfirmed";
  44.350 -        case PEP_ct_strong_but_unconfirmed:
  44.351 -            return "PEP_ct_strong_but_unconfirmed";
  44.352 -        case PEP_ct_OpenPGP_unconfirmed:
  44.353 -            return "PEP_ct_OpenPGP_unconfirmed";
  44.354 -        case PEP_ct_OTR_unconfirmed:
  44.355 -            return "PEP_ct_OTR_unconfirmed";
  44.356 -        case PEP_ct_unconfirmed_enc_anon:
  44.357 -            return "PEP_ct_unconfirmed_enc_anon";
  44.358 -        case PEP_ct_pEp_unconfirmed:
  44.359 -            return "PEP_ct_pEp_unconfirmed";
  44.360 -        case PEP_ct_confirmed:
  44.361 -            return "PEP_ct_pEp_confirmed";
  44.362 -        case PEP_ct_confirmed_encryption:
  44.363 -            return "PEP_ct_confirmed_encryption";
  44.364 -        case PEP_ct_OpenPGP_weak:
  44.365 -            return "PEP_ct_OpenPGP_weak";
  44.366 -        case PEP_ct_to_be_checked_confirmed:
  44.367 -            return "PEP_ct_to_be_checked_confirmed";
  44.368 -        case PEP_ct_SMIME:
  44.369 -            return "PEP_ct_SMIME";
  44.370 -        case PEP_ct_CMS:
  44.371 -            return "PEP_ct_CMS";
  44.372 -        case PEP_ct_strong_encryption:
  44.373 -            return "PEP_ct_strong_encryption";
  44.374 -        case PEP_ct_OpenPGP:
  44.375 -            return "PEP_ct_OpenPGP";
  44.376 -        case PEP_ct_OTR:
  44.377 -            return "PEP_ct_OTR";
  44.378 -        case PEP_ct_confirmed_enc_anon:
  44.379 -            return "PEP_ct_confirmed_enc_anon";
  44.380 -        case PEP_ct_pEp:
  44.381 -            return "PEP_ct_pEp";
  44.382 -        default:
  44.383 -            return "PEP_ct_OMGWTFBBQ\n\nIn other words, comm type is invalid. Either something's corrupt or a new ct value has been added to the enum but not to the test function.";
  44.384 -    }
  44.385 -}
  44.386 -
  44.387 -bool slurp_and_import_key(PEP_SESSION session, const char* key_filename) {
  44.388 -    std::string keyfile = slurp(key_filename);
  44.389 -    if (import_key(session, keyfile.c_str(), keyfile.size(), NULL) != PEP_TEST_KEY_IMPORT_SUCCESS)
  44.390 -        return false;
  44.391 -    return true;
  44.392 -}
  44.393 -
  44.394 -bool slurp_message_and_import_key(PEP_SESSION session, const char* message_fname, std::string& message, const char* key_filename) {
  44.395 -    bool ok = true;
  44.396 -    message = slurp(message_fname);
  44.397 -    if (key_filename)
  44.398 -        ok = slurp_and_import_key(session, key_filename);
  44.399 -    return ok;
  44.400 -}
  44.401 -
  44.402 -
  44.403 -
  44.404 -int util_delete_filepath(const char *filepath, 
  44.405 -                         const struct stat *file_stat, 
  44.406 -                         int ftw_info, 
  44.407 -                         struct FTW * ftw_struct) {
  44.408 -    int retval = 0;
  44.409 -    switch (ftw_info) {
  44.410 -        case FTW_DP:
  44.411 -            retval = rmdir(filepath);
  44.412 -            break;
  44.413 -        case FTW_F:
  44.414 -        case FTW_SLN:
  44.415 -            retval = unlink(filepath);
  44.416 -            break;    
  44.417 -        default:
  44.418 -            retval = -1;
  44.419 -    }
  44.420 -    
  44.421 -    return retval;
  44.422 -}