feat: SAC 0.6.0 user edit UI, login to dashboard, daily report timer sync
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -4,6 +4,6 @@ from app.version import APP_NAME, APP_VERSION, APP_VERSION_LABEL
|
||||
|
||||
|
||||
def test_version_constants():
|
||||
assert APP_VERSION == "0.5.0"
|
||||
assert APP_VERSION == "0.6.0"
|
||||
assert APP_NAME == "Security Alert Center"
|
||||
assert APP_VERSION_LABEL == "Security Alert Center v.0.5.0"
|
||||
assert APP_VERSION_LABEL == "Security Alert Center v.0.6.0"
|
||||
|
||||
@@ -62,3 +62,75 @@ def test_admin_create_monitor_user(client, jwt_headers):
|
||||
def test_monitor_cannot_list_users(client, jwt_monitor_headers):
|
||||
response = client.get("/api/v1/users", headers=jwt_monitor_headers)
|
||||
assert response.status_code == 403
|
||||
|
||||
|
||||
def test_admin_update_user_role_and_password(client, jwt_headers):
|
||||
create = client.post(
|
||||
"/api/v1/users",
|
||||
headers=jwt_headers,
|
||||
json={"username": "patch-me", "password": "longpassword1", "role": "monitor"},
|
||||
)
|
||||
assert create.status_code == 201
|
||||
user_id = create.json()["id"]
|
||||
|
||||
response = client.patch(
|
||||
f"/api/v1/users/{user_id}",
|
||||
headers=jwt_headers,
|
||||
json={"role": "admin", "password": "newpassword9"},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
body = response.json()
|
||||
assert body["role"] == "admin"
|
||||
|
||||
login = client.post(
|
||||
"/api/v1/auth/login",
|
||||
json={"username": "patch-me", "password": "newpassword9"},
|
||||
)
|
||||
assert login.status_code == 200
|
||||
assert login.json()["role"] == "admin"
|
||||
|
||||
|
||||
def test_admin_update_username(client, jwt_headers):
|
||||
create = client.post(
|
||||
"/api/v1/users",
|
||||
headers=jwt_headers,
|
||||
json={"username": "old-name", "password": "longpassword1", "role": "monitor"},
|
||||
)
|
||||
user_id = create.json()["id"]
|
||||
|
||||
response = client.patch(
|
||||
f"/api/v1/users/{user_id}",
|
||||
headers=jwt_headers,
|
||||
json={"username": "new-name"},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
assert response.json()["username"] == "new-name"
|
||||
|
||||
login = client.post(
|
||||
"/api/v1/auth/login",
|
||||
json={"username": "new-name", "password": "longpassword1"},
|
||||
)
|
||||
assert login.status_code == 200
|
||||
|
||||
|
||||
def test_admin_deactivate_user(client, jwt_headers):
|
||||
create = client.post(
|
||||
"/api/v1/users",
|
||||
headers=jwt_headers,
|
||||
json={"username": "to-disable", "password": "longpassword1", "role": "monitor"},
|
||||
)
|
||||
user_id = create.json()["id"]
|
||||
|
||||
response = client.patch(
|
||||
f"/api/v1/users/{user_id}",
|
||||
headers=jwt_headers,
|
||||
json={"is_active": False},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
assert response.json()["is_active"] is False
|
||||
|
||||
login = client.post(
|
||||
"/api/v1/auth/login",
|
||||
json={"username": "to-disable", "password": "longpassword1"},
|
||||
)
|
||||
assert login.status_code == 401
|
||||
|
||||
Reference in New Issue
Block a user