Add failing test for missing VAPID key

This commit is contained in:
decentral1se 2021-04-15 15:06:37 +02:00
parent a0c0aa760d
commit c64d1029b4
Signed by: decentral1se
GPG Key ID: 92DAD76BD9567B8A

View File

@ -56,3 +56,23 @@ class TestAcceptSubscription(TestCase):
push_info = PushInformation.objects.get() push_info = PushInformation.objects.get()
self.assertEqual(push_info.user, self.user) self.assertEqual(push_info.user, self.user)
self.assertEqual(push_info.subscription, sub_info) self.assertEqual(push_info.subscription, sub_info)
def test_accept_sub_missing_vapid_key(self):
payload = {
"status_type": "subscribe",
"subscription": {
"endpoint": "https://hubl.example.com",
"keys": {
"auth": "front-end-generated-secret",
"p256dh": "INVALID-PUBLIC-KEY",
},
},
"browser": "firefox",
}
url = reverse("save_webpush_info")
response = self.client.post(
url, data=json.dumps(payload), content_type="application/json"
)
self.assertEqual(response.status_code, 403)