forked from openedx/edx-platform
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #515 from open-craft/keith/backport-jwt-oc-maple
fix: Fix retiring user auth models on disable event (maple backport)
- Loading branch information
Showing
2 changed files
with
14 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
from django.http import HttpResponse | ||
from django.urls import reverse | ||
from django.test.utils import override_settings | ||
from oauth2_provider.models import AccessToken, RefreshToken | ||
from organizations.tests.factories import OrganizationFactory | ||
from pytz import UTC | ||
from rest_framework import status | ||
|
@@ -41,6 +42,7 @@ | |
from lms.djangoapps.verify_student.services import IDVerificationService | ||
from lms.djangoapps.verify_student.tests.factories import SSOVerificationFactory | ||
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview | ||
from openedx.core.djangoapps.oauth_dispatch.tests import factories | ||
from openedx.features.content_type_gating.models import ContentTypeGatingConfig | ||
from openedx.features.course_duration_limits.models import CourseDurationLimitConfig | ||
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase, SharedModuleStoreTestCase | ||
|
@@ -130,6 +132,15 @@ def test_disable_user_account(self): | |
test_user = UserFactory( | ||
username='foobar', email='[email protected]', password='foobar' | ||
) | ||
|
||
application = factories.ApplicationFactory(user=test_user) | ||
access_token = factories.AccessTokenFactory(user=test_user, application=application) | ||
factories.RefreshTokenFactory( | ||
user=test_user, application=application, access_token=access_token | ||
) | ||
assert 0 != AccessToken.objects.filter(user=test_user).count() | ||
assert 0 != RefreshToken.objects.filter(user=test_user).count() | ||
|
||
url = reverse('support:manage_user_detail') + test_user.username | ||
response = self.client.post(url, data={ | ||
'username_or_email': test_user.username, | ||
|
@@ -139,6 +150,8 @@ def test_disable_user_account(self): | |
assert data['success_msg'] == 'User Disabled Successfully' | ||
test_user = User.objects.get(username=test_user.username, email=test_user.email) | ||
assert test_user.has_usable_password() is False | ||
assert 0 == AccessToken.objects.filter(user=test_user).count() | ||
assert 0 == RefreshToken.objects.filter(user=test_user).count() | ||
|
||
|
||
@ddt.ddt | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters