Ejemplo n.º 1
0
 def setUp(self):
     self._ant = create_list('*****@*****.**')
     self._bee = create_list('*****@*****.**')
     user_manager = getUtility(IUserManager)
     self._anne = user_manager.make_user(
         '*****@*****.**', 'Anne Person')
     set_preferred(self._anne)
Ejemplo n.º 2
0
    def test_two_lists(self):
        # Both lists need to show up in the aliases file.  LP: #874929.
        # Create a second list.
        create_list("*****@*****.**")
        self.postfix.regenerate(self.output)
        # Strip out the variable and unimportant bits of the output.
        lines = self.output.getvalue().splitlines()
        output = NL.join(lines[7:])
        self.eq(
            output,
            """\
# Aliases which are visible only in the @example.com domain.
[email protected]               lmtp:[127.0.0.1]:9024
[email protected]       lmtp:[127.0.0.1]:9024
[email protected]       lmtp:[127.0.0.1]:9024
[email protected]          lmtp:[127.0.0.1]:9024
[email protected]         lmtp:[127.0.0.1]:9024
[email protected]         lmtp:[127.0.0.1]:9024
[email protected]       lmtp:[127.0.0.1]:9024
[email protected]     lmtp:[127.0.0.1]:9024
[email protected]   lmtp:[127.0.0.1]:9024

[email protected]               lmtp:[127.0.0.1]:9024
[email protected]       lmtp:[127.0.0.1]:9024
[email protected]       lmtp:[127.0.0.1]:9024
[email protected]          lmtp:[127.0.0.1]:9024
[email protected]         lmtp:[127.0.0.1]:9024
[email protected]         lmtp:[127.0.0.1]:9024
[email protected]       lmtp:[127.0.0.1]:9024
[email protected]     lmtp:[127.0.0.1]:9024
[email protected]   lmtp:[127.0.0.1]:9024
""",
        )
Ejemplo n.º 3
0
 def test_lists_are_deleted_when_domain_is_deleted(self):
     # /domains/<domain> DELETE removes all associated mailing lists.
     with transaction():
         create_list("*****@*****.**")
     content, response = call_api("http://*****:*****@example.com"))
Ejemplo n.º 4
0
 def setUp(self):
     self._ant = create_list('*****@*****.**')
     self._bee = create_list('*****@*****.**')
     user_manager = getUtility(IUserManager)
     self._anne = user_manager.create_user('*****@*****.**')
     preferred = list(self._anne.addresses)[0]
     preferred.verified_on = now()
     self._anne.preferred_address = preferred
Ejemplo n.º 5
0
 def test_cannot_create_duplicate_list(self):
     # Cannot create a mailing list if it already exists.
     create_list('*****@*****.**')
     self.args.listname = ['*****@*****.**']
     with suppress(SystemExit):
         self.command.process(self.args)
     self.assertEqual(self.command.parser.message,
                      'List already exists: [email protected]')
Ejemplo n.º 6
0
 def setUp(self):
     self._ant = create_list("*****@*****.**")
     self._bee = create_list("*****@*****.**")
     user_manager = getUtility(IUserManager)
     self._anne = user_manager.make_user("*****@*****.**", "Anne Person")
     preferred = list(self._anne.addresses)[0]
     preferred.verified_on = now()
     self._anne.preferred_address = preferred
Ejemplo n.º 7
0
 def test_cant_get_other_lists_holds(self):
     # Issue #161: It was possible to moderate a held message for another
     # list via the REST API.
     with transaction():
         held_id = hold_message(self._mlist, self._msg)
         create_list("*****@*****.**")
     with self.assertRaises(HTTPError) as cm:
         call_api("http://localhost:9001/3.0/lists/bee.example.com" "/held/{}".format(held_id))
     self.assertEqual(cm.exception.code, 404)
Ejemplo n.º 8
0
 def test_absorb_memberships(self):
     # When a user is absorbed, all of their user-subscribed memberships
     # are relinked to the absorbing user.
     mlist2 = create_list('*****@*****.**')
     mlist3 = create_list('*****@*****.**')
     with transaction():
         # This has to happen in a transaction so that both the user and
         # the preferences objects get valid ids.
         bart = self._manager.create_user('*****@*****.**', 'Bart Person')
         set_preferred(bart)
     # Subscribe both users to self._mlist.
     self._mlist.subscribe(self._anne, MemberRole.member)
     self._mlist.subscribe(bart, MemberRole.moderator)
     # Subscribe only Bart to mlist2.
     mlist2.subscribe(bart, MemberRole.owner)
     # Subscribe only Bart's address to mlist3.
     mlist3.subscribe(bart.preferred_address, MemberRole.moderator)
     # There are now 4 memberships, one with Anne two with Bart's user and
     # one with Bart's address.
     all_members = list(self._manager.members)
     self.assertEqual(len(all_members), 4, all_members)
     # Do the absorption.
     self._anne.absorb(bart)
     # The Bart user has been deleted, leaving only the Anne user in the
     # user manager.
     all_users = list(self._manager.users)
     self.assertEqual(len(all_users), 1)
     self.assertEqual(all_users[0], self._anne)
     # There are no leftover memberships for user Bart.  Anne owns all the
     # memberships.
     all_members = list(self._manager.members)
     self.assertEqual(len(all_members), 4, all_members)
     self.assertEqual(self._anne.memberships.member_count, 4)
     memberships = {(member.list_id, member.role): member
                    for member in self._anne.memberships.members}
     # Note that Anne is now both a member and moderator of the test list.
     self.assertEqual(set(memberships), set([
         ('test.example.com', MemberRole.member),
         ('test.example.com', MemberRole.moderator),
         ('test2.example.com', MemberRole.owner),
         ('test3.example.com', MemberRole.moderator),
         ]))
     # Both of Bart's previous user subscriptions are now transferred to
     # the Anne user.
     self.assertEqual(
         memberships[('test.example.com', MemberRole.moderator)].address,
         self._anne.preferred_address)
     self.assertEqual(
         memberships[('test2.example.com', MemberRole.owner)].address,
         self._anne.preferred_address)
     # Bart's address was subscribed; it must not have been changed.  Of
     # course, Anne now controls [email protected].
     key = ('test3.example.com', MemberRole.moderator)
     self.assertEqual(memberships[key].address.email, '*****@*****.**')
     self.assertEqual(self._manager.get_user('*****@*****.**'),
                      self._anne)
Ejemplo n.º 9
0
 def test_interact_overrides(self):
     create_list('*****@*****.**')
     bee = create_list('*****@*****.**')
     results = []
     fp = self._enter(NamedTemporaryFile('w', encoding='utf-8'))
     self._enter(hackenv('PYTHONSTARTUP', fp.name))
     print('results.append(mlist.list_id)', file=fp)
     fp.flush()
     interact(overrides=dict(mlist=bee))
     self.assertEqual(results, [bee.list_id])
Ejemplo n.º 10
0
    def test_issue140(self):
        # Non-UTF-8 data sent to the LMTP server crashes it.
        with transaction():
            create_list('*****@*****.**')
        self._lmtp.sendmail('*****@*****.**', ['*****@*****.**'], b"""\
From: [email protected]
To: [email protected]
Subject: My subject
Message-ID: <alpha>

\xa0
""")
        items = get_queue_messages('in', expected_count=1)
        self.assertEqual(items[0].msg['message-id'], '<alpha>')
Ejemplo n.º 11
0
    def test_lp1117176(self):
        # Upper cased list names can't be sent to via LMTP.
        with transaction():
            create_list('*****@*****.**')
        self._lmtp.sendmail('*****@*****.**', ['*****@*****.**'], """\
From: [email protected]
To: [email protected]
Subject: My subject
Message-ID: <alpha>

""")
        items = get_queue_messages('in', expected_count=1)
        self.assertEqual(items[0].msgdata['listid'],
                         'my-list.example.com')
Ejemplo n.º 12
0
    def test_two_lists_two_domains(self):
        # Now we have two lists in two different domains.  Both lists will
        # show up in the postfix_lmtp file, and both domains will show up in
        # the postfix_domains file.
        getUtility(IDomainManager).add("example.net")
        create_list("*****@*****.**")
        self.postfix.regenerate(self.tempdir)
        # There are two files in this directory.
        self.assertEqual(sorted(os.listdir(self.tempdir)), ["postfix_domains", "postfix_lmtp"])
        # Because both lists are in the same domain, there should be only one
        # entry in the relays file.
        with open(os.path.join(self.tempdir, "postfix_domains")) as fp:
            contents = _strip_header(fp.read())
        self.assertMultiLineEqual(
            contents,
            """\
example.com example.com
example.net example.net
""",
        )
        # The transport file contains entries for both lists.
        with open(os.path.join(self.tempdir, "postfix_lmtp")) as fp:
            contents = _strip_header(fp.read())
        self.assertMultiLineEqual(
            contents,
            """\
# Aliases which are visible only in the @example.com domain.
[email protected]               lmtp:[127.0.0.1]:9024
[email protected]       lmtp:[127.0.0.1]:9024
[email protected]       lmtp:[127.0.0.1]:9024
[email protected]          lmtp:[127.0.0.1]:9024
[email protected]         lmtp:[127.0.0.1]:9024
[email protected]         lmtp:[127.0.0.1]:9024
[email protected]       lmtp:[127.0.0.1]:9024
[email protected]     lmtp:[127.0.0.1]:9024
[email protected]   lmtp:[127.0.0.1]:9024

# Aliases which are visible only in the @example.net domain.
[email protected]               lmtp:[127.0.0.1]:9024
[email protected]       lmtp:[127.0.0.1]:9024
[email protected]       lmtp:[127.0.0.1]:9024
[email protected]          lmtp:[127.0.0.1]:9024
[email protected]         lmtp:[127.0.0.1]:9024
[email protected]         lmtp:[127.0.0.1]:9024
[email protected]       lmtp:[127.0.0.1]:9024
[email protected]     lmtp:[127.0.0.1]:9024
[email protected]   lmtp:[127.0.0.1]:9024
""",
        )
Ejemplo n.º 13
0
    def test_mailing_list_with_subaddress(self):
        # A mailing list with a subaddress in its name should be recognized as
        # the mailing list, not as a command.
        with transaction():
            create_list('*****@*****.**')
        self._lmtp.sendmail('*****@*****.**', ['*****@*****.**'], """\
From: [email protected]
To: [email protected]
Message-ID: <ant>
Subject: This should not be recognized as a join command

""")
        # The message is in the incoming queue but not the command queue.
        get_queue_messages('in', expected_count=1)
        get_queue_messages('command', expected_count=0)
Ejemplo n.º 14
0
    def test_mailing_list_with_subaddress_command(self):
        # Like above, but we can still send a command to the mailing list.
        with transaction():
            create_list('*****@*****.**')
        self._lmtp.sendmail('*****@*****.**',
                            ['*****@*****.**'], """\
From: [email protected]
To: [email protected]
Message-ID: <ant>
Subject: This will be recognized as a join command.

""")
        # The message is in the command queue but not the incoming queue.
        get_queue_messages('in', expected_count=0)
        get_queue_messages('command', expected_count=1)
Ejemplo n.º 15
0
    def setUp(self):
        # Create a fake mailing list and message object.
        self._msg = mfs("""\
To: [email protected]
From: [email protected]
Subject: Testing the test list
Message-ID: <ant>
Message-ID-Hash: MS6QLWERIJLGCRF44J7USBFDELMNT2BW

Tests are better than no tests
but the water deserves to be swum.
""")
        with transaction():
            self._mlist = create_list('*****@*****.**')
        tempdir = tempfile.mkdtemp()
        self.addCleanup(shutil.rmtree, tempdir)
        # Here's the command to execute our fake MHonArc process.
        shutil.copy(
            resource_filename('mailman.archiving.tests', 'fake_mhonarc.py'),
            tempdir)
        self._output_file = os.path.join(tempdir, 'output.txt')
        command = '{} {} {}'.format(
            sys.executable,
            os.path.join(tempdir, 'fake_mhonarc.py'),
            self._output_file)
        # Write an external configuration file which points the command at our
        # fake MHonArc process.
        self._cfg = os.path.join(tempdir, 'mhonarc.cfg')
        with open(self._cfg, 'w', encoding='utf-8') as fp:
            print("""\
[general]
base_url: http://$hostname/archives/$fqdn_listname
command: {command}
""".format(command=command), file=fp)
Ejemplo n.º 16
0
    def setUp(self):
        self._mlist = create_list("*****@*****.**")
        self._mlist.send_welcome_message = False
        self._bounceq = config.switchboards["bounces"]
        self._runner = make_testable_runner(BounceRunner, "bounces")
        self._anne = getUtility(IUserManager).create_address("*****@*****.**")
        self._member = self._mlist.subscribe(self._anne, MemberRole.member)
        self._msg = message_from_string(
            """\
From: [email protected]
To: [email protected]
Message-Id: <first>

"""
        )
        self._msgdata = dict(listid="test.example.com")
        self._processor = getUtility(IBounceProcessor)
        config.push(
            "site owner",
            """
        [mailman]
        site_owner: [email protected]
        """,
        )
        self.addCleanup(config.pop, "site owner")
Ejemplo n.º 17
0
    def setUp(self):
        self._mlist = create_list('*****@*****.**')
        self._mlist.personalize = Personalization.individual
        # Make Anne a member of this mailing list.
        self._anne = add_member(self._mlist,
                                '*****@*****.**', 'Anne Person',
                                'xyz', DeliveryMode.regular, 'en')
        # Clear out any results from the previous test.
        del _deliveries[:]
        self._msg = mfs("""\
From: [email protected]
To: [email protected]
Subject: test

""")
        # Set up a personalized footer for decoration.
        self._template_dir = tempfile.mkdtemp()
        path = os.path.join(self._template_dir,
                            'site', 'en', 'member-footer.txt')
        os.makedirs(os.path.dirname(path))
        with open(path, 'w') as fp:
            print("""\
address  : $user_address
delivered: $user_delivered_to
language : $user_language
name     : $user_name
options  : $user_optionsurl
""", file=fp)
        config.push('templates', """
        [paths.testing]
        template_dir: {0}
        """.format(self._template_dir))
        self._mlist.footer_uri = 'mailman:///member-footer.txt'
        # Let assertMultiLineEqual work without bounds.
        self.maxDiff = None
Ejemplo n.º 18
0
 def setUp(self):
     self._mlist = create_list('*****@*****.**')
     self._anne = getUtility(IUserManager).create_user(
         '*****@*****.**', 'Anne Person')
     preferred = list(self._anne.addresses)[0]
     preferred.verified_on = now()
     self._anne.preferred_address = preferred
Ejemplo n.º 19
0
 def setUp(self):
     self._mlist = create_list("*****@*****.**")
     anne = getUtility(IUserManager).create_address("*****@*****.**", "Anne Person")
     self._token, token_owner, member = IRegistrar(self._mlist).register(anne)
     self._command = Confirm()
     # Clear the virgin queue.
     get_queue_messages("virgin")
Ejemplo n.º 20
0
    def setUp(self):
        # Create a fake mailing list and message object
        self._msg = mfs("""\
To: [email protected]
From: [email protected]
Subject: Testing the test list
Message-ID: <ant>
X-Message-ID-Hash: MS6QLWERIJLGCRF44J7USBFDELMNT2BW

Tests are better than no tests
but the water deserves to be swum.
""")
        with transaction():
            self._mlist = create_list('*****@*****.**')
        # Set up a temporary directory for the prototype archiver so that it's
        # easier to clean up.
        self._tempdir = tempfile.mkdtemp()
        config.push('prototype', """
        [paths.testing]
        archive_dir: {0}
        """.format(self._tempdir))
        # Capture the structure of a maildir.
        self._expected_dir_structure = set(
            (os.path.join(config.ARCHIVE_DIR, path) for path in (
                'prototype',
                os.path.join('prototype', self._mlist.fqdn_listname),
                os.path.join('prototype', self._mlist.fqdn_listname, 'cur'),
                os.path.join('prototype', self._mlist.fqdn_listname, 'new'),
                os.path.join('prototype', self._mlist.fqdn_listname, 'tmp'),
                )))
        self._expected_dir_structure.add(config.ARCHIVE_DIR)
Ejemplo n.º 21
0
    def setUp(self):
        self._mlist = create_list('*****@*****.**')
        self._member = subscribe(self._mlist, 'Anne', email='*****@*****.**')
        self._msg = mfs("""\
From: [email protected]
To: [email protected]
Subject: You bounced
Message-ID: <first>

""")
        # Set up the translation context.
        self._var_dir = tempfile.mkdtemp()
        self.addCleanup(shutil.rmtree, self._var_dir)
        xx_template_path = os.path.join(
            self._var_dir, 'templates', 'site', 'xx', 'probe.txt')
        os.makedirs(os.path.dirname(xx_template_path))
        config.push('xx template dir', """\
        [paths.testing]
        var_dir: {}
        """.format(self._var_dir))
        self.addCleanup(config.pop, 'xx template dir')
        language_manager = getUtility(ILanguageManager)
        language_manager.add('xx', 'utf-8', 'Freedonia')
        self._member.preferences.preferred_language = 'xx'
        with open(xx_template_path, 'w') as fp:
            print("""\
blah blah blah
$listname
$address
$optionsurl
$owneraddr
""", file=fp)
Ejemplo n.º 22
0
 def setUp(self):
     self._mlist = create_list('*****@*****.**')
     self._mlist.digest_volume_frequency = DigestFrequency.monthly
     self._mlist.volume = 7
     self._mlist.next_digest_number = 4
     self.right_now = right_now()
     self._command = Digests()
Ejemplo n.º 23
0
    def setUp(self):
        self._mlist = create_list('*****@*****.**')
        self._now = now()
        # Enable just the dummy archiver.
        config.push('dummy', """
        [archiver.dummy]
        class: mailman.runners.tests.test_archiver.DummyArchiver
        enable: no
        [archiver.prototype]
        enable: no
        [archiver.mhonarc]
        enable: no
        [archiver.mail_archive]
        enable: no
        """)
        self._archiveq = config.switchboards['archive']
        self._msg = mfs("""\
From: [email protected]
To: [email protected]
Subject: My first post
Message-ID: <first>
X-Message-ID-Hash: 4CMWUN6BHVCMHMDAOSJZ2Q72G5M32MWB

First post!
""")
        self._runner = make_testable_runner(ArchiveRunner)
        IListArchiverSet(self._mlist).get('dummy').is_enabled = True
Ejemplo n.º 24
0
 def setUp(self):
     self.var_dir = tempfile.mkdtemp()
     config.push('template config', """\
     [paths.testing]
     var_dir: {0}
     """.format(self.var_dir))
     # The following MUST happen AFTER the push() above since pushing a new
     # config also clears out the language manager.
     getUtility(ILanguageManager).add('xx', 'utf-8', 'Xlandia')
     self.mlist = create_list('*****@*****.**')
     self.mlist.preferred_language = 'xx'
     self.fp = None
     # Populate the template directories with a few fake templates.
     def write(text, path):
         os.makedirs(os.path.dirname(path))
         with open(path, 'w') as fp:
             fp.write(text)
     self.xxsite = os.path.join(
         self.var_dir, 'templates', 'site', 'xx', 'site.txt') 
     write('Site template', self.xxsite)
     self.xxdomain = os.path.join(        
           self.var_dir, 'templates', 
           'domains', 'example.com', 'xx', 'domain.txt')
     write('Domain template', self.xxdomain)
     self.xxlist = os.path.join(
           self.var_dir, 'templates', 
           'lists', '*****@*****.**', 'xx', 'list.txt')
     write('List template', self.xxlist)
Ejemplo n.º 25
0
 def setUp(self):
     self.tempdir = tempfile.mkdtemp()
     self.utility = getUtility(IMailTransportAgentAliases)
     self.mlist = create_list('*****@*****.**')
     self.postfix = LMTP()
     # Let assertMultiLineEqual work without bounds.
     self.maxDiff = None
Ejemplo n.º 26
0
 def test_remove_list_error(self):
     # An error occurs while deleting the list's data directory.
     mlist = create_list('*****@*****.**')
     os.chmod(mlist.data_path, 0)
     self.addCleanup(shutil.rmtree, mlist.data_path)
     self.assertRaises(OSError, remove_list, mlist)
     os.chmod(mlist.data_path, 0o777)
Ejemplo n.º 27
0
 def setUp(self):
     self._mlist = create_list('*****@*****.**')
     self._msg = UserNotification(
         '*****@*****.**',
         '*****@*****.**',
         'Something you need to know',
         'I needed to tell you this.')
Ejemplo n.º 28
0
    def setUp(self):
        self.var_dir = tempfile.mkdtemp()
        config.push('template config', """\
        [paths.testing]
        var_dir: {0}
        """.format(self.var_dir))
        # The following MUST happen AFTER the push() above since pushing a new
        # config also clears out the language manager.
        getUtility(ILanguageManager).add('xx', 'utf-8', 'Xlandia')
        self.mlist = create_list('*****@*****.**')
        self.mlist.preferred_language = 'xx'
        # Populate the template directories with a few fake templates.
        path = os.path.join(self.var_dir, 'templates', 'site', 'xx')
        os.makedirs(path)
        with open(os.path.join(path, 'nosub.txt'), 'w') as fp:
            print("""\
This is a global template.
It has no substitutions.
It will be wrapped.
""", file=fp)
        with open(os.path.join(path, 'subs.txt'), 'w') as fp:
            print("""\
This is a $kind template.
It has $howmany substitutions.
It will be wrapped.
""", file=fp)
        with open(os.path.join(path, 'nowrap.txt'), 'w') as fp:
            print("""\
This is a $kind template.
It has $howmany substitutions.
It will not be wrapped.
""", file=fp)
Ejemplo n.º 29
0
    def setUp(self):
        self._mlist = create_list('*****@*****.**')
        self._mlist.welcome_message_uri = 'mailman:///welcome.txt'
        self._mlist.display_name = 'Test List'
        self.var_dir = tempfile.mkdtemp()
        config.push('template config', """\
        [paths.testing]
        template_dir: {0}/templates
        """.format(self.var_dir))
        # Populate the template directories with a few fake templates.
        path = os.path.join(self.var_dir, 'templates', 'site', 'en')
        os.makedirs(path)
        with open(os.path.join(path, 'welcome.txt'), 'w') as fp:
            print("""\
Welcome to the $list_name mailing list.

    Posting address: $fqdn_listname
    Help and other requests: $list_requests
    Your name: $user_name
    Your address: $user_address
    Your options: $user_options_uri""", file=fp)
        # Write a list-specific welcome message.
        path = os.path.join(self.var_dir, 'templates', 'lists',
                            '*****@*****.**', 'xx')
        os.makedirs(path)
        with open(os.path.join(path, 'welcome.txt'), 'w') as fp:
            print('You just joined the $list_name mailing list!', file=fp)
        # Let assertMultiLineEqual work without bounds.
        self.maxDiff = None
Ejemplo n.º 30
0
    def setUp(self):
        self._mlist = create_list('*****@*****.**')
        self._member = add_member(self._mlist, '*****@*****.**',
                                  'Anne Person', 'xxx',
                                  DeliveryMode.regular, 'en')
        self._msg = mfs("""\
From: [email protected]
To: [email protected]
Subject: You bounced
Message-ID: <first>

""")
        # Set up the translation context.
        self._var_dir = tempfile.mkdtemp()
        xx_template_path = os.path.join(
            self._var_dir, 'templates', 'site', 'xx', 'probe.txt')
        os.makedirs(os.path.dirname(xx_template_path))
        config.push('xx template dir', """\
        [paths.testing]
        var_dir: {0}
        """.format(self._var_dir))
        language_manager = getUtility(ILanguageManager)
        language_manager.add('xx', 'utf-8', 'Freedonia')
        self._member.preferences.preferred_language = 'xx'
        with open(xx_template_path, 'w') as fp:
            print("""\
blah blah blah
$listname
$address
$optionsurl
$owneraddr
""", file=fp)
        # Let assertMultiLineEqual work without bounds.
        self.maxDiff = None
Ejemplo n.º 31
0
 def setUp(self):
     self._mlist = create_list('*****@*****.**')
     self._mlist.convert_html_to_plaintext = True
     self._mlist.filter_content = True
Ejemplo n.º 32
0
 def setUp(self):
     self._ant = create_list('*****@*****.**')
     self._bee = create_list('*****@*****.**')
     self._usermanager = getUtility(IUserManager)
Ejemplo n.º 33
0
 def setUp(self):
     self._mlist = create_list('*****@*****.**')
     self._pckdict = {
         'members': {
             '*****@*****.**': 0,
             '*****@*****.**': b'*****@*****.**',
         },
         'digest_members': {
             '*****@*****.**': 0,
             '*****@*****.**': b'*****@*****.**',
         },
         'passwords': {
             '*****@*****.**': b'annepass',
             '*****@*****.**': b'bobpass',
             '*****@*****.**': b'cindypass',
             '*****@*****.**': b'davepass',
         },
         'language': {
             '*****@*****.**': b'fr',
             '*****@*****.**': b'de',
             '*****@*****.**': b'es',
             '*****@*****.**': b'it',
         },
         # Usernames are unicode strings in the pickle
         'usernames': {
             '*****@*****.**': 'Anne',
             '*****@*****.**': 'Bob',
             '*****@*****.**': 'Cindy',
             '*****@*****.**': 'Dave',
         },
         'owner': [
             '*****@*****.**',
             '*****@*****.**',
         ],
         'moderator': [
             '*****@*****.**',
             '*****@*****.**',
         ],
         'accept_these_nonmembers': [
             '*****@*****.**',
             '^gene-.*@example.com',
         ],
         'hold_these_nonmembers': [
             '*****@*****.**',
             '^homer-.*@example.com',
         ],
         'reject_these_nonmembers': [
             '*****@*****.**',
             '^iris-.*@example.com',
         ],
         'discard_these_nonmembers': [
             '*****@*****.**',
             '^kenny-.*@example.com',
         ],
     }
     self._usermanager = getUtility(IUserManager)
     language_manager = getUtility(ILanguageManager)
     for code in self._pckdict['language'].values():
         if isinstance(code, bytes):
             code = code.decode('utf-8')
         if code not in language_manager.codes:
             language_manager.add(code, 'utf-8', code)
Ejemplo n.º 34
0
 def setUp(self):
     self._mlist = create_list('*****@*****.**')
     self._registrar = IRegistrar(self._mlist)
Ejemplo n.º 35
0
 def setUp(self):
     self.utility = getUtility(IMailTransportAgentAliases)
     self.mlist = create_list('*****@*****.**')
Ejemplo n.º 36
0
 def test_remove_list_without_data_path(self):
     mlist = create_list('*****@*****.**')
     shutil.rmtree(mlist.data_path)
     remove_list(mlist)
     self.assertIsNone(getUtility(IListManager).get('*****@*****.**'))
Ejemplo n.º 37
0
 def setUp(self):
     self._mlist = create_list('*****@*****.**')
     self._mlist.send_welcome_message = False
Ejemplo n.º 38
0
    def test_send_digests_for_all_lists(self):
        # Populate ant's digest.
        msg = mfs("""\
To: [email protected]
From: [email protected]
Subject: message 1

""")
        self._handler.process(self._mlist, msg, {})
        del msg['subject']
        msg['subject'] = 'message 2'
        self._handler.process(self._mlist, msg, {})
        # Create the second list.
        bee = create_list('*****@*****.**')
        bee.digests_enabled = True
        bee.digest_size_threshold = 100000
        bee.send_welcome_message = False
        member = subscribe(bee, 'Bart')
        member.preferences.delivery_mode = DeliveryMode.plaintext_digests
        # Populate bee's digest.
        msg = mfs("""\
To: [email protected]
From: [email protected]
Subject: message 3

""")
        self._handler.process(bee, msg, {})
        del msg['subject']
        msg['subject'] = 'message 4'
        self._handler.process(bee, msg, {})
        # There are no digests for either list already being sent, but the
        # mailing lists do have a digest mbox collecting messages.
        ant_mailbox_path = os.path.join(self._mlist.data_path, 'digest.mmdf')
        self.assertGreater(os.path.getsize(ant_mailbox_path), 0)
        # Check bee's digest.
        bee_mailbox_path = os.path.join(bee.data_path, 'digest.mmdf')
        self.assertGreater(os.path.getsize(bee_mailbox_path), 0)
        # Both.
        get_queue_messages('digest', expected_count=0)
        # Process all mailing list digests by not setting any arguments.
        self._command.invoke(digests, ('-s', ))
        self._runner.run()
        # Now, neither list has a digest mbox and but there are plaintext
        # digest in the outgoing queue for both.
        self.assertFalse(os.path.exists(ant_mailbox_path))
        self.assertFalse(os.path.exists(bee_mailbox_path))
        items = get_queue_messages('virgin', expected_count=2)
        # Figure out which digest is going to ant and which to bee.
        if items[0].msg['to'] == '*****@*****.**':
            ant = items[0].msg
            bee = items[1].msg
        else:
            assert items[0].msg['to'] == '*****@*****.**'
            ant = items[1].msg
            bee = items[0].msg
        # Check ant's digest.
        digest_contents = str(ant)
        self.assertIn('Subject: message 1', digest_contents)
        self.assertIn('Subject: message 2', digest_contents)
        # Check bee's digest.
        digest_contents = str(bee)
        self.assertIn('Subject: message 3', digest_contents)
        self.assertIn('Subject: message 4', digest_contents)
Ejemplo n.º 39
0
 def setUp(self):
     self._mlist = create_list('*****@*****.**')
     self._process = config.handlers['subject-prefix'].process
Ejemplo n.º 40
0
 def setUp(self):
     self.mlist = create_list('*****@*****.**')
     self.text = """\
 def setUp(self):
     self._mlist = create_list('*****@*****.**')
     self._command = Join()
Ejemplo n.º 42
0
 def setUp(self):
     self._mlist = create_list('*****@*****.**')
     self._mlist.filter_action = DummyEnum.val
Ejemplo n.º 43
0
 def setUp(self):
     self._mlist = create_list('*****@*****.**')
     self._mlist.collapse_alternatives = True
     self._mlist.filter_content = True
     self._mlist.filter_extensions = ['xlsx']
Ejemplo n.º 44
0
 def setUp(self):
     self._mlist = create_list('*****@*****.**')
Ejemplo n.º 45
0
 def setUp(self):
     with transaction():
         self._mlist = create_list('*****@*****.**')
     self._lmtp = get_lmtp_client(quiet=True)
     self._lmtp.lhlo('remote.example.org')
     self.addCleanup(self._lmtp.close)
Ejemplo n.º 46
0
 def setUp(self):
     with transaction():
         self._mlist = create_list('*****@*****.**')
 def setUp(self):
     self._mlist = create_list('*****@*****.**')
     user_manager = getUtility(IUserManager)
     self._anne = user_manager.create_address('*****@*****.**')
     self._bart = user_manager.create_address('*****@*****.**')
     self._cris = user_manager.create_address('*****@*****.**')
Ejemplo n.º 48
0
 def test_create_no_such_style(self):
     mlist = create_list('*****@*****.**', style_name='bogus')
     # The MailmanList._preferred_language column isn't set so there's no
     # valid mapping to an ILanguage.  Therefore this call will produce a
     # KeyError.
     self.assertRaises(KeyError, getattr, mlist, 'preferred_language')
Ejemplo n.º 49
0
 def setUp(self):
     self._mlist = create_list('*****@*****.**')
     self._command = CliRunner()
 def setUp(self):
     user_manager = getUtility(IUserManager)
     with transaction():
         self._mlist = create_list('*****@*****.**')
         anne = user_manager.create_address('*****@*****.**')
         self._member = self._mlist.subscribe(anne)
Ejemplo n.º 51
0
 def setUp(self):
     self._mlist = create_list('*****@*****.**')
     self._user_manager = getUtility(IUserManager)
 def setUp(self):
     self._commandq = config.switchboards['command']
     self._runner = make_testable_runner(CommandRunner, 'command')
     with transaction():
         # Register a subscription requiring confirmation.
         self._mlist = create_list('*****@*****.**')
Ejemplo n.º 53
0
 def test_7b254d88f122_moderation_action(self):
     # Create a mailing list through the standard API.
     with transaction():
         ant = create_list('*****@*****.**')
         default_member_action = ant.default_member_action
         default_nonmember_action = ant.default_nonmember_action
     sa.sql.table(
         'mailinglist',
         sa.sql.column('id', sa.Integer),
         sa.sql.column('list_id', SAUnicode),
         sa.sql.column('default_member_action', Enum(Action)),
         sa.sql.column('default_nonmember_action', Enum(Action)),
         )
     member_table = sa.sql.table(
         'member',
         sa.sql.column('id', sa.Integer),
         sa.sql.column('list_id', SAUnicode),
         sa.sql.column('address_id', sa.Integer),
         sa.sql.column('role', Enum(MemberRole)),
         sa.sql.column('moderation_action', Enum(Action)),
         )
     user_manager = getUtility(IUserManager)
     with transaction():
         # Start at the previous revision.
         alembic.command.downgrade(alembic_cfg, 'd4fbb4fd34ca')
         # Create some members.
         anne = user_manager.create_address('*****@*****.**')
         bart = user_manager.create_address('*****@*****.**')
         cris = user_manager.create_address('*****@*****.**')
         dana = user_manager.create_address('*****@*****.**')
         # Flush the database to get the last auto-increment id.
         config.db.store.flush()
         # Assign some moderation actions to the members created above.
         config.db.store.execute(member_table.insert().values([
             {'address_id': anne.id, 'role': MemberRole.owner,
              'list_id': 'ant.example.com',
              'moderation_action': Action.accept},
             {'address_id': bart.id, 'role': MemberRole.moderator,
              'list_id': 'ant.example.com',
              'moderation_action': Action.accept},
             {'address_id': cris.id, 'role': MemberRole.member,
              'list_id': 'ant.example.com',
              'moderation_action': Action.defer},
             {'address_id': dana.id, 'role': MemberRole.nonmember,
              'list_id': 'ant.example.com',
              'moderation_action': Action.hold},
             ]))
     # Cris and Dana have actions which match the list default action for
     # members and nonmembers respectively.
     query = sa.sql.select([member_table.c.moderation_action]).where(
         sa.and_(
             member_table.c.role == MemberRole.member,
             member_table.c.list_id == 'ant.example.com',
             # [email protected]
             member_table.c.address_id == 3,
             )
         )
     action = config.db.store.execute(query).fetchone()[0]
     self.assertEqual(action, default_member_action)
     query = sa.sql.select([member_table.c.moderation_action]).where(
         sa.and_(
             member_table.c.role == MemberRole.nonmember,
             member_table.c.list_id == 'ant.example.com',
             # [email protected]
             member_table.c.address_id == 4,
             )
         )
     action = config.db.store.execute(query).fetchone()[0]
     self.assertEqual(action, default_nonmember_action)
     # Upgrade and check the moderation_actions.   Cris's and Dana's
     # actions have been set to None to fall back to the list defaults.
     alembic.command.upgrade(alembic_cfg, '7b254d88f122')
     members = config.db.store.execute(sa.select([
         member_table.c.address_id, member_table.c.moderation_action,
         ])).fetchall()
     self.assertEqual(members, [
         (anne.id, Action.accept),
         (bart.id, Action.accept),
         (cris.id, None),
         (dana.id, None),
         ])
     # Downgrade and check that Cris's and Dana's actions have been set
     # explicitly.
     alembic.command.downgrade(alembic_cfg, 'd4fbb4fd34ca')
     members = config.db.store.execute(sa.select([
         member_table.c.address_id, member_table.c.moderation_action,
         ])).fetchall()
     self.assertEqual(members, [
         (anne.id, Action.accept),
         (bart.id, Action.accept),
         (cris.id, Action.defer),
         (dana.id, Action.hold),
         ])
Ejemplo n.º 54
0
 def setUp(self):
     self._mlist = create_list('*****@*****.**')
     self._mlist.archive_policy = DummyEnum.val
Ejemplo n.º 55
0
 def setUp(self):
     self._mlist = create_list('*****@*****.**')
     self._rule = approved.Approved()
Ejemplo n.º 56
0
 def setUp(self):
     self._mlist = create_list('*****@*****.**')
     self._manager = IBanManager(self._mlist)
Ejemplo n.º 57
0
 def setUp(self):
     self._mlist = create_list('*****@*****.**')
     anne = subscribe(self._mlist, 'Anne', email='*****@*****.**')
     self._token, token_owner, member = ISubscriptionManager(
         self._mlist).unregister(anne.address)
Ejemplo n.º 58
0
 def setUp(self):
     self._manager = getUtility(IUserManager)
     self._mlist = create_list('*****@*****.**')
     self._anne = self._manager.create_user('*****@*****.**',
                                            'Anne Person')
     set_preferred(self._anne)
Ejemplo n.º 59
0
 def setUp(self):
     self.command = Import21()
     self.args = FakeArgs()
     self.mlist = create_list('*****@*****.**')
Ejemplo n.º 60
0
 def setUp(self):
     self._mlist = create_list('*****@*****.**')
     pickle_file = resource_filename('mailman.testing', 'config.pck')
     with open(pickle_file, 'rb') as fp:
         self._pckdict = load(fp)