SignOnlyTest base sync
authorKrista Bennett <krista@pep-project.org>
Tue, 20 Nov 2018 15:36:06 +0100
branchsync
changeset 3141c931141752fe
parent 3140 00a9ab97c594
child 3142 a095aa1286eb
SignOnlyTest base
test/include/SignOnlyTests.h
test/src/engine_tests/SignOnlyTests.cc
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/test/include/SignOnlyTests.h	Tue Nov 20 15:36:06 2018 +0100
     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 SIGN_ONLY_H
     1.8 +#define SIGN_ONLY_H
     1.9 +
    1.10 +#include <string>
    1.11 +#include "EngineTestIndividualSuite.h"
    1.12 +
    1.13 +using namespace std;
    1.14 +
    1.15 +class SignOnlyTests : public EngineTestIndividualSuite {
    1.16 +    public:
    1.17 +        SignOnlyTests(string test_suite, string test_home_dir);
    1.18 +    private:
    1.19 +        void check_sign_only();
    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/SignOnlyTests.cc	Tue Nov 20 15:36:06 2018 +0100
     2.3 @@ -0,0 +1,35 @@
     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 +#include <cpptest.h>
    2.10 +
    2.11 +#include "pEpEngine.h"
    2.12 +
    2.13 +#include "test_util.h"
    2.14 +#include "EngineTestIndividualSuite.h"
    2.15 +#include "SignOnlyTests.h"
    2.16 +
    2.17 +using namespace std;
    2.18 +
    2.19 +SignOnlyTests::SignOnlyTests(string suitename, string test_home_dir) :
    2.20 +    EngineTestIndividualSuite::EngineTestIndividualSuite(suitename, test_home_dir) {
    2.21 +    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("SignOnlyTests::check_sign_only"),
    2.22 +                                                                      static_cast<Func>(&SignOnlyTests::check_sign_only)));
    2.23 +}
    2.24 +
    2.25 +void SignOnlyTests::check_sign_only() {
    2.26 +    slurp_and_import_key(session, "test_keys/pub/pep-test-alice-0x6FF00E97_pub.asc");
    2.27 +    slurp_and_import_key(session, "test_keys/priv/pep-test-alice-0x6FF00E97_priv.asc");    
    2.28 +    const char* alice_fpr = "4ABE3AAF59AC32CFE4F86500A9411D176FF00E97";
    2.29 +    string msg_text = "Grrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr! I mean, yo. Greetings to Meesti.\n - Alice";
    2.30 +    char* signed_text = NULL;
    2.31 +    size_t signed_text_size = 0;
    2.32 +    
    2.33 +    PEP_STATUS status = sign_only(session, msg_text.c_str(), msg_text.size(), alice_fpr, &signed_text, &signed_text_size);
    2.34 +    TEST_ASSERT(status == PEP_STATUS_OK);
    2.35 +    cout << signed_text << endl;
    2.36 +        
    2.37 +    TEST_ASSERT(true);
    2.38 +}