Mobile App: Require encryption for registrations that support it (#21852)

## Description:

**Related issue (if applicable):** fixes #21758

## Checklist:
  - [x] The code change is tested and works locally.
  - [x] Local tests pass with `tox`. **Your PR cannot be merged unless tests pass**
  - [x] There is no commented out code in this PR.
This commit is contained in:
Robbie Trencheny authored and Paulus Schoutsen committed 2019-03-15 10:55:45 -07:00
1 parent 9e6a7a6357
commit b336322e9e
3 files changed
+32 -9

No files matched your search

@@ -149,3 +149,18 @@ async def test_webhook_handle_decryption(webhook_client): # noqa: F811
decrypted_data = decrypted_data.decode("utf-8")
assert json.loads(decrypted_data) == {'rendered': 'Hello world'}
async def test_webhook_requires_encryption(webhook_client): # noqa: F811
"""Test that encrypted registrations only accept encrypted data."""
resp = await webhook_client.post(
'/api/webhook/mobile_app_test',
json=RENDER_TEMPLATE
)
assert resp.status == 400
webhook_json = await resp.json()
assert 'error' in webhook_json
assert webhook_json['success'] is False
assert webhook_json['error']['code'] == 'encryption_required'