ENGINE-432: tests
authorKrista Bennett <krista@pep-project.org>
Tue, 28 Aug 2018 16:52:03 +0200
changeset 2896aa0ffbb0c37e
parent 2895 fcc598cc5e2f
child 2897 59e0e6ed0534
ENGINE-432: tests
test/include/MessageNullFromTests.h
test/src/engine_tests/MessageNullFromTests.cc
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/test/include/MessageNullFromTests.h	Tue Aug 28 16:52:03 2018 +0200
     1.3 @@ -0,0 +1,19 @@
     1.4 +// This file is under GNU General Public License 3.0
     1.5 +// see LICENSE.txt
     1.6 +
     1.7 +#ifndef MESSAGE_NULL_FROM_H
     1.8 +#define MESSAGE_NULL_FROM_H
     1.9 +
    1.10 +#include <string>
    1.11 +#include "EngineTestIndividualSuite.h"
    1.12 +
    1.13 +using namespace std;
    1.14 +
    1.15 +class MessageNullFromTests : public EngineTestIndividualSuite {
    1.16 +    public:
    1.17 +        MessageNullFromTests(string test_suite, string test_home_dir);
    1.18 +    private:
    1.19 +        void check_message_null_from_no_header_key_unencrypted();
    1.20 +};
    1.21 +
    1.22 +#endif
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/test/src/engine_tests/MessageNullFromTests.cc	Tue Aug 28 16:52:03 2018 +0200
     2.3 @@ -0,0 +1,38 @@
     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 <string>
     2.9 +
    2.10 +#include "pEpEngine.h"
    2.11 +#include "test_util.h"
    2.12 +
    2.13 +#include "EngineTestIndividualSuite.h"
    2.14 +#include "MessageNullFromTests.h"
    2.15 +
    2.16 +using namespace std;
    2.17 +
    2.18 +MessageNullFromTests::MessageNullFromTests(string suitename, string test_home_dir) :
    2.19 +    EngineTestIndividualSuite::EngineTestIndividualSuite(suitename, test_home_dir) {
    2.20 +    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("MessageNullFromTests::check_message_null_from_no_header_key_unencrypted"),
    2.21 +                                                                      static_cast<Func>(&MessageNullFromTests::check_message_null_from_no_header_key_unencrypted)));
    2.22 +}
    2.23 +
    2.24 +void MessageNullFromTests::check_message_null_from_no_header_key_unencrypted() {
    2.25 +    string null_from_msg = slurp("test_files/432_no_from_2.eml");
    2.26 +    cout << null_from_msg << endl;
    2.27 +    stringlist_t* keylist = NULL;
    2.28 +    PEP_decrypt_flags_t flags;
    2.29 +    PEP_rating rating;
    2.30 +    char* mime_plaintext = NULL;
    2.31 +    char* modified_src = NULL;
    2.32 +    PEP_STATUS status = MIME_decrypt_message(session, null_from_msg.c_str(),
    2.33 +                                             null_from_msg.size(),
    2.34 +                                             &mime_plaintext,
    2.35 +                                             &keylist,
    2.36 +                                             &rating,
    2.37 +                                             &flags,
    2.38 +                                             &modified_src);
    2.39 +    TEST_ASSERT_MSG(status == PEP_UNENCRYPTED, tl_status_string(status));                                         
    2.40 +}
    2.41 +