Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Commit

Permalink
bug: Normalize encryption headers.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kit Cambridge committed Feb 25, 2016
1 parent 0f908cc commit b9c3cc5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion autopush/router/webpush.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ def _crypto_headers(self, notification):
# they're present to avoid empty strings.
for name in ["encryption-key", "crypto-key"]:
if name in headers:
data[name] = headers[name]
# Normalize hyphens in header names.
data[name.replace("-", "_")] = headers[name]
return data

@inlineCallbacks
Expand Down
4 changes: 4 additions & 0 deletions autopush/tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,10 @@ def test_webpush_data_delivery_to_disconnected_client(self):
chan = result["channelID"]
test = tests[chan]
eq_(result["data"], test["result"])
headers = result["headers"]
ok_("crypto_key" in headers)
ok_("encryption" in headers)
ok_("encoding" in headers)
yield client.ack(chan, result["version"])

yield self.shut_down(client)
Expand Down
2 changes: 1 addition & 1 deletion autopush/tests/test_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ def verify_deliver(result):
eq_(result.status_code, 201)
t_h = self.message_mock.store_message.call_args[1].get('headers')
eq_(t_h.get('encryption'), self.headers.get('encryption'))
eq_(t_h.get('crypto-key'), self.headers.get('crypto-key'))
eq_(t_h.get('crypto_key'), self.headers.get('crypto-key'))
eq_(t_h.get('encoding'), self.headers.get('content-encoding'))
self.router.metrics.increment.assert_called_with(
"router.broadcast.save_hit"
Expand Down

0 comments on commit b9c3cc5

Please sign in to comment.