Add test case for verification when should headers are signed (thanks to Geoffrey Lehée for the patch)

This commit is contained in:
Scott Kitterman
2017-03-02 19:08:27 -05:00
parent ccb067c32b
commit cdbb60841a
2 changed files with 12 additions and 0 deletions
+1
View File
@@ -1,6 +1,7 @@
UNRELEASED Version 0.6.2
- Fixed python3.4 string interpolation issue
- Fix some byte casting issues & typos
- Add test case for verification when should headers are signed
2017-01-27 Version 0.6.1
- Fixed python3 dns lookup issue
+11
View File
@@ -87,6 +87,17 @@ Y+vtSBczUiKERHv1yRbcaQtZFh5wtiRrN04BLUTD21MycBX5jYchHjPY/wIDAQAB"""
res = dkim.verify(sig + self.message, dnsfunc=self.dnsfunc)
self.assertTrue(res)
def test_simple_signature(self):
# A message verifies after being signed with SHOULD headers
for header_algo in (b"simple", b"relaxed"):
for body_algo in (b"simple", b"relaxed"):
sig = dkim.sign(
self.message, b"test", b"example.com", self.key,
canonicalize=(header_algo, body_algo),
include_headers=(b'from',) + dkim.DKIM.SHOULD)
res = dkim.verify(sig + self.message, dnsfunc=self.dnsfunc)
self.assertTrue(res)
def test_altered_body_fails(self):
# An altered body fails verification.
for header_algo in (b"simple", b"relaxed"):