File tree Expand file tree Collapse file tree 2 files changed +15
-6
lines changed Expand file tree Collapse file tree 2 files changed +15
-6
lines changed Original file line number Diff line number Diff line change 11import json
2- import unittest
32from base64 import b64encode
43from unittest .mock import ANY
54
65from django .test import tag
76
87from anymail .signals import AnymailTrackingEvent
98from anymail .webhooks .mailpace import MailPaceTrackingWebhookView
9+ from tests .utils import ClientWithCsrfChecks
1010
1111from .utils_mailpace import ClientWithMailPaceSignature , make_key
1212from .webhook_cases import WebhookTestCase
1313
14+ # These tests are triggered both with and without 'pynacl' installed,
15+ # if pynacl is unavailable, we use the ClientWithCsrfChecks class
16+ try :
17+ from nacl .signing import SigningKey
18+
19+ PYNACL_INSTALLED = bool (SigningKey )
20+ except ImportError :
21+ PYNACL_INSTALLED = False
22+
1423
1524@tag ("mailpace" )
16- @unittest .skipUnless (
17- ClientWithMailPaceSignature , "Install 'pynacl' to run mailpace webhook tests"
18- )
1925class MailPaceWebhookSecurityTestCase (WebhookTestCase ):
2026 client_class = ClientWithMailPaceSignature
2127
@@ -53,7 +59,10 @@ def test_failed_signature_check(self):
5359
5460@tag ("mailpace" )
5561class MailPaceDeliveryTestCase (WebhookTestCase ):
56- client_class = ClientWithMailPaceSignature
62+ if PYNACL_INSTALLED :
63+ client_class = ClientWithMailPaceSignature
64+ else :
65+ client_class = ClientWithCsrfChecks
5766
5867 def setUp (self ):
5968 super ().setUp ()
Original file line number Diff line number Diff line change 88 from nacl .signing import SigningKey
99except ImportError :
1010 # This will be raised if signing is attempted (and pynacl wasn't found)
11- VerifyKey = _LazyError (
11+ SigningKey = _LazyError (
1212 AnymailImproperlyInstalled (missing_package = "pynacl" , install_extra = "mailpace" )
1313 )
1414
You can’t perform that action at this time.
0 commit comments