mirror of
https://github.com/freedomofpress/dangerzone.git
synced 2025-04-28 18:02:38 +02:00
Tests: add cli --archive param test
This commit is contained in:
parent
b4849995e3
commit
c36f73ac8d
1 changed files with 17 additions and 0 deletions
|
@ -15,6 +15,7 @@ from click.testing import CliRunner, Result
|
|||
from strip_ansi import strip_ansi
|
||||
|
||||
from dangerzone.cli import cli_main, display_banner
|
||||
from dangerzone.document import ARCHIVE_SUBDIR, SAFE_EXTENSION
|
||||
|
||||
from . import TestBase, for_each_doc
|
||||
|
||||
|
@ -237,6 +238,22 @@ class TestCliConversion(TestCliBasic):
|
|||
result = self.run_cli(['--output-filename="output.pdf"'] + file_paths)
|
||||
result.assert_failure()
|
||||
|
||||
def test_archive(self, tmp_path: Path) -> None:
|
||||
test_string = "original file"
|
||||
|
||||
original_doc_path = str(tmp_path / "doc.pdf")
|
||||
safe_doc_path = str(tmp_path / f"doc{SAFE_EXTENSION}")
|
||||
archived_doc_path = str(tmp_path / ARCHIVE_SUBDIR / "doc.pdf")
|
||||
shutil.copyfile(self.sample_doc, original_doc_path)
|
||||
|
||||
result = self.run_cli(["--archive", original_doc_path])
|
||||
result.assert_success()
|
||||
|
||||
# original document has been moved to unsafe/doc.pdf
|
||||
assert not os.path.exists(original_doc_path)
|
||||
assert os.path.exists(archived_doc_path)
|
||||
assert os.path.exists(safe_doc_path)
|
||||
|
||||
|
||||
class TestSecurity(TestCli):
|
||||
def test_suspicious_double_dash_file(self, tmp_path: Path) -> None:
|
||||
|
|
Loading…
Reference in a new issue