-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0676227
commit 45cbb91
Showing
10 changed files
with
157 additions
and
26 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
name: build | ||
on: | ||
push: | ||
pull_request: | ||
|
||
jobs: | ||
flake8: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install flake8 | ||
run: sudo pip install flake8 | ||
|
||
- name: Lint Python code | ||
run: flake8 --max-line-length=160 | ||
|
||
check: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v4 | ||
|
||
- name: apt update | ||
run: sudo apt update | ||
|
||
- name: Install dependencies | ||
run: sudo apt install libbsd-dev liblua5.4-dev libmilter-dev libssl-dev | ||
|
||
- name: Install Python dependencies | ||
run: sudo pip install pytest | ||
|
||
- name: Build OpenARC | ||
run: | | ||
autoreconf -fiv | ||
CFLAGS='-Wall' ./configure | ||
make -j4 | ||
- name: Check out miltertest | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: flowerysong/miltertest | ||
path: miltertest | ||
|
||
- name: Build miltertest | ||
run: | | ||
autoreconf -fiv | ||
./configure | ||
make | ||
working-directory: ${{ github.workspace }}/miltertest | ||
|
||
- name: Test OpenARC | ||
run: | | ||
make check | ||
- name: Build OpenARC with clang | ||
run: | | ||
make distclean | ||
CC=clang ./configure | ||
make -j4 | ||
- name: Build OpenARC without milter | ||
run: | | ||
make distclean | ||
CC=clang ./configure --disable-filter | ||
make -j4 |
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
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
__pycache__ |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
EXTRA_DIST = files pytest.ini *.py | ||
|
||
check: | ||
pytest -vv |
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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import os | ||
import subprocess | ||
|
||
import pytest | ||
|
||
|
||
@pytest.fixture() | ||
def private_key(scope='session'): | ||
filepath = os.path.dirname(os.path.realpath(__file__)) | ||
filepath = os.path.join(filepath, 'files', 'private.key') | ||
binargs = [ | ||
'openssl', | ||
'genrsa', | ||
'-out', filepath, | ||
'2048', | ||
] | ||
subprocess.run(binargs) | ||
|
||
|
||
@pytest.fixture() | ||
def tool_path(scope='session'): | ||
def _tool_path(tool): | ||
binpath = os.path.dirname(os.path.realpath(__file__)) | ||
binpath = os.path.join(binpath, '..', tool) | ||
return os.path.realpath(binpath) | ||
return _tool_path | ||
|
||
|
||
@pytest.fixture() | ||
def milter_config(request, private_key): | ||
base_path = os.path.join(request.fspath.dirname, 'files') | ||
for candidate in [ | ||
request.fspath.basename, # test file | ||
request.function.__name__, # test function | ||
]: | ||
fname = os.path.join(base_path, '.'.join([candidate, 'conf'])) | ||
if os.path.isfile(fname): | ||
return fname | ||
|
||
return os.path.join(base_path, 'milter.conf') | ||
|
||
|
||
@pytest.fixture() | ||
def milter_cmdline(tmp_path, tool_path, milter_config): | ||
return [ | ||
tool_path('openarc/openarc'), | ||
'-f', | ||
'-v', | ||
'-c', milter_config, | ||
'-p', tmp_path.joinpath('milter.sock'), | ||
] | ||
|
||
|
||
@pytest.fixture() | ||
def milter(milter_cmdline): | ||
milter_proc = subprocess.Popen(milter_cmdline) | ||
|
||
yield milter_proc | ||
|
||
milter_proc.terminate() |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Domain example.com | ||
KeyFile private.key | ||
Selector elpmaxe |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Domain example.com | ||
Selector elpmaxe |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[pytest] | ||
console_output_style = count | ||
log_file = pytest.log |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import subprocess | ||
|
||
|
||
def test_config(milter): | ||
pass | ||
|
||
|
||
def test_config_fail(milter_cmdline): | ||
res = subprocess.run(milter_cmdline, capture_output=True, text=True, timeout=4) | ||
assert res.returncode != 0 | ||
assert 'parameter "KeyFile" required when signing' in res.stderr |