-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CI: test a static message generated with dkimpy
- Loading branch information
1 parent
a41cf9e
commit bd3e303
Showing
2 changed files
with
57 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,15 +8,16 @@ | |
|
||
@pytest.fixture | ||
def run_miltertest(request, milter, milter_config): | ||
def _run_miltertest(headers=None): | ||
def _run_miltertest(headers=None, standard_headers=True, body='test body\r\n'): | ||
headers = headers or [] | ||
headers.extend( | ||
[ | ||
['From', '[email protected]\n'], | ||
['Date', 'Fri, 04 Oct 2024 10:11:12 -0400'], | ||
['Subject', request.function.__name__], | ||
] | ||
) | ||
if standard_headers: | ||
headers.extend( | ||
[ | ||
['From', '[email protected]\n'], | ||
['Date', 'Fri, 04 Oct 2024 10:11:12 -0400'], | ||
['Subject', request.function.__name__], | ||
] | ||
) | ||
|
||
# Connect | ||
sock = socket.socket(family=socket.AF_UNIX) | ||
|
@@ -36,7 +37,7 @@ def _run_miltertest(headers=None): | |
conn.send(libmilter.SMFIC_EOH) | ||
|
||
# Send body | ||
conn.send_body('test body\r\n') | ||
conn.send_body(body) | ||
resp = conn.send_eom() | ||
ins_headers = [] | ||
for msg in resp: | ||
|
@@ -65,6 +66,44 @@ def test_milter_basic(run_miltertest): | |
assert res['headers'][3] == ['ARC-Authentication-Results', 'i=1; example.com; arc=none'] | ||
|
||
|
||
def test_milter_staticmsg(run_miltertest): | ||
headers = [ | ||
['ARC-Seal', ( | ||
'i=1; cv=none; a=rsa-sha256; d=dkimpy.example.com; s=sel;\r\n' | ||
' t=1728713840;\r\n' | ||
' b=jmHJmDXHe4eFAurv+yXz1RTRLj+XNaHedD4GYWPt0XntR94pMNSFlU2TxT0rzkMcE4Nkt\r\n' | ||
' xFrz0OYVfexpgNJ393tO8czBH4OwEwV2E5h+U/8N1vM+KHKfcg2n02SOxUa991Z1+CXUrO6\r\n' | ||
' lUnIx7gN+iz3x2muWG6hm6d1J0h4+yaQCuVlNImf3PM/M7l57GbfHvQpbYI9m4hf6IMncRS\r\n' | ||
' sOuXyTaH8NrWpqqM0KctxR4x+kC/Y3dKNYcL5VwbajlXletkmHO79sbuGD0HsK8HUdzfE1Z\r\n' | ||
' gGinobwxRu7skmTPq0TSlBQQ/1fuxpSOpocjnY+E/g3FH3ZsAtbOG2jVYd9w==' | ||
)], | ||
['ARC-Message-Signature', ( | ||
'i=1; a=rsa-sha256; c=relaxed/relaxed;\r\n' | ||
' d=dkimpy.example.com; s=sel; t=1728713840; h=content-type :\r\n' | ||
' mime-version : content-transfer-encoding : subject : from : to : from;\r\n' | ||
' bh=Pb6s/Xlf4u1eDlYyO0NCaMRMrCg6xDNkK5byz8RDY1s=;\r\n' | ||
' b=dmFKbeiAEsaA/gnLQyuRBcX72pvARuJMrZIptplgCGp9vqudMP2ngI/g8eo63nQYMB0md\r\n' | ||
' AaofYsl5lD8qE/B20FDgn66jTHQIGsPi0Fv06Mf45NaTFpeaEyexjZunYXSLao3RY5Cqtac\r\n' | ||
' m0BcCS/MaaiMBoDmcRa5GOzBi02coJG5IsDt+ZWT6P7nHQHrDNsuLBeJBX7+vJ0bM9QHbCE\r\n' | ||
' Q+eZZxcT7W2MWaByV2Jjz4B+sh0IzfX2wPNsGOsNpD+MvpehQsa9ig7eEndNWw7V1qpaMN+\r\n' | ||
' vtOnb5H80nu0K4H7fvrNUI4h4b+UTumqR/HhiNTFRobUGiwuvrP4CWHj3dtQ==\r\n' | ||
)], | ||
['ARC-Authentication-Results', 'i=1; dkimpy.example.com'], | ||
['Content-Type', 'text/plain; charset="us-ascii"'], | ||
['MIME-Version', '1.0'], | ||
['Content-Transfer-Encoding', '7bit'], | ||
['Subject', 'test message from dkimpy'], | ||
['From', '[email protected]'], | ||
['To', '[email protected]'], | ||
] | ||
res = run_miltertest(headers, False, 'test message\r\n') | ||
assert res['headers'][0] == ['Authentication-Results', 'example.com; arc=pass smtp.remote-ip=127.0.0.1'] | ||
assert res['headers'][1][0] == 'ARC-Seal' | ||
assert 'cv=pass' in res['headers'][1][1] | ||
assert res['headers'][2][0] == 'ARC-Message-Signature' | ||
assert res['headers'][3] == ['ARC-Authentication-Results', 'i=2; example.com; arc=pass'] | ||
|
||
|
||
def test_milter_resign(run_miltertest): | ||
"""Extend the chain as much as possible""" | ||
res = run_miltertest() | ||
|