Files
smtprd-ng/tests/test_smtprd_ng.py
2024-07-06 12:58:50 +02:00

47 lines
1.7 KiB
Python

# SMTP forwarding relay daemon with signing and encryption
#
# Copyright (C) 2024 F. Brandes (additions to original code)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
Tests for smtprd_ng
"""
# pylint: disable=protected-access
import configparser
from pathlib import Path
from smtprd_ng import smtprd
def test_config_from_config():
"""Test opening and readig the config file"""
config_parser: configparser.ConfigParser = configparser.ConfigParser()
with open(Path("config.example"), "r", encoding="utf8") as fp:
config_parser.read_file(fp)
cfg = smtprd.Config._from_config(config_parser)
assert cfg.server.hostname == "localhost"
assert cfg.client.port == 465
assert cfg.client.smime_cert == ""
def test_config_from_ini():
"""Test parsing the config file and using fallbacks"""
cfg = smtprd.Config.from_ini(Path("config.example"))
assert cfg.server.hostname == "localhost"
assert cfg.client.port == 465
assert cfg.client.smime_cert == ""
assert cfg.client.use_tls is True