Browse Source

ENGINE-935: added test (EncryptSignDirectLoopTest) which can be #if'd in to the test suite to check mem leaks on encrypt_and_sign

master
Krista Bennett 4 months ago
parent
commit
628d66710a
2 changed files with 183 additions and 0 deletions
  1. +101
    -0
      test/src/EncryptSignDirectLoopTest.cc
  2. +82
    -0
      test/test_files/just_the_mimetext_maam.txt

+ 101
- 0
test/src/EncryptSignDirectLoopTest.cc View File

@ -0,0 +1,101 @@
#include <stdlib.h>
#include <string>
#include <cstring>
#include "pEpEngine.h"
#include "test_util.h"
#include "TestConstants.h"
#include "Engine.h"
#include "pgp_sequoia.h"
#include <gtest/gtest.h>
#if 0
namespace {
//The fixture for EncryptSignDirectLoopTest
class EncryptSignDirectLoopTest : public ::testing::Test {
public:
Engine* engine;
PEP_SESSION session;
protected:
// You can remove any or all of the following functions if its body
// is empty.
EncryptSignDirectLoopTest() {
// You can do set-up work for each test here.
test_suite_name = ::testing::UnitTest::GetInstance()->current_test_info()->GTEST_SUITE_SYM();
test_name = ::testing::UnitTest::GetInstance()->current_test_info()->name();
test_path = get_main_test_home_dir() + "/" + test_suite_name + "/" + test_name;
}
~EncryptSignDirectLoopTest() override {
// You can do clean-up work that doesn't throw exceptions here.
}
// If the constructor and destructor are not enough for setting up
// and cleaning up each test, you can define the following methods:
void SetUp() override {
// Code here will be called immediately after the constructor (right
// before each test).
// Leave this empty if there are no files to copy to the home directory path
std::vector<std::pair<std::string, std::string>> init_files = std::vector<std::pair<std::string, std::string>>();
// Get a new test Engine.
engine = new Engine(test_path);
ASSERT_NE(engine, nullptr);
// Ok, let's initialize test directories etc.
engine->prep(NULL, NULL, NULL, init_files);
// Ok, try to start this bugger.
engine->start();
ASSERT_NE(engine->session, nullptr);
session = engine->session;
// Engine is up. Keep on truckin'
}
void TearDown() override {
// Code here will be called immediately after each test (right
// before the destructor).
engine->shut_down();
delete engine;
engine = NULL;
session = NULL;
}
private:
const char* test_suite_name;
const char* test_name;
string test_path;
// Objects declared here can be used by all tests in the EncryptSignDirectLoopTest suite.
};
} // namespace
TEST_F(EncryptSignDirectLoopTest, check_encrypt_sign_optional_loop) {
ASSERT_TRUE(slurp_and_import_key(session, "test_keys/pub/pep-test-alice-0x6FF00E97_pub.asc"));
ASSERT_TRUE(slurp_and_import_key(session, "test_keys/priv/pep-test-alice-0x6FF00E97_priv.asc"));
ASSERT_TRUE(slurp_and_import_key(session, "test_keys/pub/pep-test-carol-0x42A85A42_pub.asc"));
string plaintext = slurp("test_files/just_the_mimetext_maam.txt");
const char* ptext = plaintext.c_str();
size_t psize = plaintext.size();
stringlist_t* keylist = new_stringlist("4ABE3AAF59AC32CFE4F86500A9411D176FF00E97");
stringlist_add(keylist, "8DD4F5827B45839E9ACCA94687BDDFFB42A85A42");
for (int i = 0; i < 1000; i++) {
char* ctext = NULL;
size_t csize = 0;
PEP_STATUS status = encrypt_and_sign(session, keylist, ptext, psize, &ctext, &csize);
ASSERT_OK;
if (i % 10 == 0)
cout << i << endl;
free(ctext);
}
}
#endif

+ 82
- 0
test/test_files/just_the_mimetext_maam.txt View File

@ -0,0 +1,82 @@
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="6f47e8af358911342c968a5c60624f4b"
--6f47e8af358911342c968a5c60624f4b
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
This message was encrypted with p=E2=89=A1p (https://pep.software). If yo=
u are seeing this message,
your client does not support raising message attachments. Please click on=
the message attachment
to view it, or better yet, consider using p=E2=89=A1p=21
--6f47e8af358911342c968a5c60624f4b
Content-Type: message/rfc822; forwarded="no"
Message-ID: <pEp.QVEC7D.0DNYNIXZV0OD0.493CE2D4-E460-4581-9CCC-B291417B03F8@pep-project.org>
From: Alice Spivak Hyatt <pep.test.alice@pep-project.org>
To: Carol Burnett <pep-test-carol@pep-project.org>
Subject: Boom shaka laka
X-pEp-Version: 2.1
X-pEp-Wrapped-Message-Info: INNER
X-pEp-Sender-FPR: 4ABE3AAF59AC32CFE4F86500A9411D176FF00E97
MIME-Version: 1.0
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
Don't you get sick of these?
--6f47e8af358911342c968a5c60624f4b
Content-Type: application/pgp-keys
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="sender_key.asc"
LS0tLS1CRUdJTiBQR1AgUFVCTElDIEtFWSBCTE9DSy0tLS0tCgp4c0JOQkZWNFBiRUJDQURUbWpH
RHNvdGkvVlBvWjN3Mm9DakxCTnExaldJR01rYmlVZ0NHVVFqVnNOclNaODBVCjdSbUEzUGN1M2ho
aVZRTkJHQTMydkw2TlBoU0pQYW5WZDc3czZYVlpnK0dxN2xsYkdHa3VJeFNrSnZWcld6WWMKa2pN
c0FJbmxKOExsMGtISGJnQVRPbE81T3RRMjFiTENmV1pQU3E3NEhFVnpRQVB0Q0dZRnZPZ3BDa3RL
VGptcwpHWGU5eXNpWU44Q0VXTVZOYkRxWG12RmhpNFVpZnBJVGVRQlZNN2R0bEJ3NVNvZUxacHNI
SWxLRjVpNVdQa053CjdudU1hZy8rbFJwT3F2UHVtaE9tcXliV0h1QVIvRHEwcE9PUGg2QnpaNE96
T0JMOTZhV1VlMWRjbklaZUJFbTgKb1J4WUMzbk45NVlzanRyTEs0QlFaVFlEVHplaDhGSWNjc0xk
QUJFQkFBSE5SSEJGY0NCVVpYTjBJRUZzYVdObApJQ2gwWlhOMElHdGxlU0JrYjI0bmRDQjFjMlVw
SUR4d1pYQXVkR1Z6ZEM1aGJHbGpaVUJ3WlhBdGNISnZhbVZqCmRDNXZjbWMrd3NDUEJCTUJDQUFp
QWhzREJnc0pDQWNEQWdZVkNBSUpDZ3NFRmdJREFRSWVBUUlYZ0FVQ1dWOWkKSXdBaENSQ3BRUjBY
Yi9BT2x4WWhCRXErT3E5WnJETFA1UGhsQUtsQkhSZHY4QTZYaWhvSUFKbXNzL0p6K1VZYwowbnhO
UGNyRWlXejlLenJhZGFyakFIdDI2dHI0aFE5V29zdzE1OGxxWkNvYmdGSVlOSDVhRUxvdTUvZ3Jr
bUJxCjV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