Browse Source

Argh, cut-and-paste error broke all the things.

pEpMIME_windows
parent
commit
98eac74e41
5 changed files with 88 additions and 6 deletions
  1. +1
    -1
      src/keymanagement.c
  2. +19
    -0
      test/include/OwnIdentitiesRetrieveTests.h
  3. +5
    -1
      test/src/SuiteMaker.cc
  4. +12
    -4
      test/src/engine_tests/NewUpdateIdAndMyselfTests.cc
  5. +51
    -0
      test/src/engine_tests/OwnIdentitiesRetrieveTests.cc

+ 1
- 1
src/keymanagement.c View File

@ -1657,7 +1657,7 @@ PEP_STATUS _own_identities_retrieve(
identity_list *_bl = _own_identities;
sqlite3_bind_int(session->own_keys_retrieve, 1, excluded_flags);
sqlite3_bind_int(session->own_identities_retrieve, 1, excluded_flags);
do {
result = sqlite3_step(session->own_identities_retrieve);


+ 19
- 0
test/include/OwnIdentitiesRetrieveTests.h View File

@ -0,0 +1,19 @@
// This file is under GNU General Public License 3.0
// see LICENSE.txt
#ifndef OWN_IDENTITIES_RETRIEVE_H
#define OWN_IDENTITIES_RETRIEVE_H
#include <string>
#include "EngineTestIndividualSuite.h"
using namespace std;
class OwnIdentitiesRetrieveTests : public EngineTestIndividualSuite {
public:
OwnIdentitiesRetrieveTests(string test_suite, string test_home_dir);
private:
void check_own_identities_retrieve();
};
#endif

+ 5
- 1
test/src/SuiteMaker.cc View File

@ -13,6 +13,7 @@
// Begin where we generate stuff
#include "MimeTests.h"
#include "OwnIdentitiesRetrieveTests.h"
#include "ExpiredSubkeyTests.h"
#include "UserIdCollisionTests.h"
#include "Engine463Tests.h"
@ -65,6 +66,7 @@
const char* SuiteMaker::all_suites[] = {
"MimeTests",
"OwnIdentitiesRetrieveTests",
"ExpiredSubkeyTests",
"UserIdCollisionTests",
"Engine463Tests",
@ -116,11 +118,13 @@ const char* SuiteMaker::all_suites[] = {
};
// This file is generated, so magic constants are ok.
int SuiteMaker::num_suites = 49;
int SuiteMaker::num_suites = 50;
void SuiteMaker::suitemaker_build(const char* test_class_name, const char* test_home, Test::Suite** test_suite) {
if (strcmp(test_class_name, "MimeTests") == 0)
*test_suite = new MimeTests(test_class_name, test_home);
else if (strcmp(test_class_name, "OwnIdentitiesRetrieveTests") == 0)
*test_suite = new OwnIdentitiesRetrieveTests(test_class_name, test_home);
else if (strcmp(test_class_name, "ExpiredSubkeyTests") == 0)
*test_suite = new ExpiredSubkeyTests(test_class_name, test_home);
else if (strcmp(test_class_name, "UserIdCollisionTests") == 0)


+ 12
- 4
test/src/engine_tests/NewUpdateIdAndMyselfTests.cc View File

@ -531,18 +531,21 @@ void NewUpdateIdAndMyselfTests::key_elect_only_revoked_mistrusted() {
revoke_fpr_arr[0] = strdup(revokemaster_3000->fpr);
free(revokemaster_3000->fpr);
revokemaster_3000->fpr = NULL;
cout << "revoke_fpr_arr[0] is " << revoke_fpr_arr[0] << endl;
status = generate_keypair(session, revokemaster_3000);
TEST_ASSERT_MSG((status == PEP_STATUS_OK && revokemaster_3000->fpr), (string(tl_status_string(status)) + " " + revokemaster_3000->fpr).c_str());
revoke_fpr_arr[1] = strdup(revokemaster_3000->fpr);
free(revokemaster_3000->fpr);
revokemaster_3000->fpr = NULL;
cout << "revoke_fpr_arr[1] is " << revoke_fpr_arr[1] << endl;
status = generate_keypair(session, revokemaster_3000);
TEST_ASSERT_MSG((status == PEP_STATUS_OK && revokemaster_3000->fpr), (string(tl_status_string(status)) + " " + revokemaster_3000->fpr).c_str());
revoke_fpr_arr[2] = strdup(revokemaster_3000->fpr);
free(revokemaster_3000->fpr);
revokemaster_3000->fpr = NULL;
cout << "revoke_fpr_arr[2] is " << revoke_fpr_arr[2] << endl;
cout << "Trust " << revoke_fpr_arr[2] << " (default for identity) and " << revoke_fpr_arr[0] << endl;
@ -583,16 +586,21 @@ void NewUpdateIdAndMyselfTests::key_elect_only_revoked_mistrusted() {
TEST_ASSERT_MSG((is_revoked), "is_revoked");
cout << "Success revoking " << revoke_fpr_arr[2] << "!!! get_trust for this fpr gives us " << revokemaster_3000->comm_type << endl;
cout << "Now see if update_identity gives us " << revoke_fpr_arr[0] << ", the only trusted key left." << endl;
// BAD ASSUMPTION - this only works if we query the trust DB in elect_pubkey, and we don't.
// cout << "Now see if update_identity gives us " << revoke_fpr_arr[0] << ", the only trusted key left." << endl;
status = update_identity(session, revokemaster_3000);
TEST_ASSERT_MSG((status == PEP_STATUS_OK), tl_status_string(status));
TEST_ASSERT_MSG((revokemaster_3000->fpr), revokemaster_3000->fpr);
TEST_ASSERT_MSG((strcmp(revokemaster_3000->fpr, revoke_fpr_arr[0]) == 0), (string("Expected ") + revoke_fpr_arr[0] + ", Got " + revokemaster_3000->fpr).c_str());
TEST_ASSERT_MSG((strcmp(revokemaster_3000->fpr, revoke_fpr_arr[0]) == 0
|| (strcmp(revokemaster_3000->fpr, revoke_fpr_arr[0]) == 0)),
(string("Expected ") + revoke_fpr_arr[0] + " or " + revoke_fpr_arr[1] + ", Got " + revokemaster_3000->fpr).c_str());
TEST_ASSERT_MSG((revokemaster_3000->comm_type & PEP_ct_confirmed), tl_ct_string(revokemaster_3000->comm_type));
cout << "Success! So let's mistrust it, because seriously, that key was so uncool." << endl;
cout << "Success! So let's mistrust " << revoke_fpr_arr[0] << ", because seriously, that key was so uncool." << endl;
free(revokemaster_3000->fpr);
revokemaster_3000->fpr = strdup(revoke_fpr_arr[0]);
status = key_mistrusted(session, revokemaster_3000);
TEST_ASSERT_MSG((status == PEP_STATUS_OK), tl_status_string(status));


+ 51
- 0
test/src/engine_tests/OwnIdentitiesRetrieveTests.cc View File

@ -0,0 +1,51 @@
// This file is under GNU General Public License 3.0
// see LICENSE.txt
#include <stdlib.h>
#include <string>
#include "pEpEngine.h"
#include "keymanagement.h"
#include <cpptest.h>
#include "EngineTestIndividualSuite.h"
#include "OwnIdentitiesRetrieveTests.h"
using namespace std;
OwnIdentitiesRetrieveTests::OwnIdentitiesRetrieveTests(string suitename, string test_home_dir) :
EngineTestIndividualSuite::EngineTestIndividualSuite(suitename, test_home_dir) {
add_test_to_suite(std::pair<std::string, void (Test::Suite::*)()>(string("OwnIdentitiesRetrieveTests::check_own_identities_retrieve"),
static_cast<Func>(&OwnIdentitiesRetrieveTests::check_own_identities_retrieve)));
}
void OwnIdentitiesRetrieveTests::check_own_identities_retrieve() {
stringlist_t* keylist = NULL;
PEP_STATUS status = own_keys_retrieve(session, &keylist);
TEST_ASSERT(keylist == NULL);
TEST_ASSERT(status == PEP_STATUS_OK);
identity_list* id_list = NULL;
status = own_identities_retrieve(session, &id_list);
TEST_ASSERT(id_list == NULL || !(id_list->ident));
TEST_ASSERT(status == PEP_STATUS_OK);
pEp_identity* me = new_identity("krista_b@darthmama.cool", NULL, "MyOwnId", "Krista B.");
status = myself(session, me);
TEST_ASSERT(status == PEP_STATUS_OK);
TEST_ASSERT(me->fpr);
// Ok, there's a me identity in the DB.
// Call the naughty function.
status = own_keys_retrieve(session, &keylist);
TEST_ASSERT(status == PEP_STATUS_OK);
TEST_ASSERT(keylist);
TEST_ASSERT(keylist->value);
cout << keylist->value << endl;
status = own_identities_retrieve(session, &id_list);
TEST_ASSERT(status == PEP_STATUS_OK);
TEST_ASSERT(id_list);
TEST_ASSERT(id_list->ident);
}

Loading…
Cancel
Save