jazzband / django-axes

Keep track of failed login attempts in Django-powered sites.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`force_login` not working in tests

yaakovLowenstein opened this issue · comments

Hey,

I've tried following the documentation and setting AXES_ENABLED = False in the test settings, but that did not work. I also tried removing 'axes' from INSTALLED_APPS in my test settings, but that also did not work?

I was able to get the test to work by using client.login and passing in a mock request, but it would be nicer if I could get it to work by just setting AXES_ENABLED.

My test:

@override_settings(AXES_ENABLED=False)
def test_gives_non_cas_admin_403_on_cas_admin_url(client, django_user_model):
    user = django_user_model.objects.create()

    client.force_login(user)
    response = client.get(reverse('create_user'))

    assert response.status_code == 403

The test is failing because it redirect back to the login view since the force_login is not working

Fixed in 6.0.4.