test/src/engine_tests/OwnIdentitiesRetrieveTests.cc
author Krista 'DarthMama' Bennett <krista@pep.foundation>
Tue, 26 Mar 2019 19:14:46 +0100
branchsync
changeset 3400 127abd38d1c2
permissions -rw-r--r--
Argh, cut-and-paste error broke all the things.
krista@3400
     1
// This file is under GNU General Public License 3.0
krista@3400
     2
// see LICENSE.txt
krista@3400
     3
krista@3400
     4
#include <stdlib.h>
krista@3400
     5
#include <string>
krista@3400
     6
krista@3400
     7
#include "pEpEngine.h"
krista@3400
     8
#include "keymanagement.h"
krista@3400
     9
krista@3400
    10
#include <cpptest.h>
krista@3400
    11
#include "EngineTestIndividualSuite.h"
krista@3400
    12
#include "OwnIdentitiesRetrieveTests.h"
krista@3400
    13
krista@3400
    14
using namespace std;
krista@3400
    15
krista@3400
    16
OwnIdentitiesRetrieveTests::OwnIdentitiesRetrieveTests(string suitename, string test_home_dir) :
krista@3400
    17
    EngineTestIndividualSuite::EngineTestIndividualSuite(suitename, test_home_dir) {
krista@3400
    18
    add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("OwnIdentitiesRetrieveTests::check_own_identities_retrieve"),
krista@3400
    19
                                                                      static_cast<Func>(&OwnIdentitiesRetrieveTests::check_own_identities_retrieve)));
krista@3400
    20
}
krista@3400
    21
krista@3400
    22
void OwnIdentitiesRetrieveTests::check_own_identities_retrieve() {
krista@3400
    23
    stringlist_t* keylist = NULL;
krista@3400
    24
    PEP_STATUS status = own_keys_retrieve(session, &keylist);
krista@3400
    25
    TEST_ASSERT(keylist == NULL);
krista@3400
    26
    TEST_ASSERT(status == PEP_STATUS_OK);
krista@3400
    27
krista@3400
    28
    identity_list* id_list = NULL;
krista@3400
    29
    status = own_identities_retrieve(session, &id_list);
krista@3400
    30
    TEST_ASSERT(id_list == NULL || !(id_list->ident));
krista@3400
    31
    TEST_ASSERT(status == PEP_STATUS_OK);
krista@3400
    32
    
krista@3400
    33
    pEp_identity* me = new_identity("krista_b@darthmama.cool", NULL, "MyOwnId", "Krista B.");
krista@3400
    34
    status = myself(session, me);
krista@3400
    35
    TEST_ASSERT(status == PEP_STATUS_OK);
krista@3400
    36
    TEST_ASSERT(me->fpr);
krista@3400
    37
    
krista@3400
    38
    // Ok, there's a me identity in the DB.
krista@3400
    39
    // Call the naughty function.
krista@3400
    40
    
krista@3400
    41
    status = own_keys_retrieve(session, &keylist);
krista@3400
    42
    TEST_ASSERT(status == PEP_STATUS_OK);
krista@3400
    43
    TEST_ASSERT(keylist);
krista@3400
    44
    TEST_ASSERT(keylist->value);
krista@3400
    45
    cout << keylist->value << endl;
krista@3400
    46
krista@3400
    47
    status = own_identities_retrieve(session, &id_list);
krista@3400
    48
    TEST_ASSERT(status == PEP_STATUS_OK);
krista@3400
    49
    TEST_ASSERT(id_list);
krista@3400
    50
    TEST_ASSERT(id_list->ident);    
krista@3400
    51
}