From a20a7710aaf8501e7ffe0138bb8d7831e4aa396f Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Tue, 12 Jul 2022 09:55:33 -0400 Subject: [PATCH] Island: Use HTTPStatus Enum in registration resource --- monkey/monkey_island/cc/resources/auth/registration.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/monkey/monkey_island/cc/resources/auth/registration.py b/monkey/monkey_island/cc/resources/auth/registration.py index e4928165f..6c2124dd5 100644 --- a/monkey/monkey_island/cc/resources/auth/registration.py +++ b/monkey/monkey_island/cc/resources/auth/registration.py @@ -1,4 +1,5 @@ import logging +from http import HTTPStatus from flask import make_response, request @@ -25,7 +26,7 @@ class Registration(AbstractResource): try: self._authentication_service.register_new_user(username, password) - return make_response({"error": ""}, 200) + return make_response({"error": ""}, HTTPStatus.OK) # API Spec: HTTP status code for AlreadyRegisteredError should be 409 (CONFLICT) except (InvalidRegistrationCredentialsError, AlreadyRegisteredError) as e: - return make_response({"error": str(e)}, 400) + return make_response({"error": str(e)}, HTTPStatus.BAD_REQUEST)