Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 12 commits into from
Aug 22, 2023
30 changes: 0 additions & 30 deletions openedx/core/djangoapps/user_authn/views/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
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
Expand Down Expand Up @@ -108,15 +107,6 @@
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'


Expand Down Expand Up @@ -699,33 +689,13 @@ def _create_response(self, request, response_dict, status_code, redirect_url=Non
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:
response_dict['error_code'] = error_code
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):
Expand Down
35 changes: 0 additions & 35 deletions openedx/core/djangoapps/user_authn/views/tests/test_register.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
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 (
Expand Down Expand Up @@ -49,7 +48,6 @@
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
Expand Down Expand Up @@ -296,39 +294,6 @@ def test_register_fullname_url_validation_error(self):
}
)

@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, {
Expand Down
Loading