feat(virgool): add POST support and use user-existence API to bypass JS cookies

Co-authored-by: soxoj <31013580+soxoj@users.noreply.github.com>
Agent-Logs-Url: https://github.com/soxoj/maigret/sessions/e7f4ab84-917a-49fc-bfbd-9bbaf76027f8
This commit is contained in:
copilot-swe-agent[bot]
2026-03-24 21:20:03 +00:00
parent 2def9a2014
commit 4d70f0f7c9
5 changed files with 98 additions and 13 deletions
+32
View File
@@ -67,3 +67,35 @@ async def test_checking_by_message_negative(httpserver, local_test_db):
result = await search('unclaimed', site_dict=sites_dict, logger=Mock())
assert result['Message']['status'].is_found() is True
@pytest.mark.slow
@pytest.mark.asyncio
async def test_checking_by_post_message(httpserver, local_test_db):
sites_dict = local_test_db.sites_dict
import json
# Existing user: API responds with {"exists": true}
httpserver.expect_request(
'/api/check',
method='POST',
json={"username": "claimed", "type": "lookup"},
).respond_with_data(
json.dumps({"exists": True}), content_type="application/json"
)
# Non-existing user: API responds with {"msg": "not found"}
httpserver.expect_request(
'/api/check',
method='POST',
json={"username": "unclaimed", "type": "lookup"},
).respond_with_data(
json.dumps({"msg": "not found"}), content_type="application/json"
)
result = await search('claimed', site_dict=sites_dict, logger=Mock())
assert result['PostMessage']['status'].is_found() is True
result = await search('unclaimed', site_dict=sites_dict, logger=Mock())
assert result['PostMessage']['status'].is_found() is False