2019-07-30 16:40:59 +02:00
|
|
|
# Pleroma: A lightweight social networking server
|
|
|
|
# Copyright © 2017-2018 Pleroma Authors <https://pleroma.social/>
|
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
defmodule Mix.Tasks.Mobilizon.RelayTest do
|
2019-09-22 16:26:23 +02:00
|
|
|
use ExVCR.Mock, adapter: ExVCR.Adapter.Hackney
|
|
|
|
|
|
|
|
use Mobilizon.DataCase
|
|
|
|
|
2019-07-30 16:40:59 +02:00
|
|
|
alias Mobilizon.Actors
|
2019-09-22 16:26:23 +02:00
|
|
|
alias Mobilizon.Actors.{Actor, Follower}
|
2020-01-22 02:14:42 +01:00
|
|
|
|
|
|
|
alias Mobilizon.Federation.ActivityPub.Relay
|
2019-07-30 16:40:59 +02:00
|
|
|
|
|
|
|
describe "running follow" do
|
|
|
|
test "relay is followed" do
|
|
|
|
use_cassette "relay/fetch_relay_follow" do
|
2019-12-03 11:29:51 +01:00
|
|
|
target_instance = "mobilizon1.com"
|
2019-07-30 16:40:59 +02:00
|
|
|
|
|
|
|
Mix.Tasks.Mobilizon.Relay.run(["follow", target_instance])
|
|
|
|
|
|
|
|
local_actor = Relay.get_actor()
|
|
|
|
assert local_actor.url =~ "/relay"
|
|
|
|
|
2019-12-03 11:29:51 +01:00
|
|
|
{:ok, target_actor} = Actors.get_actor_by_url("http://#{target_instance}/relay")
|
2019-07-30 16:40:59 +02:00
|
|
|
refute is_nil(target_actor.domain)
|
|
|
|
|
2019-09-11 03:16:37 +02:00
|
|
|
assert Actors.is_following(local_actor, target_actor)
|
2019-07-30 16:40:59 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "running unfollow" do
|
|
|
|
test "relay is unfollowed" do
|
|
|
|
use_cassette "relay/fetch_relay_unfollow" do
|
2019-12-03 11:29:51 +01:00
|
|
|
target_instance = "mobilizon1.com"
|
2019-07-30 16:40:59 +02:00
|
|
|
|
|
|
|
Mix.Tasks.Mobilizon.Relay.run(["follow", target_instance])
|
|
|
|
|
|
|
|
%Actor{} = local_actor = Relay.get_actor()
|
2019-12-03 11:29:51 +01:00
|
|
|
|
|
|
|
{:ok, %Actor{} = target_actor} =
|
|
|
|
Actors.get_actor_by_url("http://#{target_instance}/relay")
|
|
|
|
|
2019-09-11 03:16:37 +02:00
|
|
|
assert %Follower{} = Actors.is_following(local_actor, target_actor)
|
2019-07-30 16:40:59 +02:00
|
|
|
|
|
|
|
Mix.Tasks.Mobilizon.Relay.run(["unfollow", target_instance])
|
|
|
|
|
2019-09-11 03:16:37 +02:00
|
|
|
refute Actors.is_following(local_actor, target_actor)
|
2019-07-30 16:40:59 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|