Browse Source

Tests: test utils - add decryptMessage() using flags

LIB-11
heck 11 months ago
parent
commit
3ac1052cda
2 changed files with 13 additions and 9 deletions
  1. +10
    -8
      test/framework/utils.cc
  2. +3
    -1
      test/framework/utils.hh

+ 10
- 8
test/framework/utils.cc View File

@ -136,11 +136,7 @@ namespace pEp {
{
std::string name;
::pEp_identity *ident = nullptr;
ident = ::new_identity(
strdup(address.c_str()),
"",
"",
"");
ident = ::new_identity(strdup(address.c_str()), "", "", "");
ident->me = false;
return appropriate(ident);
@ -221,7 +217,8 @@ namespace pEp {
return EncryptResult(msg_out, "", could_encrypt);
}
DecryptResult decryptMessage(const pEpMessage msg)
DecryptResult decryptMessage(const pEpMessage msg, ::PEP_decrypt_flags_t *flags)
{
pEpMessage msg_out;
bool was_encrypted = false;
@ -229,14 +226,13 @@ namespace pEp {
::message *dec{ nullptr };
::stringlist_t *kl = ::new_stringlist("");
::PEP_rating rating;
unsigned int flags{ 0 };
PEP_STATUS status = ::decrypt_message(
Adapter::session(),
msg.get(),
&dec,
&kl,
&rating,
&flags);
flags);
throw_status(status);
if (dec != nullptr) {
was_encrypted = true;
@ -248,6 +244,12 @@ namespace pEp {
return DecryptResult(msg_out, rating, kl, flags, was_encrypted);
}
DecryptResult decryptMessage(const pEpMessage msg)
{
::PEP_decrypt_flags_t dummy{ 0 };
return decryptMessage(msg, &dummy);
}
EncryptResult encryptAndEncode(const pEpMessage msg)
{
EncryptResult ret = encryptMessage(msg);


+ 3
- 1
test/framework/utils.hh View File

@ -82,7 +82,8 @@ namespace pEp {
using pEpIdentList = std::shared_ptr<::identity_list>;
using pEpMessage = std::shared_ptr<::message>;
// [ DecryptedMessage, Rating, KeyList, Flags, WasEncrypted ]
using DecryptResult = std::tuple<pEpMessage, ::PEP_rating, ::stringlist_t *, unsigned int, bool>;
using DecryptResult = std::
tuple<pEpMessage, ::PEP_rating, ::stringlist_t *, ::PEP_decrypt_flags_t *, bool>;
// [ EncryptedMessage, MimeText, couldEncrypt ]
using EncryptResult = std::tuple<pEpMessage, std::string, bool>;
@ -125,6 +126,7 @@ namespace pEp {
pEpMessage mimeDecode(const std::string &mime_text);
EncryptResult encryptMessage(const pEpMessage msg);
DecryptResult decryptMessage(const pEpMessage msg, ::PEP_decrypt_flags_t *flags);
DecryptResult decryptMessage(const pEpMessage msg);
EncryptResult encryptAndEncode(const pEpMessage msg);


Loading…
Cancel
Save