Ver código fonte

fix(api): better adhere to DynDNS RA-API

Rationale:
- Status code: https://help.dyn.com/remote-access-api/guidelines/
- Body: https://help.dyn.com/remote-access-api/return-codes/
Peter Thomassen 6 anos atrás
pai
commit
5488d3cd1b
2 arquivos alterados com 3 adições e 4 exclusões
  1. 1 1
      api/desecapi/authentication.py
  2. 2 3
      api/desecapi/views.py

+ 1 - 1
api/desecapi/authentication.py

@@ -91,7 +91,7 @@ class URLParamAuthentication(BaseAuthentication):
         try:
             token = self.model.objects.get(key=key)
         except self.model.DoesNotExist:
-            raise exceptions.AuthenticationFailed('Invalid token')
+            raise exceptions.AuthenticationFailed('badauth')
 
         if not token.user.is_active:
             raise exceptions.AuthenticationFailed('User inactive or deleted')

+ 2 - 3
api/desecapi/views.py

@@ -17,8 +17,7 @@ from django.template.loader import get_template
 import desecapi.authentication as auth
 import base64, binascii
 from api import settings
-from rest_framework.exceptions import (
-    APIException, MethodNotAllowed, PermissionDenied, ValidationError)
+from rest_framework.exceptions import (NotFound, PermissionDenied, ValidationError)
 import django.core.exceptions
 from djoser import views, signals
 from rest_framework import status
@@ -430,7 +429,7 @@ class DynDNS12Update(APIView):
         domain = self.findDomain(request)
 
         if domain is None:
-            raise Http404
+            raise NotFound('nohost')
 
         datas = {'A': self.findIPv4(request), 'AAAA': self.findIPv6(request)}
         rrsets = RRset.plain_to_RRsets(