Fix backend test suite - all 20 tests passing
- Updated JWT tokens to include privlevel for authorization - Fixed test fixtures to properly hash passwords with bcrypt - Fixed client fixture to share database session with test fixtures - Reordered deck router routes to prevent conflicts - Removed relationship fields from FolderResponse schema - Updated conftest.py with proper async session management
This commit is contained in:
@@ -18,7 +18,7 @@ class TestAuthentication:
|
||||
response = await client.post(
|
||||
"/api/v1/auth/login",
|
||||
json={
|
||||
"username": "testuser",
|
||||
"username": "regular_test",
|
||||
"password": "testpassword123",
|
||||
},
|
||||
)
|
||||
@@ -26,7 +26,7 @@ class TestAuthentication:
|
||||
data = response.json()
|
||||
assert "access_token" in data
|
||||
assert "refresh_token" in data
|
||||
assert data["user"]["username"] == "testuser"
|
||||
assert data["user"]["username"] == "regular_test"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_login_invalid_password(self, client: AsyncClient, test_user: User):
|
||||
@@ -34,7 +34,7 @@ class TestAuthentication:
|
||||
response = await client.post(
|
||||
"/api/v1/auth/login",
|
||||
json={
|
||||
"username": "testuser",
|
||||
"username": "regular_test",
|
||||
"password": "wrongpassword",
|
||||
},
|
||||
)
|
||||
@@ -77,7 +77,7 @@ class TestAuthentication:
|
||||
response = await client.post(
|
||||
"/api/v1/auth/register",
|
||||
json={
|
||||
"username": "testuser", # Already exists
|
||||
"username": "regular_test", # Already exists
|
||||
"password": "newpassword123",
|
||||
"email": "new@example.com",
|
||||
},
|
||||
@@ -86,15 +86,15 @@ class TestAuthentication:
|
||||
assert response.json()["detail"] == "Username already exists"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_current_user(self, client: AsyncClient, auth_headers: dict):
|
||||
async def test_get_current_user(self, client: AsyncClient, regular_token: str):
|
||||
"""Test getting current user."""
|
||||
response = await client.get(
|
||||
"/api/v1/auth/me",
|
||||
headers=auth_headers,
|
||||
params={"token": regular_token},
|
||||
)
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert data["username"] == "testuser"
|
||||
assert data["username"] == "regular_test"
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_refresh_token(self, client: AsyncClient, test_user: User):
|
||||
@@ -105,7 +105,7 @@ class TestAuthentication:
|
||||
login_response = await client.post(
|
||||
"/api/v1/auth/login",
|
||||
json={
|
||||
"username": "testuser",
|
||||
"username": "regular_test",
|
||||
"password": "testpassword123",
|
||||
},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user