Skip to content

Commit 0f6691c

Browse files
[Fix] 500 error by enforcing valid UUID patterns in admin URLs #682
Fixes #682
1 parent d090a70 commit 0f6691c

File tree

2 files changed

+4
-21
lines changed

2 files changed

+4
-21
lines changed

openwisp_controller/config/tests/utils.py

-21
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from uuid import uuid4
1010

1111
from django.db.utils import DEFAULT_DB_ALIAS
12-
from django.http import HttpResponse
1312
from openwisp_ipam.tests import CreateModelsMixin as CreateIpamModelsMixin
1413
from swapper import load_model
1514

@@ -26,26 +25,6 @@
2625
Cert = load_model('django_x509', 'Cert')
2726

2827

29-
class TestUtilsMixin:
30-
"""
31-
Mixin for testing utility functions from utils.py
32-
"""
33-
def _create_http_request(self, ip='127.0.0.1', management_ip=None):
34-
class MockRequest:
35-
META = {'REMOTE_ADDR': ip}
36-
GET = {}
37-
38-
request = MockRequest()
39-
if management_ip:
40-
request.GET['management_ip'] = management_ip
41-
return request
42-
43-
def _create_controller_response(self, content='', content_type='text/plain', status=200):
44-
response = HttpResponse(content, content_type=content_type, status=status)
45-
response['X-Openwisp-Controller'] = 'true'
46-
return response
47-
48-
4928
class CreateDeviceMixin(TestOrganizationMixin):
5029
TEST_MAC_ADDRESS = '00:11:22:33:44:55'
5130

openwisp_controller/config/utils.py

+4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import logging
2+
import re
23

34
from django.core.exceptions import ValidationError
45
from django.db.models import Q
@@ -9,6 +10,9 @@
910

1011
logger = logging.getLogger(__name__)
1112

13+
# Define UUID_PATTERN for URL regular expressions
14+
UUID_PATTERN = r'[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}'
15+
1216

1317
def get_object_or_404(model, **kwargs):
1418
"""

0 commit comments

Comments
 (0)