diff --git a/deltachat-ffi/src/lib.rs b/deltachat-ffi/src/lib.rs index 28cfb4d42..383e4c242 100644 --- a/deltachat-ffi/src/lib.rs +++ b/deltachat-ffi/src/lib.rs @@ -698,7 +698,7 @@ pub unsafe extern "C" fn dc_preconfigure_keypair( secret_data: *const libc::c_char, ) -> i32 { if context.is_null() { - eprintln!("ignoring careless call to _dc_save_self_keypair()"); + eprintln!("ignoring careless call to dc_preconfigure_keypair()"); return 0; } let ffi_context = &*context; diff --git a/python/install_python_bindings.py b/python/install_python_bindings.py index 665f72e45..106d7fdbe 100755 --- a/python/install_python_bindings.py +++ b/python/install_python_bindings.py @@ -11,18 +11,15 @@ import sys if __name__ == "__main__": target = os.environ.get("DCC_RS_TARGET") if target is None: - os.environ["DCC_RS_TARGET"] = target = "release" + os.environ["DCC_RS_TARGET"] = target = "debug" if "DCC_RS_DEV" not in os.environ: dn = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) os.environ["DCC_RS_DEV"] = dn - # build the core library in release + debug mode because - # as of Nov 2019 rPGP generates RSA keys which take - # prohibitively long for non-release installs - os.environ["RUSTFLAGS"] = "-g" - subprocess.check_call([ - "cargo", "build", "-p", "deltachat_ffi", "--" + target - ]) + cmd = ["cargo", "build", "-p", "deltachat_ffi"] + if target == 'release': + cmd.append("--release") + subprocess.check_call(cmd) subprocess.check_call("rm -rf build/ src/deltachat/*.so" , shell=True) if len(sys.argv) <= 1 or sys.argv[1] != "onlybuild": diff --git a/python/src/deltachat/account.py b/python/src/deltachat/account.py index bab846cd3..37ac12b17 100644 --- a/python/src/deltachat/account.py +++ b/python/src/deltachat/account.py @@ -119,7 +119,7 @@ class Account(object): return from_dc_charpointer(res) def _preconfigure_keypair(self, addr, public, secret): - """See _dc_save_self_keypair() in deltachat.h. + """See dc_preconfigure_keypair() in deltachat.h. In other words, you don't need this. """ diff --git a/python/tests/conftest.py b/python/tests/conftest.py index 05896cb8c..5055308f0 100644 --- a/python/tests/conftest.py +++ b/python/tests/conftest.py @@ -1,5 +1,6 @@ from __future__ import print_function import os +import py import pytest import requests import time @@ -116,8 +117,19 @@ def session_liveconfig(request): return SessionLiveConfigFromFile(liveconfig_opt) +@pytest.fixture(scope='session') +def datadir(): + """The py.path.local object of the test-data/ directory.""" + for path in reversed(py.path.local(__file__).parts()): + datadir = path.join('test-data') + if datadir.isdir(): + return datadir + else: + pytest.skip('test-data directory not found') + + @pytest.fixture -def acfactory(pytestconfig, tmpdir, request, session_liveconfig): +def acfactory(pytestconfig, tmpdir, request, session_liveconfig, datadir): class AccountMaker: def __init__(self): @@ -125,6 +137,7 @@ def acfactory(pytestconfig, tmpdir, request, session_liveconfig): self.offline_count = 0 self._finalizers = [] self.init_time = time.time() + self._generated_keys = ["alice", "bob"] def finalize(self): while self._finalizers: @@ -144,12 +157,23 @@ def acfactory(pytestconfig, tmpdir, request, session_liveconfig): ac._evlogger.set_timeout(2) return ac + def _preconfigure_key(self, account, addr): + # Only set a key if we haven't used it yet for another account. + if self._generated_keys: + keyname = self._generated_keys.pop(0) + fname_pub = "key/{name}-public.asc".format(name=keyname) + fname_sec = "key/{name}-secret.asc".format(name=keyname) + account._preconfigure_keypair(addr, + datadir.join(fname_pub).read(), + datadir.join(fname_sec).read()) + def get_configured_offline_account(self): ac = self.get_unconfigured_account() # do a pseudo-configured account addr = "addr{}@offline.org".format(self.offline_count) ac.set_config("addr", addr) + self._preconfigure_key(ac, addr) lib.dc_set_config(ac._dc_context, b"configured_addr", addr.encode("ascii")) ac.set_config("mail_pw", "123") lib.dc_set_config(ac._dc_context, b"configured_mail_pw", b"123") @@ -175,6 +199,7 @@ def acfactory(pytestconfig, tmpdir, request, session_liveconfig): tmpdb = tmpdir.join("livedb%d" % self.live_count) ac = self.make_account(tmpdb.strpath, logid="ac{}".format(self.live_count)) + self._preconfigure_key(ac, configdict['addr']) ac._evlogger.init_time = self.init_time ac._evlogger.set_timeout(30) return ac, dict(configdict) diff --git a/python/tests/test_account.py b/python/tests/test_account.py index 4d9b379c1..e8536b949 100644 --- a/python/tests/test_account.py +++ b/python/tests/test_account.py @@ -1,5 +1,4 @@ from __future__ import print_function -import py import pytest import os import queue @@ -7,17 +6,9 @@ import time from deltachat import const, Account from deltachat.message import Message from datetime import datetime, timedelta -from conftest import wait_configuration_progress, wait_successful_IMAP_SMTP_connection, wait_securejoin_inviter_progress - - -@pytest.fixture -def datadir(): - """The py.path.local object of the test-data/ directory.""" - for path in reversed(py.path.local(__file__).parts()): - datadir = path.join('test-data') - if datadir.isdir(): - return datadir - pytest.skip('test-data directory not found') +from conftest import (wait_configuration_progress, + wait_successful_IMAP_SMTP_connection, + wait_securejoin_inviter_progress) class TestOfflineAccountBasic: @@ -38,8 +29,8 @@ class TestOfflineAccountBasic: def test_preconfigure_keypair(self, acfactory, datadir): ac = acfactory.get_unconfigured_account() ac._preconfigure_keypair("alice@example.com", - datadir.join('key/alice-public.asc').read(), - datadir.join('key/alice-secret.asc').read()) + datadir.join("key/alice-public.asc").read(), + datadir.join("key/alice-secret.asc").read()) def test_getinfo(self, acfactory): ac1 = acfactory.get_unconfigured_account() diff --git a/src/key.rs b/src/key.rs index 372e16dad..89f42fe34 100644 --- a/src/key.rs +++ b/src/key.rs @@ -305,7 +305,7 @@ impl Key { /// Use of a [KeyPair] for encryption or decryption. /// -/// This is used by [save_self_keypair] to know what kind of key is +/// This is used by [store_self_keypair] to know what kind of key is /// being saved. #[derive(Debug, Clone, Eq, PartialEq)] pub enum KeyPairUse {