Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ jobs:
name: ${{ matrix.shard_name }}(py=${{ matrix.python-version }},dj=${{ matrix.django-version }},mongo=${{ matrix.mongo-version }})
runs-on: ${{ matrix.os-version }}
strategy:
# TEMPORARY - revert before merge.
# The default (fail-fast: true) cancels every other shard as soon as one fails, so a
# change that breaks tests broadly only ever reports the first shard's failures. Let
# every shard finish so we get the full list in one run.
fail-fast: false
matrix:
python-version:
- "3.12"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,14 @@
LOGGER_NAME = 'common.djangoapps.student.management.commands.recover_account'


@override_settings(ENABLE_AUTHN_MICROFRONTEND=False)
class RecoverAccountTests(TestCase):
"""
Test account recovery and exception handling

The reset link the command mails out points at the authn MFE when
ENABLE_AUTHN_MICROFRONTEND is on, so the legacy-path cases pin it off and
test_authn_mfe_url_in_reset_link turns it back on.
"""

request_factory = RequestFactory()
Expand Down
4 changes: 4 additions & 0 deletions common/djangoapps/student/tests/test_activate_account.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@

@skip_unless_lms
@ddt.ddt
# Activation redirects and messaging differ depending on whether logistration is served by
# the legacy page or the authn MFE. Pin the flag off for the legacy cases; the MFE cases
# turn it back on per-method.
@override_settings(ENABLE_AUTHN_MICROFRONTEND=False)
class TestActivateAccount(TestCase):
"""Tests for account creation"""

Expand Down
9 changes: 3 additions & 6 deletions lms/djangoapps/course_wiki/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,11 @@ def test_redirect_when_not_logged_in(self):
self.logout()
course_wiki_page = reverse('wiki:get', kwargs={'path': self.toy.wiki_slug + '/'})

# When not logged in, we should get a 302
# When not logged in, we should get a 302 to the login page. Don't follow the
# redirect: the login page may itself redirect on to the authn MFE.
resp = self.client.get(course_wiki_page, follow=False)
assert resp.status_code == 302

# and end up at the login page
resp = self.client.get(course_wiki_page, follow=True)
target_url, __ = resp.redirect_chain[-1]
assert reverse('signin_user') in target_url
assert reverse('signin_user') in resp['Location']

@override_settings(ALLOW_WIKI_ROOT_ACCESS=True)
def test_create_wiki_with_long_course_id(self):
Expand Down
3 changes: 2 additions & 1 deletion lms/djangoapps/courseware/tests/test_course_survey.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ def test_anonymous_user_visiting_course_with_survey(self):
)
self.assertRedirects(
resp,
f'/login?next=/courses/{quote(str(self.course.id))}/courseware'
f'/login?next=/courses/{quote(str(self.course.id))}/courseware',
fetch_redirect_response=False
)

def test_visiting_course_with_existing_answers(self):
Expand Down
2 changes: 1 addition & 1 deletion lms/djangoapps/courseware/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ def test_financial_assistance_login_required(self):
):
self.client.logout()
response = self.client.get(url)
self.assertRedirects(response, reverse('signin_user') + '?next=' + url)
self.assertRedirects(response, reverse('signin_user') + '?next=' + url, fetch_redirect_response=False)

def test_financial_assistance_form_uses_site_config_account_mfe_url(self):
"""
Expand Down
6 changes: 4 additions & 2 deletions lms/djangoapps/learner_dashboard/tests/test_programs.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ def test_login_required(self, mock_get_programs):
response = self.client.get(self.url)
self.assertRedirects(
response,
'{}?next={}'.format(reverse('signin_user'), self.url)
'{}?next={}'.format(reverse('signin_user'), self.url),
fetch_redirect_response=False
)

self.client.login(username=self.user.username, password=self.TEST_PASSWORD)
Expand Down Expand Up @@ -267,7 +268,8 @@ def test_login_required(self, mock_get_programs, mock_get_pathways):
response = self.client.get(self.url)
self.assertRedirects(
response,
'{}?next={}'.format(reverse('signin_user'), self.url)
'{}?next={}'.format(reverse('signin_user'), self.url),
fetch_redirect_response=False
)

self.client.login(username=self.user.username, password=self.TEST_PASSWORD)
Expand Down
6 changes: 5 additions & 1 deletion lms/djangoapps/support/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,13 @@ def test_get_contact_us_redirect_if_undefined_zendesk_url(self):
response = self.client.get(url)
assert response.status_code == 302

@override_settings(ENABLE_AUTHN_MICROFRONTEND=False)
def test_get_password_assistance(self):
"""
Tests password assistance

/password_assistance is the legacy logistration page in reset mode, so it only
renders when the authn MFE is off.
"""
# Ensure that user is not logged in if they need
# password assistance.
Expand Down Expand Up @@ -240,7 +244,7 @@ def test_require_login(self, url_name):
login_url=reverse("signin_user"),
original_url=quote(url),
)
self.assertRedirects(response, redirect_url)
self.assertRedirects(response, redirect_url, fetch_redirect_response=False)


class SupportViewIndexTests(SupportViewTestCase):
Expand Down
2 changes: 1 addition & 1 deletion lms/djangoapps/teams/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def test_anonymous(self):
anonymous_client = APIClient()
response = anonymous_client.get(self.teams_url)
redirect_url = f'{settings.LOGIN_URL}?next={quote(self.teams_url)}'
self.assertRedirects(response, redirect_url)
self.assertRedirects(response, redirect_url, fetch_redirect_response=False)

def test_not_enrolled_not_staff(self):
""" Verifies that a student who is not enrolled cannot access the team dashboard. """
Expand Down
4 changes: 2 additions & 2 deletions lms/envs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,15 +629,15 @@

# .. toggle_name: settings.ENABLE_AUTHN_MICROFRONTEND
# .. toggle_implementation: DjangoSetting
# .. toggle_default: False
# .. toggle_default: True
# .. toggle_description: Supports staged rollout of a new micro-frontend-based implementation of the logistration.
# .. toggle_use_cases: temporary, open_edx
# .. toggle_creation_date: 2020-09-08
# .. toggle_target_removal_date: None
# .. toggle_tickets: 'https://github.com/openedx/edx-platform/pull/24908'
# .. toggle_warning: Also set settings.AUTHN_MICROFRONTEND_URL for rollout. This temporary feature
# toggle does not have a target removal date.
ENABLE_AUTHN_MICROFRONTEND = os.environ.get("EDXAPP_ENABLE_AUTHN_MFE", False)
ENABLE_AUTHN_MICROFRONTEND = os.environ.get("EDXAPP_ENABLE_AUTHN_MFE", True)

# .. toggle_name: settings.ENABLE_CATALOG_MICROFRONTEND
# .. toggle_implementation: DjangoSetting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def test_session_change_lms(self):
response = self.client.get(dashboard_url)

redirect_url = reverse('signin_user') + '?next=' + dashboard_url
self.assertRedirects(response, redirect_url, target_status_code=200)
self.assertRedirects(response, redirect_url, fetch_redirect_response=False)
mock_set_custom_attribute.assert_any_call('failed_session_verification', True)

@skip_unless_cms
Expand Down
4 changes: 1 addition & 3 deletions openedx/core/djangoapps/theming/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,13 @@ def test_preview_theme_access(self):
"""
# Anonymous users get redirected to the login page
response = self.client.get(THEMING_ADMIN_URL)
# Studio login redirects to LMS login
expected_target_status_code = 200 if settings.ROOT_URLCONF == 'lms.urls' else 302
self.assertRedirects(
response,
'{login_url}?next={url}'.format( # noqa: UP032
login_url=settings.LOGIN_URL,
url=THEMING_ADMIN_URL,
),
target_status_code=expected_target_status_code
fetch_redirect_response=False
)

# Logged in non-global staff get a 404
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,7 @@ def test_registration_form_without_filter_configuration(self):


@skip_unless_lms
@override_settings(ENABLE_AUTHN_MICROFRONTEND=False)
class LogistrationPageFiltersTest(UserAPITestCase):
"""
Tests for the Open edX Filters associated with the legacy logistration page.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@

@skip_unless_lms
@ddt.ddt
@override_settings(EMBARGO=True)
# ENABLE_AUTHN_MICROFRONTEND defaults to True, which sends /login and /register on to the
# authn MFE. Most of this class covers the legacy page these URLs still render when the MFE
# is off, so pin the flag here; the handful of MFE-redirect tests re-enable it per-method.
Comment on lines +28 to +30

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should all the ENABLE_AUTHN_MICROFRONTEND=False test methods be deleted when legacy logistration is removed? or is there core logic being tested that we need to factor out?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of these will be deleted when the legacy logistration is dropped but that won't be for a minute since there is some enterprise capability that has not been ported to the MFE yet.

@override_settings(EMBARGO=True, ENABLE_AUTHN_MICROFRONTEND=False)
class LoginAndRegistrationTest(ThirdPartyAuthTestMixin, UrlResetMixin, ModuleStoreTestCase):
""" Tests for Login and Registration. """
USERNAME = "bob"
Expand Down Expand Up @@ -417,6 +420,7 @@ def test_browser_language_dialent(self):


@skip_unless_lms
@override_settings(ENABLE_AUTHN_MICROFRONTEND=False)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same question: delete this whole test class when legacy logistration is removed? or is there core logic being tested that we need to factor out?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same answer.

class AccountCreationTestCaseWithSiteOverrides(SiteMixin, TestCase):
"""
Test cases for Feature flag ALLOW_PUBLIC_ACCOUNT_CREATION which when
Expand Down
Loading