comparison test/test_mailgw.py @ 3876:29759dfcfbcf

Tell user where to register in mail about user being unknown... ...if tracker allows anonymous web access + user creation.
author Erik Forsberg <forsberg@users.sourceforge.net>
date Sat, 01 Sep 2007 16:14:21 +0000
parents 2b63b1689cef
children 83748b2de465
comparison
equal deleted inserted replaced
3875:64a12bd91fc0 3876:29759dfcfbcf
6 # 6 #
7 # This module is distributed in the hope that it will be useful, 7 # This module is distributed in the hope that it will be useful,
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of 8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 # 10 #
11 # $Id: test_mailgw.py,v 1.85 2007-02-15 03:09:53 richard Exp $ 11 # $Id: test_mailgw.py,v 1.86 2007-09-01 16:14:21 forsberg Exp $
12 12
13 # TODO: test bcc 13 # TODO: test bcc
14 14
15 import unittest, tempfile, os, shutil, errno, imp, sys, difflib, rfc822, time 15 import unittest, tempfile, os, shutil, errno, imp, sys, difflib, rfc822, time
16 16
764 Message-Id: <dummy_test_message_id> 764 Message-Id: <dummy_test_message_id>
765 Subject: [issue] Testing... 765 Subject: [issue] Testing...
766 766
767 This is a test submission of a new issue. 767 This is a test submission of a new issue.
768 ''' 768 '''
769 self.assertRaises(Unauthorized, self._handle_mail, message) 769 try:
770 self._handle_mail(message)
771 except Unauthorized, value:
772 body_diff = self.compareMessages(str(value), """
773 You are not a registered user.
774
775 Unknown address: fubar@bork.bork.bork
776 """)
777
778 assert not body_diff, body_diff
779
780 else:
781 raise AssertionError, "Unathorized not raised when handling mail"
782
783 # Add Web Access role to anonymous, and try again to make sure
784 # we get a "please register at:" message this time.
785 p = [
786 self.db.security.getPermission('Create', 'user'),
787 self.db.security.getPermission('Web Access', None),
788 ]
789
790 self.db.security.role['anonymous'].permissions=p
791
792 try:
793 self._handle_mail(message)
794 except Unauthorized, value:
795 body_diff = self.compareMessages(str(value), """
796 You are not a registered user. Please register at:
797
798 http://tracker.example/cgi-bin/roundup.cgi/bugs/user?template=register
799
800 ...before sending mail to the tracker.
801
802 Unknown address: fubar@bork.bork.bork
803 """)
804
805 assert not body_diff, body_diff
806
807 else:
808 raise AssertionError, "Unathorized not raised when handling mail"
809
810 # Make sure list of users is the same as before.
770 m = self.db.user.list() 811 m = self.db.user.list()
771 m.sort() 812 m.sort()
772 self.assertEqual(l, m) 813 self.assertEqual(l, m)
773 814
774 # now with the permission 815 # now with the permission

Roundup Issue Tracker: http://roundup-tracker.org/