This repository has been archived on 2021-04-21. You can view files and clone it, but cannot push or open issues or pull requests.
djangoldp-webpushnotification/djangoldp_webpushnotification/tests/tests_vapidkeyset.py

15 lines
501 B
Python
Raw Normal View History

from base64 import urlsafe_b64encode
2021-04-07 14:51:55 +00:00
from django.test import TestCase
from djangoldp_webpushnotification.models import VAPIDKeyset
2021-04-15 12:28:34 +00:00
from ecdsa import NIST256p, SigningKey
2021-04-07 14:51:55 +00:00
2021-04-08 14:29:40 +00:00
class TestVAPIDKeySet(TestCase):
def test_vapidkeyset_public_key(self):
2021-04-15 12:28:34 +00:00
priv_key = SigningKey.generate(curve=NIST256p)
vapid_key_set = VAPIDKeyset.objects.create(
2021-04-15 12:28:34 +00:00
private_key=urlsafe_b64encode(priv_key.to_string()).strip(b"=")
)
assert isinstance(vapid_key_set.public_key, bytes)