Fixing tests googletest
authorKrista 'DarthMama' Bennett <krista@pep.foundation>
Tue, 27 Aug 2019 20:52:39 +0200
branchgoogletest
changeset 4020b35a96178dfd
parent 4019 7dc58e7bdee6
child 4021 c967427490ab
Fixing tests
test/Makefile
test/src/BlacklistAcceptNewKeyTest.cc
test/src/BlacklistTest.cc
test/src/CheckRenewedExpiredKeyTrustStatusTest.cc
test/src/DeleteKeyTest.cc
test/src/Engine.h
test/src/Engine358Test.cc
test/src/GetKeyRatingForUserTest.cc
test/src/KeyResetMessageTest.cc
test/src/KeyeditTest.cc
test/src/LotsOfKeysTest.cc
test/src/MapAsn1Test.cc
test/src/MimeTest.cc
test/src/OwnIdentitiesRetrieveTest.cc
test/src/OwnKeysRetrieveTest.cc
test/src/PgpBinaryTest.cc
test/src/PgpListKeysTest.cc
test/src/SequenceTest.cc
test/src/StringlistTest.cc
test/src/StringpairListTest.cc
test/src/TrustManipulationTest.cc
test/src/TrustwordsTest.cc
test/src/UserIdCollisionTest.cc
test/src/VerifyTest.cc
     1.1 --- a/test/Makefile	Tue Aug 27 11:04:53 2019 +0200
     1.2 +++ b/test/Makefile	Tue Aug 27 20:52:39 2019 +0200
     1.3 @@ -7,7 +7,7 @@
     1.4  
     1.5  include ../Makefile.conf
     1.6  
     1.7 -GTEST_DIR:=googletest
     1.8 +GTEST_DIR:=googletest/googletest
     1.9  SRCS:=$(wildcard src/*.cc) $(wildcard src/*/*.cc)
    1.10  OBJS:=$(addsuffix .o,$(basename $(SRCS)))
    1.11  DEPS:=$(OBJS:.o=.d)
     2.1 --- a/test/src/BlacklistAcceptNewKeyTest.cc	Tue Aug 27 11:04:53 2019 +0200
     2.2 +++ b/test/src/BlacklistAcceptNewKeyTest.cc	Tue Aug 27 20:52:39 2019 +0200
     2.3 @@ -97,7 +97,7 @@
     2.4      // 2797 65A2 FEB5 B7C7 31B8  61D9 3E4C EFD9 F7AF 4684 - this is the blacklisted key in blacklisted_pub.asc
     2.5  
     2.6      /* read the key into memory */
     2.7 -    const string keytext = slurp("blacklisted_pub.asc");
     2.8 +    const string keytext = slurp("test_mails/blacklisted_pub.asc");
     2.9  
    2.10      /* import it into pep */
    2.11      PEP_STATUS status7 = import_key(session, keytext.c_str(), keytext.length(), NULL);
     3.1 --- a/test/src/BlacklistTest.cc	Tue Aug 27 11:04:53 2019 +0200
     3.2 +++ b/test/src/BlacklistTest.cc	Tue Aug 27 20:52:39 2019 +0200
     3.3 @@ -147,7 +147,7 @@
     3.4  
     3.5      // 2797 65A2 FEB5 B7C7 31B8  61D9 3E4C EFD9 F7AF 4684 - this is the blacklisted key in blacklisted_pub.asc
     3.6  
     3.7 -    const string keytext = slurp("blacklisted_pub.asc");
     3.8 +    const string keytext = slurp("test_mails/blacklisted_pub.asc");
     3.9  
    3.10      /* FIXME: put in automated test stuff (N.B. only gdb mem examination to this point to get
    3.11       *        fix in */
    3.12 @@ -228,7 +228,7 @@
    3.13  
    3.14      free_message(msg23);
    3.15  
    3.16 -    const string keytext2 = slurp("blacklisted_pub2.asc");
    3.17 +    const string keytext2 = slurp("test_mails/blacklisted_pub2.asc");
    3.18      PEP_STATUS status14 = import_key(session, keytext2.c_str(), keytext2.length(), NULL);
    3.19  
    3.20      pEp_identity* blacklisted_identity2 = new_identity("blacklistedkeys@kgrothoff.org",
     4.1 --- a/test/src/CheckRenewedExpiredKeyTrustStatusTest.cc	Tue Aug 27 11:04:53 2019 +0200
     4.2 +++ b/test/src/CheckRenewedExpiredKeyTrustStatusTest.cc	Tue Aug 27 20:52:39 2019 +0200
     4.3 @@ -165,7 +165,7 @@
     4.4      ASSERT_EQ(status , PEP_KEY_UNSUITABLE);
     4.5      PEP_comm_type ct = expired_inquisitor->comm_type;
     4.6      ASSERT_EQ(ct , PEP_ct_key_not_found);
     4.7 -    ASSERT_NE(expired_inquisitor->fpr, nullptr);
     4.8 +    ASSERT_EQ(expired_inquisitor->fpr, nullptr);
     4.9  
    4.10      expired_inquisitor->fpr = strdup(inquisitor_fpr);
    4.11      status = get_trust(session, expired_inquisitor);
    4.12 @@ -314,7 +314,7 @@
    4.13      ASSERT_EQ(status , PEP_KEY_UNSUITABLE);
    4.14      PEP_comm_type ct = expired_inquisitor->comm_type;
    4.15      ASSERT_EQ(ct, PEP_ct_key_not_found);
    4.16 -    ASSERT_NE(expired_inquisitor->fpr, nullptr);
    4.17 +    ASSERT_EQ(expired_inquisitor->fpr, nullptr);
    4.18  
    4.19      expired_inquisitor->fpr = strdup(inquisitor_fpr);
    4.20      status = get_trust(session, expired_inquisitor);
     5.1 --- a/test/src/DeleteKeyTest.cc	Tue Aug 27 11:04:53 2019 +0200
     5.2 +++ b/test/src/DeleteKeyTest.cc	Tue Aug 27 20:52:39 2019 +0200
     5.3 @@ -163,7 +163,7 @@
     5.4      // Is it gone?
     5.5      status = find_keys(session, fenris_fpr, &keylist);
     5.6      ASSERT_EQ(status, PEP_STATUS_OK);
     5.7 -    ASSERT_NE(keylist, nullptr);
     5.8 +    ASSERT_EQ(keylist, nullptr);
     5.9  
    5.10      // Yay.
    5.11  }
    5.12 @@ -187,7 +187,7 @@
    5.13      // Is it gone?
    5.14      status = find_keys(session, alice_fpr, &keylist);
    5.15      ASSERT_EQ(status, PEP_STATUS_OK);
    5.16 -    ASSERT_NE(keylist, nullptr);
    5.17 +    ASSERT_EQ(keylist, nullptr);
    5.18  
    5.19      // Yay.
    5.20  }
    5.21 @@ -231,15 +231,15 @@
    5.22      // Is it gone?
    5.23      status = find_keys(session, alice_fpr, &keylist);
    5.24      ASSERT_EQ(status, PEP_STATUS_OK);
    5.25 -    ASSERT_NE(keylist, nullptr);
    5.26 +    ASSERT_EQ(keylist, nullptr);
    5.27  
    5.28      status = find_keys(session, dave_fpr, &keylist);
    5.29      ASSERT_EQ(status, PEP_STATUS_OK);
    5.30 -    ASSERT_NE(keylist, nullptr);
    5.31 +    ASSERT_EQ(keylist, nullptr);
    5.32  
    5.33      status = find_keys(session, fenris_fpr, &keylist);
    5.34      ASSERT_EQ(status, PEP_STATUS_OK);
    5.35 -    ASSERT_NE(keylist, nullptr);
    5.36 +    ASSERT_EQ(keylist, nullptr);
    5.37  
    5.38      // Yay. Make sure everyone else is still there.
    5.39      status = find_keys(session, bob_fpr, &keylist);
    5.40 @@ -333,37 +333,37 @@
    5.41      // Is it gone?
    5.42      status = find_keys(session, alice_fpr, &keylist);
    5.43      ASSERT_EQ(status, PEP_STATUS_OK);
    5.44 -    ASSERT_NE(keylist, nullptr);
    5.45 +    ASSERT_EQ(keylist, nullptr);
    5.46      free_stringlist(keylist);
    5.47      keylist = NULL;
    5.48  
    5.49      status = find_keys(session, bob_fpr, &keylist);
    5.50      ASSERT_EQ(status, PEP_STATUS_OK);
    5.51 -    ASSERT_NE(keylist, nullptr);
    5.52 +    ASSERT_EQ(keylist, nullptr);
    5.53      free_stringlist(keylist);
    5.54      keylist = NULL;
    5.55  
    5.56      status = find_keys(session, carol_fpr, &keylist);
    5.57      ASSERT_EQ(status, PEP_STATUS_OK);
    5.58 -    ASSERT_NE(keylist, nullptr);
    5.59 +    ASSERT_EQ(keylist, nullptr);
    5.60      free_stringlist(keylist);
    5.61      keylist = NULL;
    5.62  
    5.63      status = find_keys(session, dave_fpr, &keylist);
    5.64      ASSERT_EQ(status, PEP_STATUS_OK);
    5.65 -    ASSERT_NE(keylist, nullptr);
    5.66 +    ASSERT_EQ(keylist, nullptr);
    5.67      free_stringlist(keylist);
    5.68      keylist = NULL;
    5.69  
    5.70      status = find_keys(session, erin_fpr, &keylist);
    5.71      ASSERT_EQ(status, PEP_STATUS_OK);
    5.72 -    ASSERT_NE(keylist, nullptr);
    5.73 +    ASSERT_EQ(keylist, nullptr);
    5.74      free_stringlist(keylist);
    5.75      keylist = NULL;
    5.76  
    5.77      status = find_keys(session, fenris_fpr, &keylist);
    5.78      ASSERT_EQ(status, PEP_STATUS_OK);
    5.79 -    ASSERT_NE(keylist, nullptr);
    5.80 +    ASSERT_EQ(keylist, nullptr);
    5.81      free_stringlist(keylist);
    5.82      keylist = NULL;
    5.83  
    5.84 @@ -388,7 +388,7 @@
    5.85      // Is it still gone?
    5.86      status = find_keys(session, "74D79B4496E289BD8A71B70BA8E2C4530019697D", &keylist);
    5.87      ASSERT_EQ(status, PEP_STATUS_OK);
    5.88 -    ASSERT_NE(keylist, nullptr);
    5.89 +    ASSERT_EQ(keylist, nullptr);
    5.90      free_stringlist(keylist);
    5.91      keylist = NULL;
    5.92  
    5.93 @@ -412,7 +412,7 @@
    5.94      // Is it still gone?
    5.95      status = find_keys(session, "74D79B4496E289BD8A71B70BA8E2C4530019697D", &keylist);
    5.96      ASSERT_EQ(status, PEP_STATUS_OK);
    5.97 -    ASSERT_NE(keylist, nullptr);
    5.98 +    ASSERT_EQ(keylist, nullptr);
    5.99      free_stringlist(keylist);
   5.100      keylist = NULL;
   5.101  
     6.1 --- a/test/src/Engine.h	Tue Aug 27 11:04:53 2019 +0200
     6.2 +++ b/test/src/Engine.h	Tue Aug 27 20:52:39 2019 +0200
     6.3 @@ -14,7 +14,7 @@
     6.4          Engine(string engine_home_dir);
     6.5          virtual ~Engine();
     6.6          
     6.7 -        void prep(messageToSend_t mts, inject_sync_event_t ise, std::vector<std::pair<std::string, std::string>> init_files);
     6.8 +        void prep(const messageToSend_t mts, const inject_sync_event_t ise, std::vector<std::pair<std::string, std::string>> init_files);
     6.9          void start();
    6.10          void shut_down();
    6.11  
     7.1 --- a/test/src/Engine358Test.cc	Tue Aug 27 11:04:53 2019 +0200
     7.2 +++ b/test/src/Engine358Test.cc	Tue Aug 27 20:52:39 2019 +0200
     7.3 @@ -110,7 +110,7 @@
     7.4      message* enc_msg = NULL;
     7.5  
     7.6      status = encrypt_message(session, msg, NULL, &enc_msg, PEP_enc_PGP_MIME, 0);
     7.7 -    ASSERT_NE(enc_msg, nullptr);
     7.8 +    ASSERT_EQ(enc_msg, nullptr);
     7.9      ASSERT_TRUE(msg->to && msg->to->ident);
    7.10      ASSERT_EQ(status , PEP_UNENCRYPTED);
    7.11  }
     8.1 --- a/test/src/GetKeyRatingForUserTest.cc	Tue Aug 27 11:04:53 2019 +0200
     8.2 +++ b/test/src/GetKeyRatingForUserTest.cc	Tue Aug 27 20:52:39 2019 +0200
     8.3 @@ -90,7 +90,7 @@
     8.4      const char* fpr_save = alice->fpr;
     8.5      alice->fpr = NULL;
     8.6      status = get_identity(session, alice->address, alice->user_id, &test_null);
     8.7 -    ASSERT_NE(test_null, nullptr);
     8.8 +    ASSERT_EQ(test_null, nullptr);
     8.9      ASSERT_EQ(status , PEP_CANNOT_FIND_IDENTITY);
    8.10      ASSERT_EQ(alice->comm_type , PEP_ct_unknown);
    8.11  
     9.1 --- a/test/src/KeyResetMessageTest.cc	Tue Aug 27 11:04:53 2019 +0200
     9.2 +++ b/test/src/KeyResetMessageTest.cc	Tue Aug 27 20:52:39 2019 +0200
     9.3 @@ -21,220 +21,218 @@
     9.4  
     9.5  #include <gtest/gtest.h>
     9.6  
     9.7 +PEP_STATUS KRMT_message_send_callback(message* msg);
     9.8  
     9.9 -namespace {
    9.10 +static void* KRMT_fake_this;
    9.11  
    9.12 -	//The fixture for KeyResetMessageTest
    9.13 -    class KeyResetMessageTest : public ::testing::Test {
    9.14 -        public:
    9.15 -            Engine* engine;
    9.16 -            PEP_SESSION session;
    9.17 +//The fixture for KeyResetMessageTest
    9.18 +class KeyResetMessageTest : public ::testing::Test {
    9.19 +    public:
    9.20 +        Engine* engine;
    9.21 +        PEP_SESSION session;
    9.22  
    9.23 -        protected:
    9.24 -            
    9.25 -            KeyResetMessageTests* fake_this;
    9.26 +        vector<message*> m_queue;
    9.27          
    9.28 -            vector<message*> m_queue;
    9.29 -            
    9.30 -            PEP_STATUS message_send_callback(message* msg) {
    9.31 -                fake_this->m_queue.push_back(msg);
    9.32 -                return PEP_STATUS_OK;
    9.33 -            }
    9.34 +    protected:
    9.35 +                    
    9.36 +        const char* alice_fpr = "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97";
    9.37 +        const char* bob_fpr = "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39";
    9.38 +    
    9.39 +        const char* alice_receive_reset_fpr = "6A349E4F68801E39145CD4C5712616A385412538";
    9.40 +
    9.41 +        const string alice_user_id = PEP_OWN_USERID;
    9.42 +        const string bob_user_id = "BobId";
    9.43 +        const string carol_user_id = "carolId";
    9.44 +        const string dave_user_id = "DaveId";
    9.45 +        const string erin_user_id = "ErinErinErin";
    9.46 +        const string fenris_user_id = "BadWolf";
    9.47 +
    9.48 +        // You can remove any or all of the following functions if its body
    9.49 +        // is empty.
    9.50 +        KeyResetMessageTest() {
    9.51 +            // You can do set-up work for each test here.
    9.52 +            test_suite_name = ::testing::UnitTest::GetInstance()->current_test_info()->test_suite_name();
    9.53 +            test_name = ::testing::UnitTest::GetInstance()->current_test_info()->name();
    9.54 +            test_path = get_main_test_home_dir() + "/" + test_suite_name + "/" + test_name;
    9.55 +        }
    9.56 +
    9.57 +        ~KeyResetMessageTest() override {
    9.58 +            // You can do clean-up work that doesn't throw exceptions here.
    9.59 +        }
    9.60 +
    9.61 +        // If the constructor and destructor are not enough for setting up
    9.62 +        // and cleaning up each test, you can define the following methods:
    9.63 +
    9.64 +        void SetUp() override {
    9.65 +            // Code here will be called immediately after the constructor (right
    9.66 +            // before each test).
    9.67 +
    9.68 +            KRMT_fake_this = (void*)this;
    9.69 +            // Leave this empty if there are no files to copy to the home directory path
    9.70 +            std::vector<std::pair<std::string, std::string>> init_files = std::vector<std::pair<std::string, std::string>>();
    9.71 +
    9.72 +            // Get a new test Engine.
    9.73 +            engine = new Engine(test_path);
    9.74 +            ASSERT_NE(engine, nullptr);
    9.75 +
    9.76 +            // Ok, let's initialize test directories etc.
    9.77 +            engine->prep(&KRMT_message_send_callback, NULL, init_files);
    9.78 +
    9.79 +            // Ok, try to start this bugger.
    9.80 +            engine->start();
    9.81 +            ASSERT_NE(engine->session, nullptr);
    9.82 +            session = engine->session;
    9.83 +
    9.84 +            // Engine is up. Keep on truckin'
    9.85 +            m_queue.clear();
    9.86 +        }
    9.87 +
    9.88 +        void TearDown() override {
    9.89 +            // Code here will be called immediately after each test (right
    9.90 +            // before the destructor).
    9.91 +            KRMT_fake_this = NULL;            
    9.92 +            engine->shut_down();
    9.93 +            delete engine;
    9.94 +            engine = NULL;
    9.95 +            session = NULL;
    9.96 +        }
    9.97          
    9.98 -            const char* alice_fpr = "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97";
    9.99 -            const char* bob_fpr = "BFCDB7F301DEEEBBF947F29659BFF488C9C2EE39";
   9.100 +        void send_setup() {
   9.101 +            // Setup own identity
   9.102 +            PEP_STATUS status = read_file_and_import_key(session,
   9.103 +                        "test_keys/pub/pep-test-alice-0x6FF00E97_pub.asc");
   9.104 +            assert(status == PEP_KEY_IMPORTED);
   9.105 +            status = set_up_ident_from_scratch(session,
   9.106 +                        "test_keys/priv/pep-test-alice-0x6FF00E97_priv.asc",
   9.107 +                        "pep.test.alice@pep-project.org", alice_fpr,
   9.108 +                        alice_user_id.c_str(), "Alice in Wonderland", NULL, true
   9.109 +                    );
   9.110 +            ASSERT_EQ(status, PEP_STATUS_OK);
   9.111 +
   9.112 +            status = set_up_ident_from_scratch(session,
   9.113 +                        "test_keys/pub/pep-test-bob-0xC9C2EE39_pub.asc",
   9.114 +                        "pep.test.bob@pep-project.org", NULL, bob_user_id.c_str(), "Bob's Burgers",
   9.115 +                        NULL, false
   9.116 +                    );
   9.117 +            ASSERT_EQ(status, PEP_STATUS_OK);
   9.118 +
   9.119 +            status = set_up_ident_from_scratch(session,
   9.120 +                        "test_keys/pub/pep-test-carol-0x42A85A42_pub.asc",
   9.121 +                        "pep-test-carol@pep-project.org", NULL, carol_user_id.c_str(), "Carol Burnett",
   9.122 +                        NULL, false
   9.123 +                    );
   9.124 +            ASSERT_EQ(status, PEP_STATUS_OK);
   9.125 +
   9.126 +            status = set_up_ident_from_scratch(session,
   9.127 +                        "test_keys/pub/pep-test-dave-0xBB5BCCF6_pub.asc",
   9.128 +                        "pep-test-dave@pep-project.org", NULL, dave_user_id.c_str(),
   9.129 +                        "David Hasselhoff (Germans Love Me)", NULL, false
   9.130 +                    );
   9.131 +            ASSERT_EQ(status, PEP_STATUS_OK);
   9.132 +
   9.133 +            status = set_up_ident_from_scratch(session,
   9.134 +                        "test_keys/pub/pep-test-erin-0x9F8D7CBA_pub.asc",
   9.135 +                        "pep-test-erin@pep-project.org", NULL, erin_user_id.c_str(),
   9.136 +                        "Éirinn go Brách", NULL, false
   9.137 +                    );
   9.138 +            ASSERT_EQ(status, PEP_STATUS_OK);
   9.139 +
   9.140 +            status = set_up_ident_from_scratch(session,
   9.141 +                        "test_keys/pub/pep.test.fenris-0x4F3D2900_pub.asc",
   9.142 +                        "pep.test.fenris@thisstilldoesntwork.lu", NULL, fenris_user_id.c_str(),
   9.143 +                        "Fenris Leto Hawke", NULL, false
   9.144 +                    );
   9.145 +            ASSERT_EQ(status, PEP_STATUS_OK);
   9.146 +        }
   9.147 +
   9.148 +        void receive_setup() {
   9.149 +            PEP_STATUS status = read_file_and_import_key(session,
   9.150 +                        "test_keys/pub/pep-test-bob-0xC9C2EE39_pub.asc");
   9.151 +            assert(status == PEP_KEY_IMPORTED);
   9.152 +            status = set_up_ident_from_scratch(session,
   9.153 +                        "test_keys/priv/pep-test-bob-0xC9C2EE39_priv.asc",
   9.154 +                        "pep.test.bob@pep-project.org", bob_fpr,
   9.155 +                        bob_user_id.c_str(), "Robert Redford", NULL, true
   9.156 +                    );
   9.157 +            ASSERT_EQ(status, PEP_STATUS_OK);
   9.158 +
   9.159 +            status = set_up_ident_from_scratch(session,
   9.160 +                        "test_keys/pub/pep-test-alice-0x6FF00E97_pub.asc",
   9.161 +                        "pep.test.alice@pep-project.org", NULL, alice_user_id.c_str(), "Alice is tired of Bob",
   9.162 +                        NULL, false
   9.163 +                    );
   9.164 +            ASSERT_EQ(status, PEP_STATUS_OK);
   9.165 +        }
   9.166          
   9.167 -            const char* alice_receive_reset_fpr = "6A349E4F68801E39145CD4C5712616A385412538";
   9.168 +        void create_msg_for_revoked_key() {
   9.169 +            PEP_STATUS status = set_up_ident_from_scratch(session,
   9.170 +                        "test_keys/pub/pep-test-gabrielle-0xE203586C_pub.asc",
   9.171 +                        "pep-test-gabrielle@pep-project.org", NULL, PEP_OWN_USERID,
   9.172 +                        "Gabi", NULL, false
   9.173 +                    );
   9.174 +            ASSERT_EQ(status, PEP_STATUS_OK);
   9.175 +            status = set_up_ident_from_scratch(session,
   9.176 +                        "test_keys/priv/pep-test-gabrielle-0xE203586C_priv.asc",
   9.177 +                        "pep-test-gabrielle@pep-project.org", NULL, PEP_OWN_USERID,
   9.178 +                        "Gabi", NULL, false
   9.179 +                    );
   9.180 +            ASSERT_EQ(status, PEP_STATUS_OK);
   9.181  
   9.182 -            const string alice_user_id = PEP_OWN_USERID;
   9.183 -            const string bob_user_id = "BobId";
   9.184 -            const string carol_user_id = "carolId";
   9.185 -            const string dave_user_id = "DaveId";
   9.186 -            const string erin_user_id = "ErinErinErin";
   9.187 -            const string fenris_user_id = "BadWolf";
   9.188 +            status = set_up_ident_from_scratch(session,
   9.189 +                        "test_keys/pub/pep-test-alice-0x6FF00E97_pub.asc",
   9.190 +                        "pep.test.alice@pep-project.org", NULL, "AliceOther", "Alice is tired of Bob",
   9.191 +                        NULL, false
   9.192 +                    );
   9.193  
   9.194 -            // You can remove any or all of the following functions if its body
   9.195 -            // is empty.
   9.196 -            KeyResetMessageTest() {
   9.197 -                // You can do set-up work for each test here.
   9.198 -                test_suite_name = ::testing::UnitTest::GetInstance()->current_test_info()->test_suite_name();
   9.199 -                test_name = ::testing::UnitTest::GetInstance()->current_test_info()->name();
   9.200 -                test_path = get_main_test_home_dir() + "/" + test_suite_name + "/" + test_name;
   9.201 -            }
   9.202 +            pEp_identity* from_ident = new_identity("pep-test-gabrielle@pep-project.org", NULL, PEP_OWN_USERID, NULL);
   9.203 +            status = myself(session, from_ident);
   9.204 +            ASSERT_EQ(status , PEP_STATUS_OK);
   9.205 +            ASSERT_NE(from_ident->fpr, nullptr);
   9.206 +            ASSERT_STRCASEEQ(from_ident->fpr, "906C9B8349954E82C5623C3C8C541BD4E203586C");
   9.207 +            ASSERT_TRUE(from_ident->me);
   9.208  
   9.209 -            ~KeyResetMessageTest() override {
   9.210 -                // You can do clean-up work that doesn't throw exceptions here.
   9.211 -            }
   9.212 +            // "send" some messages to update the social graph entries
   9.213 +            identity_list* send_idents =
   9.214 +                new_identity_list(
   9.215 +                    new_identity("pep.test.alice@pep-project.org", NULL, "AliceOther", NULL));
   9.216 +            status = update_identity(session, send_idents->ident);
   9.217 +            ASSERT_EQ(status , PEP_STATUS_OK);
   9.218 +            status = set_as_pEp_user(session, send_idents->ident);
   9.219  
   9.220 -            // If the constructor and destructor are not enough for setting up
   9.221 -            // and cleaning up each test, you can define the following methods:
   9.222 +            message* outgoing_msg = new_message(PEP_dir_outgoing);
   9.223 +            ASSERT_NE(outgoing_msg, nullptr);
   9.224 +            outgoing_msg->from = from_ident;
   9.225 +            outgoing_msg->to = send_idents;
   9.226 +            outgoing_msg->shortmsg = strdup("Well isn't THIS a useless message...");
   9.227 +            outgoing_msg->longmsg = strdup("Hi Mom...\n");
   9.228 +            outgoing_msg->attachments = new_bloblist(NULL, 0, "application/octet-stream", NULL);
   9.229 +            cout << "Message created.\n\n";
   9.230 +            cout << "Encrypting message as MIME multipart…\n";
   9.231 +            message* enc_outgoing_msg = nullptr;
   9.232 +            cout << "Calling encrypt_message()\n";
   9.233 +            status = encrypt_message(session, outgoing_msg, NULL, &enc_outgoing_msg, PEP_enc_PGP_MIME, 0);
   9.234 +            ASSERT_EQ(status , PEP_STATUS_OK);
   9.235 +            ASSERT_NE(enc_outgoing_msg, nullptr);
   9.236 +            cout << "Message encrypted.\n";
   9.237 +            char* outstring = NULL;
   9.238 +            mime_encode_message(enc_outgoing_msg, false, &outstring);
   9.239 +            cout << outstring << endl;
   9.240 +            free_message(enc_outgoing_msg);
   9.241 +            free(outstring);
   9.242 +        }
   9.243  
   9.244 -            void SetUp() override {
   9.245 -                // Code here will be called immediately after the constructor (right
   9.246 -                // before each test).
   9.247 +    private:
   9.248 +        const char* test_suite_name;
   9.249 +        const char* test_name;
   9.250 +        string test_path;
   9.251 +        // Objects declared here can be used by all tests in the KeyResetMessageTest suite.
   9.252  
   9.253 -                fake_this = this;
   9.254 -                // Leave this empty if there are no files to copy to the home directory path
   9.255 -                std::vector<std::pair<std::string, std::string>> init_files = std::vector<std::pair<std::string, std::string>>();
   9.256 +};
   9.257  
   9.258 -                // Get a new test Engine.
   9.259 -                engine = new Engine(test_path);
   9.260 -                ASSERT_NE(engine, nullptr);
   9.261 -
   9.262 -                // Ok, let's initialize test directories etc.
   9.263 -                engine->prep(&KeyResetMessageTest::message_send_callback, NULL, init_files);
   9.264 -
   9.265 -                // Ok, try to start this bugger.
   9.266 -                engine->start();
   9.267 -                ASSERT_NE(engine->session, nullptr);
   9.268 -                session = engine->session;
   9.269 -
   9.270 -                // Engine is up. Keep on truckin'
   9.271 -                m_queue.clear();
   9.272 -            }
   9.273 -
   9.274 -            void TearDown() override {
   9.275 -                // Code here will be called immediately after each test (right
   9.276 -                // before the destructor).
   9.277 -                engine->shut_down();
   9.278 -                delete engine;
   9.279 -                engine = NULL;
   9.280 -                session = NULL;
   9.281 -            }
   9.282 -            
   9.283 -            void send_setup() {
   9.284 -                // Setup own identity
   9.285 -                PEP_STATUS status = read_file_and_import_key(session,
   9.286 -                            "test_keys/pub/pep-test-alice-0x6FF00E97_pub.asc");
   9.287 -                assert(status == PEP_KEY_IMPORTED);
   9.288 -                status = set_up_ident_from_scratch(session,
   9.289 -                            "test_keys/priv/pep-test-alice-0x6FF00E97_priv.asc",
   9.290 -                            "pep.test.alice@pep-project.org", alice_fpr,
   9.291 -                            alice_user_id.c_str(), "Alice in Wonderland", NULL, true
   9.292 -                        );
   9.293 -                ASSERT_EQ(status, PEP_STATUS_OK);
   9.294 -
   9.295 -                status = set_up_ident_from_scratch(session,
   9.296 -                            "test_keys/pub/pep-test-bob-0xC9C2EE39_pub.asc",
   9.297 -                            "pep.test.bob@pep-project.org", NULL, bob_user_id.c_str(), "Bob's Burgers",
   9.298 -                            NULL, false
   9.299 -                        );
   9.300 -                ASSERT_EQ(status, PEP_STATUS_OK);
   9.301 -
   9.302 -                status = set_up_ident_from_scratch(session,
   9.303 -                            "test_keys/pub/pep-test-carol-0x42A85A42_pub.asc",
   9.304 -                            "pep-test-carol@pep-project.org", NULL, carol_user_id.c_str(), "Carol Burnett",
   9.305 -                            NULL, false
   9.306 -                        );
   9.307 -                ASSERT_EQ(status, PEP_STATUS_OK);
   9.308 -
   9.309 -                status = set_up_ident_from_scratch(session,
   9.310 -                            "test_keys/pub/pep-test-dave-0xBB5BCCF6_pub.asc",
   9.311 -                            "pep-test-dave@pep-project.org", NULL, dave_user_id.c_str(),
   9.312 -                            "David Hasselhoff (Germans Love Me)", NULL, false
   9.313 -                        );
   9.314 -                ASSERT_EQ(status, PEP_STATUS_OK);
   9.315 -
   9.316 -                status = set_up_ident_from_scratch(session,
   9.317 -                            "test_keys/pub/pep-test-erin-0x9F8D7CBA_pub.asc",
   9.318 -                            "pep-test-erin@pep-project.org", NULL, erin_user_id.c_str(),
   9.319 -                            "Éirinn go Brách", NULL, false
   9.320 -                        );
   9.321 -                ASSERT_EQ(status, PEP_STATUS_OK);
   9.322 -
   9.323 -                status = set_up_ident_from_scratch(session,
   9.324 -                            "test_keys/pub/pep.test.fenris-0x4F3D2900_pub.asc",
   9.325 -                            "pep.test.fenris@thisstilldoesntwork.lu", NULL, fenris_user_id.c_str(),
   9.326 -                            "Fenris Leto Hawke", NULL, false
   9.327 -                        );
   9.328 -                ASSERT_EQ(status, PEP_STATUS_OK);
   9.329 -            }
   9.330 -
   9.331 -            void receive_setup() {
   9.332 -                PEP_STATUS status = read_file_and_import_key(session,
   9.333 -                            "test_keys/pub/pep-test-bob-0xC9C2EE39_pub.asc");
   9.334 -                assert(status == PEP_KEY_IMPORTED);
   9.335 -                status = set_up_ident_from_scratch(session,
   9.336 -                            "test_keys/priv/pep-test-bob-0xC9C2EE39_priv.asc",
   9.337 -                            "pep.test.bob@pep-project.org", bob_fpr,
   9.338 -                            bob_user_id.c_str(), "Robert Redford", NULL, true
   9.339 -                        );
   9.340 -                ASSERT_EQ(status, PEP_STATUS_OK);
   9.341 -
   9.342 -                status = set_up_ident_from_scratch(session,
   9.343 -                            "test_keys/pub/pep-test-alice-0x6FF00E97_pub.asc",
   9.344 -                            "pep.test.alice@pep-project.org", NULL, alice_user_id.c_str(), "Alice is tired of Bob",
   9.345 -                            NULL, false
   9.346 -                        );
   9.347 -                ASSERT_EQ(status, PEP_STATUS_OK);
   9.348 -            }
   9.349 -            
   9.350 -            void create_msg_for_revoked_key() {
   9.351 -                PEP_STATUS status = set_up_ident_from_scratch(session,
   9.352 -                            "test_keys/pub/pep-test-gabrielle-0xE203586C_pub.asc",
   9.353 -                            "pep-test-gabrielle@pep-project.org", NULL, PEP_OWN_USERID,
   9.354 -                            "Gabi", NULL, false
   9.355 -                        );
   9.356 -                ASSERT_EQ(status, PEP_STATUS_OK);
   9.357 -                status = set_up_ident_from_scratch(session,
   9.358 -                            "test_keys/priv/pep-test-gabrielle-0xE203586C_priv.asc",
   9.359 -                            "pep-test-gabrielle@pep-project.org", NULL, PEP_OWN_USERID,
   9.360 -                            "Gabi", NULL, false
   9.361 -                        );
   9.362 -                ASSERT_EQ(status, PEP_STATUS_OK);
   9.363 -
   9.364 -                status = set_up_ident_from_scratch(session,
   9.365 -                            "test_keys/pub/pep-test-alice-0x6FF00E97_pub.asc",
   9.366 -                            "pep.test.alice@pep-project.org", NULL, "AliceOther", "Alice is tired of Bob",
   9.367 -                            NULL, false
   9.368 -                        );
   9.369 -
   9.370 -                pEp_identity* from_ident = new_identity("pep-test-gabrielle@pep-project.org", NULL, PEP_OWN_USERID, NULL);
   9.371 -                status = myself(session, from_ident);
   9.372 -                ASSERT_EQ(status , PEP_STATUS_OK);
   9.373 -                TEST_ASSERT_MSG(from_ident->fpr && strcasecmp(from_ident->fpr, "906C9B8349954E82C5623C3C8C541BD4E203586C") == 0,
   9.374 -                                from_ident->fpr);
   9.375 -                ASSERT_NE(from_ident->me, nullptr);
   9.376 -
   9.377 -                // "send" some messages to update the social graph entries
   9.378 -                identity_list* send_idents =
   9.379 -                    new_identity_list(
   9.380 -                        new_identity("pep.test.alice@pep-project.org", NULL, "AliceOther", NULL));
   9.381 -                status = update_identity(session, send_idents->ident);
   9.382 -                ASSERT_EQ(status , PEP_STATUS_OK);
   9.383 -                status = set_as_pEp_user(session, send_idents->ident);
   9.384 -
   9.385 -                message* outgoing_msg = new_message(PEP_dir_outgoing);
   9.386 -                ASSERT_NE(outgoing_msg, nullptr);
   9.387 -                outgoing_msg->from = from_ident;
   9.388 -                outgoing_msg->to = send_idents;
   9.389 -                outgoing_msg->shortmsg = strdup("Well isn't THIS a useless message...");
   9.390 -                outgoing_msg->longmsg = strdup("Hi Mom...\n");
   9.391 -                outgoing_msg->attachments = new_bloblist(NULL, 0, "application/octet-stream", NULL);
   9.392 -                cout << "Message created.\n\n";
   9.393 -                cout << "Encrypting message as MIME multipart…\n";
   9.394 -                message* enc_outgoing_msg = nullptr;
   9.395 -                cout << "Calling encrypt_message()\n";
   9.396 -                status = encrypt_message(session, outgoing_msg, NULL, &enc_outgoing_msg, PEP_enc_PGP_MIME, 0);
   9.397 -                ASSERT_EQ(status , PEP_STATUS_OK);
   9.398 -                ASSERT_NE(enc_outgoing_msg, nullptr);
   9.399 -                cout << "Message encrypted.\n";
   9.400 -                char* outstring = NULL;
   9.401 -                mime_encode_message(enc_outgoing_msg, false, &outstring);
   9.402 -                cout << outstring << endl;
   9.403 -                free_message(enc_outgoing_msg);
   9.404 -                free(outstring);
   9.405 -            }
   9.406 -
   9.407 -        private:
   9.408 -            const char* test_suite_name;
   9.409 -            const char* test_name;
   9.410 -            string test_path;
   9.411 -            // Objects declared here can be used by all tests in the KeyResetMessageTest suite.
   9.412 -
   9.413 -    };
   9.414 -
   9.415 -}  // namespace
   9.416 +PEP_STATUS KRMT_message_send_callback(message* msg) {
   9.417 +    ((KeyResetMessageTest*)KRMT_fake_this)->m_queue.push_back(msg);
   9.418 +    return PEP_STATUS_OK;
   9.419 +}
   9.420  
   9.421  TEST_F(KeyResetMessageTest, check_reset_key_and_notify) {
   9.422      send_setup();
   9.423 @@ -242,9 +240,9 @@
   9.424      pEp_identity* from_ident = new_identity("pep.test.alice@pep-project.org", NULL, PEP_OWN_USERID, NULL);
   9.425      PEP_STATUS status = myself(session, from_ident);
   9.426      ASSERT_EQ(status , PEP_STATUS_OK);
   9.427 -    TEST_ASSERT_MSG(from_ident->fpr && strcasecmp(from_ident->fpr, alice_fpr) == 0,
   9.428 -                    from_ident->fpr);
   9.429 -    ASSERT_NE(from_ident->me, nullptr);
   9.430 +    ASSERT_NE(from_ident->fpr, nullptr);
   9.431 +    ASSERT_STRCASEEQ(from_ident->fpr, alice_fpr);
   9.432 +    ASSERT_TRUE(from_ident->me);
   9.433  
   9.434      // "send" some messages to update the social graph entries
   9.435      identity_list* send_idents =
   9.436 @@ -330,7 +328,7 @@
   9.437          ASSERT_NE(curr_sent_msg, nullptr);
   9.438          ASSERT_NE(curr_sent_msg->to, nullptr);
   9.439          ASSERT_NE(curr_sent_msg->to->ident, nullptr);
   9.440 -        ASSERT_NE(curr_sent_msg->to->next, nullptr);
   9.441 +        ASSERT_EQ(curr_sent_msg->to->next, nullptr);
   9.442          pEp_identity* to = curr_sent_msg->to->ident;
   9.443          ASSERT_NE(to, nullptr);
   9.444          ASSERT_NE(to->user_id, nullptr);
   9.445 @@ -387,13 +385,11 @@
   9.446      ASSERT_EQ(status , PEP_STATUS_OK);
   9.447      ASSERT_NE(keylist, nullptr);
   9.448      if (keylist) // there's a test option to continue when asserts fail, so...
   9.449 -        TEST_ASSERT_MSG(strcmp(keylist->value, alice_receive_reset_fpr) == 0,
   9.450 -                        keylist->value);
   9.451 +        ASSERT_STREQ(keylist->value,alice_receive_reset_fpr);
   9.452  
   9.453      status = update_identity(session, alice_ident);
   9.454      ASSERT_NE(alice_ident->fpr, nullptr);
   9.455 -    TEST_ASSERT_MSG(strcmp(alice_receive_reset_fpr, alice_ident->fpr) == 0,
   9.456 -                    alice_ident->fpr);
   9.457 +    ASSERT_STREQ(alice_receive_reset_fpr,alice_ident->fpr);
   9.458  
   9.459      keylist = NULL;
   9.460  
   9.461 @@ -458,8 +454,8 @@
   9.462      pEp_identity* from_ident = new_identity("pep.test.alice@pep-project.org", NULL, PEP_OWN_USERID, NULL);
   9.463      PEP_STATUS status = myself(session, from_ident);
   9.464      ASSERT_EQ(status , PEP_STATUS_OK);
   9.465 -    TEST_ASSERT_MSG(from_ident->fpr && strcasecmp(from_ident->fpr, alice_fpr) == 0,
   9.466 -                    from_ident->fpr);
   9.467 +    ASSERT_NE(from_ident->fpr, nullptr);
   9.468 +    ASSERT_STRCASEEQ(from_ident->fpr, alice_fpr);
   9.469      ASSERT_TRUE(from_ident->me);
   9.470  
   9.471      status = key_reset(session, alice_fpr, from_ident);
   9.472 @@ -568,8 +564,8 @@
   9.473      pEp_identity* from_ident = new_identity("pep.test.alice@pep-project.org", NULL, PEP_OWN_USERID, NULL);
   9.474      PEP_STATUS status = myself(session, from_ident);
   9.475      ASSERT_EQ(status , PEP_STATUS_OK);
   9.476 -    TEST_ASSERT_MSG(from_ident->fpr && strcasecmp(from_ident->fpr, alice_fpr) == 0,
   9.477 -                    from_ident->fpr);
   9.478 +    ASSERT_NE(from_ident->fpr, nullptr);
   9.479 +    ASSERT_STRCASEEQ(from_ident->fpr, alice_fpr);
   9.480      ASSERT_TRUE(from_ident->me);
   9.481  
   9.482      status = key_reset(session, NULL, NULL);
    10.1 --- a/test/src/KeyeditTest.cc	Tue Aug 27 11:04:53 2019 +0200
    10.2 +++ b/test/src/KeyeditTest.cc	Tue Aug 27 20:52:39 2019 +0200
    10.3 @@ -11,7 +11,7 @@
    10.4  #include "pEpEngine.h"
    10.5  #include "platform.h"
    10.6  
    10.7 -
    10.8 +#include "test_util.h"
    10.9  
   10.10  #include "Engine.h"
   10.11  
    11.1 --- a/test/src/LotsOfKeysTest.cc	Tue Aug 27 11:04:53 2019 +0200
    11.2 +++ b/test/src/LotsOfKeysTest.cc	Tue Aug 27 20:52:39 2019 +0200
    11.3 @@ -284,8 +284,7 @@
    11.4                  stringlist_t* keylist = NULL;
    11.5                  status = find_keys(session, ids[i]->address, &keylist);
    11.6                  free_stringlist(keylist);
    11.7 -                TEST_ASSERT_MSG(status == PEP_STATUS_OK,
    11.8 -                                tl_status_string(status));
    11.9 +                ASSERT_EQ(status, PEP_STATUS_OK);
   11.10                  ops ++;
   11.11                  elapsed = time() - start;
   11.12              } while (elapsed < TIME);
   11.13 @@ -312,11 +311,9 @@
   11.14                  pEp_identity *id = NULL;
   11.15                  status = get_identity(session, ids[i]->address,
   11.16                                        ids[i]->user_id, &id);
   11.17 -                TEST_ASSERT_MSG(status == PEP_STATUS_OK,
   11.18 -                                tl_status_string(status));
   11.19 +                ASSERT_EQ(status, PEP_STATUS_OK);
   11.20                  ASSERT_NE(id->fpr, nullptr);
   11.21 -                TEST_ASSERT_MSG(strcmp(ids[i]->fpr, id->fpr) == 0,
   11.22 -                                "fingerprint mismatch");
   11.23 +                ASSERT_STREQ(ids[i]->fpr, id->fpr);
   11.24                  free_identity(id);
   11.25  
   11.26                  ops ++;
    12.1 --- a/test/src/MapAsn1Test.cc	Tue Aug 27 11:04:53 2019 +0200
    12.2 +++ b/test/src/MapAsn1Test.cc	Tue Aug 27 20:52:39 2019 +0200
    12.3 @@ -10,7 +10,7 @@
    12.4  #include "pEpEngine.h"
    12.5  #include "map_asn1.h"
    12.6  
    12.7 -
    12.8 +#include "test_util.h"
    12.9  
   12.10  #include "Engine.h"
   12.11  
    13.1 --- a/test/src/MimeTest.cc	Tue Aug 27 11:04:53 2019 +0200
    13.2 +++ b/test/src/MimeTest.cc	Tue Aug 27 20:52:39 2019 +0200
    13.3 @@ -13,7 +13,7 @@
    13.4  #include "platform.h"
    13.5  #include "mime.h"
    13.6  
    13.7 -
    13.8 +#include "test_util.h"
    13.9  
   13.10  #include "Engine.h"
   13.11  
   13.12 @@ -148,7 +148,7 @@
   13.13      cout << "encoding message…\n";
   13.14      char *result2;
   13.15      PEP_STATUS status2 = mime_encode_message(msg2, false, &result2);
   13.16 -    ASSERT_NE(result, nullptr);
   13.17 +    ASSERT_NE(result2, nullptr);
   13.18      ASSERT_EQ(status2, PEP_STATUS_OK);
   13.19  
   13.20      cout << "result:\n";
    14.1 --- a/test/src/OwnIdentitiesRetrieveTest.cc	Tue Aug 27 11:04:53 2019 +0200
    14.2 +++ b/test/src/OwnIdentitiesRetrieveTest.cc	Tue Aug 27 20:52:39 2019 +0200
    14.3 @@ -7,7 +7,7 @@
    14.4  #include "pEpEngine.h"
    14.5  #include "keymanagement.h"
    14.6  
    14.7 -
    14.8 +#include "test_util.h"
    14.9  
   14.10  #include "Engine.h"
   14.11  
    15.1 --- a/test/src/OwnKeysRetrieveTest.cc	Tue Aug 27 11:04:53 2019 +0200
    15.2 +++ b/test/src/OwnKeysRetrieveTest.cc	Tue Aug 27 20:52:39 2019 +0200
    15.3 @@ -102,7 +102,7 @@
    15.4      ASSERT_EQ(status , PEP_STATUS_OK);
    15.5      ASSERT_NE(keylist, nullptr);
    15.6      ASSERT_NE(keylist->value, nullptr);
    15.7 -    ASSERT_NE(keylist->next, nullptr);
    15.8 +    ASSERT_EQ(keylist->next, nullptr);
    15.9  
   15.10      ASSERT_STREQ(keylist->value, "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97");
   15.11  }
   15.12 @@ -148,7 +148,7 @@
   15.13      ASSERT_EQ(status , PEP_STATUS_OK);
   15.14      ASSERT_NE(keylist, nullptr);
   15.15      ASSERT_NE(keylist->value, nullptr);
   15.16 -    ASSERT_NE(keylist->next, nullptr);
   15.17 +    ASSERT_EQ(keylist->next, nullptr);
   15.18  
   15.19      ASSERT_STREQ(keylist->value, "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97");
   15.20  }
   15.21 @@ -379,7 +379,7 @@
   15.22      }
   15.23      ASSERT_EQ(fpr_count , 5);
   15.24      for (int j = 0; j < 5; j++) {
   15.25 -        ASSERT_NE(found_list[j], nullptr);
   15.26 +        ASSERT_TRUE(found_list[j]);
   15.27      }
   15.28      free(found_list);
   15.29      free_stringlist(keylist);
   15.30 @@ -457,7 +457,7 @@
   15.31  
   15.32      status = _own_keys_retrieve(session, &keylist, 0, true);
   15.33      ASSERT_EQ(status , PEP_STATUS_OK);
   15.34 -    ASSERT_NE(keylist, nullptr);
   15.35 +    ASSERT_EQ(keylist, nullptr);
   15.36  
   15.37      free_stringlist(keylist);
   15.38  }
   15.39 @@ -520,7 +520,7 @@
   15.40  
   15.41      status = _own_keys_retrieve(session, &keylist, 0, true);
   15.42      ASSERT_EQ(status , PEP_STATUS_OK);
   15.43 -    ASSERT_NE(keylist, nullptr);
   15.44 +    ASSERT_EQ(keylist, nullptr);
   15.45  
   15.46      free_stringlist(keylist);
   15.47  }
   15.48 @@ -566,7 +566,7 @@
   15.49      ASSERT_EQ(status , PEP_STATUS_OK);
   15.50      ASSERT_NE(keylist, nullptr);
   15.51      ASSERT_NE(keylist->value, nullptr);
   15.52 -    ASSERT_NE(keylist->next, nullptr);
   15.53 +    ASSERT_EQ(keylist->next, nullptr);
   15.54  
   15.55      ASSERT_STREQ(keylist->value, "F4598A17D4690EB3B5B0F6A344F04E963B7302DB");
   15.56  
   15.57 @@ -666,7 +666,7 @@
   15.58      ASSERT_EQ(status , PEP_STATUS_OK);
   15.59      ASSERT_NE(keylist, nullptr);
   15.60      ASSERT_NE(keylist->value, nullptr);
   15.61 -    ASSERT_NE(keylist->next, nullptr);
   15.62 +    ASSERT_EQ(keylist->next, nullptr);
   15.63  
   15.64      ASSERT_STREQ(keylist->value, "F4598A17D4690EB3B5B0F6A344F04E963B7302DB");
   15.65  }
    16.1 --- a/test/src/PgpBinaryTest.cc	Tue Aug 27 11:04:53 2019 +0200
    16.2 +++ b/test/src/PgpBinaryTest.cc	Tue Aug 27 20:52:39 2019 +0200
    16.3 @@ -9,7 +9,7 @@
    16.4  #include "pEpEngine.h"
    16.5  #include "message_api.h"
    16.6  
    16.7 -
    16.8 +#include "test_util.h"
    16.9  
   16.10  #include "Engine.h"
   16.11  
    17.1 --- a/test/src/PgpListKeysTest.cc	Tue Aug 27 11:04:53 2019 +0200
    17.2 +++ b/test/src/PgpListKeysTest.cc	Tue Aug 27 20:52:39 2019 +0200
    17.3 @@ -11,7 +11,7 @@
    17.4  #include "stringpair.h"
    17.5  #include "openpgp_compat.h"
    17.6  
    17.7 -
    17.8 +#include "test_util.h"
    17.9  
   17.10  #include "Engine.h"
   17.11  
    18.1 --- a/test/src/SequenceTest.cc	Tue Aug 27 11:04:53 2019 +0200
    18.2 +++ b/test/src/SequenceTest.cc	Tue Aug 27 20:52:39 2019 +0200
    18.3 @@ -8,7 +8,7 @@
    18.4  #include <assert.h>
    18.5  #include "pEpEngine.h"
    18.6  
    18.7 -
    18.8 +#include "test_util.h"
    18.9  
   18.10  #include "Engine.h"
   18.11  
    19.1 --- a/test/src/StringlistTest.cc	Tue Aug 27 11:04:53 2019 +0200
    19.2 +++ b/test/src/StringlistTest.cc	Tue Aug 27 20:52:39 2019 +0200
    19.3 @@ -20,66 +20,7 @@
    19.4  namespace {
    19.5  
    19.6  	//The fixture for StringlistTest
    19.7 -    class StringlistTest : public ::testing::Test {
    19.8 -        public:
    19.9 -            Engine* engine;
   19.10 -            PEP_SESSION session;
   19.11 -
   19.12 -        protected:
   19.13 -            // You can remove any or all of the following functions if its body
   19.14 -            // is empty.
   19.15 -            StringlistTest() {
   19.16 -                // You can do set-up work for each test here.
   19.17 -                test_suite_name = ::testing::UnitTest::GetInstance()->current_test_info()->test_suite_name();
   19.18 -                test_name = ::testing::UnitTest::GetInstance()->current_test_info()->name();
   19.19 -                test_path = get_main_test_home_dir() + "/" + test_suite_name + "/" + test_name;
   19.20 -            }
   19.21 -
   19.22 -            ~StringlistTest() override {
   19.23 -                // You can do clean-up work that doesn't throw exceptions here.
   19.24 -            }
   19.25 -
   19.26 -            // If the constructor and destructor are not enough for setting up
   19.27 -            // and cleaning up each test, you can define the following methods:
   19.28 -
   19.29 -            void SetUp() override {
   19.30 -                // Code here will be called immediately after the constructor (right
   19.31 -                // before each test).
   19.32 -
   19.33 -                // Leave this empty if there are no files to copy to the home directory path
   19.34 -                std::vector<std::pair<std::string, std::string>> init_files = std::vector<std::pair<std::string, std::string>>();
   19.35 -
   19.36 -                // Get a new test Engine.
   19.37 -                engine = new Engine(test_path);
   19.38 -                ASSERT_NE(engine, nullptr);
   19.39 -
   19.40 -                // Ok, let's initialize test directories etc.
   19.41 -                engine->prep(NULL, NULL, init_files);
   19.42 -
   19.43 -                // Ok, try to start this bugger.
   19.44 -                engine->start();
   19.45 -                ASSERT_NE(engine->session, nullptr);
   19.46 -                session = engine->session;
   19.47 -
   19.48 -                // Engine is up. Keep on truckin'
   19.49 -            }
   19.50 -
   19.51 -            void TearDown() override {
   19.52 -                // Code here will be called immediately after each test (right
   19.53 -                // before the destructor).
   19.54 -                engine->shut_down();
   19.55 -                delete engine;
   19.56 -                engine = NULL;
   19.57 -                session = NULL;
   19.58 -            }
   19.59 -
   19.60 -        private:
   19.61 -            const char* test_suite_name;
   19.62 -            const char* test_name;
   19.63 -            string test_path;
   19.64 -            // Objects declared here can be used by all tests in the StringlistTest suite.
   19.65 -
   19.66 -    };
   19.67 +    class StringlistTest : public ::testing::Test {};
   19.68  
   19.69  }  // namespace
   19.70  
   19.71 @@ -96,7 +37,7 @@
   19.72      ASSERT_NE((src), nullptr);
   19.73      ASSERT_STREQ(src->value, str0);
   19.74      cout << "Value: " << src->value;
   19.75 -    ASSERT_EQ(src->next , NULL);
   19.76 +    ASSERT_EQ(src->next, nullptr);
   19.77      cout << "one-element stringlist created, next element is NULL\n";
   19.78  
   19.79      cout << "freeing stringlist…\n\n";
   19.80 @@ -127,7 +68,7 @@
   19.81          p = p->next;
   19.82          i++;
   19.83      }
   19.84 -    ASSERT_EQ(p , NULL); // list ends properly
   19.85 +    ASSERT_EQ(p, nullptr); // list ends properly
   19.86  
   19.87      cout << "\nduplicating four-element stringlist…\n";
   19.88      stringlist_t* dst = stringlist_dup(src);
   19.89 @@ -146,7 +87,7 @@
   19.90          p_dst = p_dst->next;
   19.91          ASSERT_TRUE((p == NULL) == (p_dst == NULL));
   19.92      }
   19.93 -    ASSERT_EQ(p_dst , NULL);
   19.94 +    ASSERT_EQ(p_dst, nullptr);
   19.95  
   19.96      cout << "freeing stringlists…\n\n";
   19.97      free_stringlist(src);
   19.98 @@ -160,7 +101,7 @@
   19.99      dst = stringlist_dup(src);
  19.100      ASSERT_STREQ(dst->value, str0);
  19.101      cout << "Value: " << src->value;
  19.102 -    ASSERT_EQ(dst->next , nullptr);
  19.103 +    ASSERT_EQ(dst->next, nullptr);
  19.104      cout << "one-element stringlist duped, next element is NULL\n";
  19.105  
  19.106      cout << "\nAdd to empty stringlist (node exists, but no value…)\n";
  19.107 @@ -201,14 +142,14 @@
  19.108      dedup_stringlist(s_list);
  19.109      ASSERT_NE(s_list->value, nullptr);
  19.110      ASSERT_STREQ(s_list->value, str1);
  19.111 -    ASSERT_NE(s_list->next, nullptr);
  19.112 +    ASSERT_EQ(s_list->next, nullptr);
  19.113  
  19.114      // Add same value
  19.115      stringlist_add(s_list, str1);
  19.116      dedup_stringlist(s_list);
  19.117      ASSERT_NE(s_list->value, nullptr);
  19.118      ASSERT_STREQ(s_list->value, str1);
  19.119 -    ASSERT_NE(s_list->next, nullptr);
  19.120 +    ASSERT_EQ(s_list->next, nullptr);
  19.121  
  19.122      stringlist_add(s_list, str1);
  19.123      stringlist_add(s_list, str2);
  19.124 @@ -216,7 +157,7 @@
  19.125      ASSERT_NE(s_list->value, nullptr);
  19.126      ASSERT_STREQ(s_list->value, str1);
  19.127      ASSERT_NE(s_list->next, nullptr);
  19.128 -    ASSERT_NE(s_list->next->next, nullptr);
  19.129 +    ASSERT_EQ(s_list->next->next, nullptr);
  19.130      ASSERT_NE(s_list->next->value, nullptr);
  19.131      ASSERT_STREQ(s_list->next->value, str2);
  19.132  
  19.133 @@ -241,7 +182,7 @@
  19.134      dedup_stringlist(s_list);
  19.135      ASSERT_NE(s_list->value, nullptr);
  19.136      ASSERT_STREQ(s_list->value, str1);
  19.137 -    ASSERT_NE(s_list->next, nullptr);
  19.138 +    ASSERT_EQ(s_list->next, nullptr);
  19.139  
  19.140      free_stringlist(s_list);
  19.141      s_list = new_stringlist(str1);
  19.142 @@ -265,7 +206,7 @@
  19.143      ASSERT_NE(s_list->value, nullptr);
  19.144      ASSERT_STREQ(s_list->value, str1);
  19.145      ASSERT_NE(s_list->next, nullptr);
  19.146 -    ASSERT_NE(s_list->next->next, nullptr);
  19.147 +    ASSERT_EQ(s_list->next->next, nullptr);
  19.148      ASSERT_NE(s_list->next->value, nullptr);
  19.149      ASSERT_STREQ(s_list->next->value, str2);
  19.150  
  19.151 @@ -285,7 +226,7 @@
  19.152      ASSERT_NE(s_list->next, nullptr);
  19.153      ASSERT_NE(s_list->next->next, nullptr);
  19.154      ASSERT_NE(s_list->next->next->next, nullptr);
  19.155 -    ASSERT_NE(s_list->next->next->next->next, nullptr);
  19.156 +    ASSERT_EQ(s_list->next->next->next->next, nullptr);
  19.157      ASSERT_NE(s_list->value, nullptr);
  19.158      ASSERT_STREQ(s_list->value, str3);
  19.159      ASSERT_NE(s_list->next->value, nullptr);
    20.1 --- a/test/src/StringpairListTest.cc	Tue Aug 27 11:04:53 2019 +0200
    20.2 +++ b/test/src/StringpairListTest.cc	Tue Aug 27 20:52:39 2019 +0200
    20.3 @@ -11,7 +11,7 @@
    20.4  
    20.5  #include "stringpair.h"
    20.6  
    20.7 -
    20.8 +#include "test_util.h"
    20.9  
   20.10  #include "Engine.h"
   20.11  
   20.12 @@ -22,57 +22,7 @@
   20.13  
   20.14  	//The fixture for StringpairListTest
   20.15      class StringpairListTest : public ::testing::Test {
   20.16 -        public:
   20.17 -            Engine* engine;
   20.18 -            PEP_SESSION session;
   20.19 -
   20.20          protected:
   20.21 -            // You can remove any or all of the following functions if its body
   20.22 -            // is empty.
   20.23 -            StringpairListTest() {
   20.24 -                // You can do set-up work for each test here.
   20.25 -                test_suite_name = ::testing::UnitTest::GetInstance()->current_test_info()->test_suite_name();
   20.26 -                test_name = ::testing::UnitTest::GetInstance()->current_test_info()->name();
   20.27 -                test_path = get_main_test_home_dir() + "/" + test_suite_name + "/" + test_name;
   20.28 -            }
   20.29 -
   20.30 -            ~StringpairListTest() override {
   20.31 -                // You can do clean-up work that doesn't throw exceptions here.
   20.32 -            }
   20.33 -
   20.34 -            // If the constructor and destructor are not enough for setting up
   20.35 -            // and cleaning up each test, you can define the following methods:
   20.36 -
   20.37 -            void SetUp() override {
   20.38 -                // Code here will be called immediately after the constructor (right
   20.39 -                // before each test).
   20.40 -
   20.41 -                // Leave this empty if there are no files to copy to the home directory path
   20.42 -                std::vector<std::pair<std::string, std::string>> init_files = std::vector<std::pair<std::string, std::string>>();
   20.43 -
   20.44 -                // Get a new test Engine.
   20.45 -                engine = new Engine(test_path);
   20.46 -                ASSERT_NE(engine, nullptr);
   20.47 -
   20.48 -                // Ok, let's initialize test directories etc.
   20.49 -                engine->prep(NULL, NULL, init_files);
   20.50 -
   20.51 -                // Ok, try to start this bugger.
   20.52 -                engine->start();
   20.53 -                ASSERT_NE(engine->session, nullptr);
   20.54 -                session = engine->session;
   20.55 -
   20.56 -                // Engine is up. Keep on truckin'
   20.57 -            }
   20.58 -
   20.59 -            void TearDown() override {
   20.60 -                // Code here will be called immediately after each test (right
   20.61 -                // before the destructor).
   20.62 -                engine->shut_down();
   20.63 -                delete engine;
   20.64 -                engine = NULL;
   20.65 -                session = NULL;
   20.66 -            }
   20.67              bool test_stringpair_equals(stringpair_t* val1, stringpair_t* val2) {
   20.68                  assert(val1);
   20.69                  assert(val2);
   20.70 @@ -82,13 +32,6 @@
   20.71                  assert(val2->value);
   20.72                  return((strcmp(val1->key, val2->key) == 0) && (strcmp(val1->value, val2->value) == 0));
   20.73              }
   20.74 -
   20.75 -        private:
   20.76 -            const char* test_suite_name;
   20.77 -            const char* test_name;
   20.78 -            string test_path;
   20.79 -            // Objects declared here can be used by all tests in the StringpairListTest suite.
   20.80 -
   20.81      };
   20.82  
   20.83  }  // namespace
   20.84 @@ -122,7 +65,7 @@
   20.85      stringpair_list_t* pairlist = new_stringpair_list(strpair);
   20.86      ASSERT_NE(pairlist->value, nullptr);
   20.87      ASSERT_TRUE(test_stringpair_equals(strpair, pairlist->value));
   20.88 -    ASSERT_EQ(pairlist->next , NULL);
   20.89 +    ASSERT_EQ(pairlist->next , nullptr);
   20.90      cout << "one-element stringpair_list created, next element is NULL\n\n";
   20.91  
   20.92      cout << "duplicating one-element list...\n";
   20.93 @@ -171,7 +114,7 @@
   20.94  
   20.95          p = p->next;
   20.96      }
   20.97 -    ASSERT_EQ(p , NULL);
   20.98 +    ASSERT_EQ(p , nullptr);
   20.99  
  20.100      cout << "\nduplicating four-element list...\n\n";
  20.101      duplist = stringpair_list_dup(pairlist);
    21.1 --- a/test/src/TrustManipulationTest.cc	Tue Aug 27 11:04:53 2019 +0200
    21.2 +++ b/test/src/TrustManipulationTest.cc	Tue Aug 27 20:52:39 2019 +0200
    21.3 @@ -164,7 +164,7 @@
    21.4      cout << "Hoorah, we now do not trust key 1. (TRUST NO ONE)" << endl;
    21.5      cout << "Now we call update_identity to see what gifts it gives us (should be an empty key and a key not found comm_type.)" << endl;
    21.6      status = update_identity(session, user);
    21.7 -    ASSERT_EQ(user->fpr , NULL);
    21.8 +    ASSERT_EQ(user->fpr , nullptr);
    21.9      ASSERT_EQ(user->comm_type , PEP_ct_key_not_found);
   21.10      cout << "Yup, we trust no keys from " << uniqname << endl;
   21.11  
    22.1 --- a/test/src/TrustwordsTest.cc	Tue Aug 27 11:04:53 2019 +0200
    22.2 +++ b/test/src/TrustwordsTest.cc	Tue Aug 27 20:52:39 2019 +0200
    22.3 @@ -7,7 +7,7 @@
    22.4  #include "pEpEngine.h"
    22.5  #include "message_api.h"
    22.6  
    22.7 -
    22.8 +#include "test_util.h"
    22.9  
   22.10  #include "Engine.h"
   22.11  
    23.1 --- a/test/src/UserIdCollisionTest.cc	Tue Aug 27 11:04:53 2019 +0200
    23.2 +++ b/test/src/UserIdCollisionTest.cc	Tue Aug 27 20:52:39 2019 +0200
    23.3 @@ -408,7 +408,7 @@
    23.4      ASSERT_EQ(real_alex_6a->comm_type , PEP_ct_pEp);
    23.5      bool pEp_peep = false;
    23.6      status = is_pEp_user(session, real_alex_6a, &pEp_peep);
    23.7 -    ASSERT_NE(pEp_peep, nullptr);
    23.8 +    ASSERT_TRUE(pEp_peep);
    23.9      free(real_alex_6a->fpr);
   23.10      real_alex_6a->fpr = strdup(alex6c_keyid);
   23.11      status = get_trust(session, real_alex_6a);
   23.12 @@ -450,7 +450,7 @@
   23.13      ASSERT_EQ(real_alex_6a->comm_type , PEP_ct_pEp);
   23.14      bool pEp_peep = false;
   23.15      status = is_pEp_user(session, real_alex_6a, &pEp_peep);
   23.16 -    ASSERT_NE(pEp_peep, nullptr);
   23.17 +    ASSERT_TRUE(pEp_peep);
   23.18      free(real_alex_6a->fpr);
   23.19      real_alex_6a->fpr = strdup(alex6c_keyid);
   23.20      status = get_trust(session, real_alex_6a);
    24.1 --- a/test/src/VerifyTest.cc	Tue Aug 27 11:04:53 2019 +0200
    24.2 +++ b/test/src/VerifyTest.cc	Tue Aug 27 20:52:39 2019 +0200
    24.3 @@ -18,12 +18,12 @@
    24.4  
    24.5  namespace {
    24.6  
    24.7 -	//The fixture for VerifyTest
    24.8 +	//The fixture for VerifyTest(keylist->next) != (nullptr)
    24.9      class VerifyTest : public ::testing::Test {
   24.10          public:
   24.11              Engine* engine;
   24.12              PEP_SESSION session;
   24.13 -
   24.14 +            const char *mary_fpr = "599B3D67800DB37E2DCE05C07F59F03CD04A226E";
   24.15          protected:
   24.16              // You can remove any or all of the following functions if its body
   24.17              // is empty.
   24.18 @@ -153,7 +153,7 @@
   24.19      ASSERT_NE(keylist, nullptr);
   24.20      // No signer.
   24.21      ASSERT_STREQ(keylist->value, "");
   24.22 -    ASSERT_NE( keylist->next, nullptr);
   24.23 +    ASSERT_EQ(keylist->next, nullptr);
   24.24  }
   24.25  
   24.26  TEST_F(VerifyTest, check_revoked_signing_key) {
   24.27 @@ -202,7 +202,7 @@
   24.28      ASSERT_NE(keylist, nullptr);
   24.29      // No signer.
   24.30      ASSERT_STREQ(keylist->value, "");
   24.31 -    ASSERT_NE( keylist->next, nullptr);
   24.32 +    ASSERT_EQ(keylist->next, nullptr);
   24.33  }
   24.34  
   24.35  TEST_F(VerifyTest, check_expired_tpk) {
   24.36 @@ -251,7 +251,7 @@
   24.37      ASSERT_NE(keylist, nullptr);
   24.38      // No signer.
   24.39      ASSERT_STREQ(keylist->value, "");
   24.40 -    ASSERT_NE( keylist->next, nullptr);
   24.41 +    ASSERT_EQ(keylist->next, nullptr);
   24.42  }
   24.43  
   24.44  TEST_F(VerifyTest, check_expired_signing_key) {
   24.45 @@ -300,5 +300,5 @@
   24.46      ASSERT_NE(keylist, nullptr);
   24.47      // No signer.
   24.48      ASSERT_STREQ(keylist->value, "");
   24.49 -    ASSERT_NE( keylist->next, nullptr);
   24.50 +    ASSERT_EQ(keylist->next, nullptr);
   24.51  }