1
0
bthlabs-jsonrpc/packages/bthlabs-jsonrpc-django/tests/auth_checks/test_is_authenticated.py
Tomek Wójcik c75ea4ea9d Initial public releases
* `bthlabs-jsonrpc-aiohttp` v1.0.0
* `bthlabs-jsonrpc-core` v1.0.0
* `bthlabs-jsonrpc-django` v1.0.0
2022-06-04 10:41:53 +02:00

41 lines
783 B
Python

# -*- coding: utf-8 -*-
from django.contrib.auth.models import AnonymousUser
from bthlabs_jsonrpc_django import auth_checks
def test_is_authenticated_anonymous_user(rf):
# Given
request = rf.get('/')
request.user = AnonymousUser()
# When
result = auth_checks.is_authenticated(request)
# Then
assert result is False
def test_is_authenticated_inactive(rf, inactive_user):
# Given
request = rf.get('/')
request.user = inactive_user
# When
result = auth_checks.is_authenticated(request)
# Then
assert result is False
def test_is_authenticated_ok(rf, user):
# Given
request = rf.get('/')
request.user = user
# When
result = auth_checks.is_authenticated(request)
# Then
assert result is True