"""Auth endpoint tests — Go/Gin backend.""" import pytest from httpx import AsyncClient from tests.conftest import auth_header class TestLogin: async def test_admin_login(self, client: AsyncClient): resp = await client.post("/api/v1/auth/login", json={ "username": "admin", "password": "admin123" }) assert resp.status_code == 200 data = resp.json() assert "access_token" in data async def test_wrong_password(self, client: AsyncClient): resp = await client.post("/api/v1/auth/login", json={ "username": "admin", "password": "wrong" }) assert resp.status_code == 401 async def test_nonexistent_user(self, client: AsyncClient): resp = await client.post("/api/v1/auth/login", json={ "username": "nobody", "password": "test" }) assert resp.status_code == 401 class TestGetMe: async def test_get_me(self, client: AsyncClient, admin_token: str): resp = await client.get("/api/v1/auth/me", headers=auth_header(admin_token)) assert resp.status_code == 200 data = resp.json() assert data["username"] == "admin" assert "role" in data assert "id" in data async def test_no_token(self, client: AsyncClient): resp = await client.get("/api/v1/auth/me") assert resp.status_code == 401