|
|
@ -7,7 +7,8 @@ |
|
|
|
#include <string.h>
|
|
|
|
#include <sys/param.h>
|
|
|
|
|
|
|
|
#include "Adapter.hh"
|
|
|
|
#include "framework.hh"
|
|
|
|
|
|
|
|
#include "passphrase_cache.hh"
|
|
|
|
#include "status_to_string.hh"
|
|
|
|
|
|
|
@ -19,18 +20,10 @@ using namespace pEp; |
|
|
|
using namespace pEp::Adapter; |
|
|
|
using namespace std; |
|
|
|
|
|
|
|
void import_key_from_file(string filename) |
|
|
|
int main() |
|
|
|
{ |
|
|
|
ifstream f(filename, ifstream::in); |
|
|
|
string key{istreambuf_iterator<char>(f), istreambuf_iterator<char>()}; |
|
|
|
::identity_list *il = NULL; |
|
|
|
PEP_STATUS status = ::import_key(session(), key.c_str(), key.length(), &il); |
|
|
|
assert(status == PEP_KEY_IMPORTED); |
|
|
|
::free_identity_list(il); |
|
|
|
} |
|
|
|
Test::setup(); |
|
|
|
|
|
|
|
void test() |
|
|
|
{ |
|
|
|
passphrase_cache.add("erwin"); |
|
|
|
passphrase_cache.add("cathy"); |
|
|
|
passphrase_cache.add("bob"); |
|
|
@ -41,8 +34,8 @@ void test() |
|
|
|
const char* erwin_filename = ENGINE_TEST "/test_keys/erwin_normal_encrypted.pgp"; |
|
|
|
const char* erwin_fpr = "CBA968BC01FCEB89F04CCF155C5E9E3F0420A570"; |
|
|
|
|
|
|
|
import_key_from_file(bob_filename); |
|
|
|
import_key_from_file(erwin_filename); |
|
|
|
Test::import_key_from_file(bob_filename); |
|
|
|
Test::import_key_from_file(erwin_filename); |
|
|
|
|
|
|
|
pEp_identity* bob = ::new_identity("bob@example.org", bob_fpr, "BOB", "Bob Dog"); |
|
|
|
PEP_STATUS status = ::set_own_key(session(), bob, bob_fpr); |
|
|
@ -59,20 +52,7 @@ void test() |
|
|
|
::free_identity(erwin); |
|
|
|
|
|
|
|
session(Adapter::release); |
|
|
|
} |
|
|
|
|
|
|
|
int main() |
|
|
|
{ |
|
|
|
char path[MAXPATHLEN+1]; |
|
|
|
const char *templ = "/tmp/test_ensure_passphrase.XXXXXXXXXXXX"; |
|
|
|
strcpy(path, templ); |
|
|
|
char *tmpdir = mkdtemp(path); |
|
|
|
assert(tmpdir); |
|
|
|
chdir(tmpdir); |
|
|
|
setenv("HOME", path, 1); |
|
|
|
cerr << "test directory: " << path << endl; |
|
|
|
|
|
|
|
test(); |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|