Mercurial > p > roundup > code
comparison test/test_mailgw.py @ 5151:6bbb6dd97458
Fix subject parsing in mail gateway.
The previous parsing routine would not ensure that arguments are at the
end of the subject and when subject_suffix_parsing was configured to be
'loose' it would truncate the subject when encountering a double prefix,
e.g. Subject: [frobulated] [frobulatedagain] this part would be lost
| author | Ralf Schlatterbeck <rsc@runtux.com> |
|---|---|
| date | Tue, 19 Jul 2016 11:47:53 +0200 |
| parents | 0c9eed9c4029 |
| children | 65b42fd96c00 |
comparison
equal
deleted
inserted
replaced
| 5150:0c9eed9c4029 | 5151:6bbb6dd97458 |
|---|---|
| 3057 ''') | 3057 ''') |
| 3058 assert not os.path.exists(SENDMAILDEBUG) | 3058 assert not os.path.exists(SENDMAILDEBUG) |
| 3059 self.assertEqual(self.db.issue.get(nodeid, 'title'), | 3059 self.assertEqual(self.db.issue.get(nodeid, 'title'), |
| 3060 '[frobulated] testing') | 3060 '[frobulated] testing') |
| 3061 | 3061 |
| 3062 def testInvalidClassLooseReplyQuoted(self): | |
| 3063 self.instance.config.MAILGW_SUBJECT_PREFIX_PARSING = 'loose' | |
| 3064 nodeid = self._handle_mail('''Content-Type: text/plain; | |
| 3065 charset="iso-8859-1" | |
| 3066 From: Chef <chef@bork.bork.bork> | |
| 3067 To: issue_tracker@your.tracker.email.domain.example | |
| 3068 Subject: Re: "[frobulated] testing" | |
| 3069 Cc: richard@test.test | |
| 3070 Reply-To: chef@bork.bork.bork | |
| 3071 Message-Id: <dummy_test_message_id> | |
| 3072 | |
| 3073 Dumb mailers may put quotes around the subject after the reply prefix, | |
| 3074 e.g. Re: "[issue1] bla bla" | |
| 3075 ''') | |
| 3076 assert not os.path.exists(SENDMAILDEBUG) | |
| 3077 self.assertEqual(self.db.issue.get(nodeid, 'title'), | |
| 3078 '[frobulated] testing') | |
| 3079 | |
| 3062 def testInvalidClassLoose(self): | 3080 def testInvalidClassLoose(self): |
| 3063 self.instance.config.MAILGW_SUBJECT_PREFIX_PARSING = 'loose' | 3081 self.instance.config.MAILGW_SUBJECT_PREFIX_PARSING = 'loose' |
| 3064 nodeid = self._handle_mail('''Content-Type: text/plain; | 3082 nodeid = self._handle_mail('''Content-Type: text/plain; |
| 3065 charset="iso-8859-1" | 3083 charset="iso-8859-1" |
| 3066 From: Chef <chef@bork.bork.bork> | 3084 From: Chef <chef@bork.bork.bork> |
| 3088 Message-Id: <dummy_test_message_id> | 3106 Message-Id: <dummy_test_message_id> |
| 3089 | 3107 |
| 3090 ''') | 3108 ''') |
| 3091 assert not os.path.exists(SENDMAILDEBUG) | 3109 assert not os.path.exists(SENDMAILDEBUG) |
| 3092 self.assertEqual(self.db.keyword.get('1', 'name'), 'Bar') | 3110 self.assertEqual(self.db.keyword.get('1', 'name'), 'Bar') |
| 3111 | |
| 3112 def testDoublePrefixLoose(self): | |
| 3113 self.instance.config.MAILGW_SUBJECT_PREFIX_PARSING = 'loose' | |
| 3114 self.instance.config.MAILGW_SUBJECT_SUFFIX_PARSING = 'loose' | |
| 3115 nodeid = self._handle_mail('''Content-Type: text/plain; | |
| 3116 charset="iso-8859-1" | |
| 3117 From: Chef <chef@bork.bork.bork> | |
| 3118 To: issue_tracker@your.tracker.email.domain.example | |
| 3119 Subject: [frobulated] [frobulatedagain] testing stuff after double prefix | |
| 3120 Cc: richard@test.test | |
| 3121 Reply-To: chef@bork.bork.bork | |
| 3122 Message-Id: <dummy_test_message_id> | |
| 3123 | |
| 3124 ''') | |
| 3125 assert not os.path.exists(SENDMAILDEBUG) | |
| 3126 self.assertEqual(self.db.issue.get(nodeid, 'title'), | |
| 3127 '[frobulated] [frobulatedagain] testing stuff after double prefix') | |
| 3093 | 3128 |
| 3094 def testClassStrictInvalid(self): | 3129 def testClassStrictInvalid(self): |
| 3095 self.instance.config.MAILGW_SUBJECT_PREFIX_PARSING = 'strict' | 3130 self.instance.config.MAILGW_SUBJECT_PREFIX_PARSING = 'strict' |
| 3096 self.instance.config.MAILGW_DEFAULT_CLASS = '' | 3131 self.instance.config.MAILGW_DEFAULT_CLASS = '' |
| 3097 | 3132 |
