mirror of
https://github.com/caronc/apprise-api.git
synced 2025-08-16 17:40:56 +02:00
allow restrictions to stateless url queries
This commit is contained in:
@ -637,23 +637,25 @@ class StatelessNotifyTests(SimpleTestCase):
|
||||
|
||||
# Send our service with the `json://` denied
|
||||
with override_settings(APPRISE_ALLOW_SERVICES=""):
|
||||
with override_settings(APPRISE_DENY_SERVICES="json"):
|
||||
# Send our notification as a JSON object
|
||||
response = self.client.post(
|
||||
'/notify',
|
||||
data=json.dumps(json_data),
|
||||
content_type='application/json',
|
||||
)
|
||||
# Test our stateless storage setting (just to kill 2 birds with 1 stone)
|
||||
with override_settings(APPRISE_STATELESS_STORAGE="yes"):
|
||||
with override_settings(APPRISE_DENY_SERVICES="json"):
|
||||
# Send our notification as a JSON object
|
||||
response = self.client.post(
|
||||
'/notify',
|
||||
data=json.dumps(json_data),
|
||||
content_type='application/json',
|
||||
)
|
||||
|
||||
# json:// is disabled
|
||||
assert response.status_code == 204
|
||||
assert mock_send.call_count == 0
|
||||
# json:// is disabled
|
||||
assert response.status_code == 204
|
||||
assert mock_send.call_count == 0
|
||||
|
||||
# What actually took place behind close doors:
|
||||
assert N_MGR['json'].enabled is False
|
||||
# What actually took place behind close doors:
|
||||
assert N_MGR['json'].enabled is False
|
||||
|
||||
# Reset our flag (for next test)
|
||||
N_MGR['json'].enabled = True
|
||||
# Reset our flag (for next test)
|
||||
N_MGR['json'].enabled = True
|
||||
|
||||
# Reset Mock
|
||||
mock_send.reset_mock()
|
||||
|
@ -1363,13 +1363,17 @@ class StatelessNotifyView(View):
|
||||
kwargs = {
|
||||
# Load our dynamic plugin path
|
||||
'plugin_paths': settings.APPRISE_PLUGIN_PATHS,
|
||||
# Load our persistent storage path
|
||||
'storage_path': settings.APPRISE_STORAGE_DIR,
|
||||
# Our storage URL ID Length
|
||||
'storage_idlen': settings.APPRISE_STORAGE_UID_LENGTH,
|
||||
# Define if we flush to disk as soon as possible or not when required
|
||||
'storage_mode': settings.APPRISE_STORAGE_MODE,
|
||||
}
|
||||
if settings.APPRISE_STATELESS_STORAGE:
|
||||
# Persistent Storage is allowed with Stateless queries
|
||||
kwargs.update({
|
||||
# Load our persistent storage path
|
||||
'storage_path': settings.APPRISE_STORAGE_DIR,
|
||||
# Our storage URL ID Length
|
||||
'storage_idlen': settings.APPRISE_STORAGE_UID_LENGTH,
|
||||
# Define if we flush to disk as soon as possible or not when required
|
||||
'storage_mode': settings.APPRISE_STORAGE_MODE,
|
||||
})
|
||||
|
||||
if body_format:
|
||||
# Store our defined body format
|
||||
|
Reference in New Issue
Block a user