aboutsummaryrefslogtreecommitdiffstats
path: root/src/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/api')
-rw-r--r--src/api/tests/test_models_unittest.py2
-rw-r--r--src/api/views.py6
2 files changed, 6 insertions, 2 deletions
diff --git a/src/api/tests/test_models_unittest.py b/src/api/tests/test_models_unittest.py
index 2a6fa0b..2dee29b 100644
--- a/src/api/tests/test_models_unittest.py
+++ b/src/api/tests/test_models_unittest.py
@@ -116,7 +116,7 @@ class ValidBookingCreatesValidJob(TestCase):
count = hostprofile.interfaceprofile.all().count()
for i in range(count):
network_struct.append([])
- while(nets):
+ while (nets):
index = len(nets) % count
network_struct[index].append(nets.pop())
diff --git a/src/api/views.py b/src/api/views.py
index 1516374..ffa9b3f 100644
--- a/src/api/views.py
+++ b/src/api/views.py
@@ -430,7 +430,11 @@ def auth_and_log(request, endpoint):
token = Token.objects.get(key=user_token)
except Token.DoesNotExist:
token = None
- response = HttpResponse('Unauthorized', status=401)
+ # Added logic to detect malformed token
+ if len(str(user_token)) != 40:
+ response = HttpResponse('Malformed Token', status=401)
+ else:
+ response = HttpResponse('Unauthorized', status=401)
x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR')
if x_forwarded_for: