Skip to content

Commit 1249fbf

Browse files
feanilclaude
andcommitted
refactor: replace third_party_auth skip helpers with skip_unless_lms
testutil.AUTH_FEATURE_ENABLED was hasattr(settings, 'ENABLE_THIRD_PARTY_AUTH'), which is true under LMS settings (the flag is defined in lms/envs/common.py, absent from cms/envs) and false under CMS, regardless of the flag's value. So both @unittest.skipUnless(AUTH_FEATURE_ENABLED, ...) and the skip_unless_thirdpartyauth() helper (whose docstring literally says "skip ... tests in CMS") were roundabout ways of saying "run only in the LMS test suite" -- but they read as if they gated on the feature being enabled, which was misleading. Replace every usage with the existing @skip_unless_lms decorator and delete AUTH_FEATURES_KEY, AUTH_FEATURE_ENABLED, and skip_unless_thirdpartyauth(). Behavior is unchanged: these tests run in the LMS suite and skip in the CMS suite (verified locally: LMS runs, CMS skips). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent eb5b970 commit 1249fbf

14 files changed

Lines changed: 31 additions & 47 deletions

common/djangoapps/third_party_auth/saml_configuration/tests/test_saml_configuration.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from common.djangoapps.student.tests.factories import UserFactory
1010
from common.djangoapps.third_party_auth.models import SAMLConfiguration
11-
from common.djangoapps.third_party_auth.tests.utils import skip_unless_thirdpartyauth
11+
from openedx.core.djangolib.testing.utils import skip_unless_lms
1212

1313
SAML_CONFIGURATIONS = [
1414
{
@@ -43,7 +43,7 @@
4343
TEST_PASSWORD = 'testpwd'
4444

4545

46-
@skip_unless_thirdpartyauth()
46+
@skip_unless_lms
4747
class SAMLConfigurationTests(APITestCase):
4848
"""
4949
API Tests for SAMLConfiguration objects retrieval.

common/djangoapps/third_party_auth/tests/specs/base.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"""
44

55
import json
6-
import unittest
76
from contextlib import contextmanager
87
from unittest import mock
98

@@ -31,6 +30,7 @@
3130
from openedx.core.djangoapps.user_authn.views.login import login_user
3231
from openedx.core.djangoapps.user_authn.views.login_form import login_and_registration_form
3332
from openedx.core.djangoapps.user_authn.views.register import RegistrationView
33+
from openedx.core.djangolib.testing.utils import skip_unless_lms
3434

3535

3636
def create_account(request):
@@ -575,9 +575,7 @@ def complete_url(self):
575575
return reverse("social:complete", kwargs={"backend": self.PROVIDER_BACKEND})
576576

577577

578-
@unittest.skipUnless(
579-
testutil.AUTH_FEATURE_ENABLED, testutil.AUTH_FEATURES_KEY + " not enabled"
580-
)
578+
@skip_unless_lms
581579
@django_utils.override_settings() # For settings reversion on a method-by-method basis.
582580
class IntegrationTest(testutil.TestCase, test.TestCase, HelperMixin):
583581
"""Abstract base class for provider integration tests."""

common/djangoapps/third_party_auth/tests/specs/test_generic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
Use the 'Dummy' auth provider for generic integration tests of third_party_auth.
33
"""
44
from common.djangoapps.third_party_auth.tests import testutil
5-
from common.djangoapps.third_party_auth.tests.utils import skip_unless_thirdpartyauth
5+
from openedx.core.djangolib.testing.utils import skip_unless_lms
66

77
from .base import IntegrationTestMixin
88

99

10-
@skip_unless_thirdpartyauth()
10+
@skip_unless_lms
1111
class GenericIntegrationTest(IntegrationTestMixin, testutil.TestCase):
1212
"""
1313
Basic integration tests of third_party_auth using Dummy provider

common/djangoapps/third_party_auth/tests/specs/test_testshib.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
from common.djangoapps.third_party_auth.tests import testutil, utils
2929
from common.test.utils import assert_dict_contains_subset
3030
from openedx.core.djangoapps.user_authn.views.login import login_user
31+
from openedx.core.djangolib.testing.utils import skip_unless_lms
3132

3233
from .base import IntegrationTestMixin
3334

@@ -160,7 +161,7 @@ def do_provider_login(self, provider_redirect_url):
160161

161162

162163
@ddt.ddt
163-
@utils.skip_unless_thirdpartyauth()
164+
@skip_unless_lms
164165
class TestIndexExceptionTest(SamlIntegrationTestUtilities, IntegrationTestMixin, testutil.SAMLTestCase):
165166
"""
166167
To test SAML error handling when presented with an empty-list attribute value
@@ -199,7 +200,7 @@ def get_response_data(self):
199200

200201

201202
@ddt.ddt
202-
@utils.skip_unless_thirdpartyauth()
203+
@skip_unless_lms
203204
class TestShibIntegrationTest(SamlIntegrationTestUtilities, IntegrationTestMixin, testutil.SAMLTestCase):
204205
"""
205206
TestShib provider Integration Test, to test SAML functionality
@@ -404,7 +405,7 @@ def test_login_with_testshib_provider_short_session_length(self):
404405
self._test_return_login(previous_session_timed_out=True)
405406

406407

407-
@utils.skip_unless_thirdpartyauth()
408+
@skip_unless_lms
408409
class SuccessFactorsIntegrationTest(SamlIntegrationTestUtilities, IntegrationTestMixin, testutil.SAMLTestCase):
409410
"""
410411
Test basic SAML capability using the TestShib details, and then check that we're able

common/djangoapps/third_party_auth/tests/test_admin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
from common.djangoapps.third_party_auth.admin import OAuth2ProviderConfigAdmin
1212
from common.djangoapps.third_party_auth.models import OAuth2ProviderConfig
1313
from common.djangoapps.third_party_auth.tests import testutil
14-
from common.djangoapps.third_party_auth.tests.utils import skip_unless_thirdpartyauth
14+
from openedx.core.djangolib.testing.utils import skip_unless_lms
1515

1616
TEST_PASSWORD = 'Password1234'
1717

1818

1919
# This is necessary because cms does not implement third party auth
20-
@skip_unless_thirdpartyauth()
20+
@skip_unless_lms
2121
class Oauth2ProviderConfigAdminTest(testutil.TestCase):
2222
"""
2323
Tests for oauth2 provider config admin

common/djangoapps/third_party_auth/tests/test_decorators.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from common.djangoapps.third_party_auth.decorators import xframe_allow_whitelisted
1010
from common.djangoapps.third_party_auth.tests.testutil import TestCase
11-
from common.djangoapps.third_party_auth.tests.utils import skip_unless_thirdpartyauth
11+
from openedx.core.djangolib.testing.utils import skip_unless_lms
1212

1313

1414
@xframe_allow_whitelisted
@@ -17,7 +17,7 @@ def mock_view(_request):
1717
return HttpResponse()
1818

1919

20-
@skip_unless_thirdpartyauth()
20+
@skip_unless_lms
2121
@ddt.ddt
2222
class TestXFrameWhitelistDecorator(TestCase):
2323
""" Test the xframe_allow_whitelisted decorator. """

common/djangoapps/third_party_auth/tests/test_identityserver3.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77

88
from common.djangoapps.third_party_auth.identityserver3 import IdentityServer3
99
from common.djangoapps.third_party_auth.tests import testutil
10-
from common.djangoapps.third_party_auth.tests.utils import skip_unless_thirdpartyauth
1110
from common.test.utils import assert_dict_contains_subset
11+
from openedx.core.djangolib.testing.utils import skip_unless_lms
1212

1313

14-
@skip_unless_thirdpartyauth()
14+
@skip_unless_lms
1515
@ddt.ddt
1616
class IdentityServer3Test(testutil.TestCase):
1717
"""

common/djangoapps/third_party_auth/tests/test_pipeline.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
from common.djangoapps.third_party_auth.tests.specs.base import IntegrationTestMixin
1212
from common.djangoapps.third_party_auth.tests.specs.test_testshib import SamlIntegrationTestUtilities
1313
from common.djangoapps.third_party_auth.tests.testutil import simulate_running_pipeline
14-
from common.djangoapps.third_party_auth.tests.utils import skip_unless_thirdpartyauth
14+
from openedx.core.djangolib.testing.utils import skip_unless_lms
1515

1616

17-
@skip_unless_thirdpartyauth()
17+
@skip_unless_lms
1818
@ddt.ddt
1919
class ProviderUserStateTestCase(testutil.TestCase):
2020
"""Tests ProviderUserState behavior."""
@@ -54,7 +54,7 @@ def test_get_idp_logout_url_from_running_pipeline(self, idp_type, backend_name):
5454
assert idp_config['logout_url'] == logout_url
5555

5656

57-
@skip_unless_thirdpartyauth()
57+
@skip_unless_lms
5858
@ddt.ddt
5959
class PipelineOverridesTest(SamlIntegrationTestUtilities, IntegrationTestMixin, testutil.SAMLTestCase):
6060
"""

common/djangoapps/third_party_auth/tests/test_pipeline_integration.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515
from common.djangoapps.student.tests.factories import UserFactory
1616
from common.djangoapps.third_party_auth import pipeline, provider
1717
from common.djangoapps.third_party_auth.tests import testutil
18-
from common.djangoapps.third_party_auth.tests.utils import skip_unless_thirdpartyauth
1918
from lms.djangoapps.verify_student.models import SSOVerification
19+
from openedx.core.djangolib.testing.utils import skip_unless_lms
2020

2121
# Get Django User model by reference from python-social-auth. Not a type
2222
# constant, pylint.
2323
User = social_models.DjangoStorage.user.user_model() # pylint: disable=invalid-name
2424

2525

26-
@skip_unless_thirdpartyauth()
26+
@skip_unless_lms
2727
class TestCase(testutil.TestCase, test.TestCase):
2828
"""Base test case."""
2929

common/djangoapps/third_party_auth/tests/test_provider.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@
1010

1111
from common.djangoapps.third_party_auth import provider
1212
from common.djangoapps.third_party_auth.tests import testutil
13-
from common.djangoapps.third_party_auth.tests.utils import skip_unless_thirdpartyauth
1413
from openedx.core.djangoapps.site_configuration.tests.test_util import (
1514
with_site_configuration,
1615
with_site_configuration_context,
1716
)
17+
from openedx.core.djangolib.testing.utils import skip_unless_lms
1818

1919
SITE_DOMAIN_A = 'professionalx.example.com'
2020
SITE_DOMAIN_B = 'somethingelse.example.com'
2121

2222

23-
@skip_unless_thirdpartyauth()
23+
@skip_unless_lms
2424
class RegistryTest(testutil.TestCase):
2525
"""Tests registry discovery and operation."""
2626

0 commit comments

Comments
 (0)