Interop with a real GoToSocial server, and the fixes it found (phase 2, step 8)
CI / validate-monitoring (push) Successful in 7s
CI / lint (push) Successful in 10s
CI / test (push) Successful in 2m16s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / notify (push) Successful in 6s
CI / validate-monitoring (push) Successful in 7s
CI / lint (push) Successful in 10s
CI / test (push) Successful in 2m16s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / notify (push) Successful in 6s
scripts/interop/run.sh brings up Scrobbler (API, worker, UI behind a throwaway-TLS Caddy) and GoToSocial 0.22.1 on a private .test network, creates a GoToSocial user, drives its sign-in/OAuth screens for a token, and checks: lookup by handle, follow accepted, unfollow, manual approval and approve, remove, block and unblock, and decline. Found and fixed along the way: - Keys whose id is a path serving the actor (GoToSocial's <actor>/main-key) weren't resolved; now all three publishing styles are handled - An Undo of an older Follow arriving after a newer Follow removed the new follower; an Undo now only removes the Follow it names (and Undo referencing a Follow by id is understood) - Rejects embedded the Follow, which some servers (GoToSocial) match by account pair, so a late Reject could cancel a newer request; Rejects now reference the Follow by id - Unblocking didn't tell the other server; it now sends Undo(Block) - Actors publish an (empty) featured collection, which Mastodon and GoToSocial fetch GoToSocial 0.22.1 ignores Reject for already-accepted follows (a TODO in its code, fixed on its main branch); the removal check on its side is skipped until a release has it (GTS_REJECT_ENDS_FOLLOWS=1 enables). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
This commit is contained in:
1 parent
ec658a7751
commit
b93cfea5b3
16 files changed
+694
-17
No files matched your search
@@ -111,6 +111,10 @@ def test_block_and_unblock(fed_client, auth_headers, accounts):
|
||||
assert sent_types()[-1] == "Reject"
|
||||
|
||||
assert api(fed_client, "delete", f"/blocks/{block['id']}", auth_headers).status_code == 204
|
||||
# Their server is told they're unblocked: an Undo of our Block
|
||||
undo = db.session.scalars(db.select(FederationActivity).filter_by(activity_type="Undo")).one()
|
||||
assert undo.document["object"]["type"] == "Block"
|
||||
assert undo.document["object"]["object"] == accounts["bob"].uri
|
||||
follow(fed_client, accounts["bob"]) # now allowed
|
||||
assert len(api(fed_client, "get", "/followers", auth_headers).get_json()) == 1
|
||||
|
||||
|
||||
@@ -185,6 +185,44 @@ def test_undo_follow(fed_client, bob, sharing_user):
|
||||
assert followers_of(sharing_user) == []
|
||||
|
||||
|
||||
def test_undo_referencing_the_follow_by_id(fed_client, bob, sharing_user):
|
||||
follow = bob.follow()
|
||||
bob.deliver(fed_client, follow)
|
||||
process_all()
|
||||
bob.deliver(fed_client, bob.activity("Undo", follow["id"]))
|
||||
process_all()
|
||||
assert last_item().reason == "unfollowed"
|
||||
assert followers_of(sharing_user) == []
|
||||
|
||||
|
||||
def test_rejects_reference_the_follow_by_id(fed_client, bob, sharing_user):
|
||||
"""So a late Reject can't be matched to a newer request between the same accounts."""
|
||||
from scrobbler.federation import followers
|
||||
|
||||
follow = bob.follow()
|
||||
bob.deliver(fed_client, follow)
|
||||
process_all()
|
||||
followers.remove("alice", followers_of(sharing_user)[0])
|
||||
db.session.commit()
|
||||
[reject] = sent("Reject")
|
||||
assert reject.document["object"] == follow["id"]
|
||||
|
||||
|
||||
def test_a_late_undo_of_an_old_follow_keeps_the_new_one(fed_client, bob, sharing_user):
|
||||
"""Deliveries race: an Undo of an earlier Follow can arrive after a newer Follow
|
||||
(seen against GoToSocial). Only an Undo of the current Follow removes the follower."""
|
||||
old_follow = bob.follow()
|
||||
bob.deliver(fed_client, old_follow)
|
||||
process_all()
|
||||
new_follow = bob.follow()
|
||||
bob.deliver(fed_client, new_follow)
|
||||
bob.deliver(fed_client, bob.activity("Undo", old_follow)) # arrives after the new Follow
|
||||
process_all()
|
||||
assert last_item().reason == "undo_stale"
|
||||
[follower] = followers_of(sharing_user)
|
||||
assert follower.follow_activity_id == new_follow["id"]
|
||||
|
||||
|
||||
def test_undo_of_someone_elses_follow_is_rejected(fed_client, bob, remote, sharing_user):
|
||||
carol = RemoteAccount(remote, "carol")
|
||||
follow = carol.follow()
|
||||
|
||||
@@ -254,3 +254,26 @@ def test_gone_actors_are_marked(fed_remote):
|
||||
with pytest.raises(FetchError):
|
||||
remote.get_actor(uri, refresh=True)
|
||||
assert db.session.scalar(db.select(FederationRemoteActor).filter_by(uri=uri)).gone is True
|
||||
|
||||
|
||||
def test_actor_for_a_key_url_that_serves_the_actor(fed_remote):
|
||||
"""GoToSocial: the key id is <actor>/main-key, and fetching it returns the actor."""
|
||||
uri = fed_remote.url("/users/dana")
|
||||
doc = actor_doc(fed_remote, name="dana")
|
||||
key_id = f"{uri}/main-key"
|
||||
doc["publicKey"]["id"] = key_id
|
||||
fed_remote.routes["/users/dana"] = (200, {}, doc)
|
||||
fed_remote.routes["/users/dana/main-key"] = (200, {}, doc) # same document
|
||||
actor = remote.actor_for_key(key_id)
|
||||
assert (actor.uri, actor.public_key_id) == (uri, key_id)
|
||||
|
||||
|
||||
def test_key_owner_on_another_host_is_refused(fed_remote):
|
||||
key_id = fed_remote.url("/keys/eve")
|
||||
fed_remote.routes["/keys/eve"] = (
|
||||
200,
|
||||
{},
|
||||
{"id": key_id, "owner": "https://elsewhere.example/users/eve", "publicKeyPem": "x"},
|
||||
)
|
||||
with pytest.raises(remote.ActorError):
|
||||
remote.actor_for_key(key_id)
|
||||
Reference in new issue
Block a user