mirror of
https://github.com/akuker/RASCSI.git
synced 2024-11-26 13:49:21 +00:00
1b10b123d2
- copy/move/delete file class methods now take Path objects as arguments - The file download endpoint in the Web UI uses the safer download from dir method - Simplified logging - Merged nested if statements - Removed naked handling of unknown error states - Added fallback empty list for drive_properties, to avoid errors when json file is missing or broken - Move drive_properties to env[] - Constants for common error messages - Dummy variable for list comprehension
45 lines
1.3 KiB
Python
45 lines
1.3 KiB
Python
from conftest import STATUS_SUCCESS, STATUS_ERROR
|
|
|
|
|
|
# route("/login", methods=["POST"])
|
|
def test_login_with_valid_credentials(pytestconfig, http_client_unauthenticated):
|
|
# Note: This test depends on the rascsi group existing and 'username' a member the group
|
|
response = http_client_unauthenticated.post(
|
|
"/login",
|
|
data={
|
|
"username": pytestconfig.getoption("rascsi_username"),
|
|
"password": pytestconfig.getoption("rascsi_password"),
|
|
},
|
|
)
|
|
|
|
response_data = response.json()
|
|
|
|
assert response.status_code == 200
|
|
assert response_data["status"] == STATUS_SUCCESS
|
|
assert "env" in response_data["data"]
|
|
|
|
|
|
# route("/login", methods=["POST"])
|
|
def test_login_with_invalid_credentials(http_client_unauthenticated):
|
|
response = http_client_unauthenticated.post(
|
|
"/login",
|
|
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 'rascsi' group"
|
|
)
|
|
|
|
|
|
# route("/logout")
|
|
def test_logout(http_client):
|
|
response = http_client.get("/logout")
|
|
assert response.status_code == 200
|