Skip to content

Commit 1747806

Browse files
blarghmateyfarhaanbukhsh
authored andcommitted
test: verify exempt-user session persistence via Session model, not dashboard view
The dashboard-view GET added to test_single_session_exempt_user passed locally but failed in CI's shared-with-cms-1 job (400 instead of 200), likely from unrelated view-layer state (MFE redirect flags, site config) picked up when run alongside the rest of that shard. Assert against Session.objects directly instead -- that's the actual mechanism set_login_session uses to evict a session, so it verifies the same thing without depending on the dashboard view rendering successfully.
1 parent f677d66 commit 1747806

1 file changed

Lines changed: 5 additions & 11 deletions

File tree

openedx/core/djangoapps/user_authn/views/tests/test_login.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import ddt
1414
from django.conf import settings
1515
from django.contrib.auth.models import Group, User # pylint: disable=imported-auth-user
16+
from django.contrib.sessions.models import Session
1617
from django.core import mail
1718
from django.core.cache import cache
1819
from django.http import HttpResponse
@@ -682,17 +683,10 @@ def test_single_session_exempt_user(self):
682683
# session is ever deleted.
683684
assert 'session_id' not in self.user.profile.get_meta()
684685

685-
try:
686-
# this test can be run with either lms or studio settings
687-
# since studio does not have a dashboard url, we should
688-
# look for another url that is login_required, in that case
689-
url = reverse('dashboard')
690-
except NoReverseMatch:
691-
url = reverse('upload_transcripts')
692-
response = client1.get(url)
693-
# client1 remains authenticated; the exempt user's first session
694-
# was not evicted by the second login.
695-
assert response.status_code == 200
686+
# client1's Django session itself was never evicted -- this is
687+
# the actual mechanism set_login_session uses to end a session,
688+
# so it stays valid independent of what profile meta records.
689+
assert Session.objects.filter(session_key=client1.session.session_key).exists()
696690

697691
@patch.dict("django.conf.settings.FEATURES", {'PREVENT_CONCURRENT_LOGINS': True})
698692
def test_single_session_exempt_group(self):

0 commit comments

Comments
 (0)