Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
SKairinos committed Jan 25, 2024
1 parent a7e8bc4 commit 1695c5f
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions codeforlife/user/tests/auth/backends/test_otp_bypass_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from django.test import RequestFactory, TestCase
from django.utils import timezone
from django.utils.crypto import get_random_string

from ....auth.backends import OtpBypassTokenBackend
from ....models import (
Expand Down Expand Up @@ -38,9 +37,7 @@ def setUp(self):
auth_factor=self.auth_factor,
)

self.tokens = [
get_random_string(8) for _ in range(OtpBypassToken.max_count)
]
self.tokens = OtpBypassToken.generate_tokens()
self.otp_bypass_tokens = OtpBypassToken.objects.bulk_create(
[
OtpBypassToken(user=self.user, token=token)
Expand All @@ -52,7 +49,7 @@ def test_authenticate(self):
request = self.request_factory.post("/")
request.user = self.user

user = self.backend.authenticate(request, token=self.tokens[0])
user = self.backend.authenticate(request, token=next(iter(self.tokens)))

assert user == self.user
assert self.otp_bypass_tokens[0].id is None

0 comments on commit 1695c5f

Please sign in to comment.