mirror of
https://github.com/borgbackup/borg.git
synced 2025-02-26 16:04:06 +00:00
get_security_dir: legacy=False default
This commit is contained in:
parent
1d4810af23
commit
bde0f11e1e
2 changed files with 11 additions and 3 deletions
|
@ -81,7 +81,7 @@ def get_keys_dir(*, legacy=False):
|
||||||
return keys_dir
|
return keys_dir
|
||||||
|
|
||||||
|
|
||||||
def get_security_dir(repository_id=None, *, legacy=True):
|
def get_security_dir(repository_id=None, *, legacy=False):
|
||||||
"""Determine where to store local security information."""
|
"""Determine where to store local security information."""
|
||||||
security_dir = os.environ.get("BORG_SECURITY_DIR")
|
security_dir = os.environ.get("BORG_SECURITY_DIR")
|
||||||
if security_dir is None:
|
if security_dir is None:
|
||||||
|
|
|
@ -693,12 +693,20 @@ def test_get_security_dir(monkeypatch):
|
||||||
monkeypatch.delenv("BORG_BASE_DIR", raising=False)
|
monkeypatch.delenv("BORG_BASE_DIR", raising=False)
|
||||||
if is_win32:
|
if is_win32:
|
||||||
monkeypatch.delenv("BORG_SECURITY_DIR", raising=False)
|
monkeypatch.delenv("BORG_SECURITY_DIR", raising=False)
|
||||||
assert get_security_dir(legacy=False) == os.path.join(
|
assert get_security_dir() == os.path.join(
|
||||||
os.path.expanduser("~"), "AppData", "Local", "borg", "borg", "security"
|
os.path.expanduser("~"), "AppData", "Local", "borg", "borg", "security"
|
||||||
)
|
)
|
||||||
assert get_security_dir(repository_id="1234", legacy=False) == os.path.join(
|
assert get_security_dir(repository_id="1234") == os.path.join(
|
||||||
os.path.expanduser("~"), "AppData", "Local", "borg", "borg", "security", "1234"
|
os.path.expanduser("~"), "AppData", "Local", "borg", "borg", "security", "1234"
|
||||||
)
|
)
|
||||||
|
elif is_darwin:
|
||||||
|
monkeypatch.delenv("BORG_SECURITY_DIR", raising=False)
|
||||||
|
assert get_security_dir() == os.path.join(os.path.expanduser("~"), "Library", "Preferences", "borg", "security")
|
||||||
|
assert get_security_dir(repository_id="1234") == os.path.join(
|
||||||
|
os.path.expanduser("~"), "Library", "Preferences", "borg", "security", "1234"
|
||||||
|
)
|
||||||
|
monkeypatch.setenv("BORG_SECURITY_DIR", "/var/tmp")
|
||||||
|
assert get_security_dir() == "/var/tmp"
|
||||||
else:
|
else:
|
||||||
monkeypatch.delenv("XDG_CONFIG_HOME", raising=False)
|
monkeypatch.delenv("XDG_CONFIG_HOME", raising=False)
|
||||||
monkeypatch.delenv("BORG_SECURITY_DIR", raising=False)
|
monkeypatch.delenv("BORG_SECURITY_DIR", raising=False)
|
||||||
|
|
Loading…
Reference in a new issue