brand: remove all poona references and standardize on XYZ Hospital
This commit is contained in:
@@ -39,30 +39,30 @@ def _auth_headers(client, email: str, password: str = "Demo@123") -> dict[str, s
|
||||
|
||||
|
||||
def test_login_valid_and_invalid(client, db):
|
||||
res = client.post("/api/auth/login", json={"email": "admin@poona.demo", "password": "Demo@123"})
|
||||
res = client.post("/api/auth/login", json={"email": "admin@xyz.demo", "password": "Demo@123"})
|
||||
assert res.status_code == 200
|
||||
body = res.json()
|
||||
assert body["token_type"] == "bearer"
|
||||
assert body["access_token"]
|
||||
assert body["user"]["email"] == "admin@poona.demo"
|
||||
assert body["user"]["email"] == "admin@xyz.demo"
|
||||
assert body["user"]["role"] == "system_admin"
|
||||
assert body["user"]["demo_as_of_date"] is None
|
||||
|
||||
bad_pw = client.post("/api/auth/login", json={"email": "admin@poona.demo", "password": "wrong"})
|
||||
bad_pw = client.post("/api/auth/login", json={"email": "admin@xyz.demo", "password": "wrong"})
|
||||
assert bad_pw.status_code == 401
|
||||
|
||||
bad_email = client.post("/api/auth/login", json={"email": "nobody@poona.demo", "password": "Demo@123"})
|
||||
bad_email = client.post("/api/auth/login", json={"email": "nobody@xyz.demo", "password": "Demo@123"})
|
||||
assert bad_email.status_code == 401
|
||||
|
||||
# Inactive user rejected
|
||||
user = db.query(User).filter(User.email == "neha.chavan@poona.demo").first()
|
||||
user = db.query(User).filter(User.email == "neha.chavan@xyz.demo").first()
|
||||
assert user is not None
|
||||
user.is_active = False
|
||||
db.commit()
|
||||
try:
|
||||
res_inactive = client.post(
|
||||
"/api/auth/login",
|
||||
json={"email": "neha.chavan@poona.demo", "password": "Demo@123"},
|
||||
json={"email": "neha.chavan@xyz.demo", "password": "Demo@123"},
|
||||
)
|
||||
assert res_inactive.status_code in (401, 403)
|
||||
finally:
|
||||
@@ -77,11 +77,11 @@ def test_auth_me(client):
|
||||
bad_tok = client.get("/api/auth/me", headers={"Authorization": "Bearer invalid.token.here"})
|
||||
assert bad_tok.status_code == 401
|
||||
|
||||
headers = _auth_headers(client, "dept@poona.demo")
|
||||
headers = _auth_headers(client, "dept@xyz.demo")
|
||||
me = client.get("/api/auth/me", headers=headers)
|
||||
assert me.status_code == 200
|
||||
data = me.json()
|
||||
assert data["email"] == "dept@poona.demo"
|
||||
assert data["email"] == "dept@xyz.demo"
|
||||
assert data["role"] == "department_user"
|
||||
assert data["department_name"] == "Intensive Care Unit"
|
||||
|
||||
@@ -89,16 +89,16 @@ def test_auth_me(client):
|
||||
@pytest.mark.parametrize(
|
||||
"email",
|
||||
[
|
||||
"bio@poona.demo",
|
||||
"dept@poona.demo",
|
||||
"mgmt@poona.demo",
|
||||
"coord@poona.demo",
|
||||
"bio@xyz.demo",
|
||||
"dept@xyz.demo",
|
||||
"mgmt@xyz.demo",
|
||||
"coord@xyz.demo",
|
||||
],
|
||||
)
|
||||
def test_non_admin_forbidden_on_admin_endpoints(client, db, email):
|
||||
headers = _auth_headers(client, email)
|
||||
dept = db.query(Department).first()
|
||||
target_user = db.query(User).filter(User.email == "dept@poona.demo").first()
|
||||
target_user = db.query(User).filter(User.email == "dept@xyz.demo").first()
|
||||
|
||||
# Masters GET is allowed for authenticated users
|
||||
assert client.get("/api/departments", headers=headers).status_code == 200
|
||||
@@ -134,7 +134,7 @@ def test_non_admin_forbidden_on_admin_endpoints(client, db, email):
|
||||
headers=headers,
|
||||
json={
|
||||
"name": "Hack",
|
||||
"email": "hack@poona.demo",
|
||||
"email": "hack@xyz.demo",
|
||||
"password": "Password1",
|
||||
"role": "biomedical",
|
||||
},
|
||||
@@ -172,7 +172,7 @@ def test_non_admin_forbidden_on_admin_endpoints(client, db, email):
|
||||
|
||||
|
||||
def test_admin_masters_and_users_crud(client):
|
||||
headers = _auth_headers(client, "admin@poona.demo")
|
||||
headers = _auth_headers(client, "admin@xyz.demo")
|
||||
|
||||
# Department create, patch, soft-delete
|
||||
r = client.post(
|
||||
@@ -201,7 +201,7 @@ def test_admin_masters_and_users_crud(client):
|
||||
headers=headers,
|
||||
json={
|
||||
"name": "Temp Staff",
|
||||
"email": "temp.staff@poona.demo",
|
||||
"email": "temp.staff@xyz.demo",
|
||||
"password": "InitPassword1",
|
||||
"role": "biomedical",
|
||||
},
|
||||
@@ -218,7 +218,7 @@ def test_admin_masters_and_users_crud(client):
|
||||
assert u_patch.status_code == 200
|
||||
login_new = client.post(
|
||||
"/api/auth/login",
|
||||
json={"email": "temp.staff@poona.demo", "password": "NewPassword2"},
|
||||
json={"email": "temp.staff@xyz.demo", "password": "NewPassword2"},
|
||||
)
|
||||
assert login_new.status_code == 200
|
||||
|
||||
@@ -280,7 +280,7 @@ def test_permissions_matrix_all_roles():
|
||||
|
||||
|
||||
def test_settings_validation_and_demo_date(client, db):
|
||||
headers = _auth_headers(client, "admin@poona.demo")
|
||||
headers = _auth_headers(client, "admin@xyz.demo")
|
||||
|
||||
res = client.get("/api/settings", headers=headers)
|
||||
assert res.status_code == 200
|
||||
|
||||
Reference in New Issue
Block a user