Merge pull request #9691 from mr-raj12/testsuite-argon2-wrong-passphrase

testsuite: add argon2 wrong-passphrase test for decrypt_key_file, refs #9686
This commit is contained in:
TW 2026-05-31 18:27:44 +02:00 committed by GitHub
commit a0448abde0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -328,3 +328,13 @@ def test_key_file_roundtrip(monkeypatch):
assert to_dict(load_me) == to_dict(save_me)
assert msgpack.unpackb(a2b_base64(saved))["algorithm"] == KEY_ALGORITHMS["argon2"]
def test_argon2_wrong_passphrase_returns_none(monkeypatch):
# a wrong passphrase derives a different key, so the Argon2 integrity check fails;
# decrypt_key_file signals this by returning None, not by raising (refs #8036)
repository = MagicMock(id=b"repository_id")
monkeypatch.setenv("BORG_PASSPHRASE", "correct passphrase")
key = AESOCBRepoKey.create(repository, args=MagicMock(key_algorithm="argon2"))
saved = repository.save_key.call_args.args[0]
assert key.decrypt_key_file(a2b_base64(saved), "wrong passphrase") is None