mirror of
https://github.com/ansible/awx.git
synced 2026-01-12 10:30:03 -03:30
add test for invalid login
This commit is contained in:
parent
01ee2adf30
commit
ee20fc478b
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
|
||||
Loading…
x
Reference in New Issue
Block a user