Add test test_non_utf8 which at least demonstrates not crashing on non UTF-8 data
This commit is contained in:
@@ -0,0 +1,12 @@
|
|||||||
|
From: Tomá? SixPack <Tomá?@football.example.com>
|
||||||
|
To: Suzie Q <suzie@shopping.example.net>
|
||||||
|
Subject: Is dinner ready?
|
||||||
|
Date: Fri, 11 Jul 2003 21:00:37 -0700 (PDT)
|
||||||
|
Message-ID: <20030712040037.46341.5F8J@football.example.com>
|
||||||
|
|
||||||
|
Hi.
|
||||||
|
|
||||||
|
We lost the game. Are you hungry yet?
|
||||||
|
|
||||||
|
Tomá?.
|
||||||
|
|
||||||
@@ -61,6 +61,7 @@ class TestSignAndVerify(unittest.TestCase):
|
|||||||
self.message4 = read_test_data("rfc6376.signed.msg")
|
self.message4 = read_test_data("rfc6376.signed.msg")
|
||||||
self.message5 = read_test_data("rfc6376.signed.rsa.msg")
|
self.message5 = read_test_data("rfc6376.signed.rsa.msg")
|
||||||
self.message6 = read_test_data("test.message.baddomain")
|
self.message6 = read_test_data("test.message.baddomain")
|
||||||
|
self.message7 = read_test_data("rfc6376.w1258.msg")
|
||||||
self.key = read_test_data("test.private")
|
self.key = read_test_data("test.private")
|
||||||
self.rfckey = read_test_data("rfc8032_7_1.key")
|
self.rfckey = read_test_data("rfc8032_7_1.key")
|
||||||
|
|
||||||
@@ -249,6 +250,17 @@ b/mPfjC0QJTocVBq6Za/PlzfV+Py92VaCak19F4WrbVTK5Gg5tW220MCAwEAAQ=="""
|
|||||||
d = dkim.DKIM(self.message4)
|
d = dkim.DKIM(self.message4)
|
||||||
res = d.verify(dnsfunc=self.dnsfunc5)
|
res = d.verify(dnsfunc=self.dnsfunc5)
|
||||||
self.assertTrue(res)
|
self.assertTrue(res)
|
||||||
|
def test_non_utf8(self):
|
||||||
|
# A message with Windows-1258 encoding is signed and verifies.
|
||||||
|
for header_algo in (b"simple", b"relaxed"):
|
||||||
|
for body_algo in (b"simple", b"relaxed"):
|
||||||
|
sig = dkim.sign(
|
||||||
|
self.message7, b"test", b"football.example.com", self.key,
|
||||||
|
canonicalize=(header_algo, body_algo), signature_algorithm=b'rsa-sha256')
|
||||||
|
d = dkim.DKIM(self.message7)
|
||||||
|
res = d.verify(dnsfunc=self.dnsfunc5)
|
||||||
|
# As of 1.1.0 this won't verify, but at least we don't crash. FIXME
|
||||||
|
self.assertFalse(res)
|
||||||
|
|
||||||
def test_catch_bad_key(self):
|
def test_catch_bad_key(self):
|
||||||
# Raise correct error for defective public key.
|
# Raise correct error for defective public key.
|
||||||
|
|||||||
Reference in New Issue
Block a user