2004-08-16 19:20:16 +00:00
|
|
|
|
# -*- coding: iso-8859-1 -*-
|
2005-01-11 02:22:43 +00:00
|
|
|
|
# Copyright (C) 2004-2005 Bastian Kleineidam
|
2004-08-16 19:20:16 +00:00
|
|
|
|
#
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
|
# (at your option) any later version.
|
|
|
|
|
|
#
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
|
|
#
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
|
|
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
2005-01-19 15:08:02 +00:00
|
|
|
|
"""
|
|
|
|
|
|
Test mail checking.
|
|
|
|
|
|
"""
|
2004-08-16 19:20:16 +00:00
|
|
|
|
|
|
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
|
|
|
|
import linkcheck.ftests
|
|
|
|
|
|
|
|
|
|
|
|
class TestMail (linkcheck.ftests.StandardTest):
|
2005-01-19 14:38:01 +00:00
|
|
|
|
"""
|
|
|
|
|
|
Test mailto: link checking.
|
|
|
|
|
|
"""
|
2004-08-16 19:20:16 +00:00
|
|
|
|
|
2004-08-23 20:04:54 +00:00
|
|
|
|
needed_resources = ['network']
|
|
|
|
|
|
|
2004-08-16 19:20:16 +00:00
|
|
|
|
def test_good_mail (self):
|
2005-01-19 14:38:01 +00:00
|
|
|
|
"""
|
|
|
|
|
|
Test some good mailto addrs.
|
|
|
|
|
|
"""
|
2004-11-14 01:58:05 +00:00
|
|
|
|
url = self.norm(u"mailto:Dude <calvin@users.sf.net> , "\
|
2004-08-16 19:20:16 +00:00
|
|
|
|
"Killer <calvin@users.sourceforge.net>?subject=bla")
|
|
|
|
|
|
resultlines = [
|
2004-11-14 01:55:47 +00:00
|
|
|
|
u"url %s" % url,
|
|
|
|
|
|
u"cache key mailto:calvin@users.sf.net,calvin@users.sourceforge.net",
|
|
|
|
|
|
u"real url %s" % url,
|
2004-11-19 13:31:30 +00:00
|
|
|
|
u"info Verified address: <calvin> is deliverable.",
|
2004-11-14 01:55:47 +00:00
|
|
|
|
u"valid",
|
2004-08-16 19:20:16 +00:00
|
|
|
|
]
|
|
|
|
|
|
self.direct(url, resultlines)
|
2004-11-14 01:58:05 +00:00
|
|
|
|
url = self.norm(u"mailto:Bastian Kleineidam <calvin@users.sf.net>?"\
|
2004-08-31 20:29:32 +00:00
|
|
|
|
"bcc=calvin%40users.sourceforge.net")
|
2004-08-16 19:20:16 +00:00
|
|
|
|
resultlines = [
|
2004-11-14 01:55:47 +00:00
|
|
|
|
u"url %s" % url,
|
|
|
|
|
|
u"cache key mailto:calvin@users.sf.net,calvin@users.sourceforge.net",
|
|
|
|
|
|
u"real url %s" % url,
|
2004-11-19 13:31:30 +00:00
|
|
|
|
u"info Verified address: <calvin> is deliverable.",
|
2004-11-14 01:55:47 +00:00
|
|
|
|
u"valid",
|
2004-08-16 19:20:16 +00:00
|
|
|
|
]
|
|
|
|
|
|
self.direct(url, resultlines)
|
2004-11-14 01:58:05 +00:00
|
|
|
|
url = self.norm(u"mailto:Bastian Kleineidam <calvin@users.sf.net>")
|
2004-08-16 19:20:16 +00:00
|
|
|
|
resultlines = [
|
2004-11-14 01:55:47 +00:00
|
|
|
|
u"url %s" % url,
|
|
|
|
|
|
u"cache key mailto:calvin@users.sf.net",
|
|
|
|
|
|
u"real url %s" % url,
|
2004-11-19 13:31:30 +00:00
|
|
|
|
u"info Verified address: <calvin> is deliverable.",
|
2004-11-14 01:55:47 +00:00
|
|
|
|
u"valid",
|
2004-08-16 19:20:16 +00:00
|
|
|
|
]
|
|
|
|
|
|
self.direct(url, resultlines)
|
2004-11-14 01:58:05 +00:00
|
|
|
|
url = self.norm(u"mailto:o'hara@users.sf.net")
|
2004-08-16 19:20:16 +00:00
|
|
|
|
resultlines = [
|
2004-11-14 01:55:47 +00:00
|
|
|
|
u"url %s" % url,
|
|
|
|
|
|
u"cache key mailto:o'hara@users.sf.net",
|
|
|
|
|
|
u"real url %s" % url,
|
2004-11-19 13:31:30 +00:00
|
|
|
|
u"info Verified address: <o'hara> is deliverable.",
|
2004-11-14 01:55:47 +00:00
|
|
|
|
u"valid",
|
2004-08-16 19:20:16 +00:00
|
|
|
|
]
|
|
|
|
|
|
self.direct(url, resultlines)
|
2004-11-14 01:58:05 +00:00
|
|
|
|
url = self.norm(u"mailto:?to=calvin@users.sf.net&subject=blubb&"\
|
2004-08-16 19:20:16 +00:00
|
|
|
|
"cc=calvin_cc@users.sf.net&CC=calvin_CC@users.sf.net")
|
|
|
|
|
|
resultlines = [
|
2004-11-14 01:55:47 +00:00
|
|
|
|
u"url %s" % url,
|
|
|
|
|
|
u"cache key mailto:calvin@users.sf.net,calvin_CC@users.sf.net,calvin_cc@users.sf.net",
|
|
|
|
|
|
u"real url %s" % url,
|
2004-11-19 13:31:30 +00:00
|
|
|
|
u"info Verified address: <calvin> is deliverable.",
|
|
|
|
|
|
u"info Verified address: <calvin_cc> is deliverable.",
|
|
|
|
|
|
u"info Verified address: <calvin_CC> is deliverable.",
|
2004-11-14 01:55:47 +00:00
|
|
|
|
u"valid",
|
2004-08-16 19:20:16 +00:00
|
|
|
|
]
|
|
|
|
|
|
self.direct(url, resultlines)
|
2004-11-14 01:58:05 +00:00
|
|
|
|
url = self.norm(u"mailto:news-admins@freshmeat.net?subject="\
|
2004-08-16 19:20:16 +00:00
|
|
|
|
"Re:%20[fm%20#11093]%20(news-admins)%20Submission%20"\
|
|
|
|
|
|
"report%20-%20Pretty%20CoLoRs")
|
2004-08-25 19:02:31 +00:00
|
|
|
|
resultlines = [
|
2004-11-14 01:55:47 +00:00
|
|
|
|
u"url %s" % url,
|
|
|
|
|
|
u"cache key mailto:news-admins@freshmeat.net",
|
|
|
|
|
|
u"real url %s" % url,
|
2005-01-11 14:34:23 +00:00
|
|
|
|
u"warning Unverified address: VRFY command is disabled.",
|
2004-11-14 01:55:47 +00:00
|
|
|
|
u"valid",
|
2004-08-25 19:02:31 +00:00
|
|
|
|
]
|
2004-08-16 19:20:16 +00:00
|
|
|
|
self.direct(url, resultlines)
|
2004-11-14 01:58:05 +00:00
|
|
|
|
url = self.norm(u"mailto:foo@foo-bar.de?subject=test")
|
2004-08-25 19:02:31 +00:00
|
|
|
|
resultlines = [
|
2004-11-14 01:55:47 +00:00
|
|
|
|
u"url %s" % url,
|
|
|
|
|
|
u"cache key mailto:foo@foo-bar.de",
|
|
|
|
|
|
u"real url %s" % url,
|
2005-01-11 14:34:23 +00:00
|
|
|
|
u"info Unverified address: Cannot VRFY user; try RCPT to attempt delivery. But mail will be sent anyway.",
|
2004-11-14 01:55:47 +00:00
|
|
|
|
u"valid",
|
2004-08-25 19:02:31 +00:00
|
|
|
|
]
|
2004-08-16 19:20:16 +00:00
|
|
|
|
self.direct(url, resultlines)
|
|
|
|
|
|
|
|
|
|
|
|
def test_warn_mail (self):
|
2005-01-19 14:38:01 +00:00
|
|
|
|
"""
|
|
|
|
|
|
Test some mailto addrs with warnings.
|
|
|
|
|
|
"""
|
2004-08-16 19:20:16 +00:00
|
|
|
|
# contains non-quoted characters
|
2004-11-03 22:34:20 +00:00
|
|
|
|
url = u"mailto:calvin@users.sf.net?subject=<3D><><EFBFBD>"
|
2004-11-14 01:55:47 +00:00
|
|
|
|
qurl = self.norm(url)
|
2004-08-16 19:20:16 +00:00
|
|
|
|
resultlines = [
|
2004-11-14 01:55:47 +00:00
|
|
|
|
u"url %s" % url,
|
|
|
|
|
|
u"cache key mailto:calvin@users.sf.net",
|
|
|
|
|
|
u"real url %s" % qurl,
|
2004-11-19 13:31:30 +00:00
|
|
|
|
u"info Verified address: <calvin> is deliverable.",
|
2004-11-14 01:55:47 +00:00
|
|
|
|
u"warning Base URL is not properly normed. Normed url is %s." % qurl,
|
|
|
|
|
|
u"valid",
|
2004-08-16 19:20:16 +00:00
|
|
|
|
]
|
2004-08-27 08:44:36 +00:00
|
|
|
|
self.direct(url, resultlines)
|
2004-11-03 22:34:20 +00:00
|
|
|
|
url = u"mailto:calvin@users.sf.net?subject=Halli hallo"
|
2004-11-14 01:55:47 +00:00
|
|
|
|
qurl = self.norm(url)
|
2004-08-16 19:20:16 +00:00
|
|
|
|
resultlines = [
|
2004-11-14 01:55:47 +00:00
|
|
|
|
u"url %s" % url,
|
|
|
|
|
|
u"cache key mailto:calvin@users.sf.net",
|
|
|
|
|
|
u"real url %s" % qurl,
|
2004-11-19 13:31:30 +00:00
|
|
|
|
u"info Verified address: <calvin> is deliverable.",
|
2004-11-14 01:55:47 +00:00
|
|
|
|
u"warning Base URL is not properly normed. Normed url is %s." % qurl,
|
|
|
|
|
|
u"valid",
|
2004-08-16 19:20:16 +00:00
|
|
|
|
]
|
2004-08-27 08:44:36 +00:00
|
|
|
|
self.direct(url, resultlines)
|
2004-11-14 01:58:05 +00:00
|
|
|
|
url = self.norm(u"mailto:")
|
2004-08-16 19:20:16 +00:00
|
|
|
|
resultlines = [
|
2004-11-14 01:55:47 +00:00
|
|
|
|
u"url %s" % url,
|
|
|
|
|
|
u"cache key %s" % url,
|
|
|
|
|
|
u"real url %s" % url,
|
2004-11-19 13:31:30 +00:00
|
|
|
|
u"warning No addresses found.",
|
2004-11-14 01:55:47 +00:00
|
|
|
|
u"valid",
|
2004-08-16 19:20:16 +00:00
|
|
|
|
]
|
|
|
|
|
|
self.direct(url, resultlines)
|
|
|
|
|
|
|
|
|
|
|
|
def test_bad_mail (self):
|
2005-01-19 14:38:01 +00:00
|
|
|
|
"""
|
|
|
|
|
|
Test some mailto addrs with bad syntax.
|
|
|
|
|
|
"""
|
2004-08-16 19:20:16 +00:00
|
|
|
|
# ? extension forbidden in <> construct
|
2004-11-14 01:58:05 +00:00
|
|
|
|
url = self.norm(u"mailto:Bastian Kleineidam "\
|
2004-08-16 19:20:16 +00:00
|
|
|
|
"<calvin@users.sf.net?foo=bar>")
|
2004-08-24 15:00:18 +00:00
|
|
|
|
resultlines = [
|
2004-11-14 01:55:47 +00:00
|
|
|
|
u"url %s" % url,
|
|
|
|
|
|
u"cache key None",
|
|
|
|
|
|
u"real url %s" % url,
|
|
|
|
|
|
u"error",
|
2004-08-24 15:00:18 +00:00
|
|
|
|
]
|
2004-08-16 19:20:16 +00:00
|
|
|
|
self.direct(url, resultlines)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_suite ():
|
2005-01-19 14:38:01 +00:00
|
|
|
|
"""
|
|
|
|
|
|
Build and return a TestSuite.
|
|
|
|
|
|
"""
|
2004-08-16 19:20:16 +00:00
|
|
|
|
suite = unittest.TestSuite()
|
|
|
|
|
|
suite.addTest(unittest.makeSuite(TestMail))
|
|
|
|
|
|
return suite
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
|
unittest.main()
|