This repository has been archived by the owner on Nov 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 254
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
27 additions
and
12 deletions.
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 |
---|---|---|
|
@@ -2,9 +2,7 @@ | |
|
||
import json | ||
|
||
import jwt | ||
import mock | ||
from django.conf import settings | ||
from django.contrib.auth import get_user_model | ||
from django.urls import reverse | ||
from oscar.core.loading import get_class, get_model | ||
|
@@ -16,6 +14,7 @@ | |
from ecommerce.courses.tests.factories import CourseFactory | ||
from ecommerce.extensions.api.v2.tests.views import JSON_CONTENT_TYPE, ProductSerializerMixin | ||
from ecommerce.extensions.catalogue.tests.mixins import DiscoveryTestMixin | ||
from ecommerce.tests.mixins import JwtMixin | ||
from ecommerce.tests.testcases import TestCase | ||
|
||
Product = get_model('catalogue', 'Product') | ||
|
@@ -24,7 +23,7 @@ | |
User = get_user_model() | ||
|
||
|
||
class CourseViewSetTests(ProductSerializerMixin, DiscoveryTestMixin, TestCase): | ||
class CourseViewSetTests(JwtMixin, ProductSerializerMixin, DiscoveryTestMixin, TestCase): | ||
list_path = reverse('api:v2:course-list') | ||
|
||
def setUp(self): | ||
|
@@ -75,14 +74,9 @@ def test_jwt_authentication(self): | |
""" Verify the endpoint supports JWT authentication and user creation. """ | ||
username = 'some-user' | ||
email = '[email protected]' | ||
payload = { | ||
'administrator': True, | ||
'username': username, | ||
'email': email, | ||
'iss': settings.JWT_AUTH['JWT_ISSUERS'][0]['ISSUER'] | ||
} | ||
auth_header = "JWT {token}".format( | ||
token=jwt.encode(payload, settings.JWT_AUTH['JWT_SECRET_KEY']).decode('utf-8')) | ||
is_staff = True | ||
|
||
auth_header = f'JWT {self.generate_new_user_token(username, email, is_staff)}' | ||
self.assertFalse(User.objects.filter(username=username).exists()) | ||
|
||
response = self.client.get( | ||
|
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