Tomek Wójcik
c75ea4ea9d
* `bthlabs-jsonrpc-aiohttp` v1.0.0 * `bthlabs-jsonrpc-core` v1.0.0 * `bthlabs-jsonrpc-django` v1.0.0
41 lines
783 B
Python
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
|