Merge remote-tracking branch 'origin/develop' into language-detection
This commit is contained in:
commit
2b1ef1bbdf
1005 changed files with 13890 additions and 4733 deletions
|
|
@ -116,6 +116,7 @@ defmodule Pleroma.DataCase do
|
|||
Mox.stub_with(Pleroma.Web.FederatorMock, Pleroma.Web.Federator)
|
||||
Mox.stub_with(Pleroma.ConfigMock, Pleroma.Config)
|
||||
Mox.stub_with(Pleroma.StaticStubbedConfigMock, Pleroma.Test.StaticConfig)
|
||||
Mox.stub_with(Pleroma.StubbedHTTPSignaturesMock, Pleroma.Test.HTTPSignaturesProxy)
|
||||
end
|
||||
|
||||
def ensure_local_uploader(context) do
|
||||
|
|
|
|||
|
|
@ -53,6 +53,13 @@ defmodule Pleroma.Factory do
|
|||
keys: pem
|
||||
}
|
||||
|
||||
user
|
||||
|> Map.put(:raw_bio, user.bio)
|
||||
|> merge_attributes(Map.delete(attrs, :domain))
|
||||
|> make_user_urls(attrs)
|
||||
end
|
||||
|
||||
defp make_user_urls(user, attrs) do
|
||||
urls =
|
||||
if attrs[:local] == false do
|
||||
base_domain = attrs[:domain] || Enum.random(["domain1.com", "domain2.com", "domain3.com"])
|
||||
|
|
@ -60,26 +67,22 @@ defmodule Pleroma.Factory do
|
|||
ap_id = "https://#{base_domain}/users/#{user.nickname}"
|
||||
|
||||
%{
|
||||
ap_id: ap_id,
|
||||
follower_address: ap_id <> "/followers",
|
||||
following_address: ap_id <> "/following",
|
||||
featured_address: ap_id <> "/collections/featured"
|
||||
ap_id: attrs[:ap_id] || ap_id,
|
||||
follower_address: attrs[:follower_address] || ap_id <> "/followers",
|
||||
following_address: attrs[:following_address] || ap_id <> "/following",
|
||||
featured_address: attrs[:featured_address] || ap_id <> "/collections/featured",
|
||||
inbox: attrs[:inbox] || "https://#{base_domain}/inbox"
|
||||
}
|
||||
else
|
||||
%{
|
||||
ap_id: User.ap_id(user),
|
||||
follower_address: User.ap_followers(user),
|
||||
following_address: User.ap_following(user),
|
||||
featured_address: User.ap_featured_collection(user)
|
||||
ap_id: attrs[:ap_id] || User.ap_id(user),
|
||||
follower_address: attrs[:follower_address] || User.ap_followers(user),
|
||||
following_address: attrs[:following_address] || User.ap_following(user),
|
||||
featured_address: attrs[:featured_address] || User.ap_featured_collection(user)
|
||||
}
|
||||
end
|
||||
|
||||
attrs = Map.delete(attrs, :domain)
|
||||
|
||||
user
|
||||
|> Map.put(:raw_bio, user.bio)
|
||||
|> Map.merge(urls)
|
||||
|> merge_attributes(attrs)
|
||||
Map.merge(user, urls)
|
||||
end
|
||||
|
||||
def user_relationship_factory(attrs \\ %{}) do
|
||||
|
|
@ -238,6 +241,7 @@ defmodule Pleroma.Factory do
|
|||
|
||||
def question_factory(attrs \\ %{}) do
|
||||
user = attrs[:user] || insert(:user)
|
||||
closed = attrs[:closed] || DateTime.utc_now() |> DateTime.add(86_400) |> DateTime.to_iso8601()
|
||||
|
||||
data = %{
|
||||
"id" => Pleroma.Web.ActivityPub.Utils.generate_object_id(),
|
||||
|
|
@ -248,7 +252,8 @@ defmodule Pleroma.Factory do
|
|||
"to" => ["https://www.w3.org/ns/activitystreams#Public"],
|
||||
"cc" => [user.follower_address],
|
||||
"context" => Pleroma.Web.ActivityPub.Utils.generate_context_id(),
|
||||
"closed" => DateTime.utc_now() |> DateTime.add(86_400) |> DateTime.to_iso8601(),
|
||||
"closed" => closed,
|
||||
"content" => "Which flavor of ice cream do you prefer?",
|
||||
"oneOf" => [
|
||||
%{
|
||||
"type" => "Note",
|
||||
|
|
@ -505,7 +510,8 @@ defmodule Pleroma.Factory do
|
|||
%Pleroma.Activity{
|
||||
data: data,
|
||||
actor: data["actor"],
|
||||
recipients: data["to"]
|
||||
recipients: data["to"],
|
||||
local: user.local
|
||||
}
|
||||
|> Map.merge(attrs)
|
||||
end
|
||||
|
|
@ -662,4 +668,11 @@ defmodule Pleroma.Factory do
|
|||
|> Map.merge(params)
|
||||
|> Pleroma.Announcement.add_rendered_properties()
|
||||
end
|
||||
|
||||
def hashtag_factory(params \\ %{}) do
|
||||
%Pleroma.Hashtag{
|
||||
name: "test #{sequence(:hashtag_name, & &1)}"
|
||||
}
|
||||
|> Map.merge(params)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1521,6 +1521,120 @@ defmodule HttpRequestMock do
|
|||
}}
|
||||
end
|
||||
|
||||
def get("https://mastodon.example/.well-known/host-meta", _, _, _) do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
status: 302,
|
||||
headers: [{"location", "https://sub.mastodon.example/.well-known/host-meta"}]
|
||||
}}
|
||||
end
|
||||
|
||||
def get("https://sub.mastodon.example/.well-known/host-meta", _, _, _) do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
body:
|
||||
"test/fixtures/webfinger/masto-host-meta.xml"
|
||||
|> File.read!()
|
||||
|> String.replace("{{domain}}", "sub.mastodon.example")
|
||||
}}
|
||||
end
|
||||
|
||||
def get(
|
||||
"https://sub.mastodon.example/.well-known/webfinger?resource=acct:a@mastodon.example",
|
||||
_,
|
||||
_,
|
||||
_
|
||||
) do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
body:
|
||||
"test/fixtures/webfinger/masto-webfinger.json"
|
||||
|> File.read!()
|
||||
|> String.replace("{{nickname}}", "a")
|
||||
|> String.replace("{{domain}}", "mastodon.example")
|
||||
|> String.replace("{{subdomain}}", "sub.mastodon.example"),
|
||||
headers: [{"content-type", "application/jrd+json"}]
|
||||
}}
|
||||
end
|
||||
|
||||
def get("https://sub.mastodon.example/users/a", _, _, _) do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
body:
|
||||
"test/fixtures/webfinger/masto-user.json"
|
||||
|> File.read!()
|
||||
|> String.replace("{{nickname}}", "a")
|
||||
|> String.replace("{{domain}}", "sub.mastodon.example"),
|
||||
headers: [{"content-type", "application/activity+json"}]
|
||||
}}
|
||||
end
|
||||
|
||||
def get("https://sub.mastodon.example/users/a/collections/featured", _, _, _) do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
body:
|
||||
File.read!("test/fixtures/users_mock/masto_featured.json")
|
||||
|> String.replace("{{domain}}", "sub.mastodon.example")
|
||||
|> String.replace("{{nickname}}", "a"),
|
||||
headers: [{"content-type", "application/activity+json"}]
|
||||
}}
|
||||
end
|
||||
|
||||
def get("https://pleroma.example/.well-known/host-meta", _, _, _) do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
status: 302,
|
||||
headers: [{"location", "https://sub.pleroma.example/.well-known/host-meta"}]
|
||||
}}
|
||||
end
|
||||
|
||||
def get("https://sub.pleroma.example/.well-known/host-meta", _, _, _) do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
body:
|
||||
"test/fixtures/webfinger/pleroma-host-meta.xml"
|
||||
|> File.read!()
|
||||
|> String.replace("{{domain}}", "sub.pleroma.example")
|
||||
}}
|
||||
end
|
||||
|
||||
def get(
|
||||
"https://sub.pleroma.example/.well-known/webfinger?resource=acct:a@pleroma.example",
|
||||
_,
|
||||
_,
|
||||
_
|
||||
) do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
body:
|
||||
"test/fixtures/webfinger/pleroma-webfinger.json"
|
||||
|> File.read!()
|
||||
|> String.replace("{{nickname}}", "a")
|
||||
|> String.replace("{{domain}}", "pleroma.example")
|
||||
|> String.replace("{{subdomain}}", "sub.pleroma.example"),
|
||||
headers: [{"content-type", "application/jrd+json"}]
|
||||
}}
|
||||
end
|
||||
|
||||
def get("https://sub.pleroma.example/users/a", _, _, _) do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
body:
|
||||
"test/fixtures/webfinger/pleroma-user.json"
|
||||
|> File.read!()
|
||||
|> String.replace("{{nickname}}", "a")
|
||||
|> String.replace("{{domain}}", "sub.pleroma.example"),
|
||||
headers: [{"content-type", "application/activity+json"}]
|
||||
}}
|
||||
end
|
||||
|
||||
def get(url, query, body, headers) do
|
||||
{:error,
|
||||
"Mock response not implemented for GET #{inspect(url)}, #{query}, #{inspect(body)}, #{inspect(headers)}"}
|
||||
|
|
@ -1610,7 +1724,7 @@ defmodule HttpRequestMock do
|
|||
]
|
||||
|
||||
def head(url, _query, _body, _headers) when url in @rich_media_mocks do
|
||||
{:ok, %Tesla.Env{status: 404, body: ""}}
|
||||
{:ok, %Tesla.Env{status: 200, body: ""}}
|
||||
end
|
||||
|
||||
def head("https://example.com/pdf-file", _, _, _) do
|
||||
|
|
|
|||
9
test/support/http_signatures_proxy.ex
Normal file
9
test/support/http_signatures_proxy.ex
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
defmodule Pleroma.Test.HTTPSignaturesProxy do
|
||||
@behaviour Pleroma.HTTPSignaturesAPI
|
||||
|
||||
@impl true
|
||||
defdelegate validate_conn(conn), to: HTTPSignatures
|
||||
|
||||
@impl true
|
||||
defdelegate signature_for_conn(conn), to: HTTPSignatures
|
||||
end
|
||||
|
|
@ -28,9 +28,8 @@ Mox.defmock(Pleroma.Web.FederatorMock, for: Pleroma.Web.Federator.Publishing)
|
|||
Mox.defmock(Pleroma.ConfigMock, for: Pleroma.Config.Getting)
|
||||
Mox.defmock(Pleroma.UnstubbedConfigMock, for: Pleroma.Config.Getting)
|
||||
Mox.defmock(Pleroma.StaticStubbedConfigMock, for: Pleroma.Config.Getting)
|
||||
Mox.defmock(Pleroma.StubbedHTTPSignaturesMock, for: Pleroma.HTTPSignaturesAPI)
|
||||
|
||||
Mox.defmock(Pleroma.LoggerMock, for: Pleroma.Logging)
|
||||
|
||||
Mox.defmock(Pleroma.User.Backup.ProcessorMock, for: Pleroma.User.Backup.ProcessorAPI)
|
||||
|
||||
Mox.defmock(Pleroma.Uploaders.S3.ExAwsMock, for: Pleroma.Uploaders.S3.ExAwsAPI)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue