Skip to content

Commit

Permalink
Fixed assert form error
Browse files Browse the repository at this point in the history
  • Loading branch information
felixoi committed Dec 30, 2023
1 parent 770f5b0 commit 20963d9
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions spongeauth/accounts/tests/test_view_login.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ def test_constructs_authentication_form(self):
def test_errors_with_invalid_username(self):
resp = self.client.post(self.path(), {"username": "foobar", "password": "barbarbar"})
assert isinstance(resp.context["form"], forms.AuthenticationForm)
self.assertFormError(resp, "form", "username", "There is no user with that username.")
self.assertFormError(resp.context["form"], "username", "There is no user with that username.")
user = django.contrib.auth.get_user(self.client)
assert not user.is_authenticated

def test_errors_with_invalid_password(self):
user = factories.UserFactory.create()
resp = self.client.post(self.path(), {"username": user.username, "password": "barbarbar"})
assert isinstance(resp.context["form"], forms.AuthenticationForm)
self.assertFormError(resp, "form", "password", "The provided password was incorrect.")
self.assertFormError(resp.context["form"], "password", "The provided password was incorrect.")
user = django.contrib.auth.get_user(self.client)
assert not user.is_authenticated

Expand Down
2 changes: 1 addition & 1 deletion spongeauth/twofa/tests/test_view_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def test_has_paper_codes(self):

@pytest.mark.django_db
class TestGeneratePaperCodesIfNeeded:
def setup(self):
def setup_method(self):
self.user = accounts.models.User(twofa_enabled=True)
self.user.save()

Expand Down
2 changes: 1 addition & 1 deletion spongeauth/twofa/tests/test_view_setup_totp.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def extract_secret(self, resp, user=None):
return base64.b32decode(setup_signer.unsign(resp.context[-1]["form"].secret))

def signer(self, user):
return django.core.signing.TimestampSigner("twofa.views.setup_totp:{}".format(user.pk))
return django.core.signing.TimestampSigner(key="twofa.views.setup_totp:{}".format(user.pk))

def test_requires_login(self):
client = django.test.Client()
Expand Down
2 changes: 1 addition & 1 deletion spongeauth/twofa/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def setup_totp(request):
messages.error(request, _("You may not have multiple Google Authenticators attached to your account."))
return redirect("twofa:list")

setup_signer = TimestampSigner("twofa.views.setup_totp:{}".format(request.user.pk))
setup_signer = TimestampSigner(key="twofa.views.setup_totp:{}".format(request.user.pk))

if request.method == "POST" and "secret" in request.POST:
try:
Expand Down

0 comments on commit 20963d9

Please sign in to comment.