Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial printing support for sd-export-usb #277

Merged
merged 6 commits into from
Jul 19, 2019
Merged

Conversation

emkll
Copy link
Contributor

@emkll emkll commented Jul 2, 2019

Functional testing

Note that for now this should only work with brother printers due to .ppd configuration that must be done within the dispVM itself. I will try to get my hands on other printer makes/models to support other vendors.

Testing should be very similar to that performed in #259, as the handler script is the same and the export archive format is the same

  • Specify persistent usb device in config.json (you can see which usb device is used by running qvm-usb in dom0)
  • Provision sd-export vms by either running make all or make sd-export with a printer connected to the configured usb
    In sd-svs:
  • create a .sd-export archive with export method in metadata.json set to "device": "printer-test"
  • qvm-open-in-vm sd-export-usb .sd-export
  • Printer settings appear, printer is selectable
  • Printer test page prints successfully
  • create a .sd-export archive with export method in metadata.json set to "device": "printer"
  • add some files under the export_data folder to be printed
  • qvm-open-in-vm sd-export-usb .sd-export
  • All files in export_data folder are printed
  • No files remain in /tmp/

App tests (for sd-export-usb)

  • create python3 vitualenv and install requirements
  • pytest sd-export/test-export.py
  • All tests pass

redshiftzero and others added 2 commits July 2, 2019 10:33
Provides inital support for printing files inside an `sd-export` archive sent to sd-export-usb. The format supports two actions:

* `"device": "printer-test"` will print the default printer test page.
* `"device": "printer" will print the documents in the archive.
@emkll emkll force-pushed the 267-printing branch 3 times, most recently from abe9697 to 5f1d51b Compare July 3, 2019 14:53
* Ensure more reliable and DRY parsing of sd-export metadata.json
* Use notify-send to provide user feedback on export status
README.md Outdated Show resolved Hide resolved
@eloquence
Copy link
Member

I understand that we'll likely want to treat each print job as blocking other print jobs for now. I'm still curious what happens in this proof-of-concept implementation if we don't.

What happens in this implementation if you kick off a job when one is already in progress? And one after that? Does the printer queue get cleared out? Do previous jobs get interrupted?

@emkll emkll force-pushed the 267-printing branch 2 times, most recently from 66015d1 to 7b344c6 Compare July 8, 2019 20:38
@emkll
Copy link
Contributor Author

emkll commented Jul 8, 2019

What happens in this implementation if you kick off a job when one is already in progress? And one after that? Does the printer queue get cleared out? Do previous jobs get interrupted?

No : because the Disposable VM is not shut down, the previous job remains in the printer queue, and sent to the printer. If another job is triggered, it will appended to the queue and be printed after the first one. Given the manual nature of the export flow at this point, it's very hard to effectively test for race conditions.

* Use xpp for printer settings menu prior to sending to printer, add applet for printing
* Poll lpinfo to wait for job to be sent before returning: lpinfo considers the job complete once the job was sent to the printer, and *not* when the print is completed.
* Convert openoffice files to pdf prior to printing, which requires openoffice to be installed. This will convert the openoffice document to pdf. Out of the box, lp/xpp/lpr cannot print openoffice/word files
* Delete extracted files from /tmp/ after printing.
…n.list

fpf-apt-test-repo.sls would append the repo URL to /etc/apt/sources.list.d/securedrop_workstation.list each time make * is called. This is because templates persist accross installs, and the source is added to the template. Using `clean_file: True` will ensure `/etc/apt/sources.list.d/securedrop_workstation.list` is squashed each time fpf-apt-test-repo.sls is invoked.
@emkll emkll marked this pull request as ready for review July 11, 2019 19:49
@zenmonkeykstop
Copy link
Contributor

zenmonkeykstop commented Jul 17, 2019

Followed instructions as given for setup.
manual testing
On sd-svs:
Created a .sd-export archive with export method in metadata.json set to "device": "printer-test" and ran qvm-open-in-vm sd-export-usb .sd-export

  • Printer settings appear, printer is selectable (PPD for specific printer not available but default Brother br7030.ppd worked)
  • Printer test page prints successfully

Created a .sd-export archive with export method in metadata.json set to "device": "printer" and added pdf and text files under the export_data folder to be printed, ran qvm-open-in-vm sd-export-usb .sd-export

  • All files in export_data folder are printed printer dialog appears for each document
  • No related files remain in /tmp/

app tests
Set up python3 virtualenv on sd-export-usb as follows:

sudo apt-get install python3-pip
sudo apt-get install python3-virtualenv
sudo apt-get install git
git clone -b 267-printing https://github.com/freedomofpress/securedrop-workstation && cd securedrop-workstation
python3 -m virtualenv -p python3 .
source ./bin/activate
pip install -r sd-export/test-requirements.txt
pytest -v sd-export/test_export.py

All 12 tests passed, 1 warning about the imp module's deprecation.

Looks good @emkll!

Copy link
Contributor

@zenmonkeykstop zenmonkeykstop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved based on test plan and diff review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants