Merge branch 'develop' into gun
This commit is contained in:
commit
39ed608b13
34 changed files with 457 additions and 90 deletions
|
|
@ -341,6 +341,44 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
|
|||
assert "ok" == json_response(conn, 200)
|
||||
assert Instances.reachable?(sender_url)
|
||||
end
|
||||
|
||||
test "accept follow activity", %{conn: conn} do
|
||||
Pleroma.Config.put([:instance, :federating], true)
|
||||
relay = Relay.get_actor()
|
||||
|
||||
assert {:ok, %Activity{} = activity} = Relay.follow("https://relay.mastodon.host/actor")
|
||||
|
||||
followed_relay = Pleroma.User.get_by_ap_id("https://relay.mastodon.host/actor")
|
||||
relay = refresh_record(relay)
|
||||
|
||||
accept =
|
||||
File.read!("test/fixtures/relay/accept-follow.json")
|
||||
|> String.replace("{{ap_id}}", relay.ap_id)
|
||||
|> String.replace("{{activity_id}}", activity.data["id"])
|
||||
|
||||
assert "ok" ==
|
||||
conn
|
||||
|> assign(:valid_signature, true)
|
||||
|> put_req_header("content-type", "application/activity+json")
|
||||
|> post("/inbox", accept)
|
||||
|> json_response(200)
|
||||
|
||||
ObanHelpers.perform(all_enqueued(worker: ReceiverWorker))
|
||||
|
||||
assert Pleroma.FollowingRelationship.following?(
|
||||
relay,
|
||||
followed_relay
|
||||
)
|
||||
|
||||
Mix.shell(Mix.Shell.Process)
|
||||
|
||||
on_exit(fn ->
|
||||
Mix.shell(Mix.Shell.IO)
|
||||
end)
|
||||
|
||||
:ok = Mix.Tasks.Pleroma.Relay.run(["list"])
|
||||
assert_receive {:mix_shell, :info, ["relay.mastodon.host"]}
|
||||
end
|
||||
end
|
||||
|
||||
describe "/users/:nickname/inbox" do
|
||||
|
|
|
|||
|
|
@ -202,13 +202,15 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
CommonAPI.post(user, %{"status" => ""})
|
||||
end
|
||||
|
||||
test "it returns error when character limit is exceeded" do
|
||||
test "it validates character limits are correctly enforced" do
|
||||
Pleroma.Config.put([:instance, :limit], 5)
|
||||
|
||||
user = insert(:user)
|
||||
|
||||
assert {:error, "The status is over the character limit"} =
|
||||
CommonAPI.post(user, %{"status" => "foobar"})
|
||||
|
||||
assert {:ok, activity} = CommonAPI.post(user, %{"status" => "12345"})
|
||||
end
|
||||
|
||||
test "it can handle activities that expire" do
|
||||
|
|
|
|||
|
|
@ -601,6 +601,8 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
[valid_params: valid_params]
|
||||
end
|
||||
|
||||
clear_config([:instance, :account_activation_required])
|
||||
|
||||
test "Account registration via Application", %{conn: conn} do
|
||||
conn =
|
||||
post(conn, "/api/v1/apps", %{
|
||||
|
|
@ -685,7 +687,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
assert json_response(res, 200)
|
||||
|
||||
[{127, 0, 0, 1}, {127, 0, 0, 2}, {127, 0, 0, 3}, {127, 0, 0, 4}]
|
||||
|> Stream.zip(valid_params)
|
||||
|> Stream.zip(Map.delete(valid_params, :email))
|
||||
|> Enum.each(fn {ip, {attr, _}} ->
|
||||
res =
|
||||
conn
|
||||
|
|
@ -697,6 +699,54 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
end)
|
||||
end
|
||||
|
||||
clear_config([:instance, :account_activation_required])
|
||||
|
||||
test "returns bad_request if missing email params when :account_activation_required is enabled",
|
||||
%{conn: conn, valid_params: valid_params} do
|
||||
Pleroma.Config.put([:instance, :account_activation_required], true)
|
||||
|
||||
app_token = insert(:oauth_token, user: nil)
|
||||
conn = put_req_header(conn, "authorization", "Bearer " <> app_token.token)
|
||||
|
||||
res =
|
||||
conn
|
||||
|> Map.put(:remote_ip, {127, 0, 0, 5})
|
||||
|> post("/api/v1/accounts", Map.delete(valid_params, :email))
|
||||
|
||||
assert json_response(res, 400) == %{"error" => "Missing parameters"}
|
||||
|
||||
res =
|
||||
conn
|
||||
|> Map.put(:remote_ip, {127, 0, 0, 6})
|
||||
|> post("/api/v1/accounts", Map.put(valid_params, :email, ""))
|
||||
|
||||
assert json_response(res, 400) == %{"error" => "{\"email\":[\"can't be blank\"]}"}
|
||||
end
|
||||
|
||||
test "allow registration without an email", %{conn: conn, valid_params: valid_params} do
|
||||
app_token = insert(:oauth_token, user: nil)
|
||||
conn = put_req_header(conn, "authorization", "Bearer " <> app_token.token)
|
||||
|
||||
res =
|
||||
conn
|
||||
|> Map.put(:remote_ip, {127, 0, 0, 7})
|
||||
|> post("/api/v1/accounts", Map.delete(valid_params, :email))
|
||||
|
||||
assert json_response(res, 200)
|
||||
end
|
||||
|
||||
test "allow registration with an empty email", %{conn: conn, valid_params: valid_params} do
|
||||
app_token = insert(:oauth_token, user: nil)
|
||||
conn = put_req_header(conn, "authorization", "Bearer " <> app_token.token)
|
||||
|
||||
res =
|
||||
conn
|
||||
|> Map.put(:remote_ip, {127, 0, 0, 8})
|
||||
|> post("/api/v1/accounts", Map.put(valid_params, :email, ""))
|
||||
|
||||
assert json_response(res, 200)
|
||||
end
|
||||
|
||||
test "returns forbidden if token is invalid", %{conn: conn, valid_params: valid_params} do
|
||||
conn = put_req_header(conn, "authorization", "Bearer " <> "invalid-token")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue