fix: Removed usage of djangoratelimitbackend. (#30116)

* fix: Removed usage of djangoratelimitbackend.
This commit is contained in:
Awais Qureshi
2022-03-25 15:27:39 +05:00
committed by GitHub
parent 935c01c9ee
commit bc45f1ee48
14 changed files with 28 additions and 98 deletions

View File

@@ -6,9 +6,6 @@ This is not inside a django app because it is a global property of the system.
import ddt
from django.test import TestCase
from django.urls import reverse
from edx_toggles.toggles.testutils import override_waffle_flag
from openedx.core.djangoapps.user_authn.config.waffle import ADMIN_AUTH_REDIRECT_TO_LMS
@ddt.ddt
@@ -16,17 +13,8 @@ class TestAdminView(TestCase):
"""
Tests of the admin view.
"""
@override_waffle_flag(ADMIN_AUTH_REDIRECT_TO_LMS, True)
@ddt.data('/admin/', '/admin/login', reverse('admin:login'))
def test_admin_login_redirect(self, admin_url):
"""Admin login will redirect towards the site login page."""
response = self.client.get(admin_url, follow=True)
assert any('/login/edx-oauth2/?next=' in r[0] for r in response.redirect_chain)
def test_admin_login_default(self):
"""Without flag Admin login will redirect towards the admin default login page."""
response = self.client.get('/admin/', follow=True)
assert response.status_code == 200
self.assertIn('/admin/login/?next=/admin/', response.redirect_chain[0])
assert len(response.redirect_chain) == 1
assert response.template_name == ['admin/login.html']

View File

@@ -7,10 +7,8 @@ from django.conf import settings
from django.shortcuts import redirect
from urllib.parse import quote_plus # lint-amnesty, pylint: disable=wrong-import-order
from waffle.decorators import waffle_switch
from django.contrib import admin
from common.djangoapps.edxmako.shortcuts import render_to_response
from openedx.core.djangoapps.user_authn.config.waffle import ADMIN_AUTH_REDIRECT_TO_LMS
from ..config import waffle
@@ -48,10 +46,7 @@ def redirect_to_lms_login_for_admin(request):
"""
This view redirect the admin/login url to the site's login page.
"""
if ADMIN_AUTH_REDIRECT_TO_LMS.is_enabled():
return redirect('/login?next=/admin')
else:
return admin.site.login(request)
return redirect('/login?next=/admin')
def _build_next_param(request):

View File

@@ -17,10 +17,7 @@
{% endif %}
{% endif %}
{% flag "user_authn.admin_auth_redirect_to_lms" %}
<a href="/logout/">{% trans 'Log out' as tmsg %} {{tmsg|force_escape}}</a>
{% else %}
<a href="{% url 'admin:logout' %}">{% trans 'Log out' as tmsg %} {{tmsg|force_escape}}</a>
{% endflag %}
<a href="/logout/">{% trans 'Log out' as tmsg %} {{tmsg|force_escape}}</a>
{% endblock %}