File tree Expand file tree Collapse file tree 1 file changed +2
-5
lines changed
codeforlife/user/tests/auth/backends Expand file tree Collapse file tree 1 file changed +2
-5
lines changed Original file line number Diff line number Diff line change 2
2
3
3
from django .test import RequestFactory , TestCase
4
4
from django .utils import timezone
5
- from django .utils .crypto import get_random_string
6
5
7
6
from ....auth .backends import OtpBypassTokenBackend
8
7
from ....models import (
@@ -38,9 +37,7 @@ def setUp(self):
38
37
auth_factor = self .auth_factor ,
39
38
)
40
39
41
- self .tokens = [
42
- get_random_string (8 ) for _ in range (OtpBypassToken .max_count )
43
- ]
40
+ self .tokens = OtpBypassToken .generate_tokens ()
44
41
self .otp_bypass_tokens = OtpBypassToken .objects .bulk_create (
45
42
[
46
43
OtpBypassToken (user = self .user , token = token )
@@ -52,7 +49,7 @@ def test_authenticate(self):
52
49
request = self .request_factory .post ("/" )
53
50
request .user = self .user
54
51
55
- user = self .backend .authenticate (request , token = self .tokens [ 0 ] )
52
+ user = self .backend .authenticate (request , token = next ( iter ( self .tokens )) )
56
53
57
54
assert user == self .user
58
55
assert self .otp_bypass_tokens [0 ].id is None
You can’t perform that action at this time.
0 commit comments