mirror of
https://github.com/freedomofpress/dangerzone.git
synced 2025-04-28 18:02:38 +02:00
Qubes: add test if MAX_PAGES is enforced in client
Because the server also checks the MAX_PAGES limit, the test in base would hide the fact that the client is not enforcing the limit. This ensures that's not the case. When the pages in containers are streamed (#443), then this test should be in base.py.
This commit is contained in:
parent
54b8ffbf96
commit
6f26fc6303
1 changed files with 21 additions and 3 deletions
|
@ -1,9 +1,13 @@
|
|||
import pytest
|
||||
from pytest_mock import MockerFixture
|
||||
|
||||
from dangerzone.isolation_provider.qubes import Qubes
|
||||
from dangerzone.conversion import errors
|
||||
from dangerzone.document import Document
|
||||
from dangerzone.isolation_provider.base import IsolationProvider
|
||||
from dangerzone.isolation_provider.qubes import Qubes, running_on_qubes
|
||||
|
||||
# XXX Fixtures used in abstract Test class need to be imported regardless
|
||||
from .. import pdf_11k_pages, sanitized_text, uncommon_text
|
||||
from .. import pdf_11k_pages, sample_doc, sanitized_text, uncommon_text
|
||||
from .base import IsolationProviderTest
|
||||
|
||||
|
||||
|
@ -12,5 +16,19 @@ def provider() -> Qubes:
|
|||
return Qubes()
|
||||
|
||||
|
||||
@pytest.mark.skipif(not running_on_qubes(), reason="Not on a Qubes system")
|
||||
class TestQubes(IsolationProviderTest):
|
||||
pass
|
||||
def test_max_pages_client_side_enforcement(
|
||||
self,
|
||||
sample_doc: str,
|
||||
provider: Qubes,
|
||||
mocker: MockerFixture,
|
||||
) -> None:
|
||||
provider.progress_callback = mocker.MagicMock()
|
||||
mocker.patch(
|
||||
"dangerzone.conversion.errors.MAX_PAGES", 1
|
||||
) # sample_doc has 4 pages > 1
|
||||
doc = Document(sample_doc)
|
||||
with pytest.raises(errors.MaxPagesException):
|
||||
success = provider._convert(doc, ocr_lang=None)
|
||||
assert not success
|
||||
|
|
Loading…
Reference in a new issue