filter root component JID in MailHandler
darcs-hash:20070605194240-86b55-3eac72f253c5b012c713dcc38812452d1d870111.gz
This commit is contained in:
@@ -199,7 +199,8 @@ class MailHandler(Handler):
|
||||
|
||||
def filter(self, stanza, lang_class):
|
||||
"""Return empty array if JID match '.*%.*@componentJID'"""
|
||||
if self.dest_jid_regexp.match(stanza.get_to().node):
|
||||
node = stanza.get_to().node
|
||||
if node is not None and self.dest_jid_regexp.match(node):
|
||||
bare_from_jid = unicode(stanza.get_from().bare())
|
||||
accounts = Account.select(Account.q.user_jid == bare_from_jid)
|
||||
if accounts.count() == 0:
|
||||
|
||||
@@ -692,6 +692,22 @@ class MailHandler_TestCase(unittest.TestCase):
|
||||
self.assertEquals(accounts[0].name, "account11")
|
||||
del account.hub.threadConnection
|
||||
|
||||
def test_filter_root(self):
|
||||
account.hub.threadConnection = connectionForURI('sqlite://' + DB_URL)
|
||||
account11 = SMTPAccount(user_jid="user1@test.com",
|
||||
name="account11",
|
||||
jid="account11@jcl.test.com")
|
||||
account11.default_account = True
|
||||
account12 = SMTPAccount(user_jid="user1@test.com",
|
||||
name="account12",
|
||||
jid="account12@jcl.test.com")
|
||||
message = Message(from_jid="user1@test.com",
|
||||
to_jid="jcl.test.com",
|
||||
body="message")
|
||||
accounts = self.handler.filter(message, None)
|
||||
self.assertEquals(accounts, None)
|
||||
del account.hub.threadConnection
|
||||
|
||||
def test_filter_no_default(self):
|
||||
account.hub.threadConnection = connectionForURI('sqlite://' + DB_URL)
|
||||
account11 = SMTPAccount(user_jid = "user1@test.com", \
|
||||
|
||||
Reference in New Issue
Block a user