fix: [VAN-823] Remove Authn MFE Waffle Flag (#29778)
This commit is contained in:
@@ -13,14 +13,12 @@ from django.core.management import call_command, CommandError
|
||||
from django.core.files.uploadedfile import SimpleUploadedFile
|
||||
from django.test import TestCase, RequestFactory, override_settings
|
||||
|
||||
from edx_toggles.toggles.testutils import override_waffle_flag
|
||||
|
||||
from testfixtures import LogCapture
|
||||
from common.djangoapps.student.tests.factories import UserFactory
|
||||
from common.djangoapps.student.models import AccountRecoveryConfiguration
|
||||
|
||||
from openedx.core.djangolib.testing.utils import skip_unless_lms
|
||||
from openedx.core.djangoapps.user_authn.toggles import REDIRECT_TO_AUTHN_MICROFRONTEND
|
||||
|
||||
LOGGER_NAME = 'common.djangoapps.student.management.commands.recover_account'
|
||||
FEATURES_WITH_AUTHN_MFE_ENABLED = settings.FEATURES.copy()
|
||||
@@ -73,7 +71,6 @@ class RecoverAccountTests(TestCase):
|
||||
assert not self.client.login(username=self.user.username, password='password')
|
||||
|
||||
@override_settings(FEATURES=FEATURES_WITH_AUTHN_MFE_ENABLED)
|
||||
@override_waffle_flag(REDIRECT_TO_AUTHN_MICROFRONTEND, active=True)
|
||||
@skip_unless_lms
|
||||
def test_authn_mfe_url_in_reset_link(self):
|
||||
"""
|
||||
|
||||
@@ -12,12 +12,10 @@ from django.contrib.auth.models import User # lint-amnesty, pylint: disable=imp
|
||||
from django.test import TestCase, override_settings
|
||||
from django.urls import reverse
|
||||
from django.utils.http import urlencode
|
||||
from edx_toggles.toggles.testutils import override_waffle_flag
|
||||
|
||||
from common.djangoapps.student.models import Registration
|
||||
from common.djangoapps.student.tests.factories import UserFactory
|
||||
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
|
||||
from openedx.core.djangoapps.user_authn.toggles import REDIRECT_TO_AUTHN_MICROFRONTEND
|
||||
from openedx.features.enterprise_support.tests.factories import EnterpriseCustomerUserFactory
|
||||
|
||||
FEATURES_WITH_AUTHN_MFE_ENABLED = settings.FEATURES.copy()
|
||||
@@ -184,7 +182,6 @@ class TestActivateAccount(TestCase):
|
||||
|
||||
@override_settings(LOGIN_REDIRECT_WHITELIST=['localhost:1991'])
|
||||
@override_settings(FEATURES={**FEATURES_WITH_AUTHN_MFE_ENABLED, 'ENABLE_ENTERPRISE_INTEGRATION': True})
|
||||
@override_waffle_flag(REDIRECT_TO_AUTHN_MICROFRONTEND, active=True)
|
||||
def test_authenticated_account_activation_with_valid_next_url(self):
|
||||
"""
|
||||
Verify that an activation link with a valid next URL will redirect
|
||||
@@ -213,8 +210,6 @@ class TestActivateAccount(TestCase):
|
||||
self._assert_user_active_state(expected_active_state=True)
|
||||
|
||||
@override_settings(LOGIN_REDIRECT_WHITELIST=['localhost:9876'])
|
||||
@override_settings(FEATURES=FEATURES_WITH_AUTHN_MFE_ENABLED)
|
||||
@override_waffle_flag(REDIRECT_TO_AUTHN_MICROFRONTEND, active=False)
|
||||
def test_account_activation_invalid_next_url_redirects_dashboard(self):
|
||||
"""
|
||||
Verify that an activation link with an invalid next URL (i.e. it's for a domain
|
||||
@@ -241,7 +236,6 @@ class TestActivateAccount(TestCase):
|
||||
self._assert_user_active_state(expected_active_state=True)
|
||||
|
||||
@override_settings(FEATURES=FEATURES_WITH_AUTHN_MFE_ENABLED)
|
||||
@override_waffle_flag(REDIRECT_TO_AUTHN_MICROFRONTEND, active=True)
|
||||
def test_unauthenticated_user_redirects_to_mfe(self):
|
||||
"""
|
||||
Verify that if Authn MFE is enabled then authenticated user redirects to
|
||||
@@ -267,7 +261,6 @@ class TestActivateAccount(TestCase):
|
||||
|
||||
@override_settings(LOGIN_REDIRECT_WHITELIST=['localhost:1991'])
|
||||
@override_settings(FEATURES=FEATURES_WITH_AUTHN_MFE_ENABLED)
|
||||
@override_waffle_flag(REDIRECT_TO_AUTHN_MICROFRONTEND, active=True)
|
||||
def test_unauthenticated_user_redirects_to_mfe_with_valid_next_url(self):
|
||||
"""
|
||||
Verify that if Authn MFE is enabled then authenticated user redirects to
|
||||
|
||||
@@ -5,7 +5,6 @@ Toggles for user_authn
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
from edx_toggles.toggles import WaffleFlag
|
||||
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
|
||||
from openedx.core.djangoapps.theming.helpers import get_current_request
|
||||
|
||||
@@ -23,18 +22,6 @@ def is_require_third_party_auth_enabled():
|
||||
# TODO: Replace function with SettingToggle when it is available.
|
||||
return getattr(settings, "ENABLE_REQUIRE_THIRD_PARTY_AUTH", False)
|
||||
|
||||
# .. toggle_name: user_authn.redirect_to_microfrontend
|
||||
# .. toggle_implementation: WaffleFlag
|
||||
# .. toggle_default: False
|
||||
# .. toggle_description: Supports staged rollout of a new micro-frontend-based implementation of the login and
|
||||
# registration pages
|
||||
# .. toggle_use_cases: temporary, open_edx
|
||||
# .. toggle_creation_date: 2021-02-02
|
||||
# .. toggle_target_removal_date: None
|
||||
# .. toggle_warnings: Also set settings.AUTHN_MICROFRONTEND_URL and site's ENABLE_AUTHN_MICROFRONTEND
|
||||
# .. toggle_tickets: VAN-308
|
||||
REDIRECT_TO_AUTHN_MICROFRONTEND = WaffleFlag('user_authn.redirect_to_microfrontend', __name__)
|
||||
|
||||
|
||||
def should_redirect_to_authn_microfrontend():
|
||||
"""
|
||||
@@ -43,7 +30,6 @@ def should_redirect_to_authn_microfrontend():
|
||||
request = get_current_request()
|
||||
if request and request.GET.get('skip_authn_mfe'):
|
||||
return False
|
||||
|
||||
return configuration_helpers.get_value(
|
||||
'ENABLE_AUTHN_MICROFRONTEND', settings.FEATURES.get('ENABLE_AUTHN_MICROFRONTEND')
|
||||
) and REDIRECT_TO_AUTHN_MICROFRONTEND.is_enabled()
|
||||
)
|
||||
|
||||
@@ -18,7 +18,7 @@ from django.http import HttpResponse
|
||||
from django.test.client import Client
|
||||
from django.test.utils import override_settings
|
||||
from django.urls import NoReverseMatch, reverse
|
||||
from edx_toggles.toggles.testutils import override_waffle_flag, override_waffle_switch
|
||||
from edx_toggles.toggles.testutils import override_waffle_switch
|
||||
from freezegun import freeze_time
|
||||
from common.djangoapps.student.tests.factories import RegistrationFactory, UserFactory, UserProfileFactory
|
||||
from openedx_events.tests.utils import OpenEdxEventsTestMixin # lint-amnesty, pylint: disable=wrong-import-order
|
||||
@@ -30,7 +30,6 @@ from openedx.core.djangoapps.password_policy.compliance import (
|
||||
from openedx.core.djangoapps.user_api.accounts import EMAIL_MIN_LENGTH, EMAIL_MAX_LENGTH
|
||||
from openedx.core.djangoapps.user_authn.cookies import jwt_cookies
|
||||
from openedx.core.djangoapps.user_authn.tests.utils import setup_login_oauth_client
|
||||
from openedx.core.djangoapps.user_authn.toggles import REDIRECT_TO_AUTHN_MICROFRONTEND
|
||||
from openedx.core.djangoapps.user_authn.views.login import (
|
||||
ENABLE_LOGIN_USING_THIRDPARTY_AUTH_ONLY,
|
||||
AllowedAuthUser,
|
||||
@@ -192,7 +191,6 @@ class LoginTest(SiteMixin, CacheIsolationTestCase, OpenEdxEventsTestMixin):
|
||||
@ddt.unpack
|
||||
@override_settings(LOGIN_REDIRECT_WHITELIST=['openedx.service'])
|
||||
@override_settings(FEATURES=FEATURES_WITH_AUTHN_MFE_ENABLED)
|
||||
@override_waffle_flag(REDIRECT_TO_AUTHN_MICROFRONTEND, active=True)
|
||||
@skip_unless_lms
|
||||
def test_login_success_with_redirect(self, next_url, course_id, expected_redirect):
|
||||
post_params = {}
|
||||
@@ -215,7 +213,6 @@ class LoginTest(SiteMixin, CacheIsolationTestCase, OpenEdxEventsTestMixin):
|
||||
@ddt.unpack
|
||||
@patch.dict(settings.FEATURES, {'ENABLE_AUTHN_MICROFRONTEND': True, 'ENABLE_ENTERPRISE_INTEGRATION': True})
|
||||
@override_settings(LOGIN_REDIRECT_WHITELIST=['openedx.service'])
|
||||
@override_waffle_flag(REDIRECT_TO_AUTHN_MICROFRONTEND, active=True)
|
||||
@patch('openedx.features.enterprise_support.api.EnterpriseApiClient')
|
||||
@patch('openedx.core.djangoapps.user_authn.views.login.reverse')
|
||||
@skip_unless_lms
|
||||
@@ -265,7 +262,6 @@ class LoginTest(SiteMixin, CacheIsolationTestCase, OpenEdxEventsTestMixin):
|
||||
@ddt.data(('', True), ('/enterprise/select/active/?success_url=', False))
|
||||
@ddt.unpack
|
||||
@patch.dict(settings.FEATURES, {'ENABLE_AUTHN_MICROFRONTEND': True, 'ENABLE_ENTERPRISE_INTEGRATION': True})
|
||||
@override_waffle_flag(REDIRECT_TO_AUTHN_MICROFRONTEND, active=True)
|
||||
@patch('openedx.features.enterprise_support.api.EnterpriseApiClient')
|
||||
@patch('openedx.core.djangoapps.user_authn.views.login.activate_learner_enterprise')
|
||||
@patch('openedx.core.djangoapps.user_authn.views.login.reverse')
|
||||
|
||||
@@ -18,7 +18,6 @@ from django.test.client import RequestFactory
|
||||
from django.test.utils import override_settings
|
||||
from django.urls import reverse
|
||||
from django.utils.translation import gettext as _
|
||||
from edx_toggles.toggles.testutils import override_waffle_flag
|
||||
from freezegun import freeze_time
|
||||
from pytz import UTC
|
||||
|
||||
@@ -27,7 +26,6 @@ from lms.djangoapps.branding.api import get_privacy_url
|
||||
from openedx.core.djangoapps.site_configuration.tests.mixins import SiteMixin
|
||||
from openedx.core.djangoapps.theming.tests.test_util import with_comprehensive_theme_context
|
||||
from openedx.core.djangoapps.user_authn.cookies import JWT_COOKIE_NAMES
|
||||
from openedx.core.djangoapps.user_authn.toggles import REDIRECT_TO_AUTHN_MICROFRONTEND
|
||||
from openedx.core.djangoapps.user_authn.tests.utils import setup_login_oauth_client
|
||||
from openedx.core.djangoapps.user_authn.views.login_form import login_and_registration_form
|
||||
from openedx.core.djangolib.js_utils import dump_js_escaped_json
|
||||
@@ -83,14 +81,8 @@ class LoginAndRegistrationTest(ThirdPartyAuthTestMixin, UrlResetMixin, ModuleSto
|
||||
the correct URL.
|
||||
"""
|
||||
|
||||
# Test with setting enabled and waffle flag in-active, does not redirect
|
||||
response = self.client.get(reverse(url_name))
|
||||
self.assertContains(response, 'Sign in or Register')
|
||||
|
||||
# Test with setting enabled and waffle flag active, redirects to microfrontend
|
||||
with override_waffle_flag(REDIRECT_TO_AUTHN_MICROFRONTEND, active=True):
|
||||
response = self.client.get(reverse(url_name))
|
||||
self.assertRedirects(response, settings.AUTHN_MICROFRONTEND_URL + path, fetch_redirect_response=False)
|
||||
self.assertRedirects(response, settings.AUTHN_MICROFRONTEND_URL + path, fetch_redirect_response=False)
|
||||
|
||||
@ddt.data(
|
||||
(
|
||||
@@ -106,7 +98,6 @@ class LoginAndRegistrationTest(ThirdPartyAuthTestMixin, UrlResetMixin, ModuleSto
|
||||
)
|
||||
@ddt.unpack
|
||||
@override_settings(FEATURES=FEATURES_WITH_AUTHN_MFE_ENABLED)
|
||||
@override_waffle_flag(REDIRECT_TO_AUTHN_MICROFRONTEND, active=True)
|
||||
def test_logistration_redirect_params(self, url_name, path, query_params):
|
||||
"""
|
||||
Test that if request is redirected to logistration MFE,
|
||||
|
||||
@@ -22,7 +22,6 @@ from django.test.client import RequestFactory
|
||||
from django.test.utils import override_settings
|
||||
from django.urls import reverse
|
||||
from django.utils.http import int_to_base36
|
||||
from edx_toggles.toggles.testutils import override_waffle_flag
|
||||
from freezegun import freeze_time
|
||||
from oauth2_provider import models as dot_models
|
||||
from pytz import UTC
|
||||
@@ -36,7 +35,6 @@ from openedx.core.djangoapps.user_api.accounts import EMAIL_MAX_LENGTH, EMAIL_MI
|
||||
from openedx.core.djangoapps.user_authn.views.password_reset import (
|
||||
SETTING_CHANGE_INITIATED, password_reset, LogistrationPasswordResetView,
|
||||
PasswordResetConfirmWrapper)
|
||||
from openedx.core.djangoapps.user_authn.toggles import REDIRECT_TO_AUTHN_MICROFRONTEND
|
||||
from openedx.core.djangolib.testing.utils import CacheIsolationTestCase
|
||||
from common.djangoapps.student.tests.factories import TEST_PASSWORD, UserFactory
|
||||
from common.djangoapps.student.tests.test_configuration_overrides import fake_get_value
|
||||
@@ -325,7 +323,6 @@ class ResetPasswordTests(EventTestMixin, CacheIsolationTestCase):
|
||||
)
|
||||
|
||||
@override_settings(FEATURES=ENABLE_AUTHN_MICROFRONTEND)
|
||||
@override_waffle_flag(REDIRECT_TO_AUTHN_MICROFRONTEND, active=True)
|
||||
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', "Test only valid in LMS")
|
||||
@ddt.data(('Crazy Awesome Site', 'Crazy Awesome Site'), ('edX', 'edX'))
|
||||
@ddt.unpack
|
||||
|
||||
Reference in New Issue
Block a user