Browse Source

ENGINE-463: get_trust_by_userid

doc_update_sequoia
Krista Bennett 4 years ago
parent
commit
35a17cf8d3
4 changed files with 151 additions and 112 deletions
  1. +39
    -2
      src/pEpEngine.c
  2. +2
    -1
      src/pEpEngine.h
  3. +1
    -0
      src/pEp_internal.h
  4. +109
    -109
      test/src/SuiteMaker.cc

+ 39
- 2
src/pEpEngine.c View File

@ -113,7 +113,6 @@ static const char *sql_get_identity_without_trust_check =
static const char *sql_get_identities_by_address =
"select user_id, identity.main_key_id, username, lang,"
" identity.flags, is_own"
" from identity"
" join person on id = identity.user_id"
@ -126,7 +125,7 @@ static const char *sql_get_identities_by_address =
" timestamp desc; ";
static const char* sql_get_identities_by_userid =
"select address, identity.main_key_id, username, lang"
"select address, identity.main_key_id, username, lang,"
" identity.flags, is_own"
" from identity"
" join person on id = identity.user_id"
@ -319,6 +318,9 @@ static const char *sql_get_trust =
"select comm_type from trust where user_id = ?1 "
"and pgp_keypair_fpr = upper(replace(?2,' ','')) ;";
static const char *sql_get_trust_by_userid =
"select pgp_keypair_fpr, comm_type from trust where user_id = ?1 ";
static const char *sql_least_trust =
"select min(comm_type) from trust where"
" pgp_keypair_fpr = upper(replace(?1,' ',''))"
@ -1214,6 +1216,10 @@ DYNAMIC_API PEP_STATUS init(PEP_SESSION *session)
(int)strlen(sql_get_trust), &_session->get_trust, NULL);
assert(int_result == SQLITE_OK);
int_result = sqlite3_prepare_v2(_session->db, sql_get_trust_by_userid,
(int)strlen(sql_get_trust_by_userid), &_session->get_trust_by_userid, NULL);
assert(int_result == SQLITE_OK);
int_result = sqlite3_prepare_v2(_session->db, sql_least_trust,
(int)strlen(sql_least_trust), &_session->least_trust, NULL);
assert(int_result == SQLITE_OK);
@ -1453,6 +1459,8 @@ DYNAMIC_API void release(PEP_SESSION session)
sqlite3_finalize(session->update_trust_for_fpr);
if (session->get_trust)
sqlite3_finalize(session->get_trust);
if (session->get_trust_by_userid)
sqlite3_finalize(session->get_trust_by_userid);
if (session->least_trust)
sqlite3_finalize(session->least_trust);
if (session->mark_compromised)
@ -3112,6 +3120,35 @@ DYNAMIC_API PEP_STATUS get_trust(PEP_SESSION session, pEp_identity *identity)
return status;
}
PEP_STATUS get_trust_by_userid(PEP_SESSION session, const char* user_id,
labeled_int_list_t** trust_list)
{
int result;
if (!(session && user_id && user_id[0]))
return PEP_ILLEGAL_VALUE;
*trust_list = NULL;
labeled_int_list_t* t_list = new_labeled_int_list(0, NULL); // empty
sqlite3_reset(session->get_trust_by_userid);
sqlite3_bind_text(session->get_trust_by_userid, 1, user_id, -1, SQLITE_STATIC);
while ((result = sqlite3_step(session->get_trust_by_userid)) == SQLITE_ROW) {
labeled_int_list_add(t_list, sqlite3_column_int(session->get_trust_by_userid, 1),
(const char *) sqlite3_column_text(session->get_trust_by_userid, 0));
}
sqlite3_reset(session->get_trust_by_userid);
if (!t_list->label)
free_labeled_int_list(t_list);
else
*trust_list = t_list;
return PEP_STATUS_OK;
}
DYNAMIC_API PEP_STATUS least_trust(
PEP_SESSION session,
const char *fpr,


+ 2
- 1
src/pEpEngine.h View File

@ -13,7 +13,8 @@ extern "C" {
#include "dynamic_api.h"
#include "stringlist.h"
#include "stringpair.h"
#include "stringpair.h"
#include "labeled_int_list.h"
#include "timestamp.h"
#define PEP_VERSION "2.0" // protocol version


+ 1
- 0
src/pEp_internal.h View File

@ -157,6 +157,7 @@ struct _pEpSession {
sqlite3_stmt *exists_trust_entry;
sqlite3_stmt *update_trust_for_fpr;
sqlite3_stmt *get_trust;
sqlite3_stmt *get_trust_by_userid;
sqlite3_stmt *least_trust;
sqlite3_stmt *mark_compromised;
sqlite3_stmt *reset_trust;


+ 109
- 109
test/src/SuiteMaker.cc View File

@ -12,82 +12,82 @@
#include "SuiteMaker.h"
// Begin where we generate stuff
#include "MapAsn1Tests.h"
#include "DecorateTests.h"
#include "EncryptMissingPrivateKeyTests.h"
#include "KeyeditTests.h"
#include "BlacklistAcceptNewKeyTests.h"
#include "DecryptAttachPrivateKeyUntrustedTests.h"
#include "ReencryptPlusExtraKeysTests.h"
#include "BlacklistTests.h"
#include "AppleMailTests.h"
#include "CaseAndDotAddressTests.h"
#include "SequenceTests.h"
#include "MessageTwoPointOhTests.h"
#include "IdentityListTests.h"
#include "I18nTests.h"
#include "DecryptAttachPrivateKeyUntrustedTests.h"
#include "BCCTests.h"
#include "LeastColorGroupTests.h"
#include "MistrustUndoTests.h"
#include "BlacklistAcceptNewKeyTests.h"
#include "MessageApiTests.h"
#include "I18nTests.h"
#include "CrashdumpTests.h"
#include "PgpBinaryTests.h"
#include "StringlistTests.h"
#include "StringpairListTests.h"
#include "TrustManipulationTests.h"
#include "EncryptAttachPrivateKeyTests.h"
#include "BloblistTests.h"
#include "SequenceTests.h"
#include "TrustwordsTests.h"
#include "RevokeRegenAttachTests.h"
#include "BlacklistTests.h"
#include "LeastCommonDenomColorTests.h"
#include "EncryptMissingPrivateKeyTests.h"
#include "PepSubjectReceivedTests.h"
#include "MistrustUndoTests.h"
#include "StringpairListTests.h"
#include "PgpListKeysTests.h"
#include "ReencryptPlusExtraKeysTests.h"
#include "KeyeditTests.h"
#include "MapAsn1Tests.h"
#include "PgpBinaryTests.h"
#include "DecryptAttachPrivateKeyTrustedTests.h"
#include "MessageNullFromTests.h"
#include "MimeTests.h"
#include "BloblistTests.h"
#include "PgpListKeysTests.h"
#include "NewUpdateIdAndMyselfTests.h"
#include "StringlistTests.h"
#include "LeastColorGroupTests.h"
#include "ExternalRevokeTests.h"
#include "EncryptForIdentityTests.h"
#include "TrustwordsTests.h"
#include "TrustManipulationTests.h"
#include "MessageTwoPointOhTests.h"
#include "MessageNullFromTests.h"
#include "EncryptAttachPrivateKeyTests.h"
#include "DecryptAttachPrivateKeyTrustedTests.h"
#include "IdentityListTests.h"
#include "CrashdumpTests.h"
#include "CaseAndDotAddressTests.h"
#include "LeastCommonDenomColorTests.h"
#include "ExternalRevokeTests.h"
#include "UserIDAliasTests.h"
const char* SuiteMaker::all_suites[] = {
"MapAsn1Tests",
"DecorateTests",
"EncryptMissingPrivateKeyTests",
"KeyeditTests",
"BlacklistAcceptNewKeyTests",
"DecryptAttachPrivateKeyUntrustedTests",
"ReencryptPlusExtraKeysTests",
"BlacklistTests",
"AppleMailTests",
"CaseAndDotAddressTests",
"SequenceTests",
"MessageTwoPointOhTests",
"IdentityListTests",
"I18nTests",
"DecryptAttachPrivateKeyUntrustedTests",
"BCCTests",
"LeastColorGroupTests",
"MistrustUndoTests",
"BlacklistAcceptNewKeyTests",
"MessageApiTests",
"I18nTests",
"CrashdumpTests",
"PgpBinaryTests",
"StringlistTests",
"StringpairListTests",
"TrustManipulationTests",
"EncryptAttachPrivateKeyTests",
"BloblistTests",
"SequenceTests",
"TrustwordsTests",
"RevokeRegenAttachTests",
"BlacklistTests",
"LeastCommonDenomColorTests",
"EncryptMissingPrivateKeyTests",
"PepSubjectReceivedTests",
"MistrustUndoTests",
"StringpairListTests",
"PgpListKeysTests",
"ReencryptPlusExtraKeysTests",
"KeyeditTests",
"MapAsn1Tests",
"PgpBinaryTests",
"DecryptAttachPrivateKeyTrustedTests",
"MessageNullFromTests",
"MimeTests",
"BloblistTests",
"PgpListKeysTests",
"NewUpdateIdAndMyselfTests",
"StringlistTests",
"LeastColorGroupTests",
"ExternalRevokeTests",
"EncryptForIdentityTests",
"TrustwordsTests",
"TrustManipulationTests",
"MessageTwoPointOhTests",
"MessageNullFromTests",
"EncryptAttachPrivateKeyTests",
"DecryptAttachPrivateKeyTrustedTests",
"IdentityListTests",
"CrashdumpTests",
"CaseAndDotAddressTests",
"LeastCommonDenomColorTests",
"ExternalRevokeTests",
"UserIDAliasTests",
};
@ -95,78 +95,78 @@ const char* SuiteMaker::all_suites[] = {
int SuiteMaker::num_suites = 37;
void SuiteMaker::suitemaker_build(const char* test_class_name, const char* test_home, Test::Suite** test_suite) {
if (strcmp(test_class_name, "MapAsn1Tests") == 0)
*test_suite = new MapAsn1Tests(test_class_name, test_home);
else if (strcmp(test_class_name, "DecorateTests") == 0)
if (strcmp(test_class_name, "DecorateTests") == 0)
*test_suite = new DecorateTests(test_class_name, test_home);
else if (strcmp(test_class_name, "EncryptMissingPrivateKeyTests") == 0)
*test_suite = new EncryptMissingPrivateKeyTests(test_class_name, test_home);
else if (strcmp(test_class_name, "KeyeditTests") == 0)
*test_suite = new KeyeditTests(test_class_name, test_home);
else if (strcmp(test_class_name, "BlacklistAcceptNewKeyTests") == 0)
*test_suite = new BlacklistAcceptNewKeyTests(test_class_name, test_home);
else if (strcmp(test_class_name, "DecryptAttachPrivateKeyUntrustedTests") == 0)
*test_suite = new DecryptAttachPrivateKeyUntrustedTests(test_class_name, test_home);
else if (strcmp(test_class_name, "ReencryptPlusExtraKeysTests") == 0)
*test_suite = new ReencryptPlusExtraKeysTests(test_class_name, test_home);
else if (strcmp(test_class_name, "BlacklistTests") == 0)
*test_suite = new BlacklistTests(test_class_name, test_home);
else if (strcmp(test_class_name, "AppleMailTests") == 0)
*test_suite = new AppleMailTests(test_class_name, test_home);
else if (strcmp(test_class_name, "CaseAndDotAddressTests") == 0)
*test_suite = new CaseAndDotAddressTests(test_class_name, test_home);
else if (strcmp(test_class_name, "SequenceTests") == 0)
*test_suite = new SequenceTests(test_class_name, test_home);
else if (strcmp(test_class_name, "MessageTwoPointOhTests") == 0)
*test_suite = new MessageTwoPointOhTests(test_class_name, test_home);
else if (strcmp(test_class_name, "IdentityListTests") == 0)
*test_suite = new IdentityListTests(test_class_name, test_home);
else if (strcmp(test_class_name, "I18nTests") == 0)
*test_suite = new I18nTests(test_class_name, test_home);
else if (strcmp(test_class_name, "DecryptAttachPrivateKeyUntrustedTests") == 0)
*test_suite = new DecryptAttachPrivateKeyUntrustedTests(test_class_name, test_home);
else if (strcmp(test_class_name, "BCCTests") == 0)
*test_suite = new BCCTests(test_class_name, test_home);
else if (strcmp(test_class_name, "LeastColorGroupTests") == 0)
*test_suite = new LeastColorGroupTests(test_class_name, test_home);
else if (strcmp(test_class_name, "MistrustUndoTests") == 0)
*test_suite = new MistrustUndoTests(test_class_name, test_home);
else if (strcmp(test_class_name, "BlacklistAcceptNewKeyTests") == 0)
*test_suite = new BlacklistAcceptNewKeyTests(test_class_name, test_home);
else if (strcmp(test_class_name, "MessageApiTests") == 0)
*test_suite = new MessageApiTests(test_class_name, test_home);
else if (strcmp(test_class_name, "I18nTests") == 0)
*test_suite = new I18nTests(test_class_name, test_home);
else if (strcmp(test_class_name, "CrashdumpTests") == 0)
*test_suite = new CrashdumpTests(test_class_name, test_home);
else if (strcmp(test_class_name, "PgpBinaryTests") == 0)
*test_suite = new PgpBinaryTests(test_class_name, test_home);
else if (strcmp(test_class_name, "StringlistTests") == 0)
*test_suite = new StringlistTests(test_class_name, test_home);
else if (strcmp(test_class_name, "StringpairListTests") == 0)
*test_suite = new StringpairListTests(test_class_name, test_home);
else if (strcmp(test_class_name, "TrustManipulationTests") == 0)
*test_suite = new TrustManipulationTests(test_class_name, test_home);
else if (strcmp(test_class_name, "EncryptAttachPrivateKeyTests") == 0)
*test_suite = new EncryptAttachPrivateKeyTests(test_class_name, test_home);
else if (strcmp(test_class_name, "BloblistTests") == 0)
*test_suite = new BloblistTests(test_class_name, test_home);
else if (strcmp(test_class_name, "SequenceTests") == 0)
*test_suite = new SequenceTests(test_class_name, test_home);
else if (strcmp(test_class_name, "TrustwordsTests") == 0)
*test_suite = new TrustwordsTests(test_class_name, test_home);
else if (strcmp(test_class_name, "RevokeRegenAttachTests") == 0)
*test_suite = new RevokeRegenAttachTests(test_class_name, test_home);
else if (strcmp(test_class_name, "BlacklistTests") == 0)
*test_suite = new BlacklistTests(test_class_name, test_home);
else if (strcmp(test_class_name, "LeastCommonDenomColorTests") == 0)
*test_suite = new LeastCommonDenomColorTests(test_class_name, test_home);
else if (strcmp(test_class_name, "EncryptMissingPrivateKeyTests") == 0)
*test_suite = new EncryptMissingPrivateKeyTests(test_class_name, test_home);
else if (strcmp(test_class_name, "PepSubjectReceivedTests") == 0)
*test_suite = new PepSubjectReceivedTests(test_class_name, test_home);
else if (strcmp(test_class_name, "MistrustUndoTests") == 0)
*test_suite = new MistrustUndoTests(test_class_name, test_home);
else if (strcmp(test_class_name, "StringpairListTests") == 0)
*test_suite = new StringpairListTests(test_class_name, test_home);
else if (strcmp(test_class_name, "PgpListKeysTests") == 0)
*test_suite = new PgpListKeysTests(test_class_name, test_home);
else if (strcmp(test_class_name, "ReencryptPlusExtraKeysTests") == 0)
*test_suite = new ReencryptPlusExtraKeysTests(test_class_name, test_home);
else if (strcmp(test_class_name, "KeyeditTests") == 0)
*test_suite = new KeyeditTests(test_class_name, test_home);
else if (strcmp(test_class_name, "MapAsn1Tests") == 0)
*test_suite = new MapAsn1Tests(test_class_name, test_home);
else if (strcmp(test_class_name, "PgpBinaryTests") == 0)
*test_suite = new PgpBinaryTests(test_class_name, test_home);
else if (strcmp(test_class_name, "DecryptAttachPrivateKeyTrustedTests") == 0)
*test_suite = new DecryptAttachPrivateKeyTrustedTests(test_class_name, test_home);
else if (strcmp(test_class_name, "MessageNullFromTests") == 0)
*test_suite = new MessageNullFromTests(test_class_name, test_home);
else if (strcmp(test_class_name, "MimeTests") == 0)
*test_suite = new MimeTests(test_class_name, test_home);
else if (strcmp(test_class_name, "BloblistTests") == 0)
*test_suite = new BloblistTests(test_class_name, test_home);
else if (strcmp(test_class_name, "PgpListKeysTests") == 0)
*test_suite = new PgpListKeysTests(test_class_name, test_home);
else if (strcmp(test_class_name, "NewUpdateIdAndMyselfTests") == 0)
*test_suite = new NewUpdateIdAndMyselfTests(test_class_name, test_home);
else if (strcmp(test_class_name, "StringlistTests") == 0)
*test_suite = new StringlistTests(test_class_name, test_home);
else if (strcmp(test_class_name, "LeastColorGroupTests") == 0)
*test_suite = new LeastColorGroupTests(test_class_name, test_home);
else if (strcmp(test_class_name, "ExternalRevokeTests") == 0)
*test_suite = new ExternalRevokeTests(test_class_name, test_home);
else if (strcmp(test_class_name, "EncryptForIdentityTests") == 0)
*test_suite = new EncryptForIdentityTests(test_class_name, test_home);
else if (strcmp(test_class_name, "TrustwordsTests") == 0)
*test_suite = new TrustwordsTests(test_class_name, test_home);
else if (strcmp(test_class_name, "TrustManipulationTests") == 0)
*test_suite = new TrustManipulationTests(test_class_name, test_home);
else if (strcmp(test_class_name, "MessageTwoPointOhTests") == 0)
*test_suite = new MessageTwoPointOhTests(test_class_name, test_home);
else if (strcmp(test_class_name, "MessageNullFromTests") == 0)
*test_suite = new MessageNullFromTests(test_class_name, test_home);
else if (strcmp(test_class_name, "EncryptAttachPrivateKeyTests") == 0)
*test_suite = new EncryptAttachPrivateKeyTests(test_class_name, test_home);
else if (strcmp(test_class_name, "DecryptAttachPrivateKeyTrustedTests") == 0)
*test_suite = new DecryptAttachPrivateKeyTrustedTests(test_class_name, test_home);
else if (strcmp(test_class_name, "IdentityListTests") == 0)
*test_suite = new IdentityListTests(test_class_name, test_home);
else if (strcmp(test_class_name, "CrashdumpTests") == 0)
*test_suite = new CrashdumpTests(test_class_name, test_home);
else if (strcmp(test_class_name, "CaseAndDotAddressTests") == 0)
*test_suite = new CaseAndDotAddressTests(test_class_name, test_home);
else if (strcmp(test_class_name, "LeastCommonDenomColorTests") == 0)
*test_suite = new LeastCommonDenomColorTests(test_class_name, test_home);
else if (strcmp(test_class_name, "ExternalRevokeTests") == 0)
*test_suite = new ExternalRevokeTests(test_class_name, test_home);
else if (strcmp(test_class_name, "UserIDAliasTests") == 0)
*test_suite = new UserIDAliasTests(test_class_name, test_home);
}


Loading…
Cancel
Save