예제 #1
0
def test_superuser_force_mfa_auth(rf, superuser):
    request = rf.get('/admin/')
    request.user = superuser
    TOTPDevice.objects.create(user=superuser, confirmed=True)

    middleware = VerifyUserMiddleware()
    response = middleware.process_request(request)
    assert response.url == '%s?next=/admin/' % reverse('wagtail_2fa_auth')
예제 #2
0
def test_superuser_dont_require_register_device(rf, superuser, settings):
    settings.WAGTAIL_2FA_REQUIRED = False

    request = rf.get("/admin/")
    request.user = superuser

    middleware = VerifyUserMiddleware(lambda x: x)
    response = middleware.process_request(request)
    assert response is None
예제 #3
0
def test_verified_request(rf, superuser):
    request = rf.get("/admin/")
    request.user = superuser
    device = TOTPDevice.objects.create(user=superuser, confirmed=True)
    otp_login(request, device)

    middleware = VerifyUserMiddleware()
    response = middleware.process_request(request)
    assert response is None
예제 #4
0
def test_superuser_require_register_device(rf, superuser, settings):
    settings.WAGTAIL_2FA_REQUIRED = True

    request = rf.get('/admin/')
    request.user = superuser

    middleware = VerifyUserMiddleware()
    response = middleware.process_request(request)
    assert response.url == '%s?next=/admin/' % reverse(
        'wagtail_2fa_device_new')