Skip to content
Snippets Groups Projects
Unverified Commit 295f0f5f authored by Michael Youngstrom's avatar Michael Youngstrom Committed by GitHub
Browse files

Merge pull request #20333 from edx/youngstrom/INCR-192

INCR-192
parents 48c32a43 ceaff53b
No related branches found
No related tags found
No related merge requests found
Showing
with 52 additions and 29 deletions
# pylint: disable=missing-docstring
from __future__ import absolute_import
from datetime import datetime, timedelta
import factory
import pytz
from factory.django import DjangoModelFactory
from factory.fuzzy import FuzzyText
import pytz
from oauth2_provider.models import Application, AccessToken, RefreshToken
from oauth2_provider.models import AccessToken, Application, RefreshToken
from organizations.tests.factories import OrganizationFactory
from openedx.core.djangoapps.oauth_dispatch.models import ApplicationAccess, ApplicationOrganization
......
"""
OAuth Dispatch test mixins
"""
from django.conf import settings
from __future__ import absolute_import
import jwt
from django.conf import settings
from jwkest.jwk import KEYS
from jwkest.jws import JWS
import jwt
from jwt.exceptions import ExpiredSignatureError
from student.models import UserProfile, anonymous_id_for_user
......
""" Tests for OAuth Dispatch python API module. """
from __future__ import absolute_import
import unittest
from django.conf import settings
from django.http import HttpRequest
from django.test import TestCase
from oauth2_provider.models import AccessToken
from student.tests.factories import UserFactory
from student.tests.factories import UserFactory
OAUTH_PROVIDER_ENABLED = settings.FEATURES.get('ENABLE_OAUTH2_PROVIDER')
if OAUTH_PROVIDER_ENABLED:
......
""" Tests for OAuth 2.0 client credentials support. """
from __future__ import unicode_literals
from __future__ import absolute_import, unicode_literals
import json
import unittest
from django.conf import settings
from django.urls import reverse
from django.test import TestCase
from django.urls import reverse
from edx_oauth2_provider.tests.factories import ClientFactory
from oauth2_provider.models import Application
from provider.oauth2.models import AccessToken
from student.tests.factories import UserFactory
from ..adapters import DOTAdapter
from . import mixins
from .constants import DUMMY_REDIRECT_URL
from ..adapters import DOTAdapter
@unittest.skipUnless(settings.FEATURES.get("ENABLE_OAUTH2_PROVIDER"), "OAuth2 not enabled")
......
......@@ -2,13 +2,15 @@
Tests for DOP Adapter
"""
from __future__ import absolute_import
from datetime import timedelta
import ddt
from django.test import TestCase
from django.utils.timezone import now
from provider.oauth2 import models
from provider import constants
from provider.oauth2 import models
from student.tests.factories import UserFactory
......
......@@ -2,15 +2,18 @@
Tests for DOT Adapter
"""
from __future__ import absolute_import
import unittest
from datetime import timedelta
import ddt
import six
from django.conf import settings
from django.test import TestCase
from django.utils.timezone import now
import ddt
from oauth2_provider import models
from student.tests.factories import UserFactory
# oauth_dispatch is not in CMS' INSTALLED_APPS so these imports will error during test collection
......@@ -54,7 +57,7 @@ class DOTAdapterTestCase(TestCase):
"""
Make sure unicode representation of RestrictedApplication is correct
"""
self.assertEqual(unicode(self.restricted_app), u"<RestrictedApplication '{name}'>".format(
self.assertEqual(six.text_type(self.restricted_app), u"<RestrictedApplication '{name}'>".format(
name=self.restricted_client.name
))
......
......@@ -3,13 +3,16 @@ Test of custom django-oauth-toolkit behavior
"""
# pylint: disable=protected-access
from __future__ import absolute_import
import datetime
import unittest
from django.conf import settings
from django.contrib.auth.models import User
from django.test import RequestFactory, TestCase
from django.utils import timezone
from django.test import TestCase, RequestFactory
from student.tests.factories import UserFactory
# oauth_dispatch is not in CMS' INSTALLED_APPS so these imports will error during test collection
......
# pylint: disable=missing-docstring
from __future__ import absolute_import
import unittest
from django.conf import settings
from django.test import TestCase
from oauth2_provider.models import Application, AccessToken, RefreshToken
import unittest
from oauth2_provider.models import AccessToken, Application, RefreshToken
from openedx.core.djangoapps.oauth_dispatch.tests import factories
from student.tests.factories import UserFactory
......
""" Tests for OAuth Dispatch's jwt module. """
from __future__ import absolute_import
import itertools
from datetime import timedelta
from mock import patch
import ddt
from django.test import TestCase
from django.utils.timezone import now
from mock import patch
from openedx.core.djangoapps.oauth_dispatch import jwt as jwt_api
from openedx.core.djangoapps.oauth_dispatch.adapters import DOTAdapter, DOPAdapter
from openedx.core.djangoapps.oauth_dispatch.adapters import DOPAdapter, DOTAdapter
from openedx.core.djangoapps.oauth_dispatch.models import RestrictedApplication
from openedx.core.djangoapps.oauth_dispatch.tests.mixins import AccessTokenMixin
from openedx.core.djangoapps.oauth_dispatch.toggles import ENFORCE_JWT_SCOPES
......
"""
Tests for oauth_dispatch models.
"""
from __future__ import absolute_import
import six
from django.test import TestCase
from openedx.core.djangoapps.oauth_dispatch.tests.factories import ApplicationOrganizationFactory
......@@ -17,4 +20,4 @@ class ApplicationOrganizationTestCase(TestCase):
org_relation = ApplicationOrganizationFactory()
organization = org_relation.organization
jwt_filter_claim = org_relation.to_jwt_filter_claim()
assert jwt_filter_claim == unicode(':'.join([org_relation.relation_type, organization.short_name]))
assert jwt_filter_claim == six.text_type(':'.join([org_relation.relation_type, organization.short_name]))
"""
Tests for custom DOT scopes backend.
"""
from __future__ import absolute_import
import ddt
from django.conf import settings
from django.test import TestCase
......@@ -29,5 +31,5 @@ class ApplicationModelScopesTestCase(TestCase):
scopes = ApplicationModelScopes()
self.assertEqual(
set(scopes.get_available_scopes(application_access.application)),
set(settings.OAUTH2_DEFAULT_SCOPES.keys() + expected_additional_scopes),
set(list(settings.OAUTH2_DEFAULT_SCOPES.keys()) + expected_additional_scopes),
)
......@@ -2,26 +2,27 @@
Tests for Blocks Views
"""
from __future__ import absolute_import
import json
import unittest
import ddt
import httpretty
from Cryptodome.PublicKey import RSA
from django.conf import settings
from django.urls import reverse
from django.test import RequestFactory, TestCase
from mock import call, patch
from Cryptodome.PublicKey import RSA
from django.urls import reverse
from jwkest import jwk
from mock import call, patch
from oauth2_provider import models as dot_models
from organizations.tests.factories import OrganizationFactory
from provider import constants
from openedx.core.djangoapps.oauth_dispatch.toggles import ENFORCE_JWT_SCOPES
from provider import constants
from student.tests.factories import UserFactory
from third_party_auth.tests.utils import ThirdPartyOAuthTestMixin, ThirdPartyOAuthTestMixinGoogle
from . import mixins
# NOTE (CCB): We use this feature flag in a roundabout way to determine if the oauth_dispatch app is installed
......@@ -559,7 +560,7 @@ class TestViewDispatch(TestCase):
msg_not_callable = _msg_base.format(view=view_candidate, reason=u'it is not callable')
msg_no_request = _msg_base.format(view=view_candidate, reason=u'it has no request argument')
self.assertTrue(hasattr(view_candidate, '__call__'), msg_not_callable)
args = view_candidate.func_code.co_varnames
args = view_candidate.__code__.co_varnames
self.assertTrue(args, msg_no_request)
self.assertEqual(args[0], 'request')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment