Skip to content

Commit 0fff302

Browse files
committed
Fix response codes and updated tests
Changes to be committed: modified: authentication/apis.py modified: tests/fixtures/test_data.json modified: tests/test_views/test_api_auth_remove.py
1 parent 357443f commit 0fff302

File tree

3 files changed

+90
-150
lines changed

3 files changed

+90
-150
lines changed

authentication/apis.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,8 @@ class RemoveAuthenticationApi(APIView):
213213
request_body=schema,
214214
responses={
215215
200: "Remove authentication is successful.",
216-
400: "Bad request.",
217-
409: "That object already exists for this account.",
216+
403: "Authentication failed.",
217+
404: "That object does not exist for this account.",
218218
},
219219
tags=["Authentication"],
220220
)
@@ -225,20 +225,21 @@ def post(self, request):
225225
result = validate_auth_service(request.data)
226226
if result != 1:
227227
return Response(
228-
status=status.HTTP_400_BAD_REQUEST,
228+
status=status.HTTP_403_FORBIDDEN,
229229
data=result
230230
)
231+
231232
try:
232233
auth_object = Authentication.objects.get(username=request.user.username)
233234
except Authentication.DoesNotExist:
234235
return Response(
235-
status=status.HTTP_409_CONFLICT,
236-
data={"message": "That object does not exists."}
236+
status=status.HTTP_404_NOT_FOUND,
237+
data={"message": "That object does not exists for this user."}
237238
)
238239
if request.data not in auth_object.auth_service:
239240
return Response(
240-
status=status.HTTP_409_CONFLICT,
241-
data={"message": "That object does not exists."}
241+
status=status.HTTP_404_NOT_FOUND,
242+
data={"message": "That object does not exists for this user."}
242243
)
243244
auth_object.auth_service.remove(request.data)
244245
auth_object.save()

0 commit comments

Comments
 (0)