Skip to content
This repository has been archived by the owner on May 20, 2024. It is now read-only.

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
nicksellen committed Oct 10, 2023
1 parent cf0cc74 commit 7b119c4
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 59 deletions.
27 changes: 0 additions & 27 deletions karrot/management/commands/send_push.py

This file was deleted.

24 changes: 0 additions & 24 deletions karrot/subscriptions/factories.py
@@ -1,34 +1,10 @@
import base64
import os

from factory import LazyAttribute, SubFactory
from factory.django import DjangoModelFactory

from karrot.subscriptions.models import WebPushSubscription
from karrot.users.factories import UserFactory
from cryptography.hazmat.primitives.asymmetric import ec
from cryptography.hazmat.backends import default_backend
from karrot.utils.tests.fake import faker

TEST_VAPID_PRIVATE_KEY = (
"MHcCAQEEIPeN1iAipHbt8+/KZ2NIF8NeN24jqAmnMLFZEMocY8RboAoGCCqGSM49"
"AwEHoUQDQgAEEJwJZq/GN8jJbo1GGpyU70hmP2hbWAUpQFKDByKB81yldJ9GTklB"
"M5xqEwuPM7VuQcyiLDhvovthPIXx+gsQRQ=="
)


# Adapted from https://github.com/web-push-libs/pywebpush/blob/992efed89454629e741f8540f690bef681b17f2d/pywebpush/tests/test_webpush.py#L27
def _gen_subscription_info(self, recv_key=None, endpoint="https://example.com/"):
if not recv_key:
recv_key = ec.generate_private_key(ec.SECP256R1, default_backend())
return {
"endpoint": endpoint,
"keys": {
'auth': base64.urlsafe_b64encode(os.urandom(16)).strip(b'='),
'p256dh': self._get_pubkey_str(recv_key),
}
}


class WebPushSubscriptionFactory(DjangoModelFactory):
class Meta:
Expand Down
9 changes: 1 addition & 8 deletions karrot/users/factories.py
Expand Up @@ -5,13 +5,6 @@
from karrot.utils.tests.fake import faker


def set_password(obj, *args, **kwargs_):
if hasattr(obj, 'set_password'):
obj.set_password(obj.display_name)
else:
print('HMMM', obj)


class UserFactory(DjangoModelFactory):
class Meta:
model = get_user_model()
Expand All @@ -25,7 +18,7 @@ class Meta:
description = LazyAttribute(lambda _: faker.text())

# Use display_name as password, as it is readable
password = PostGeneration(set_password)
password = PostGeneration(lambda obj, *args, **kwargs: obj.set_password(obj.display_name))

@classmethod
def _create(cls, model_class, *args, **kwargs):
Expand Down

0 comments on commit 7b119c4

Please sign in to comment.