Skip to content

Commit

Permalink
CI: rename Python libmilter to miltertest
Browse files Browse the repository at this point in the history
  • Loading branch information
flowerysong committed Oct 13, 2024
1 parent d29d949 commit 94dbbc2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ jobs:
run: sudo apt update

- name: Install dependencies
run: sudo apt install libbsd-dev liblua5.4-dev libmilter-dev libssl-dev
run: sudo apt install libbsd-dev libmilter-dev libssl-dev

- name: Install Python dependencies
run: sudo pip install pytest git+https://github.com/flowerysong/python-libmilter#egg=libmilter
run: sudo pip install pytest miltertest

- name: Build OpenARC
run: |
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,11 @@ you will also need:

## Testing

Tests can be run with `make check`. OpenARC's test suite requires
Python >= 3.7, [pytest](https://pytest.org), and
[a Python library](https://github.com/flowerysong/python-libmilter).
Tests can be run with `make check`. OpenARC's test suite requires:

* Python >= 3.8
* [pytest](https://pytest.org)
* The Python [miltertest](https://pypi.org/project/miltertest/) library

## Additional Documentation

Expand Down
26 changes: 13 additions & 13 deletions test/test_milter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import socket

import libmilter
import miltertest
import pytest


Expand All @@ -22,29 +22,29 @@ def _run_miltertest(headers=None, standard_headers=True, body='test body\r\n'):
# Connect
sock = socket.socket(family=socket.AF_UNIX)
sock.connect(bytes(milter_config['sock']))
conn = libmilter.MilterConnection(sock)
conn.optneg_mta(protocol=libmilter.SMFI_V6_PROT ^ libmilter.SMFIP_HDR_LEADSPC)
conn.send(libmilter.SMFIC_CONNECT, hostname='localhost', address='127.0.0.1', family=libmilter.SMFIA_INET, port=666)
conn.send(libmilter.SMFIC_HELO, helo='mx.example.com')
conn = miltertest.MilterConnection(sock)
conn.optneg_mta(protocol=miltertest.SMFI_V6_PROT ^ miltertest.SMFIP_HDR_LEADSPC)
conn.send(miltertest.SMFIC_CONNECT, hostname='localhost', address='127.0.0.1', family=miltertest.SMFIA_INET, port=666)
conn.send(miltertest.SMFIC_HELO, helo='mx.example.com')

# Envelope data
conn.send(libmilter.SMFIC_MAIL, args=['<[email protected]>'])
conn.send(libmilter.SMFIC_RCPT, args=['<[email protected]>'])
conn.send(miltertest.SMFIC_MAIL, args=['<[email protected]>'])
conn.send(miltertest.SMFIC_RCPT, args=['<[email protected]>'])

# Send headers
conn.send(libmilter.SMFIC_DATA)
conn.send(miltertest.SMFIC_DATA)
conn.send_headers(headers)
conn.send(libmilter.SMFIC_EOH)
conn.send(miltertest.SMFIC_EOH)

# Send body
conn.send_body(body)
resp = conn.send_eom()
ins_headers = []
for msg in resp:
if msg[0] == libmilter.SMFIR_INSHEADER:
if msg[0] == miltertest.SMFIR_INSHEADER:
ins_headers.insert(msg[1]['index'], [msg[1]['name'], msg[1]['value']])
elif msg[0] in libmilter.DISPOSITION_REPLIES:
assert msg[0] == libmilter.SMFIR_ACCEPT
elif msg[0] in miltertest.DISPOSITION_REPLIES:
assert msg[0] == miltertest.SMFIR_ACCEPT
else:
pytest.fail(f'Unexpected EOM response {msg}')

Expand Down Expand Up @@ -215,5 +215,5 @@ def test_milter_ar_multi(run_miltertest):

def test_milter_peerlist(run_miltertest):
"""Connections from peers just get `accept` back immediately"""
with pytest.raises(libmilter.MilterError, match='unexpected response: a'):
with pytest.raises(miltertest.MilterError, match='unexpected response: a'):
run_miltertest()

0 comments on commit 94dbbc2

Please sign in to comment.