feat: 회원 탈퇴 (DELETE /v1/auth/me, 웹·앱 내 정보 시트 '탈퇴하기')
- 계정과 남긴 댓글·좋아요·저장을 한 트랜잭션으로 지우고 게시물·댓글 수를 맞춘다 - 로그아웃·탈퇴 때 내 정보 캐시를 먼저 버려 401 로 로그인 창이 뜨지 않게 - 탈퇴 테스트 추가, 공용 API 클라이언트 다시 생성
This commit is contained in:
1 parent
dd2d02758b
commit
86a0ea26ca
15 files changed
+313
-17
No files matched your search
@@ -121,3 +121,31 @@ async def test_logout_invalidates_access_and_refresh_tokens():
|
||||
assert (await c.post("/v1/auth/refresh", json={"refresh_token": body["refresh_token"]})).json()["result"]["desc"] == "AUTH_TOKEN_INVALID"
|
||||
again = (await c.post("/v1/auth/login", json={"login_id": "mina_out", "password": "password1"})).json()
|
||||
assert (await c.get("/v1/auth/me", headers={"Authorization": f"Bearer {again['access_token']}"})).status_code == 200
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_withdraw_deletes_account_and_reactions(offline):
|
||||
async with client() as c:
|
||||
body = await _signup(c, login_id="mina_bye")
|
||||
h = {"Authorization": f"Bearer {body['access_token']}"}
|
||||
other = {"Authorization": f"Bearer {(await _signup(c, 'other_bye', '남는사람'))['access_token']}"}
|
||||
post_id = (await c.get("/v1/feed", params={"region": REGION})).json()["posts"][0]["post_id"]
|
||||
await c.post(f"/v1/reaction/post/{post_id}/like", headers=h)
|
||||
await c.post(f"/v1/reaction/post/{post_id}/save", headers=h)
|
||||
mine = (await c.post(f"/v1/reaction/post/{post_id}/comment", headers=h, json={"body": "곧 떠나요"})).json()["comment"]
|
||||
kept = (await c.post(f"/v1/reaction/post/{post_id}/comment", headers=other, json={"body": "남아요"})).json()["comment"]
|
||||
await c.post(f"/v1/reaction/comment/{kept['comment_id']}/like", headers=h)
|
||||
await c.post(f"/v1/reaction/comment/{mine['comment_id']}/like", headers=other)
|
||||
|
||||
assert (await c.delete("/v1/auth/me")).status_code == 401
|
||||
assert (await c.delete("/v1/auth/me", headers=h)).json()["result"]["success"] is True
|
||||
|
||||
assert (await c.get("/v1/auth/me", headers=h)).status_code == 401
|
||||
assert (await c.post("/v1/auth/refresh", json={"refresh_token": body["refresh_token"]})).json()["result"]["desc"] == "AUTH_TOKEN_INVALID"
|
||||
assert (await c.post("/v1/auth/login", json={"login_id": "mina_bye", "password": "password1"})).json()["result"]["desc"] == "AUTH_FAILED"
|
||||
comments = (await c.get(f"/v1/reaction/post/{post_id}/comment/list")).json()["comments"]
|
||||
assert [x["body"] for x in comments] == ["남아요"] and comments[0]["like_count"] == 0
|
||||
p = next(x for x in (await c.get("/v1/feed", params={"region": REGION})).json()["posts"] if x["post_id"] == post_id)
|
||||
assert p["like_count"] == 0 and p["comment_count"] == 1
|
||||
# 같은 아이디로 다시 가입할 수 있다
|
||||
assert (await _signup(c, login_id="mina_bye"))["result"]["success"] is True
|
||||
Reference in new issue
Block a user