-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor oxauth, no longer using for login
- Loading branch information
Showing
9 changed files
with
44 additions
and
121 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
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Generated by Django 4.2.8 on 2023-12-20 21:02 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("oxauth", "0003_alter_openstaxuserprofile_options"), | ||
] | ||
|
||
operations = [ | ||
migrations.DeleteModel( | ||
name="OpenStaxUserProfile", | ||
), | ||
] |
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 |
---|---|---|
@@ -1,13 +1 @@ | ||
from django.contrib.auth.models import User | ||
from django.db import models | ||
|
||
class OpenStaxUserProfile(models.Model): | ||
user = models.OneToOneField(User, on_delete=models.CASCADE) | ||
openstax_accounts_id = models.IntegerField() | ||
openstax_accounts_uuid = models.UUIDField() | ||
|
||
def __str__(self): | ||
return self.user.username | ||
|
||
class Meta: | ||
verbose_name = 'OpenStax User Profile' |
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Generated by Django 4.2.8 on 2023-12-20 21:02 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("oxmenus", "0002_alter_menus_menu"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterModelOptions( | ||
name="menus", | ||
options={"verbose_name_plural": "Menus"}, | ||
), | ||
] |
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
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,10 +2,8 @@ | |
from django.core.handlers.base import BaseHandler | ||
from django.test.client import RequestFactory | ||
from django.http.response import HttpResponsePermanentRedirect | ||
from django.contrib.auth import login as auth_login | ||
from django.contrib.auth.models import User | ||
from oxauth.functions import decrypt_cookie | ||
from oxauth.views import create_sso_profile | ||
|
||
|
||
def assertPathDoesNotRedirectToTrailingSlash(test, path): | ||
try: | ||
|
@@ -15,19 +13,24 @@ def assertPathDoesNotRedirectToTrailingSlash(test, path): | |
|
||
response = test.client.get(path) | ||
|
||
if (isinstance(response, HttpResponsePermanentRedirect)): | ||
test.assertNotEqual(response.url, path + "/") | ||
if isinstance(response, HttpResponsePermanentRedirect): | ||
test.assertNotEqual(response.url, path + "/") | ||
|
||
|
||
def mock_user_login(): | ||
cookie = 'eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2R0NNIn0..mktqRLloaCze0VeT.0WU9d20PI1Iu6zajuQMiIJ5GQJVy0DQ1H3BINxkYIS56f1X6p_mesuujHphLcukQny6q0_rmvZUkKLEyojpo14p3czXXu0GF2EWtxprPmfOnPdAig0GXCBJxYVbxKIuZdR4FYodIZaDuDUjXC_hJohHuVoiTQW7jJEGIFj8m9dgAqP-3hOnqaO0C0OvKWoXi0sLb3CvTraT2AGRgj69jkg4B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ookie(cookie).payload_dict['sub'] | ||
user, _ = User.objects.get_or_create( | ||
username='test', | ||
first_name='Test', | ||
last_name='User', | ||
email='[email protected]' | ||
) | ||
|
||
user = create_sso_profile(decrypted_cookie) | ||
return user | ||
|
||
|
||
class RequestMock(RequestFactory): | ||
def request(self, **request): | ||
"Construct a generic request object." | ||
"""Construct a generic request object.""" | ||
request = RequestFactory.request(self, **request) | ||
handler = BaseHandler() | ||
handler.load_middleware() | ||
|