From 49c45b7aa7783509693230ae615d97758263cb15 Mon Sep 17 00:00:00 2001 From: jlgijsbers Date: Sat, 6 Sep 2003 10:21:18 +0000 Subject: [PATCH] mailgw now accepts registration confirmation mail that contains the following in the subject line: -- key <32-char otk, such as Aj4euk4LZSAdwePohj90SME5SpopLETL>. git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1859 57a73879-2fb5-44c3-a270-3262357dd7e2 --- roundup/mailgw.py | 14 ++++++++++---- test/test_mailgw.py | 23 ++++++++++++++++++++++- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/roundup/mailgw.py b/roundup/mailgw.py index 11cbf74..1c8bc5d 100644 --- a/roundup/mailgw.py +++ b/roundup/mailgw.py @@ -73,7 +73,7 @@ are calling the create() method to create a new node). If an auditor raises an exception, the original message is bounced back to the sender with the explanatory message given in the exception. -$Id: mailgw.py,v 1.127 2003-09-05 20:56:39 jlgijsbers Exp $ +$Id: mailgw.py,v 1.128 2003-09-06 10:21:18 jlgijsbers Exp $ """ import string, re, os, mimetools, cStringIO, smtplib, socket, binascii, quopri @@ -514,9 +514,15 @@ Emails to Roundup trackers must include a Subject: line! # get the classname classname = m.group('classname') if classname is None: - # no classname, fallback on the default - if hasattr(self.instance.config, 'MAIL_DEFAULT_CLASS') and \ - self.instance.config.MAIL_DEFAULT_CLASS: + # no classname, check if this a registration confirmation email + # or fallback on the default class + otk_re = re.compile('-- key (?P[a-zA-Z0-9]{32})') + otk = otk_re.search(m.group('title')).group('otk') + if otk: + self.db.confirm_registration(otk) + return + elif hasattr(self.instance.config, 'MAIL_DEFAULT_CLASS') and \ + self.instance.config.MAIL_DEFAULT_CLASS: classname = self.instance.config.MAIL_DEFAULT_CLASS else: # fail diff --git a/test/test_mailgw.py b/test/test_mailgw.py index 355de47..1cc8c85 100644 --- a/test/test_mailgw.py +++ b/test/test_mailgw.py @@ -8,7 +8,7 @@ # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -# $Id: test_mailgw.py,v 1.46 2003-05-06 21:49:20 kedder Exp $ +# $Id: test_mailgw.py,v 1.47 2003-09-06 10:21:03 jlgijsbers Exp $ import unittest, cStringIO, tempfile, os, shutil, errno, imp, sys, difflib import rfc822 @@ -959,9 +959,30 @@ This is a followup self.assertEqual(rfc2822.encode_header(ascii_header), ascii_header) self.assertEqual(rfc2822.encode_header(unicode_header), unicode_encoded) + def testRegistrationConfirmation(self): + otk = "Aj4euk4LZSAdwePohj90SME5SpopLETL" + self.db.otks.set(otk, username='johannes', __time='') + message = cStringIO.StringIO('''Content-Type: text/plain; + charset="iso-8859-1" +From: Chef +To: issue_tracker@your.tracker.email.domain.example +Cc: richard@test +Message-Id: +Subject: Re: Complete your registration to Roundup issue tracker + -- key %s + +This is a test confirmation of registration. +''' % otk) + handler = self.instance.MailGW(self.instance, self.db) + handler.trapExceptions = 0 + handler.main(message) + + self.db.user.lookup('johannes') + def suite(): l = [unittest.makeSuite(MailgwTestCase), ] + l = [MailgwTestCase("testRegistrationConfirmation")] return unittest.TestSuite(l) -- 2.30.2