linkchecker/tests/checker/test_mail_bad.py

51 lines
2.1 KiB
Python
Raw Normal View History

# Copyright (C) 2004-2014 Bastian Kleineidam
2012-10-01 18:11:59 +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.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
"""
Test mail checking of bad mail addresses.
"""
from . import MailTest
class TestMailBad(MailTest):
2012-10-01 18:11:59 +00:00
"""Test mailto: link checking."""
def test_error_mail(self):
2012-10-01 18:11:59 +00:00
# too long or too short
2020-04-30 19:11:59 +00:00
self.mail_error("mailto:@")
self.mail_error("mailto:@example.org")
self.mail_error("mailto:a@")
2020-05-28 19:29:13 +00:00
self.mail_error("mailto:%s@example.org" % ("a" * 65))
self.mail_error("mailto:a@%s.com" % ("a" * 64))
2012-10-01 18:11:59 +00:00
# local part quoted
2020-05-28 19:29:13 +00:00
self.mail_error('mailto:"a""@example.com', cache_key="mailto:a")
2020-04-30 19:11:59 +00:00
self.mail_error('mailto:""a"@example.com', cache_key='mailto:""a"@example.com')
self.mail_error('mailto:"a\\"@example.com', cache_key='mailto:a"@example.com')
# local part unquoted
2020-05-28 19:29:13 +00:00
self.mail_error("mailto:.a@example.com")
self.mail_error("mailto:a.@example.com")
self.mail_error("mailto:a..b@example.com")
2012-10-01 18:11:59 +00:00
# domain part
2020-05-28 19:29:13 +00:00
self.mail_error("mailto:a@a_b.com")
self.mail_error("mailto:a@example.com.")
self.mail_error("mailto:a@example.com.111")
self.mail_error("mailto:a@example..com")
2012-10-01 18:11:59 +00:00
# other
# ? extension forbidden in <> construct
2020-05-28 19:29:13 +00:00
self.mail_error(
"mailto:Bastian Kleineidam <calvin@users.sourceforge.net?foo=bar>",
cache_key="mailto:calvin@users.sourceforge.net?foo=bar",
)