"""auth 도메인 e2e — 로그인 / 내정보 / 인증거부 흐름. 유저 시드/로그인은 auth_headers 픽스처. """ async def test_login_and_me_flow(auth_headers, client, company_id): """검증: 시드된 유저가 로그인해 받은 토큰으로 /me 호출. 기대결과: 200, 본인 id·name·소속사(company_id)가 그대로 반환.""" h = await auth_headers("user1", name="홍길동") r = await client.get("/v1/auth/me", headers=h) assert r.status_code == 200 me = r.json() assert me["id"] == "user1" assert me["name"] == "홍길동" assert me["company"]["company_id"] == company_id async def test_login_with_wrong_password(auth_headers, client): """검증: 존재하는 계정에 '틀린 비밀번호'로 로그인. 기대결과: 로그인 실패 — success=False, code=1100(ACCOUNT_INVALID_INFO), 토큰 빈 문자열.""" await auth_headers("user2") # pw1234 로 시드 r = await client.post("/v1/auth/login", json={"id": "user2", "password": "wrong"}) body = r.json() assert body["result"]["success"] is False assert body["result"]["code"] == 1100 assert body.get("access_token", "") == "" async def test_login_nonexistent_account(client): """검증: 존재하지 않는 계정으로 로그인. 기대결과: 실패 — success=False (계정 유무를 '틀린 비번'과 구분해 흘리지 않음).""" r = await client.post("/v1/auth/login", json={"id": "ghost", "password": "whatever"}) assert r.json()["result"]["success"] is False async def test_me_without_token_is_rejected(client): """검증: 토큰 없이 보호 엔드포인트 /me 호출. 기대결과: 인증 단계에서 거부 — HTTP 401 또는 403.""" r = await client.get("/v1/auth/me") assert r.status_code in (401, 403)