Reformat code with automated tools

Apply standardized code style
This commit is contained in:
medmunds
2023-02-06 12:27:43 -08:00
committed by Mike Edmunds
parent 40891fcb4a
commit b4e22c63b3
94 changed files with 12936 additions and 7443 deletions

View File

@@ -6,10 +6,8 @@ from tests.utils import ClientWithCsrfChecks
HAS_CRYPTOGRAPHY = True
try:
from cryptography.hazmat.primitives.asymmetric import rsa
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.asymmetric import padding
from cryptography.hazmat.primitives import hashes, serialization
from cryptography.hazmat.primitives.asymmetric import padding, rsa
except ImportError:
HAS_CRYPTOGRAPHY = False
@@ -24,14 +22,14 @@ def make_key():
def derive_public_webhook_key(private_key):
"""Derive public """
"""Derive public"""
public_key = private_key.public_key()
public_bytes = public_key.public_bytes(
encoding=serialization.Encoding.PEM,
format=serialization.PublicFormat.SubjectPublicKeyInfo
format=serialization.PublicFormat.SubjectPublicKeyInfo,
)
public_bytes = b'\n'.join(public_bytes.splitlines()[1:-1])
return public_bytes.decode('utf-8')
public_bytes = b"\n".join(public_bytes.splitlines()[1:-1])
return public_bytes.decode("utf-8")
def sign(private_key, message):
@@ -47,11 +45,11 @@ class _ClientWithPostalSignature(ClientWithCsrfChecks):
self.private_key = private_key
def post(self, *args, **kwargs):
signature = b64encode(sign(self.private_key, kwargs['data'].encode('utf-8')))
kwargs.setdefault('HTTP_X_POSTAL_SIGNATURE', signature)
signature = b64encode(sign(self.private_key, kwargs["data"].encode("utf-8")))
kwargs.setdefault("HTTP_X_POSTAL_SIGNATURE", signature)
webhook_key = derive_public_webhook_key(self.private_key)
with override_settings(ANYMAIL={'POSTAL_WEBHOOK_KEY': webhook_key}):
with override_settings(ANYMAIL={"POSTAL_WEBHOOK_KEY": webhook_key}):
return super().post(*args, **kwargs)