feat: remove the registration.enable_failure_logging temporary Waffle… (#32977)

* feat: remove the registration.enable_failure_logging temporary WaffleFlag depr84
This commit is contained in:
Yagnesh1998
2023-08-22 19:33:28 +05:30
committed by GitHub
parent a3cb678a16
commit a5b1fdad38
2 changed files with 0 additions and 65 deletions

View File

@@ -23,7 +23,6 @@ from django.views.decorators.csrf import csrf_exempt, ensure_csrf_cookie
from django.views.decorators.debug import sensitive_post_parameters
from django_countries import countries
from edx_django_utils.monitoring import set_custom_attribute
from edx_toggles.toggles import WaffleFlag
from openedx_events.learning.data import UserData, UserPersonalData
from openedx_events.learning.signals import STUDENT_REGISTRATION_COMPLETED
from openedx_filters.learning.filters import StudentRegistrationRequested
@@ -108,15 +107,6 @@ IS_MARKETABLE = 'is_marketable'
REGISTER_USER = Signal()
# .. toggle_name: registration.enable_failure_logging
# .. toggle_implementation: WaffleFlag
# .. toggle_default: False
# .. toggle_description: Enable verbose logging of registration failure messages
# .. toggle_use_cases: temporary
# .. toggle_creation_date: 2020-04-30
# .. toggle_target_removal_date: 2020-06-01
# .. toggle_warning: This temporary feature toggle does not have a target removal date.
REGISTRATION_FAILURE_LOGGING_FLAG = WaffleFlag('registration.enable_failure_logging', __name__)
REAL_IP_KEY = 'openedx.core.djangoapps.util.ratelimit.real_ip'
@@ -699,8 +689,6 @@ class RegistrationView(APIView):
if status_code == 200:
# keeping this `success` field in for now, as we have outstanding clients expecting this
response_dict['success'] = True
else:
self._log_validation_errors(request, response_dict, status_code)
if redirect_url:
response_dict['redirect_url'] = redirect_url
if error_code:
@@ -708,24 +696,6 @@ class RegistrationView(APIView):
set_custom_attribute('register_error_code', error_code)
return JsonResponse(response_dict, status=status_code)
def _log_validation_errors(self, request, errors, status_code):
if not REGISTRATION_FAILURE_LOGGING_FLAG.is_enabled():
return
try:
for field_key, errors in errors.items(): # lint-amnesty, pylint: disable=redefined-argument-from-local
for error in errors:
log.info(
'message=registration_failed, status_code=%d, agent="%s", field="%s", error="%s"',
status_code,
request.META.get('HTTP_USER_AGENT', ''),
field_key,
error['user_message']
)
except: # pylint: disable=bare-except
log.exception("Failed to log registration validation error")
pass # lint-amnesty, pylint: disable=unnecessary-pass
# pylint: disable=line-too-long
class RegistrationValidationView(APIView):

View File

@@ -20,7 +20,6 @@ from social_django.models import Partial, UserSocialAuth
from testfixtures import LogCapture
from openedx_events.tests.utils import OpenEdxEventsTestMixin
from edx_toggles.toggles.testutils import override_waffle_flag
from openedx.core.djangoapps.site_configuration.helpers import get_value
from openedx.core.djangoapps.site_configuration.tests.test_util import with_site_configuration
from openedx.core.djangoapps.user_api.accounts import (
@@ -49,7 +48,6 @@ from openedx.core.djangoapps.user_api.accounts.tests.retirement_helpers import (
from openedx.core.djangoapps.user_api.tests.test_constants import SORTED_COUNTRIES
from openedx.core.djangoapps.user_api.tests.test_helpers import TestCaseForm
from openedx.core.djangoapps.user_api.tests.test_views import UserAPITestCase
from openedx.core.djangoapps.user_authn.views.register import REGISTRATION_FAILURE_LOGGING_FLAG
from openedx.core.djangolib.testing.utils import CacheIsolationTestCase, skip_unless_lms
from openedx.core.lib.api import test_utils
from common.djangoapps.student.helpers import authenticate_new_user
@@ -296,39 +294,6 @@ class RegistrationViewValidationErrorTest(
}
)
@override_waffle_flag(REGISTRATION_FAILURE_LOGGING_FLAG, True)
def test_registration_failure_logging(self):
# Register a user
response = self.client.post(self.url, {
"email": self.EMAIL,
"name": self.NAME,
"username": self.USERNAME,
"password": self.PASSWORD,
"honor_code": "true",
})
self.assertHttpOK(response)
# Try to create a second user with the same email address
response = self.client.post(self.url, {
"email": self.EMAIL,
"name": "Someone Else",
"username": "someone_else",
"password": self.PASSWORD,
"honor_code": "true",
})
assert response.status_code == 409
response_json = json.loads(response.content.decode('utf-8'))
self.assertDictEqual(
response_json,
{
"email": [{
"user_message": AUTHN_EMAIL_CONFLICT_MSG,
}],
"error_code": "duplicate-email"
}
)
def test_register_duplicate_username_account_validation_error(self):
# Register the first user
response = self.client.post(self.url, {