Skip to content

Commit

Permalink
Added test case to test verify complex mailto:// parsing (#991)
Browse files Browse the repository at this point in the history
  • Loading branch information
caronc authored Nov 5, 2023
1 parent bd90f37 commit 7e87807
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions test/test_plugin_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -1584,3 +1584,38 @@ def test_plugin_email_plus_in_toemail(mock_smtp, mock_smtp_ssl):
assert len(_to) == 1
assert _to[0] == '[email protected]'
assert _msg.split('\n')[-3] == 'test'


@mock.patch('smtplib.SMTP_SSL')
@mock.patch('smtplib.SMTP')
def test_plugin_email_formatting_990(mock_smtp, mock_smtp_ssl):
"""
NotifyEmail() GitHub Issue 990
https://github.com/caronc/apprise/issues/990
Email formatting not working correctly
"""

response = mock.Mock()
mock_smtp_ssl.return_value = response
mock_smtp.return_value = response

results = NotifyEmail.parse_url(
'mailtos://mydomain.com?smtp=mail.local.mydomain.com'
'&[email protected]&pass=mypassword'
'&[email protected]&[email protected]&mode=ssl&port=465')

assert isinstance(results, dict)
assert '[email protected]' == results['user']
assert 'mydomain.com' == results['host']
assert 'mail.local.mydomain.com' == results['smtp_host']
assert 'mypassword' == results['password']
assert 'ssl' == results['secure_mode']
assert '465' == results['port']
assert '[email protected]' in results['targets']

obj = Apprise.instantiate(results, suppress_exceptions=False)
assert isinstance(obj, NotifyEmail) is True

assert len(obj.targets) == 1
assert (False, '[email protected]') in obj.targets

0 comments on commit 7e87807

Please sign in to comment.