RASCSI/python/web/tests/api/test_auth.py
Daniel Markstedt 05b9e0eb18
Web UI: Rework the Attach Device section to be universal (#1393)
* Correct German translation for Key

* Web UI: Rework the Attach Device section to be universal

* Web UI: Warn when working dirs are missing

* Refactor tests to use global endpoint constants

* Add fallback for unknown disk type devices

* Rearrange the index page sections

* Move Macproxy help text to admins page

* Remove image list exception for SCHD

* Show Settings button when auth is diabled

* Tweak CSS styles for both themes

* Move Eject action next to the file name, and improve UI labels
2023-12-07 17:38:24 -08:00

42 lines
1.3 KiB
Python

from conftest import STATUS_SUCCESS, STATUS_ERROR, LOGIN_ENDPOINT, LOGOUT_ENDPOINT
def test_login_with_valid_credentials(pytestconfig, http_client_unauthenticated):
# Note: This test depends on the piscsi group existing and 'username' a member the group
response = http_client_unauthenticated.post(
LOGIN_ENDPOINT,
data={
"username": pytestconfig.getoption("piscsi_username"),
"password": pytestconfig.getoption("piscsi_password"),
},
)
response_data = response.json()
assert response.status_code == 200
assert response_data["status"] == STATUS_SUCCESS
assert "env" in response_data["data"]
def test_login_with_invalid_credentials(http_client_unauthenticated):
response = http_client_unauthenticated.post(
LOGIN_ENDPOINT,
data={
"username": "__INVALID_USER__",
"password": "__INVALID_PASS__",
},
)
response_data = response.json()
assert response.status_code == 401
assert response_data["status"] == STATUS_ERROR
assert response_data["messages"][0]["message"] == (
"You must log in with valid credentials for a user in the 'piscsi' group"
)
def test_logout(http_client):
response = http_client.get(LOGOUT_ENDPOINT)
assert response.status_code == 200