forked from jazzband/django-two-factor-auth
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed wrapping of django-otp random_hex function. (jazzband#392)
From django-otp 0.8.0 and up, random_hex is always a string. We don't need to wrap it any longer.
- Loading branch information
Showing
8 changed files
with
28 additions
and
31 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
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 |
---|---|---|
|
@@ -9,8 +9,7 @@ | |
from django.urls import reverse | ||
from django_otp import DEVICE_ID_SESSION_KEY | ||
from django_otp.oath import totp | ||
|
||
from two_factor.models import random_hex_str | ||
from django_otp.util import random_hex | ||
|
||
from .utils import UserMixin | ||
|
||
|
@@ -95,7 +94,7 @@ def test_valid_login_primary_key_stored(self, mock_time): | |
mock_time.time.return_value = 12345.12 | ||
user = self.create_user() | ||
user.totpdevice_set.create(name='default', | ||
key=random_hex_str()) | ||
key=random_hex()) | ||
|
||
response = self._post({'auth-username': '[email protected]', | ||
'auth-password': 'secret', | ||
|
@@ -113,7 +112,7 @@ def test_valid_login_post_auth_session_clear_of_form_data(self, mock_time): | |
mock_time.time.return_value = 12345.12 | ||
user = self.create_user() | ||
user.totpdevice_set.create(name='default', | ||
key=random_hex_str()) | ||
key=random_hex()) | ||
|
||
response = self._post({'auth-username': '[email protected]', | ||
'auth-password': 'secret', | ||
|
@@ -132,7 +131,7 @@ def test_valid_login_expired(self, mock_time, mock_logger): | |
mock_time.time.return_value = 12345.12 | ||
user = self.create_user() | ||
device = user.totpdevice_set.create(name='default', | ||
key=random_hex_str()) | ||
key=random_hex()) | ||
|
||
response = self._post({'auth-username': '[email protected]', | ||
'auth-password': 'secret', | ||
|
@@ -165,7 +164,7 @@ def test_valid_login_no_timeout(self, mock_time): | |
mock_time.time.return_value = 12345.12 | ||
user = self.create_user() | ||
device = user.totpdevice_set.create(name='default', | ||
key=random_hex_str()) | ||
key=random_hex()) | ||
|
||
response = self._post({'auth-username': '[email protected]', | ||
'auth-password': 'secret', | ||
|
@@ -210,7 +209,7 @@ def test_valid_login_with_redirect_authenticated_user_loop(self): | |
def test_with_generator(self, mock_signal): | ||
user = self.create_user() | ||
device = user.totpdevice_set.create(name='default', | ||
key=random_hex_str()) | ||
key=random_hex()) | ||
|
||
response = self._post({'auth-username': '[email protected]', | ||
'auth-password': 'secret', | ||
|
@@ -240,7 +239,7 @@ def test_with_generator(self, mock_signal): | |
def test_throttle_with_generator(self, mock_signal): | ||
user = self.create_user() | ||
device = user.totpdevice_set.create(name='default', | ||
key=random_hex_str()) | ||
key=random_hex()) | ||
|
||
self._post({'auth-username': '[email protected]', | ||
'auth-password': 'secret', | ||
|
@@ -265,11 +264,11 @@ def test_with_backup_phone(self, mock_signal, fake): | |
user = self.create_user() | ||
for no_digits in (6, 8): | ||
with self.settings(TWO_FACTOR_TOTP_DIGITS=no_digits): | ||
user.totpdevice_set.create(name='default', key=random_hex_str(), | ||
user.totpdevice_set.create(name='default', key=random_hex(), | ||
digits=no_digits) | ||
device = user.phonedevice_set.create(name='backup', number='+31101234567', | ||
method='sms', | ||
key=random_hex_str()) | ||
key=random_hex()) | ||
|
||
# Backup phones should be listed on the login form | ||
response = self._post({'auth-username': '[email protected]', | ||
|
@@ -322,7 +321,7 @@ def test_with_backup_phone(self, mock_signal, fake): | |
@mock.patch('two_factor.views.core.signals.user_verified.send') | ||
def test_with_backup_token(self, mock_signal): | ||
user = self.create_user() | ||
user.totpdevice_set.create(name='default', key=random_hex_str()) | ||
user.totpdevice_set.create(name='default', key=random_hex()) | ||
device = user.staticdevice_set.create(name='backup') | ||
device.token_set.create(token='abcdef123') | ||
|
||
|
@@ -475,7 +474,7 @@ def setUp(self): | |
super().setUp() | ||
self.user = self.create_user() | ||
self.device = self.user.totpdevice_set.create(name='default', | ||
key=random_hex_str()) | ||
key=random_hex()) | ||
|
||
def _post(self, data=None): | ||
return self.client.post(reverse('two_factor:login'), data=data) | ||
|
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
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
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