Refactor tests for relay task and refresh cassetes
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
5f291336fd
commit
ed7b53357f
|
@ -16,9 +16,10 @@ defmodule Mix.Tasks.Mobilizon.Relay.Follow do
|
|||
{:ok, _activity, _follow} ->
|
||||
# put this task to sleep to allow the genserver to push out the messages
|
||||
:timer.sleep(500)
|
||||
shell_info("Requested to follow #{target}")
|
||||
|
||||
{:error, e} ->
|
||||
IO.puts(:stderr, "Error while following #{target}: #{inspect(e)}")
|
||||
shell_error("Error while following #{target}: #{inspect(e)}")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -16,9 +16,10 @@ defmodule Mix.Tasks.Mobilizon.Relay.Unfollow do
|
|||
{:ok, _activity, _follow} ->
|
||||
# put this task to sleep to allow the genserver to push out the messages
|
||||
:timer.sleep(500)
|
||||
shell_info("Unfollowed #{target}")
|
||||
|
||||
{:error, e} ->
|
||||
IO.puts(:stderr, "Error while unfollowing #{target}: #{inspect(e)}")
|
||||
shell_error("Error while unfollowing #{target}: #{inspect(e)}")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,101 +0,0 @@
|
|||
[
|
||||
{
|
||||
"request": {
|
||||
"body": "",
|
||||
"headers": {
|
||||
"Accept": "application/json, application/activity+json, application/jrd+json"
|
||||
},
|
||||
"method": "get",
|
||||
"options": {
|
||||
"follow_redirect": "true"
|
||||
},
|
||||
"request_body": "",
|
||||
"url": "http://mobilizon1.com/.well-known/webfinger?resource=acct:relay@mobilizon1.com"
|
||||
},
|
||||
"response": {
|
||||
"binary": false,
|
||||
"body": "{\"aliases\":[\"http://mobilizon1.com/relay\"],\"links\":[{\"href\":\"http://mobilizon1.com/relay\",\"rel\":\"self\",\"type\":\"application/activity+json\"},{\"href\":\"http://mobilizon1.com/relay\",\"rel\":\"https://webfinger.net/rel/profile-page/\",\"type\":\"text/html\"}],\"subject\":\"acct:relay@mobilizon1.com\"}",
|
||||
"headers": {
|
||||
"Server": "nginx/1.16.1",
|
||||
"Date": "Fri, 13 Dec 2019 09:41:40 GMT",
|
||||
"Content-Type": "application/json; charset=utf-8",
|
||||
"Content-Length": "284",
|
||||
"Connection": "keep-alive",
|
||||
"access-control-allow-credentials": "true",
|
||||
"access-control-allow-origin": "*",
|
||||
"access-control-expose-headers": "",
|
||||
"cache-control": "max-age=0, private, must-revalidate",
|
||||
"x-request-id": "Fd_k7OtPJ28p8-MAAAOh"
|
||||
},
|
||||
"status_code": 200,
|
||||
"type": "ok"
|
||||
}
|
||||
},
|
||||
{
|
||||
"request": {
|
||||
"body": "",
|
||||
"headers": {
|
||||
"Accept": "application/activity+json"
|
||||
},
|
||||
"method": "get",
|
||||
"options": {
|
||||
"follow_redirect": "true"
|
||||
},
|
||||
"request_body": "",
|
||||
"url": "http://mobilizon1.com/relay"
|
||||
},
|
||||
"response": {
|
||||
"binary": false,
|
||||
"body": "{\"@context\":[\"https://www.w3.org/ns/activitystreams\",\"https://litepub.social/litepub/context.jsonld\",{\"Hashtag\":\"as:Hashtag\",\"category\":\"sc:category\",\"ical\":\"http://www.w3.org/2002/12/cal/ical#\",\"joinMode\":{\"@id\":\"mz:joinMode\",\"@type\":\"mz:joinModeType\"},\"joinModeType\":{\"@id\":\"mz:joinModeType\",\"@type\":\"rdfs:Class\"},\"maximumAttendeeCapacity\":\"sc:maximumAttendeeCapacity\",\"mz\":\"https://joinmobilizon.org/ns#\",\"repliesModerationOption\":{\"@id\":\"mz:repliesModerationOption\",\"@type\":\"mz:repliesModerationOptionType\"},\"repliesModerationOptionType\":{\"@id\":\"mz:repliesModerationOptionType\",\"@type\":\"rdfs:Class\"},\"sc\":\"http://schema.org#\",\"uuid\":\"sc:identifier\"}],\"endpoints\":{\"sharedInbox\":\"http://mobilizon1.com/inbox\"},\"followers\":\"http://mobilizon1.com/relay/followers\",\"following\":\"http://mobilizon1.com/relay/following\",\"id\":\"http://mobilizon1.com/relay\",\"inbox\":\"http://mobilizon1.com/inbox\",\"manuallyApprovesFollowers\":false,\"name\":\"Mobilizon\",\"outbox\":null,\"preferredUsername\":\"relay\",\"publicKey\":{\"id\":\"http://mobilizon1.com/relay#main-key\",\"owner\":\"http://mobilizon1.com/relay\",\"publicKeyPem\":\"-----BEGIN RSA PUBLIC KEY-----\\nMIIBCgKCAQEAqBbeHMV5UVw0AIVch7fWDp2it5rqbGZX6yXPYnnT8LHhdvfv3DFk\\npk74BN66MzNqsthvSVznu2BEil0sEKD5rQoE9Yirhzz/LN9SlnU+u6262nBA18E3\\nkQ10RgL2jpZ9e8Om6qYqarhN7draupJXYRKEaUoEFPT09ABbwQv+4K1YadU8klJi\\nHJ6D+IIHiXNizfsxVLDKpbUKStMYeEzyfqCkWw0EQEuzc3O7Aci5lwCMkCts2993\\nsTbNyzsYAVWJNcy/An1F1P+K4iZhWEtZInQz67MBtjMWtQUhyWib0e671HdBiWM6\\nkZq74U8c6RR6eMzBLuY7YAUCG6nWg90zxwIDAQAB\\n-----END RSA PUBLIC KEY-----\\n\\n\"},\"summary\":\"Change this to a proper description of your instance\",\"type\":\"Application\",\"url\":\"http://mobilizon1.com/relay\"}",
|
||||
"headers": {
|
||||
"Server": "nginx/1.16.1",
|
||||
"Date": "Fri, 13 Dec 2019 09:41:41 GMT",
|
||||
"Content-Type": "application/activity+json",
|
||||
"Content-Length": "1657",
|
||||
"Connection": "keep-alive",
|
||||
"access-control-allow-credentials": "true",
|
||||
"access-control-allow-origin": "*",
|
||||
"access-control-expose-headers": "",
|
||||
"cache-control": "max-age=0, private, must-revalidate",
|
||||
"x-request-id": "Fd_k7PjOAWuySL0AAAPB"
|
||||
},
|
||||
"status_code": 200,
|
||||
"type": "ok"
|
||||
}
|
||||
},
|
||||
{
|
||||
"request": {
|
||||
"body": "{\"@context\":[\"https://www.w3.org/ns/activitystreams\",\"https://litepub.social/litepub/context.jsonld\",{\"Hashtag\":\"as:Hashtag\",\"category\":\"sc:category\",\"ical\":\"http://www.w3.org/2002/12/cal/ical#\",\"joinMode\":{\"@id\":\"mz:joinMode\",\"@type\":\"mz:joinModeType\"},\"joinModeType\":{\"@id\":\"mz:joinModeType\",\"@type\":\"rdfs:Class\"},\"maximumAttendeeCapacity\":\"sc:maximumAttendeeCapacity\",\"mz\":\"https://joinmobilizon.org/ns#\",\"repliesModerationOption\":{\"@id\":\"mz:repliesModerationOption\",\"@type\":\"mz:repliesModerationOptionType\"},\"repliesModerationOptionType\":{\"@id\":\"mz:repliesModerationOptionType\",\"@type\":\"rdfs:Class\"},\"sc\":\"http://schema.org#\",\"uuid\":\"sc:identifier\"}],\"actor\":\"http://mobilizon.test/relay\",\"cc\":[\"https://www.w3.org/ns/activitystreams#Public\"],\"id\":\"http://mobilizon.test/follow/b7791977-2a75-4715-815b-6e7125065b71\",\"object\":\"http://mobilizon1.com/relay\",\"to\":[\"http://mobilizon1.com/relay\"],\"type\":\"Follow\"}",
|
||||
"headers": {
|
||||
"Content-Type": "application/activity+json",
|
||||
"signature": "keyId=\"http://mobilizon.test/relay#main-key\",algorithm=\"rsa-sha256\",headers=\"(request-target) content-length date digest host\",signature=\"WbyGHT/WdvdRpWek8uCGHrFSblLpg+Iq802R5S2cjNj035OKpxRmu1r8u9Qr5KGIKgZn6LHt9YmB+PNlwsubPtTSkJpE8AAUDMHLKgCrH7A5Q6x6GlARl5bHNo4QtOxkXvnEbn31xfNDNp70QqZb/emw95TnELYUlMLZds0qYutT8U4WdDhSWcVytQmKJWNZXxEj+KlMDUaxag3lGscJ/HY0F+yGNov7FHthid1Y4LTGFsp/tismnMTlba12NH/kXPHtduNsX8uxFslM2ODwqAaospTGEpXmr9CPgbNy7626qgYaR2RdB/fYlCayLI4JJIlH8gOdocGHPrWNtVEHaQ==\"",
|
||||
"digest": "SHA-256=ibNFcsnBeCCjWZo9We60tKfbRN3el0WCMVdOxtuC1cg=",
|
||||
"date": "Fri, 13 Dec 2019 09:41:41 GMT"
|
||||
},
|
||||
"method": "post",
|
||||
"options": {
|
||||
"pool": "default"
|
||||
},
|
||||
"request_body": "",
|
||||
"url": "http://mobilizon1.com/inbox"
|
||||
},
|
||||
"response": {
|
||||
"binary": false,
|
||||
"body": "# HTTPoison.Error at POST /inbox\n\nException:\n\n ** (HTTPoison.Error) :nxdomain\n (httpoison) lib/httpoison.ex:128: HTTPoison.request!/5\n (mobilizon) lib/service/activity_pub/activity_pub.ex:610: Mobilizon.Service.ActivityPub.fetch_and_prepare_actor_from_url/1\n (mobilizon) lib/service/activity_pub/activity_pub.ex:473: Mobilizon.Service.ActivityPub.make_actor_from_url/2\n (mobilizon) lib/service/activity_pub/activity_pub.ex:122: Mobilizon.Service.ActivityPub.get_or_fetch_actor_by_url/2\n (mobilizon) lib/service/http_signatures/signature.ex:54: Mobilizon.Federation.HTTPSignatures.Signature.get_public_key_for_url/1\n (mobilizon) lib/service/http_signatures/signature.ex:74: Mobilizon.Federation.HTTPSignatures.Signature.fetch_public_key/1\n (http_signatures) lib/http_signatures/http_signatures.ex:40: HTTPSignatures.validate_conn/1\n (mobilizon) lib/mobilizon_web/http_signature.ex:45: Mobilizon.Web.HTTPSignaturePlug.call/2\n (mobilizon) Mobilizon.Web.Router.activity_pub_signature/2\n (mobilizon) lib/mobilizon_web/router.ex:1: Mobilizon.Web.Router.__pipe_through7__/1\n (phoenix) lib/phoenix/router.ex:283: Phoenix.Router.__call__/2\n (mobilizon) lib/mobilizon_web/endpoint.ex:1: Mobilizon.Web.Endpoint.plug_builder_call/2\n (mobilizon) lib/plug/debugger.ex:122: Mobilizon.Web.Endpoint.\"call (overridable 3)\"/2\n (mobilizon) lib/mobilizon_web/endpoint.ex:1: Mobilizon.Web.Endpoint.call/2\n (phoenix) lib/phoenix/endpoint/cowboy2_handler.ex:42: Phoenix.Endpoint.Cowboy2Handler.init/4\n (cowboy) /home/tcit/dev/frama/mobilizon/deps/cowboy/src/cowboy_handler.erl:41: :cowboy_handler.execute/2\n (cowboy) /home/tcit/dev/frama/mobilizon/deps/cowboy/src/cowboy_stream_h.erl:320: :cowboy_stream_h.execute/3\n (cowboy) /home/tcit/dev/frama/mobilizon/deps/cowboy/src/cowboy_stream_h.erl:302: :cowboy_stream_h.request_process/3\n (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3\n \n\n## Connection details\n\n### Params\n\n %{\"@context\" => [\"https://www.w3.org/ns/activitystreams\", \"https://litepub.social/litepub/context.jsonld\", %{\"Hashtag\" => \"as:Hashtag\", \"category\" => \"sc:category\", \"ical\" => \"http://www.w3.org/2002/12/cal/ical#\", \"joinMode\" => %{\"@id\" => \"mz:joinMode\", \"@type\" => \"mz:joinModeType\"}, \"joinModeType\" => %{\"@id\" => \"mz:joinModeType\", \"@type\" => \"rdfs:Class\"}, \"maximumAttendeeCapacity\" => \"sc:maximumAttendeeCapacity\", \"mz\" => \"https://joinmobilizon.org/ns#\", \"repliesModerationOption\" => %{\"@id\" => \"mz:repliesModerationOption\", \"@type\" => \"mz:repliesModerationOptionType\"}, \"repliesModerationOptionType\" => %{\"@id\" => \"mz:repliesModerationOptionType\", \"@type\" => \"rdfs:Class\"}, \"sc\" => \"http://schema.org#\", \"uuid\" => \"sc:identifier\"}], \"actor\" => \"http://mobilizon.test/relay\", \"cc\" => [\"https://www.w3.org/ns/activitystreams#Public\"], \"id\" => \"http://mobilizon.test/follow/b7791977-2a75-4715-815b-6e7125065b71\", \"object\" => \"http://mobilizon1.com/relay\", \"to\" => [\"http://mobilizon1.com/relay\"], \"type\" => \"Follow\"}\n\n### Request info\n\n * URI: http://mobilizon1.com:80/inbox\n * Query string: \n\n### Headers\n \n * connection: upgrade\n * content-length: 912\n * content-type: application/activity+json\n * date: Fri, 13 Dec 2019 09:41:41 GMT\n * digest: SHA-256=ibNFcsnBeCCjWZo9We60tKfbRN3el0WCMVdOxtuC1cg=\n * host: mobilizon1.com\n * signature: keyId=\"http://mobilizon.test/relay#main-key\",algorithm=\"rsa-sha256\",headers=\"(request-target) content-length date digest host\",signature=\"WbyGHT/WdvdRpWek8uCGHrFSblLpg+Iq802R5S2cjNj035OKpxRmu1r8u9Qr5KGIKgZn6LHt9YmB+PNlwsubPtTSkJpE8AAUDMHLKgCrH7A5Q6x6GlARl5bHNo4QtOxkXvnEbn31xfNDNp70QqZb/emw95TnELYUlMLZds0qYutT8U4WdDhSWcVytQmKJWNZXxEj+KlMDUaxag3lGscJ/HY0F+yGNov7FHthid1Y4LTGFsp/tismnMTlba12NH/kXPHtduNsX8uxFslM2ODwqAaospTGEpXmr9CPgbNy7626qgYaR2RdB/fYlCayLI4JJIlH8gOdocGHPrWNtVEHaQ==\"\n * user-agent: hackney/1.15.2\n * x-forwarded-for: 127.0.0.1\n * x-real-ip: 127.0.0.1\n\n### Session\n\n %{}\n",
|
||||
"headers": {
|
||||
"Server": "nginx/1.16.1",
|
||||
"Date": "Fri, 13 Dec 2019 09:41:41 GMT",
|
||||
"Content-Type": "text/markdown; charset=utf-8",
|
||||
"Content-Length": "3977",
|
||||
"Connection": "keep-alive",
|
||||
"access-control-allow-credentials": "true",
|
||||
"access-control-allow-origin": "*",
|
||||
"access-control-expose-headers": "",
|
||||
"cache-control": "max-age=0, private, must-revalidate",
|
||||
"x-request-id": "Fd_k7PoZpCCBYRQAAAPh"
|
||||
},
|
||||
"status_code": 500,
|
||||
"type": "ok"
|
||||
}
|
||||
}
|
||||
]
|
|
@ -1,101 +0,0 @@
|
|||
[
|
||||
{
|
||||
"request": {
|
||||
"body": "",
|
||||
"headers": {
|
||||
"Accept": "application/json, application/activity+json, application/jrd+json"
|
||||
},
|
||||
"method": "get",
|
||||
"options": {
|
||||
"follow_redirect": "true"
|
||||
},
|
||||
"request_body": "",
|
||||
"url": "http://mobilizon1.com/.well-known/webfinger?resource=acct:relay@mobilizon1.com"
|
||||
},
|
||||
"response": {
|
||||
"binary": false,
|
||||
"body": "{\"aliases\":[\"http://mobilizon1.com/relay\"],\"links\":[{\"href\":\"http://mobilizon1.com/relay\",\"rel\":\"self\",\"type\":\"application/activity+json\"},{\"href\":\"http://mobilizon1.com/relay\",\"rel\":\"https://webfinger.net/rel/profile-page/\",\"type\":\"text/html\"}],\"subject\":\"acct:relay@mobilizon1.com\"}",
|
||||
"headers": {
|
||||
"Server": "nginx/1.16.1",
|
||||
"Date": "Fri, 13 Dec 2019 09:41:39 GMT",
|
||||
"Content-Type": "application/json; charset=utf-8",
|
||||
"Content-Length": "284",
|
||||
"Connection": "keep-alive",
|
||||
"access-control-allow-credentials": "true",
|
||||
"access-control-allow-origin": "*",
|
||||
"access-control-expose-headers": "",
|
||||
"cache-control": "max-age=0, private, must-revalidate",
|
||||
"x-request-id": "Fd_k7LmY5k0CMQkAAANB"
|
||||
},
|
||||
"status_code": 200,
|
||||
"type": "ok"
|
||||
}
|
||||
},
|
||||
{
|
||||
"request": {
|
||||
"body": "",
|
||||
"headers": {
|
||||
"Accept": "application/activity+json"
|
||||
},
|
||||
"method": "get",
|
||||
"options": {
|
||||
"follow_redirect": "true"
|
||||
},
|
||||
"request_body": "",
|
||||
"url": "http://mobilizon1.com/relay"
|
||||
},
|
||||
"response": {
|
||||
"binary": false,
|
||||
"body": "{\"@context\":[\"https://www.w3.org/ns/activitystreams\",\"https://litepub.social/litepub/context.jsonld\",{\"Hashtag\":\"as:Hashtag\",\"category\":\"sc:category\",\"ical\":\"http://www.w3.org/2002/12/cal/ical#\",\"joinMode\":{\"@id\":\"mz:joinMode\",\"@type\":\"mz:joinModeType\"},\"joinModeType\":{\"@id\":\"mz:joinModeType\",\"@type\":\"rdfs:Class\"},\"maximumAttendeeCapacity\":\"sc:maximumAttendeeCapacity\",\"mz\":\"https://joinmobilizon.org/ns#\",\"repliesModerationOption\":{\"@id\":\"mz:repliesModerationOption\",\"@type\":\"mz:repliesModerationOptionType\"},\"repliesModerationOptionType\":{\"@id\":\"mz:repliesModerationOptionType\",\"@type\":\"rdfs:Class\"},\"sc\":\"http://schema.org#\",\"uuid\":\"sc:identifier\"}],\"endpoints\":{\"sharedInbox\":\"http://mobilizon1.com/inbox\"},\"followers\":\"http://mobilizon1.com/relay/followers\",\"following\":\"http://mobilizon1.com/relay/following\",\"id\":\"http://mobilizon1.com/relay\",\"inbox\":\"http://mobilizon1.com/inbox\",\"manuallyApprovesFollowers\":false,\"name\":\"Mobilizon\",\"outbox\":null,\"preferredUsername\":\"relay\",\"publicKey\":{\"id\":\"http://mobilizon1.com/relay#main-key\",\"owner\":\"http://mobilizon1.com/relay\",\"publicKeyPem\":\"-----BEGIN RSA PUBLIC KEY-----\\nMIIBCgKCAQEAqBbeHMV5UVw0AIVch7fWDp2it5rqbGZX6yXPYnnT8LHhdvfv3DFk\\npk74BN66MzNqsthvSVznu2BEil0sEKD5rQoE9Yirhzz/LN9SlnU+u6262nBA18E3\\nkQ10RgL2jpZ9e8Om6qYqarhN7draupJXYRKEaUoEFPT09ABbwQv+4K1YadU8klJi\\nHJ6D+IIHiXNizfsxVLDKpbUKStMYeEzyfqCkWw0EQEuzc3O7Aci5lwCMkCts2993\\nsTbNyzsYAVWJNcy/An1F1P+K4iZhWEtZInQz67MBtjMWtQUhyWib0e671HdBiWM6\\nkZq74U8c6RR6eMzBLuY7YAUCG6nWg90zxwIDAQAB\\n-----END RSA PUBLIC KEY-----\\n\\n\"},\"summary\":\"Change this to a proper description of your instance\",\"type\":\"Application\",\"url\":\"http://mobilizon1.com/relay\"}",
|
||||
"headers": {
|
||||
"Server": "nginx/1.16.1",
|
||||
"Date": "Fri, 13 Dec 2019 09:41:40 GMT",
|
||||
"Content-Type": "application/activity+json",
|
||||
"Content-Length": "1657",
|
||||
"Connection": "keep-alive",
|
||||
"access-control-allow-credentials": "true",
|
||||
"access-control-allow-origin": "*",
|
||||
"access-control-expose-headers": "",
|
||||
"cache-control": "max-age=0, private, must-revalidate",
|
||||
"x-request-id": "Fd_k7L4h92fDp5cAAANh"
|
||||
},
|
||||
"status_code": 200,
|
||||
"type": "ok"
|
||||
}
|
||||
},
|
||||
{
|
||||
"request": {
|
||||
"body": "{\"@context\":[\"https://www.w3.org/ns/activitystreams\",\"https://litepub.social/litepub/context.jsonld\",{\"Hashtag\":\"as:Hashtag\",\"category\":\"sc:category\",\"ical\":\"http://www.w3.org/2002/12/cal/ical#\",\"joinMode\":{\"@id\":\"mz:joinMode\",\"@type\":\"mz:joinModeType\"},\"joinModeType\":{\"@id\":\"mz:joinModeType\",\"@type\":\"rdfs:Class\"},\"maximumAttendeeCapacity\":\"sc:maximumAttendeeCapacity\",\"mz\":\"https://joinmobilizon.org/ns#\",\"repliesModerationOption\":{\"@id\":\"mz:repliesModerationOption\",\"@type\":\"mz:repliesModerationOptionType\"},\"repliesModerationOptionType\":{\"@id\":\"mz:repliesModerationOptionType\",\"@type\":\"rdfs:Class\"},\"sc\":\"http://schema.org#\",\"uuid\":\"sc:identifier\"}],\"actor\":\"http://mobilizon.test/relay\",\"cc\":[\"https://www.w3.org/ns/activitystreams#Public\"],\"id\":\"http://mobilizon.test/follow/57a6973e-f43f-4533-bf71-7a14a4c6e5ac\",\"object\":\"http://mobilizon1.com/relay\",\"to\":[\"http://mobilizon1.com/relay\"],\"type\":\"Follow\"}",
|
||||
"headers": {
|
||||
"Content-Type": "application/activity+json",
|
||||
"signature": "keyId=\"http://mobilizon.test/relay#main-key\",algorithm=\"rsa-sha256\",headers=\"(request-target) content-length date digest host\",signature=\"JQPqSiJ0ZYdU6llrYXNMuN/bfzoLyubwOB59bljFq6i8ORXLw62Pt7Jue5WkMsySFcCXgS8k8K/H81YZkKzfWadwQV9L5rQEFSuW/DYJ2xffsDj90GsSi+sDRaQ5Ke8nPEbEMGR9jalh/F2VL97XscCgm6i3tdpbs6aFmqjKC+LzeH665t0WCHUxTgK47wECrMHw3j7lteGdm6N6IKWoWsRYeJoyFr/QCbNdWQOaAYYpCbJd0fjhPQRHhWQXidBoaDkhwesWc3mO8pvEnply9ES7Nzc6ULK7B98hg+aWeep8/KzRbxFyJ0OgnDJj/l39QiJ9t7v0yHX/WUzn0CaiiQ==\"",
|
||||
"digest": "SHA-256=Qc9d9X3qh2EqIqtn/72iY17OMDXAOINDC10hARNAc4w=",
|
||||
"date": "Fri, 13 Dec 2019 09:41:40 GMT"
|
||||
},
|
||||
"method": "post",
|
||||
"options": {
|
||||
"pool": "default"
|
||||
},
|
||||
"request_body": "",
|
||||
"url": "http://mobilizon1.com/inbox"
|
||||
},
|
||||
"response": {
|
||||
"binary": false,
|
||||
"body": "# HTTPoison.Error at POST /inbox\n\nException:\n\n ** (HTTPoison.Error) :nxdomain\n (httpoison) lib/httpoison.ex:128: HTTPoison.request!/5\n (mobilizon) lib/service/activity_pub/activity_pub.ex:610: Mobilizon.Service.ActivityPub.fetch_and_prepare_actor_from_url/1\n (mobilizon) lib/service/activity_pub/activity_pub.ex:473: Mobilizon.Service.ActivityPub.make_actor_from_url/2\n (mobilizon) lib/service/activity_pub/activity_pub.ex:122: Mobilizon.Service.ActivityPub.get_or_fetch_actor_by_url/2\n (mobilizon) lib/service/http_signatures/signature.ex:54: Mobilizon.Service.HTTPSignatures.Signature.get_public_key_for_url/1\n (mobilizon) lib/service/http_signatures/signature.ex:74: Mobilizon.Service.HTTPSignatures.Signature.fetch_public_key/1\n (http_signatures) lib/http_signatures/http_signatures.ex:40: HTTPSignatures.validate_conn/1\n (mobilizon) lib/mobilizon_web/http_signature.ex:45: Mobilizon.Web.HTTPSignaturePlug.call/2\n (mobilizon) Mobilizon.Web.Router.activity_pub_signature/2\n (mobilizon) lib/mobilizon_web/router.ex:1: Mobilizon.Web.Router.__pipe_through7__/1\n (phoenix) lib/phoenix/router.ex:283: Phoenix.Router.__call__/2\n (mobilizon) lib/mobilizon_web/endpoint.ex:1: Mobilizon.Web.Endpoint.plug_builder_call/2\n (mobilizon) lib/plug/debugger.ex:122: Mobilizon.Web.Endpoint.\"call (overridable 3)\"/2\n (mobilizon) lib/mobilizon_web/endpoint.ex:1: Mobilizon.Web.Endpoint.call/2\n (phoenix) lib/phoenix/endpoint/cowboy2_handler.ex:42: Phoenix.Endpoint.Cowboy2Handler.init/4\n (cowboy) /home/tcit/dev/frama/mobilizon/deps/cowboy/src/cowboy_handler.erl:41: :cowboy_handler.execute/2\n (cowboy) /home/tcit/dev/frama/mobilizon/deps/cowboy/src/cowboy_stream_h.erl:320: :cowboy_stream_h.execute/3\n (cowboy) /home/tcit/dev/frama/mobilizon/deps/cowboy/src/cowboy_stream_h.erl:302: :cowboy_stream_h.request_process/3\n (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3\n \n\n## Connection details\n\n### Params\n\n %{\"@context\" => [\"https://www.w3.org/ns/activitystreams\", \"https://litepub.social/litepub/context.jsonld\", %{\"Hashtag\" => \"as:Hashtag\", \"category\" => \"sc:category\", \"ical\" => \"http://www.w3.org/2002/12/cal/ical#\", \"joinMode\" => %{\"@id\" => \"mz:joinMode\", \"@type\" => \"mz:joinModeType\"}, \"joinModeType\" => %{\"@id\" => \"mz:joinModeType\", \"@type\" => \"rdfs:Class\"}, \"maximumAttendeeCapacity\" => \"sc:maximumAttendeeCapacity\", \"mz\" => \"https://joinmobilizon.org/ns#\", \"repliesModerationOption\" => %{\"@id\" => \"mz:repliesModerationOption\", \"@type\" => \"mz:repliesModerationOptionType\"}, \"repliesModerationOptionType\" => %{\"@id\" => \"mz:repliesModerationOptionType\", \"@type\" => \"rdfs:Class\"}, \"sc\" => \"http://schema.org#\", \"uuid\" => \"sc:identifier\"}], \"actor\" => \"http://mobilizon.test/relay\", \"cc\" => [\"https://www.w3.org/ns/activitystreams#Public\"], \"id\" => \"http://mobilizon.test/follow/57a6973e-f43f-4533-bf71-7a14a4c6e5ac\", \"object\" => \"http://mobilizon1.com/relay\", \"to\" => [\"http://mobilizon1.com/relay\"], \"type\" => \"Follow\"}\n\n### Request info\n\n * URI: http://mobilizon1.com:80/inbox\n * Query string: \n\n### Headers\n \n * connection: upgrade\n * content-length: 912\n * content-type: application/activity+json\n * date: Fri, 13 Dec 2019 09:41:40 GMT\n * digest: SHA-256=Qc9d9X3qh2EqIqtn/72iY17OMDXAOINDC10hARNAc4w=\n * host: mobilizon1.com\n * signature: keyId=\"http://mobilizon.test/relay#main-key\",algorithm=\"rsa-sha256\",headers=\"(request-target) content-length date digest host\",signature=\"JQPqSiJ0ZYdU6llrYXNMuN/bfzoLyubwOB59bljFq6i8ORXLw62Pt7Jue5WkMsySFcCXgS8k8K/H81YZkKzfWadwQV9L5rQEFSuW/DYJ2xffsDj90GsSi+sDRaQ5Ke8nPEbEMGR9jalh/F2VL97XscCgm6i3tdpbs6aFmqjKC+LzeH665t0WCHUxTgK47wECrMHw3j7lteGdm6N6IKWoWsRYeJoyFr/QCbNdWQOaAYYpCbJd0fjhPQRHhWQXidBoaDkhwesWc3mO8pvEnply9ES7Nzc6ULK7B98hg+aWeep8/KzRbxFyJ0OgnDJj/l39QiJ9t7v0yHX/WUzn0CaiiQ==\"\n * user-agent: hackney/1.15.2\n * x-forwarded-for: 127.0.0.1\n * x-real-ip: 127.0.0.1\n\n### Session\n\n %{}\n",
|
||||
"headers": {
|
||||
"Server": "nginx/1.16.1",
|
||||
"Date": "Fri, 13 Dec 2019 09:41:40 GMT",
|
||||
"Content-Type": "text/markdown; charset=utf-8",
|
||||
"Content-Length": "3977",
|
||||
"Connection": "keep-alive",
|
||||
"access-control-allow-credentials": "true",
|
||||
"access-control-allow-origin": "*",
|
||||
"access-control-expose-headers": "",
|
||||
"cache-control": "max-age=0, private, must-revalidate",
|
||||
"x-request-id": "Fd_k7MU4jVIgj4wAAAOB"
|
||||
},
|
||||
"status_code": 500,
|
||||
"type": "ok"
|
||||
}
|
||||
}
|
||||
]
|
|
@ -11,6 +11,7 @@ defmodule Mix.Tasks.Mobilizon.ActorsTest do
|
|||
|
||||
@username "someone"
|
||||
@domain "somewhere.tld"
|
||||
@error "Error: No such actor"
|
||||
|
||||
describe "show actor" do
|
||||
test "show existing local actor" do
|
||||
|
@ -50,7 +51,7 @@ defmodule Mix.Tasks.Mobilizon.ActorsTest do
|
|||
test "show non-existing actor" do
|
||||
Show.run([@username])
|
||||
assert_received {:mix_shell, :error, [message]}
|
||||
assert message =~ "Error: No such actor"
|
||||
assert message =~ @error
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,52 +3,73 @@
|
|||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Mix.Tasks.Mobilizon.RelayTest do
|
||||
use ExVCR.Mock, adapter: ExVCR.Adapter.Hackney
|
||||
|
||||
use Mobilizon.DataCase
|
||||
|
||||
alias Mobilizon.Actors
|
||||
alias Mobilizon.Actors.{Actor, Follower}
|
||||
alias Mix.Tasks.Mobilizon.Relay.{Follow, Unfollow}
|
||||
|
||||
alias Mobilizon.Federation.ActivityPub.Relay
|
||||
import Mock
|
||||
|
||||
Mix.shell(Mix.Shell.Process)
|
||||
|
||||
@target_instance "mobilizon1.com"
|
||||
|
||||
@output_1 "Requested to follow #{@target_instance}"
|
||||
@error_1 "Some error"
|
||||
@error_msg_1 "Error while following #{@target_instance}: \"#{@error_1}\""
|
||||
@error_msg_1_unfollow "Error while unfollowing #{@target_instance}: \"#{@error_1}\""
|
||||
@error_msg_2 "mobilizon.relay.follow requires an instance hostname as arguments"
|
||||
@error_msg_2_unfollow "mobilizon.relay.unfollow requires an instance hostname as arguments"
|
||||
|
||||
@output_2 "Unfollowed #{@target_instance}"
|
||||
|
||||
describe "running follow" do
|
||||
test "relay is followed" do
|
||||
use_cassette "relay/fetch_relay_follow" do
|
||||
target_instance = "mobilizon1.com"
|
||||
|
||||
Follow.run([target_instance])
|
||||
|
||||
local_actor = Relay.get_actor()
|
||||
assert local_actor.url =~ "/relay"
|
||||
|
||||
{:ok, target_actor} = Actors.get_actor_by_url("http://#{target_instance}/relay")
|
||||
refute is_nil(target_actor.domain)
|
||||
|
||||
assert Actors.is_following(local_actor, target_actor)
|
||||
with_mock Relay, [:passthrough], follow: fn @target_instance -> {:ok, nil, nil} end do
|
||||
Follow.run([@target_instance])
|
||||
assert_received {:mix_shell, :info, [output_received]}
|
||||
assert output_received == @output_1
|
||||
end
|
||||
end
|
||||
|
||||
test "returns an error" do
|
||||
with_mock Relay, [:passthrough], follow: fn @target_instance -> {:error, @error_1} end do
|
||||
Follow.run([@target_instance])
|
||||
assert_received {:mix_shell, :error, [output_received]}
|
||||
assert output_received == @error_msg_1
|
||||
end
|
||||
end
|
||||
|
||||
test "without arguments" do
|
||||
Follow.run([])
|
||||
assert_received {:mix_shell, :error, [output_received]}
|
||||
assert output_received == @error_msg_2
|
||||
end
|
||||
end
|
||||
|
||||
describe "running unfollow" do
|
||||
test "relay is unfollowed" do
|
||||
use_cassette "relay/fetch_relay_unfollow" do
|
||||
target_instance = "mobilizon1.com"
|
||||
with_mock Relay, [:passthrough], unfollow: fn @target_instance -> {:ok, nil, nil} end do
|
||||
Unfollow.run([@target_instance])
|
||||
|
||||
Follow.run([target_instance])
|
||||
|
||||
%Actor{} = local_actor = Relay.get_actor()
|
||||
|
||||
{:ok, %Actor{} = target_actor} =
|
||||
Actors.get_actor_by_url("http://#{target_instance}/relay")
|
||||
|
||||
assert %Follower{} = Actors.is_following(local_actor, target_actor)
|
||||
|
||||
Unfollow.run([target_instance])
|
||||
|
||||
refute Actors.is_following(local_actor, target_actor)
|
||||
assert_received {:mix_shell, :info, [output_received]}
|
||||
assert output_received == @output_2
|
||||
end
|
||||
end
|
||||
|
||||
test "returns an error" do
|
||||
with_mock Relay, [:passthrough], unfollow: fn @target_instance -> {:error, @error_1} end do
|
||||
Unfollow.run([@target_instance])
|
||||
|
||||
assert_received {:mix_shell, :error, [output_received]}
|
||||
assert output_received == @error_msg_1_unfollow
|
||||
end
|
||||
end
|
||||
|
||||
test "without arguments" do
|
||||
Unfollow.run([])
|
||||
assert_received {:mix_shell, :error, [output_received]}
|
||||
assert output_received == @error_msg_2_unfollow
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue