mirror of
https://github.com/caronc/apprise-api.git
synced 2025-08-16 17:40:56 +02:00
Increased key length maximum size to 128 characters (#138)
This commit is contained in:
@ -28,6 +28,7 @@ from unittest.mock import patch
|
||||
from django.test.utils import override_settings
|
||||
from ..forms import AUTO_DETECT_CONFIG_KEYWORD
|
||||
import json
|
||||
import hashlib
|
||||
|
||||
|
||||
class AddTests(SimpleTestCase):
|
||||
@ -39,6 +40,30 @@ class AddTests(SimpleTestCase):
|
||||
response = self.client.get('/add/**invalid-key**')
|
||||
assert response.status_code == 404
|
||||
|
||||
def test_key_lengths(self):
|
||||
"""
|
||||
Test our key lengths
|
||||
"""
|
||||
|
||||
# our key to use
|
||||
h = hashlib.sha512()
|
||||
h.update(b'string')
|
||||
key = h.hexdigest()
|
||||
|
||||
# Our limit
|
||||
assert len(key) == 128
|
||||
|
||||
# Add our URL
|
||||
response = self.client.post(
|
||||
'/add/{}'.format(key), {'urls': 'mailto://user:pass@yahoo.ca'})
|
||||
assert response.status_code == 200
|
||||
|
||||
# However adding just 1 more character exceeds our limit and the save
|
||||
# will fail
|
||||
response = self.client.post(
|
||||
'/add/{}'.format(key + 'x'), {'urls': 'mailto://user:pass@yahoo.ca'})
|
||||
assert response.status_code == 404
|
||||
|
||||
@override_settings(APPRISE_CONFIG_LOCK=True)
|
||||
def test_save_config_by_urls_with_lock(self):
|
||||
"""
|
||||
|
Reference in New Issue
Block a user