|
@@ -1408,6 +1408,45 @@ class TestPassphrase:
|
|
|
def test_passphrase_repr(self):
|
|
|
assert "secret" not in repr(Passphrase("secret"))
|
|
|
|
|
|
+ def test_passphrase_wrong_debug(self, capsys, monkeypatch):
|
|
|
+ passphrase = "wrong_passphrase"
|
|
|
+ monkeypatch.setenv("BORG_DEBUG_PASSPHRASE", "YES")
|
|
|
+ monkeypatch.setenv("BORG_PASSPHRASE", "env_passphrase")
|
|
|
+ monkeypatch.setenv("BORG_PASSCOMMAND", "command")
|
|
|
+ monkeypatch.setenv("BORG_PASSPHRASE_FD", "fd_value")
|
|
|
+
|
|
|
+ Passphrase.display_debug_info(passphrase)
|
|
|
+
|
|
|
+ out, err = capsys.readouterr()
|
|
|
+ assert "Incorrect passphrase!" in err
|
|
|
+ assert passphrase in err
|
|
|
+ assert bin_to_hex(passphrase.encode("utf-8")) in err
|
|
|
+ assert 'BORG_PASSPHRASE = "env_passphrase"' in err
|
|
|
+ assert 'BORG_PASSCOMMAND = "command"' in err
|
|
|
+ assert 'BORG_PASSPHRASE_FD = "fd_value"' in err
|
|
|
+
|
|
|
+ monkeypatch.delenv("BORG_DEBUG_PASSPHRASE", raising=False)
|
|
|
+ Passphrase.display_debug_info(passphrase)
|
|
|
+ out, err = capsys.readouterr()
|
|
|
+
|
|
|
+ assert "Incorrect passphrase!" not in err
|
|
|
+ assert passphrase not in err
|
|
|
+
|
|
|
+ def test_verification(self, capsys, monkeypatch):
|
|
|
+ passphrase = "test_passphrase"
|
|
|
+ hex_value = passphrase.encode("utf-8").hex()
|
|
|
+
|
|
|
+ monkeypatch.setenv("BORG_DISPLAY_PASSPHRASE", "no")
|
|
|
+ Passphrase.verification(passphrase)
|
|
|
+ out, err = capsys.readouterr()
|
|
|
+ assert passphrase not in err
|
|
|
+
|
|
|
+ monkeypatch.setenv("BORG_DISPLAY_PASSPHRASE", "yes")
|
|
|
+ Passphrase.verification(passphrase)
|
|
|
+ out, err = capsys.readouterr()
|
|
|
+ assert passphrase in err
|
|
|
+ assert hex_value in err
|
|
|
+
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
|
"ec_range,ec_class",
|