Skip to content

Commit

Permalink
Proxy the job owner from google to CUPS
Browse files Browse the repository at this point in the history
Google gives us a ownerId and if we set job-originating-user-name CUPS
will display the user's email address as the other in the print queue.
  • Loading branch information
armooo committed Jan 28, 2017
1 parent a6ecfbd commit 108b9f0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions cloudprint/cloudprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ def process_job(cups_connection, cpp, printer, job):
del options['request']

options = dict((str(k), str(v)) for k, v in list(options.items()))
options['job-originating-user-name'] = job['ownerId']

# Cap the title length to 255, or cups will complain about invalid
# job-name
Expand Down
4 changes: 4 additions & 0 deletions test/test_process_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def test_print(requests, cups, cpp, xmpp_conn):
'ticketUrl': 'http://ticket',
'title': '*' * 300,
'id': 'job_1',
'ownerId': 'owner@example.com'
}]

xmpp_conn.is_connected.return_value = True
Expand All @@ -43,6 +44,7 @@ def test_print(requests, cups, cpp, xmpp_conn):
{
'a': '1',
'b': '2',
'job-originating-user-name': 'owner@example.com',
},
)
cpp.finish_job.assert_called_with('job_1')
Expand All @@ -59,6 +61,7 @@ def test_retry(requests, cups, cpp, xmpp_conn):
'ticketUrl': 'http://ticket',
'title': '*' * 300,
'id': 'job_1',
'ownerId': 'owner@example.com'
}]

requests.get(url='http://print_job.pdf', status_code=500)
Expand All @@ -77,6 +80,7 @@ def test_failed(requests, cups, cpp, xmpp_conn):
'ticketUrl': 'http://ticket',
'title': '*' * 300,
'id': 'job_1',
'ownerId': 'owner@example.com'
}]

requests.get(url='http://print_job.pdf', status_code=500)
Expand Down

0 comments on commit 108b9f0

Please sign in to comment.