mirror of
https://github.com/ansible/awx.git
synced 2026-02-26 23:46:05 -03:30
add test for invalid login
This commit is contained in:
26
awx/main/tests/functional/api/test_auth.py
Normal file
26
awx/main/tests/functional/api/test_auth.py
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
import pytest
|
||||||
|
|
||||||
|
from django.contrib import auth
|
||||||
|
from django.test import Client
|
||||||
|
|
||||||
|
from rest_framework.test import APIRequestFactory
|
||||||
|
|
||||||
|
from awx.api.generics import LoggedLoginView
|
||||||
|
from awx.api.versioning import drf_reverse
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.django_db
|
||||||
|
def test_invalid_login():
|
||||||
|
anon = auth.get_user(Client())
|
||||||
|
url = drf_reverse('api:login')
|
||||||
|
|
||||||
|
factory = APIRequestFactory()
|
||||||
|
|
||||||
|
data = {'userame': 'invalid', 'password': 'invalid'}
|
||||||
|
|
||||||
|
request = factory.post(url, data)
|
||||||
|
request.user = anon
|
||||||
|
|
||||||
|
response = LoggedLoginView.as_view()(request)
|
||||||
|
|
||||||
|
assert response.status_code == 401
|
||||||
Reference in New Issue
Block a user