Add test case verifying no t= (timestamp) with x= (expiration) in signature
This commit is contained in:
@@ -0,0 +1,20 @@
|
|||||||
|
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple;
|
||||||
|
d=football.example.com; i=@football.example.com;
|
||||||
|
q=dns/txt; s=test; h=from : to : subject :
|
||||||
|
date : message-id : from : subject : date; x=100000000000;
|
||||||
|
bh=4bLNXImK9drULnmePzZNEBleUanJCX5PIsDIFoH4KTQ=;
|
||||||
|
b=icKcLSEZYXJ95flvWE8FT6hl5iqd8MC/LEKYH0QjsqYy6MO/4pgVNCZH
|
||||||
|
l/RAXAuADxE/40Fg7uTlxwwD1hjN2Ple6J//cJfslBdDOq6zTVbne1dqtl
|
||||||
|
NOat7iamJ1AfRqyG+ja7a2AZsrpUuJ7VA6O+0zRYPqpwMEkEFIzI9i/Xk=
|
||||||
|
From: Joe SixPack <joe@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?
|
||||||
|
|
||||||
|
Joe.
|
||||||
|
|
||||||
@@ -62,6 +62,7 @@ class TestSignAndVerify(unittest.TestCase):
|
|||||||
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.message7 = read_test_data("rfc6376.w1258.msg")
|
||||||
|
self.message8 = read_test_data("rfc6376.signed.no_t.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")
|
||||||
|
|
||||||
@@ -250,6 +251,7 @@ 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):
|
def test_non_utf8(self):
|
||||||
# A message with Windows-1258 encoding is signed and verifies.
|
# A message with Windows-1258 encoding is signed and verifies.
|
||||||
for header_algo in (b"simple", b"relaxed"):
|
for header_algo in (b"simple", b"relaxed"):
|
||||||
@@ -262,6 +264,13 @@ b/mPfjC0QJTocVBq6Za/PlzfV+Py92VaCak19F4WrbVTK5Gg5tW220MCAwEAAQ=="""
|
|||||||
# As of 1.1.0 this won't verify, but at least we don't crash. FIXME
|
# As of 1.1.0 this won't verify, but at least we don't crash. FIXME
|
||||||
self.assertFalse(res)
|
self.assertFalse(res)
|
||||||
|
|
||||||
|
def test_no_t(self):
|
||||||
|
# Signature Timestamp is optional, so don't crash if it's missing.
|
||||||
|
d = dkim.DKIM(self.message8)
|
||||||
|
res = d.verify(dnsfunc=self.dnsfunc5)
|
||||||
|
# Signature won't verify, but that's not what we are testing.
|
||||||
|
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.
|
||||||
d = dkim.DKIM(self.message5)
|
d = dkim.DKIM(self.message5)
|
||||||
|
|||||||
Reference in New Issue
Block a user