Add global support for port= directive in URL parsing (#639)

pull/642/head
Chris Caron 2 years ago committed by GitHub
parent 7f7f6863c9
commit 450fc54dbb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -677,6 +677,9 @@ class URLBase(object):
if 'cto' in results['qsd']:
results['socket_connect_timeout'] = results['qsd']['cto']
if 'port' in results['qsd']:
results['port'] = results['qsd']['port']
return results
@staticmethod

@ -863,3 +863,30 @@ def test_plugin_email_url_parsing(mock_smtp, mock_smtp_ssl):
'mailtos://user:pass123@hotmail.com')
obj = Apprise.instantiate(results, suppress_exceptions=False)
assert isinstance(obj, plugins.NotifyEmail) is True
#
# Test Port Over-Riding
#
results = plugins.NotifyEmail.parse_url(
"mailtos://abc:password@xyz.cn:465?"
"smtp=smtp.exmail.qq.com&mode=ssl")
obj = Apprise.instantiate(results, suppress_exceptions=False)
assert isinstance(obj, plugins.NotifyEmail) is True
# Verify our over-rides are in place
assert obj.smtp_host == 'smtp.exmail.qq.com'
assert obj.port == 465
assert obj.from_addr == 'abc@xyz.cn'
assert obj.secure_mode == 'ssl'
results = plugins.NotifyEmail.parse_url(
"mailtos://abc:password@xyz.cn?"
"smtp=smtp.exmail.qq.com&mode=ssl&port=465")
obj = Apprise.instantiate(results, suppress_exceptions=False)
assert isinstance(obj, plugins.NotifyEmail) is True
# Verify our over-rides are in place
assert obj.smtp_host == 'smtp.exmail.qq.com'
assert obj.port == 465
assert obj.from_addr == 'abc@xyz.cn'
assert obj.secure_mode == 'ssl'

Loading…
Cancel
Save