status check fix and ENGINE-762 possible fix (import_key WAL checkpoint removal - it doesn't need to be there explicitly and causes issues)
authorKrista 'DarthMama' Bennett <krista@pep.foundation>
Fri, 19 Jun 2020 14:55:47 +0200
changeset 4752d86aedba2d52
parent 4746 74d6fb83a391
child 4753 76930ab28dd8
child 4757 f5f8da7627e9
status check fix and ENGINE-762 possible fix (import_key WAL checkpoint removal - it doesn't need to be there explicitly and causes issues)
src/pgp_sequoia.c
test/src/IOS1664Test.cc
     1.1 --- a/src/pgp_sequoia.c	Wed Jun 17 12:46:06 2020 +0200
     1.2 +++ b/src/pgp_sequoia.c	Fri Jun 19 14:55:47 2020 +0200
     1.3 @@ -1701,9 +1701,9 @@
     1.4          if (! verifier)
     1.5              ERROR_OUT(err, PEP_UNKNOWN_ERROR, "Creating verifier");
     1.6  
     1.7 -        pgp_status_t status = pgp_detached_verifier_verify (&err, verifier, reader);
     1.8 +        pgp_status_t pgp_status = pgp_detached_verifier_verify (&err, verifier, reader);
     1.9          pgp_detached_verifier_free (verifier);
    1.10 -        if (status)
    1.11 +        if (pgp_status)
    1.12              ERROR_OUT(err, PEP_UNKNOWN_ERROR, "Verifying data");
    1.13      } else {
    1.14          pgp_reader_t verifier = NULL;
    1.15 @@ -1715,9 +1715,9 @@
    1.16          if (! verifier)
    1.17              ERROR_OUT(err, PEP_UNKNOWN_ERROR, "Creating verifier");
    1.18  
    1.19 -        pgp_status_t status = pgp_reader_discard(&err, verifier);
    1.20 +        pgp_status_t pgp_status = pgp_reader_discard(&err, verifier);
    1.21          pgp_reader_free(verifier);
    1.22 -        if (status)
    1.23 +        if (pgp_status)
    1.24              ERROR_OUT(err, PEP_UNKNOWN_ERROR, "verifier");
    1.25      }
    1.26  
    1.27 @@ -2482,17 +2482,6 @@
    1.28          break;
    1.29      }
    1.30  
    1.31 -    int int_result = sqlite3_exec(
    1.32 -        session->key_db,
    1.33 -        "PRAGMA wal_checkpoint(FULL);\n"
    1.34 -        ,
    1.35 -        NULL,
    1.36 -        NULL,
    1.37 -        NULL
    1.38 -    );
    1.39 -    if (int_result != SQLITE_OK)
    1.40 -        status = PEP_UNKNOWN_DB_ERROR;
    1.41 -
    1.42   out:
    1.43      pgp_cert_parser_free(parser);
    1.44  
     2.1 --- a/test/src/IOS1664Test.cc	Wed Jun 17 12:46:06 2020 +0200
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,135 +0,0 @@
     2.4 -// This file is under GNU General Public License 3.0
     2.5 -// see LICENSE.txt
     2.6 -
     2.7 -#include <stdlib.h>
     2.8 -#include <cstring>
     2.9 -#include <string>
    2.10 -
    2.11 -#include "test_util.h"
    2.12 -#include "TestConstants.h"
    2.13 -
    2.14 -#include "pEpEngine.h"
    2.15 -
    2.16 -#include "mime.h"
    2.17 -
    2.18 -
    2.19 -#include "Engine.h"
    2.20 -
    2.21 -#include <gtest/gtest.h>
    2.22 -
    2.23 -
    2.24 -namespace {
    2.25 -
    2.26 -	//The fixture for IOS1664Test
    2.27 -    class IOS1664Test : public ::testing::Test {
    2.28 -        public:
    2.29 -            Engine* engine;
    2.30 -            PEP_SESSION session;
    2.31 -
    2.32 -        protected:
    2.33 -            // You can remove any or all of the following functions if its body
    2.34 -            // is empty.
    2.35 -            IOS1664Test() {
    2.36 -                // You can do set-up work for each test here.
    2.37 -                test_suite_name = ::testing::UnitTest::GetInstance()->current_test_info()->GTEST_SUITE_SYM();
    2.38 -                test_name = ::testing::UnitTest::GetInstance()->current_test_info()->name();
    2.39 -                test_path = get_main_test_home_dir() + "/" + test_suite_name + "/" + test_name;
    2.40 -            }
    2.41 -
    2.42 -            ~IOS1664Test() override {
    2.43 -                // You can do clean-up work that doesn't throw exceptions here.
    2.44 -            }
    2.45 -
    2.46 -            // If the constructor and destructor are not enough for setting up
    2.47 -            // and cleaning up each test, you can define the following methods:
    2.48 -
    2.49 -            void SetUp() override {
    2.50 -                // Code here will be called immediately after the constructor (right
    2.51 -                // before each test).
    2.52 -
    2.53 -                // Leave this empty if there are no files to copy to the home directory path
    2.54 -                std::vector<std::pair<std::string, std::string>> init_files = std::vector<std::pair<std::string, std::string>>();
    2.55 -
    2.56 -                // Get a new test Engine.
    2.57 -                engine = new Engine(test_path);
    2.58 -                ASSERT_NE(engine, nullptr);
    2.59 -
    2.60 -                // Ok, let's initialize test directories etc.
    2.61 -                engine->prep(NULL, NULL, init_files);
    2.62 -
    2.63 -                // Ok, try to start this bugger.
    2.64 -                engine->start();
    2.65 -                ASSERT_NE(engine->session, nullptr);
    2.66 -                session = engine->session;
    2.67 -
    2.68 -                // Engine is up. Keep on truckin'
    2.69 -            }
    2.70 -
    2.71 -            void TearDown() override {
    2.72 -                // Code here will be called immediately after each test (right
    2.73 -                // before the destructor).
    2.74 -                engine->shut_down();
    2.75 -                delete engine;
    2.76 -                engine = NULL;
    2.77 -                session = NULL;
    2.78 -            }
    2.79 -
    2.80 -        private:
    2.81 -            const char* test_suite_name;
    2.82 -            const char* test_name;
    2.83 -            string test_path;
    2.84 -            // Objects declared here can be used by all tests in the IOS1664Test suite.
    2.85 -
    2.86 -    };
    2.87 -
    2.88 -}  // namespace
    2.89 -
    2.90 -
    2.91 -TEST_F(IOS1664Test, check_i_o_s1664) {
    2.92 -    string email = slurp("test_mails/0.47.eml");
    2.93 -    ASSERT_FALSE(email.empty());
    2.94 -
    2.95 -    message* message_mail = NULL;
    2.96 -    bool raise_att;
    2.97 -
    2.98 -    PEP_STATUS status = mime_decode_message(email.c_str(), email.size(), &message_mail, &raise_att);
    2.99 -    ASSERT_EQ(status , PEP_STATUS_OK && message_mail);
   2.100 -
   2.101 -    // create own identity here, because we want to reply, before we start.
   2.102 -    pEp_identity* me = new_identity("android01@peptest.ch", NULL, PEP_OWN_USERID, NULL);
   2.103 -    status = myself(session, me);
   2.104 -
   2.105 -    ASSERT_EQ(status , PEP_STATUS_OK && me->fpr != NULL && me->fpr[0] != '\0');
   2.106 -
   2.107 -    // Ok, now read the message
   2.108 -    message* read_message = NULL;
   2.109 -    stringlist_t* keylist;
   2.110 -    PEP_rating rating;
   2.111 -    PEP_decrypt_flags_t flags = 0;
   2.112 -
   2.113 -    status = decrypt_message(session, message_mail, &read_message, &keylist, &rating, &flags);
   2.114 -    ASSERT_EQ(status , PEP_UNENCRYPTED);
   2.115 -
   2.116 -    pEp_identity* you = new_identity("superxat@gmail.com", NULL, NULL, NULL);
   2.117 -
   2.118 -    // N.B. while obviously it would be better to write the test expecting us to
   2.119 -    // accept the key, I'm actually testing that we don't get the wrong status
   2.120 -    // based on the presumption of rejection
   2.121 -
   2.122 -    message* out_msg = new_message(PEP_dir_outgoing);
   2.123 -    out_msg->from = me;
   2.124 -    out_msg->to = new_identity_list(you);
   2.125 -    out_msg->shortmsg = strdup("Hussidente 2020!");
   2.126 -    out_msg->longmsg = strdup("A Huss in every office!");
   2.127 -
   2.128 -    status = identity_rating(session, out_msg->from, &rating);
   2.129 -    ASSERT_EQ(status , PEP_STATUS_OK);
   2.130 -    ASSERT_EQ(rating , PEP_rating_trusted_and_anonymized);
   2.131 -    status = identity_rating(session, out_msg->to->ident, &rating);
   2.132 -    ASSERT_EQ(status , PEP_STATUS_OK);
   2.133 -    ASSERT_EQ(rating , PEP_rating_reliable);
   2.134 -
   2.135 -    status = outgoing_message_rating(session, out_msg, &rating);
   2.136 -    ASSERT_EQ(rating , PEP_rating_reliable);
   2.137 -
   2.138 -}