test/src/IOS1664Test.cc
changeset 4752 d86aedba2d52
parent 4746 74d6fb83a391
child 4753 76930ab28dd8
child 4757 f5f8da7627e9
     1.1 --- a/test/src/IOS1664Test.cc	Wed Jun 17 12:46:06 2020 +0200
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,135 +0,0 @@
     1.4 -// This file is under GNU General Public License 3.0
     1.5 -// see LICENSE.txt
     1.6 -
     1.7 -#include <stdlib.h>
     1.8 -#include <cstring>
     1.9 -#include <string>
    1.10 -
    1.11 -#include "test_util.h"
    1.12 -#include "TestConstants.h"
    1.13 -
    1.14 -#include "pEpEngine.h"
    1.15 -
    1.16 -#include "mime.h"
    1.17 -
    1.18 -
    1.19 -#include "Engine.h"
    1.20 -
    1.21 -#include <gtest/gtest.h>
    1.22 -
    1.23 -
    1.24 -namespace {
    1.25 -
    1.26 -	//The fixture for IOS1664Test
    1.27 -    class IOS1664Test : public ::testing::Test {
    1.28 -        public:
    1.29 -            Engine* engine;
    1.30 -            PEP_SESSION session;
    1.31 -
    1.32 -        protected:
    1.33 -            // You can remove any or all of the following functions if its body
    1.34 -            // is empty.
    1.35 -            IOS1664Test() {
    1.36 -                // You can do set-up work for each test here.
    1.37 -                test_suite_name = ::testing::UnitTest::GetInstance()->current_test_info()->GTEST_SUITE_SYM();
    1.38 -                test_name = ::testing::UnitTest::GetInstance()->current_test_info()->name();
    1.39 -                test_path = get_main_test_home_dir() + "/" + test_suite_name + "/" + test_name;
    1.40 -            }
    1.41 -
    1.42 -            ~IOS1664Test() override {
    1.43 -                // You can do clean-up work that doesn't throw exceptions here.
    1.44 -            }
    1.45 -
    1.46 -            // If the constructor and destructor are not enough for setting up
    1.47 -            // and cleaning up each test, you can define the following methods:
    1.48 -
    1.49 -            void SetUp() override {
    1.50 -                // Code here will be called immediately after the constructor (right
    1.51 -                // before each test).
    1.52 -
    1.53 -                // Leave this empty if there are no files to copy to the home directory path
    1.54 -                std::vector<std::pair<std::string, std::string>> init_files = std::vector<std::pair<std::string, std::string>>();
    1.55 -
    1.56 -                // Get a new test Engine.
    1.57 -                engine = new Engine(test_path);
    1.58 -                ASSERT_NE(engine, nullptr);
    1.59 -
    1.60 -                // Ok, let's initialize test directories etc.
    1.61 -                engine->prep(NULL, NULL, init_files);
    1.62 -
    1.63 -                // Ok, try to start this bugger.
    1.64 -                engine->start();
    1.65 -                ASSERT_NE(engine->session, nullptr);
    1.66 -                session = engine->session;
    1.67 -
    1.68 -                // Engine is up. Keep on truckin'
    1.69 -            }
    1.70 -
    1.71 -            void TearDown() override {
    1.72 -                // Code here will be called immediately after each test (right
    1.73 -                // before the destructor).
    1.74 -                engine->shut_down();
    1.75 -                delete engine;
    1.76 -                engine = NULL;
    1.77 -                session = NULL;
    1.78 -            }
    1.79 -
    1.80 -        private:
    1.81 -            const char* test_suite_name;
    1.82 -            const char* test_name;
    1.83 -            string test_path;
    1.84 -            // Objects declared here can be used by all tests in the IOS1664Test suite.
    1.85 -
    1.86 -    };
    1.87 -
    1.88 -}  // namespace
    1.89 -
    1.90 -
    1.91 -TEST_F(IOS1664Test, check_i_o_s1664) {
    1.92 -    string email = slurp("test_mails/0.47.eml");
    1.93 -    ASSERT_FALSE(email.empty());
    1.94 -
    1.95 -    message* message_mail = NULL;
    1.96 -    bool raise_att;
    1.97 -
    1.98 -    PEP_STATUS status = mime_decode_message(email.c_str(), email.size(), &message_mail, &raise_att);
    1.99 -    ASSERT_EQ(status , PEP_STATUS_OK && message_mail);
   1.100 -
   1.101 -    // create own identity here, because we want to reply, before we start.
   1.102 -    pEp_identity* me = new_identity("android01@peptest.ch", NULL, PEP_OWN_USERID, NULL);
   1.103 -    status = myself(session, me);
   1.104 -
   1.105 -    ASSERT_EQ(status , PEP_STATUS_OK && me->fpr != NULL && me->fpr[0] != '\0');
   1.106 -
   1.107 -    // Ok, now read the message
   1.108 -    message* read_message = NULL;
   1.109 -    stringlist_t* keylist;
   1.110 -    PEP_rating rating;
   1.111 -    PEP_decrypt_flags_t flags = 0;
   1.112 -
   1.113 -    status = decrypt_message(session, message_mail, &read_message, &keylist, &rating, &flags);
   1.114 -    ASSERT_EQ(status , PEP_UNENCRYPTED);
   1.115 -
   1.116 -    pEp_identity* you = new_identity("superxat@gmail.com", NULL, NULL, NULL);
   1.117 -
   1.118 -    // N.B. while obviously it would be better to write the test expecting us to
   1.119 -    // accept the key, I'm actually testing that we don't get the wrong status
   1.120 -    // based on the presumption of rejection
   1.121 -
   1.122 -    message* out_msg = new_message(PEP_dir_outgoing);
   1.123 -    out_msg->from = me;
   1.124 -    out_msg->to = new_identity_list(you);
   1.125 -    out_msg->shortmsg = strdup("Hussidente 2020!");
   1.126 -    out_msg->longmsg = strdup("A Huss in every office!");
   1.127 -
   1.128 -    status = identity_rating(session, out_msg->from, &rating);
   1.129 -    ASSERT_EQ(status , PEP_STATUS_OK);
   1.130 -    ASSERT_EQ(rating , PEP_rating_trusted_and_anonymized);
   1.131 -    status = identity_rating(session, out_msg->to->ident, &rating);
   1.132 -    ASSERT_EQ(status , PEP_STATUS_OK);
   1.133 -    ASSERT_EQ(rating , PEP_rating_reliable);
   1.134 -
   1.135 -    status = outgoing_message_rating(session, out_msg, &rating);
   1.136 -    ASSERT_EQ(rating , PEP_rating_reliable);
   1.137 -
   1.138 -}