core, memory (sqla), plugins XEP-0277, XEP-0346: various fixes:
- `is_local`: now use `server_jid`. - `aio_func`: pass the missing `self` argument (`aio_fund` is unbound). - Declare `pubsub_service` in `core_types.SatXMPPEntity` - plugin XEP-0277: fix handling of `MbData.from_element` when node is not specified (so we use default node). - plugin XEP-0346: `IdentityData`: fix field access, following move to Pydantic model.
This commit is contained in:
parent
f862efe790
commit
50ffc8c3b4
6 changed files with 26 additions and 25 deletions
|
|
@ -380,18 +380,20 @@ async def mock_get_pubsub_node(client, service, node, with_subscriptions=False,
|
|||
return fake_cached_node
|
||||
|
||||
|
||||
def mock_client(jid):
|
||||
def mock_client(client_jid):
|
||||
client = MagicMock()
|
||||
client.jid = jid
|
||||
client.jid = client_jid
|
||||
client.host = "test.example"
|
||||
# same derivation as SatXMPPComponent.server_jid
|
||||
client.server_jid = jid.JID(client_jid.host.split(".", 1)[-1])
|
||||
client._ap_storage.get = AsyncMock()
|
||||
client._ap_storage.aset = AsyncMock()
|
||||
client.is_local = lambda jid_: SatXMPPComponent.is_local(client, jid_)
|
||||
return client
|
||||
|
||||
|
||||
def get_virtual_client(jid):
|
||||
return mock_client(jid)
|
||||
def get_virtual_client(client_jid):
|
||||
return mock_client(client_jid)
|
||||
|
||||
|
||||
class FakeTReqPostResponse:
|
||||
|
|
@ -450,12 +452,12 @@ class TestActivityPubGateway:
|
|||
== "some_other_node---simple@test.example"
|
||||
)
|
||||
|
||||
# local pubsub node
|
||||
# pubsub node on non local pubsub service (exact domain match)
|
||||
with patch.object(ap_gateway, "is_pubsub") as is_pubsub:
|
||||
is_pubsub.return_value = True
|
||||
assert (
|
||||
await get_account(jid_=jid.JID("pubsub.test.example"), node="some_node")
|
||||
== "some_node@pubsub.test.example"
|
||||
== "___some_node.40pubsub.2etest.2eexample@ap.test.example"
|
||||
)
|
||||
|
||||
# non local pubsub node
|
||||
|
|
@ -505,16 +507,13 @@ class TestActivityPubGateway:
|
|||
with patch.object(ap_gateway, "is_pubsub") as is_pubsub:
|
||||
is_pubsub.return_value = True
|
||||
|
||||
# simple local node
|
||||
assert await get_jid_node("toto@pubsub.test.example") == (
|
||||
jid.JID("pubsub.test.example"),
|
||||
"toto",
|
||||
)
|
||||
# node on non local pubsub service is not allowed with local_only
|
||||
with pytest.raises(exceptions.PermissionError):
|
||||
await get_jid_node("toto@pubsub.test.example")
|
||||
|
||||
# encoded local node
|
||||
assert await get_jid_node(
|
||||
"___urn.3axmpp.3amicroblog.3a0@pubsub.test.example"
|
||||
) == (jid.JID("pubsub.test.example"), "urn:xmpp:microblog:0")
|
||||
# same with an encoded node
|
||||
with pytest.raises(exceptions.PermissionError):
|
||||
await get_jid_node("___urn.3axmpp.3amicroblog.3a0@pubsub.test.example")
|
||||
|
||||
@ed
|
||||
async def test_ap_to_pubsub_conversion(self, ap_gateway, monkeypatch):
|
||||
|
|
|
|||
Loading…
Reference in a new issue