forked from p15670423/monkey
cc: expanduser in data_dir path in Encryptor
This commit is contained in:
parent
d265238107
commit
a09cd8f497
|
@ -16,7 +16,9 @@ class Encryptor:
|
||||||
_PASSWORD_FILENAME = "mongo_key.bin"
|
_PASSWORD_FILENAME = "mongo_key.bin"
|
||||||
|
|
||||||
def __init__(self, data_dir):
|
def __init__(self, data_dir):
|
||||||
password_file = os.path.join(data_dir, self._PASSWORD_FILENAME)
|
password_file = os.path.expanduser(
|
||||||
|
os.path.join(data_dir, self._PASSWORD_FILENAME)
|
||||||
|
)
|
||||||
|
|
||||||
if os.path.exists(password_file):
|
if os.path.exists(password_file):
|
||||||
self._load_existing_key(password_file)
|
self._load_existing_key(password_file)
|
||||||
|
|
|
@ -27,3 +27,11 @@ def test_create_new_password_file(tmpdir):
|
||||||
initialize_encryptor(tmpdir)
|
initialize_encryptor(tmpdir)
|
||||||
|
|
||||||
assert os.path.isfile(os.path.join(tmpdir, PASSWORD_FILENAME))
|
assert os.path.isfile(os.path.join(tmpdir, PASSWORD_FILENAME))
|
||||||
|
|
||||||
|
|
||||||
|
def test_expand_home(monkeypatch, tmpdir):
|
||||||
|
monkeypatch.setenv("HOME", str(tmpdir))
|
||||||
|
|
||||||
|
initialize_encryptor("~/")
|
||||||
|
|
||||||
|
assert os.path.isfile(os.path.join(tmpdir, "mongo_key.bin"))
|
||||||
|
|
Loading…
Reference in New Issue