def test_arc_sign_non_ascii_privkey(self):
        # Private Key contains non-ascii characters.
        config = Configuration()

        uni_keyfile = tempfile.NamedTemporaryFile(delete=True)
        uni_keyfile.write("¢¢¢¢¢¢¢".encode('utf-8'))
        uni_keyfile.flush()
        with ExitStack() as resources:

            fp = resources.enter_context(
                NamedTemporaryFile('w', encoding='utf-8'))
            print("""\
[ARC]
enabled: yes
authserv_id: lists.example.org
selector: dummy
domain: example.org
sig_headers: mime-version, date, from, to, subject
privkey: {}
""".format(uni_keyfile.name), file=fp)
            fp.flush()
            # Suppress warning messages in the test output.  Also, make sure
            # that the config.load() call doesn't break global state.
            resources.enter_context(mock.patch('sys.stderr'))
            resources.enter_context(mock.patch.object(config, '_clear'))
            resources.enter_context(self.assertRaises(SystemExit))
            config.load(fp.name)
Ejemplo n.º 2
0
    def test_path_expansion_infloop(self):
        # A path expansion never completes because it references a
        # non-existent substitution variable.
        fd, filename = tempfile.mkstemp()
        self.addCleanup(os.remove, filename)
        os.close(fd)
        with open(filename, 'w') as fp:
            print("""\
[paths.dev]
log_dir: $nopath/log_dir
""", file=fp)
        config = Configuration()
        # Suppress warning messages in the test output.
        with self.assertRaises(SystemExit) as cm, mock.patch('sys.stderr'):
            config.load(filename)
        self.assertEqual(cm.exception.args, (1,))
Ejemplo n.º 3
0
    def test_bad_path_layout_specifier(self):
        # Using a [mailman]layout name that doesn't exist is a fatal error.
        fd, filename = tempfile.mkstemp()
        self.addCleanup(os.remove, filename)
        os.close(fd)
        with open(filename, 'w') as fp:
            print("""\
[mailman]
layout: nonesuch
""", file=fp)
        # Use a fake sys.exit() function that records that it was called, and
        # that prevents further processing.
        config = Configuration()
        # Suppress warning messages in the test output.
        with self.assertRaises(SystemExit) as cm, mock.patch('sys.stderr'):
            config.load(filename)
        self.assertEqual(cm.exception.args, (1,))
Ejemplo n.º 4
0
    def test_bad_path_layout_specifier(self):
        # Using a [mailman]layout name that doesn't exist is a fatal error.
        config = Configuration()
        with ExitStack() as resources:
            fp = resources.enter_context(
                NamedTemporaryFile('w', encoding='utf-8'))
            print("""\
[mailman]
layout: nonesuch
""", file=fp)
            fp.flush()
            # Suppress warning messages in the test output.  Also, make sure
            # that the config.load() call doesn't break global state.
            resources.enter_context(mock.patch('sys.stderr'))
            resources.enter_context(mock.patch.object(config, '_clear'))
            cm = resources.enter_context(self.assertRaises(SystemExit))
            config.load(fp.name)
        self.assertEqual(cm.exception.args, (1,))
Ejemplo n.º 5
0
    def test_bad_path_layout_specifier(self):
        # Using a [mailman]layout name that doesn't exist is a fatal error.
        config = Configuration()
        with ExitStack() as resources:
            fp = resources.enter_context(
                NamedTemporaryFile('w', encoding='utf-8'))
            print("""\
[mailman]
layout: nonesuch
""", file=fp)
            fp.flush()
            # Suppress warning messages in the test output.  Also, make sure
            # that the config.load() call doesn't break global state.
            resources.enter_context(mock.patch('sys.stderr'))
            resources.enter_context(mock.patch.object(config, '_clear'))
            cm = resources.enter_context(self.assertRaises(SystemExit))
            config.load(fp.name)
        self.assertEqual(cm.exception.args, (1,))
Ejemplo n.º 6
0
    def test_path_expansion_infloop(self):
        # A path expansion never completes because it references a non-existent
        # substitution variable.
        config = Configuration()
        with ExitStack() as resources:
            fp = resources.enter_context(
                NamedTemporaryFile('w', encoding='utf-8'))
            print("""\
[paths.here]
log_dir: $nopath/log_dir
""", file=fp)
            fp.flush()
            # Suppress warning messages in the test output.  Also, make sure
            # that the config.load() call doesn't break global state.
            resources.enter_context(mock.patch('sys.stderr'))
            resources.enter_context(mock.patch.object(config, '_clear'))
            cm = resources.enter_context(self.assertRaises(SystemExit))
            config.load(fp.name)
        self.assertEqual(cm.exception.args, (1,))
Ejemplo n.º 7
0
    def test_path_expansion_infloop(self):
        # A path expansion never completes because it references a non-existent
        # substitution variable.
        config = Configuration()
        with ExitStack() as resources:
            fp = resources.enter_context(
                NamedTemporaryFile('w', encoding='utf-8'))
            print("""\
[paths.here]
log_dir: $nopath/log_dir
""", file=fp)
            fp.flush()
            # Suppress warning messages in the test output.  Also, make sure
            # that the config.load() call doesn't break global state.
            resources.enter_context(mock.patch('sys.stderr'))
            resources.enter_context(mock.patch.object(config, '_clear'))
            cm = resources.enter_context(self.assertRaises(SystemExit))
            config.load(fp.name)
        self.assertEqual(cm.exception.args, (1,))
Ejemplo n.º 8
0
    def test_config_template_dir_is_source(self):
        # This test will leave a 'var' directory in the top-level source
        # directory.  Be sure to clean it up.
        config = Configuration()
        with ExitStack() as resources:
            fp = resources.enter_context(
                NamedTemporaryFile('w', encoding='utf-8'))
            var_dir = resources.enter_context(TemporaryDirectory())
            # Don't let the post-processing after the config.load() to put a
            # 'var' directory in the source tree's top level directory.
            print("""\
[paths.here]
template_dir: :source:
var_dir: {}
""".format(var_dir), file=fp)
            fp.flush()
            config.load(fp.name)
        import mailman.templates
        self.assertEqual(config.TEMPLATE_DIR,
                         os.path.dirname(mailman.templates.__file__))
Ejemplo n.º 9
0
    def test_path_expansion_infloop(self):
        # A path expansion never completes because it references a non-existent
        # substitution variable.
        fd, filename = tempfile.mkstemp()
        self.addCleanup(os.remove, filename)
        os.close(fd)
        with open(filename, 'w') as fp:
            print("""\
[paths.here]
log_dir: $nopath/log_dir
""", file=fp)
        config = Configuration()
        # Suppress warning messages in the test output.  Also, make sure that
        # the config.load() call doesn't break global state.
        with ExitStack() as resources:
            resources.enter_context(mock.patch('sys.stderr'))
            resources.enter_context(mock.patch.object(config, '_clear'))
            cm = resources.enter_context(self.assertRaises(SystemExit))
            config.load(filename)
        self.assertEqual(cm.exception.args, (1,))
Ejemplo n.º 10
0
    def test_config_template_dir_is_source(self):
        # This test will leave a 'var' directory in the top-level source
        # directory.  Be sure to clean it up.
        config = Configuration()
        with ExitStack() as resources:
            fp = resources.enter_context(
                NamedTemporaryFile('w', encoding='utf-8'))
            var_dir = resources.enter_context(TemporaryDirectory())
            # Don't let the post-processing after the config.load() to put a
            # 'var' directory in the source tree's top level directory.
            print("""\
[paths.here]
template_dir: :source:
var_dir: {}
""".format(var_dir), file=fp)
            fp.flush()
            config.load(fp.name)
        import mailman.templates
        self.assertEqual(config.TEMPLATE_DIR,
                         os.path.dirname(mailman.templates.__file__))
Ejemplo n.º 11
0
    def test_path_expansion_infloop(self):
        # A path expansion never completes because it references a non-existent
        # substitution variable.
        fd, filename = tempfile.mkstemp()
        self.addCleanup(os.remove, filename)
        os.close(fd)
        with open(filename, 'w') as fp:
            print("""\
[paths.here]
log_dir: $nopath/log_dir
""", file=fp)
        config = Configuration()
        # Suppress warning messages in the test output.  Also, make sure that
        # the config.load() call doesn't break global state.
        with ExitStack() as resources:
            resources.enter_context(mock.patch('sys.stderr'))
            resources.enter_context(mock.patch.object(config, '_clear'))
            cm = resources.enter_context(self.assertRaises(SystemExit))
            config.load(filename)
        self.assertEqual(cm.exception.args, (1, ))
Ejemplo n.º 12
0
    def test_bad_path_layout_specifier(self):
        # Using a [mailman]layout name that doesn't exist is a fatal error.
        fd, filename = tempfile.mkstemp()
        self.addCleanup(os.remove, filename)
        os.close(fd)
        with open(filename, 'w') as fp:
            print("""\
[mailman]
layout: nonesuch
""", file=fp)
        # Use a fake sys.exit() function that records that it was called, and
        # that prevents further processing.
        config = Configuration()
        # Suppress warning messages in the test output.  Also, make sure that
        # the config.load() call doesn't break global state.
        with ExitStack() as resources:
            resources.enter_context(mock.patch('sys.stderr'))
            resources.enter_context(mock.patch.object(config, '_clear'))
            cm = resources.enter_context(self.assertRaises(SystemExit))
            config.load(filename)
        self.assertEqual(cm.exception.args, (1, ))
Ejemplo n.º 13
0
    def test_bad_path_layout_specifier(self):
        # Using a [mailman]layout name that doesn't exist is a fatal error.
        fd, filename = tempfile.mkstemp()
        self.addCleanup(os.remove, filename)
        os.close(fd)
        with open(filename, 'w') as fp:
            print("""\
[mailman]
layout: nonesuch
""", file=fp)
        # Use a fake sys.exit() function that records that it was called, and
        # that prevents further processing.
        config = Configuration()
        # Suppress warning messages in the test output.  Also, make sure that
        # the config.load() call doesn't break global state.
        with ExitStack() as resources:
            resources.enter_context(mock.patch('sys.stderr'))
            resources.enter_context(mock.patch.object(config, '_clear'))
            cm = resources.enter_context(self.assertRaises(SystemExit))
            config.load(filename)
        self.assertEqual(cm.exception.args, (1,))
    def test_arc_enabled_but_wrong_file(self):
        # Unreadable private key when ARC is enabled.
        config = Configuration()
        with ExitStack() as resources:
            fp = resources.enter_context(
                NamedTemporaryFile('w', encoding='utf-8'))
            print("""\
[ARC]
enabled: yes
authserv_id: lists.example.org
selector: dummy
domain: example.org
sig_headers: mime-version, date, from, to, subject
privkey: /missing/location.pem
""", file=fp)
            fp.flush()
            # Suppress warning messages in the test output.  Also, make sure
            # that the config.load() call doesn't break global state.
            resources.enter_context(mock.patch('sys.stderr'))
            resources.enter_context(mock.patch.object(config, '_clear'))
            resources.enter_context(self.assertRaises(SystemExit))
            config.load(fp.name)
    def test_arc_missing_from_in_headers(self):
        # List of sig_headers should always include "From" header, otherwise,
        # exception is raised when signing a message.
        config = Configuration()

        with ExitStack() as resources:
            fp = resources.enter_context(
                NamedTemporaryFile('w', encoding='utf-8'))
            print("""\
[ARC]
enabled: yes
authserv_id: lists.example.org
selector: dummy
domain: example.org
sig_headers: to, subject, date
privkey: {}
""".format(self.keyfile.name), file=fp)
            fp.flush()
            # Suppress warning messages in the test output.  Also, make sure
            # that the config.load() call doesn't break global state.
            resources.enter_context(mock.patch('sys.stderr'))
            resources.enter_context(mock.patch.object(config, '_clear'))
            resources.enter_context(self.assertRaises(SystemExit))
            config.load(fp.name)
Ejemplo n.º 16
0
# Copyright (C) 2008-2021 by the Free Software Foundation, Inc.
#
# This file is part of GNU Mailman.
#
# GNU Mailman is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option)
# any later version.
#
# GNU Mailman 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 General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along with
# GNU Mailman.  If not, see <https://www.gnu.org/licenses/>.

"""Mailman configuration package."""

from mailman.config.config import Configuration
from public import public


public(config=Configuration())
Ejemplo n.º 17
0
# Copyright (C) 2008-2015 by the Free Software Foundation, Inc.
#
# This file is part of GNU Mailman.
#
# GNU Mailman is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option)
# any later version.
#
# GNU Mailman 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 General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along with
# GNU Mailman.  If not, see <http://www.gnu.org/licenses/>.
"""Mailman configuration package."""

__all__ = [
    'config',
]

from mailman.config.config import Configuration

config = Configuration()