| 1 |
# BSD 2-Clause License |
| 2 |
# |
| 3 |
# Apprise - Push Notification Library. |
| 4 |
# Copyright (c) 2026, Chris Caron <[email protected]> |
| 5 |
# |
| 6 |
# Redistribution and use in source and binary forms, with or without |
| 7 |
# modification, are permitted provided that the following conditions are met: |
| 8 |
# |
| 9 |
# 1. Redistributions of source code must retain the above copyright notice, |
| 10 |
# this list of conditions and the following disclaimer. |
| 11 |
# |
| 12 |
# 2. Redistributions in binary form must reproduce the above copyright notice, |
| 13 |
# this list of conditions and the following disclaimer in the documentation |
| 14 |
# and/or other materials provided with the distribution. |
| 15 |
# |
| 16 |
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 17 |
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 18 |
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 19 |
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
| 20 |
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 21 |
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 22 |
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 23 |
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 24 |
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 25 |
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 26 |
# POSSIBILITY OF SUCH DAMAGE. |
| 27 |
|
| 28 |
# Disable logging for a cleaner testing output |
| 29 |
import logging |
| 30 |
|
| 31 |
from helpers import AppriseURLTester |
| 32 |
import requests |
| 33 |
|
| 34 |
from apprise.exception import AppriseImproperlyConfigured |
| 35 |
from apprise.plugins.notica import NotifyNotica |
| 36 |
|
| 37 |
logging.disable(logging.CRITICAL) |
| 38 |
|
| 39 |
# Our Testing URLs |
| 40 |
apprise_url_tests = ( |
| 41 |
( |
| 42 |
"notica://", |
| 43 |
{ |
| 44 |
"instance": AppriseImproperlyConfigured, |
| 45 |
}, |
| 46 |
), |
| 47 |
( |
| 48 |
"notica://:@/", |
| 49 |
{ |
| 50 |
"instance": AppriseImproperlyConfigured, |
| 51 |
}, |
| 52 |
), |
| 53 |
# Native URL |
| 54 |
( |
| 55 |
"https://notica.us/?%s" % ("z" * 6), |
| 56 |
{ |
| 57 |
"instance": NotifyNotica, |
| 58 |
# Our expected url(privacy=True) startswith() response: |
| 59 |
"privacy_url": "notica://z...z/", |
| 60 |
}, |
| 61 |
), |
| 62 |
# Native URL with additional arguments |
| 63 |
( |
| 64 |
"https://notica.us/?%s&overflow=upstream" % ("z" * 6), |
| 65 |
{ |
| 66 |
"instance": NotifyNotica, |
| 67 |
# Our expected url(privacy=True) startswith() response: |
| 68 |
"privacy_url": "notica://z...z/", |
| 69 |
}, |
| 70 |
), |
| 71 |
# Token specified |
| 72 |
( |
| 73 |
"notica://%s" % ("a" * 6), |
| 74 |
{ |
| 75 |
"instance": NotifyNotica, |
| 76 |
# Our expected url(privacy=True) startswith() response: |
| 77 |
"privacy_url": "notica://a...a/", |
| 78 |
}, |
| 79 |
), |
| 80 |
# Self-Hosted configuration |
| 81 |
( |
| 82 |
"notica://localhost/%s" % ("b" * 6), |
| 83 |
{ |
| 84 |
"instance": NotifyNotica, |
| 85 |
}, |
| 86 |
), |
| 87 |
( |
| 88 |
"notica://user@localhost/%s" % ("c" * 6), |
| 89 |
{ |
| 90 |
"instance": NotifyNotica, |
| 91 |
}, |
| 92 |
), |
| 93 |
( |
| 94 |
"notica://user:pass@localhost/%s/" % ("d" * 6), |
| 95 |
{ |
| 96 |
"instance": NotifyNotica, |
| 97 |
# Our expected url(privacy=True) startswith() response: |
| 98 |
"privacy_url": "notica://user:****@localhost/d...d", |
| 99 |
}, |
| 100 |
), |
| 101 |
( |
| 102 |
"notica://user:pass@localhost/a/path/%s/" % ("r" * 6), |
| 103 |
{ |
| 104 |
"instance": NotifyNotica, |
| 105 |
# Our expected url(privacy=True) startswith() response: |
| 106 |
"privacy_url": "notica://user:****@localhost/a/path/r...r", |
| 107 |
}, |
| 108 |
), |
| 109 |
( |
| 110 |
"notica://localhost:8080/%s" % ("a" * 6), |
| 111 |
{ |
| 112 |
"instance": NotifyNotica, |
| 113 |
}, |
| 114 |
), |
| 115 |
( |
| 116 |
"notica://user:pass@localhost:8080/%s" % ("b" * 6), |
| 117 |
{ |
| 118 |
"instance": NotifyNotica, |
| 119 |
}, |
| 120 |
), |
| 121 |
( |
| 122 |
"noticas://localhost/%s" % ("j" * 6), |
| 123 |
{ |
| 124 |
"instance": NotifyNotica, |
| 125 |
"privacy_url": "noticas://localhost/j...j", |
| 126 |
}, |
| 127 |
), |
| 128 |
( |
| 129 |
"noticas://user:pass@localhost/%s" % ("e" * 6), |
| 130 |
{ |
| 131 |
"instance": NotifyNotica, |
| 132 |
# Our expected url(privacy=True) startswith() response: |
| 133 |
"privacy_url": "noticas://user:****@localhost/e...e", |
| 134 |
}, |
| 135 |
), |
| 136 |
( |
| 137 |
"noticas://localhost:8080/path/%s" % ("5" * 6), |
| 138 |
{ |
| 139 |
"instance": NotifyNotica, |
| 140 |
"privacy_url": "noticas://localhost:8080/path/5...5", |
| 141 |
}, |
| 142 |
), |
| 143 |
( |
| 144 |
"noticas://user:pass@localhost:8080/%s" % ("6" * 6), |
| 145 |
{ |
| 146 |
"instance": NotifyNotica, |
| 147 |
}, |
| 148 |
), |
| 149 |
( |
| 150 |
"notica://%s" % ("b" * 6), |
| 151 |
{ |
| 152 |
"instance": NotifyNotica, |
| 153 |
# don't include an image by default |
| 154 |
"include_image": False, |
| 155 |
}, |
| 156 |
), |
| 157 |
# Test Header overrides |
| 158 |
( |
| 159 |
"notica://localhost:8080//%s/?+HeaderKey=HeaderValue" % ("7" * 6), |
| 160 |
{ |
| 161 |
"instance": NotifyNotica, |
| 162 |
}, |
| 163 |
), |
| 164 |
( |
| 165 |
"notica://%s" % ("c" * 6), |
| 166 |
{ |
| 167 |
"instance": NotifyNotica, |
| 168 |
# force a failure |
| 169 |
"response": False, |
| 170 |
"requests_response_code": requests.codes.internal_server_error, |
| 171 |
}, |
| 172 |
), |
| 173 |
( |
| 174 |
"notica://%s" % ("d" * 7), |
| 175 |
{ |
| 176 |
"instance": NotifyNotica, |
| 177 |
# throw a bizarre code forcing us to fail to look it up |
| 178 |
"response": False, |
| 179 |
"requests_response_code": 999, |
| 180 |
}, |
| 181 |
), |
| 182 |
( |
| 183 |
"notica://%s" % ("e" * 8), |
| 184 |
{ |
| 185 |
"instance": NotifyNotica, |
| 186 |
# Throws a series of i/o exceptions with this flag |
| 187 |
# is set and tests that we gracefully handle them |
| 188 |
"test_requests_exceptions": True, |
| 189 |
}, |
| 190 |
), |
| 191 |
) |
| 192 |
|
| 193 |
|
| 194 |
def test_plugin_notica_urls(): |
| 195 |
"""NotifyNotica() Apprise URLs.""" |
| 196 |
|
| 197 |
# Run our general tests |
| 198 |
AppriseURLTester(tests=apprise_url_tests).run_all() |