Merge branch 'develop' of git.pleroma.social:pleroma/pleroma into remove-twitter-api
This commit is contained in:
commit
1963e143c5
82 changed files with 1163 additions and 238 deletions
|
|
@ -10,7 +10,6 @@ defmodule Pleroma.Config.HolderTest do
|
|||
test "default_config/0" do
|
||||
config = Holder.default_config()
|
||||
assert config[:pleroma][Pleroma.Uploaders.Local][:uploads] == "test/uploads"
|
||||
assert config[:tesla][:adapter] == Tesla.Mock
|
||||
|
||||
refute config[:pleroma][Pleroma.Repo]
|
||||
refute config[:pleroma][Pleroma.Web.Endpoint]
|
||||
|
|
@ -18,17 +17,15 @@ defmodule Pleroma.Config.HolderTest do
|
|||
refute config[:pleroma][:configurable_from_database]
|
||||
refute config[:pleroma][:database]
|
||||
refute config[:phoenix][:serve_endpoints]
|
||||
refute config[:tesla][:adapter]
|
||||
end
|
||||
|
||||
test "default_config/1" do
|
||||
pleroma_config = Holder.default_config(:pleroma)
|
||||
assert pleroma_config[Pleroma.Uploaders.Local][:uploads] == "test/uploads"
|
||||
tesla_config = Holder.default_config(:tesla)
|
||||
assert tesla_config[:adapter] == Tesla.Mock
|
||||
end
|
||||
|
||||
test "default_config/2" do
|
||||
assert Holder.default_config(:pleroma, Pleroma.Uploaders.Local) == [uploads: "test/uploads"]
|
||||
assert Holder.default_config(:tesla, :adapter) == Tesla.Mock
|
||||
end
|
||||
end
|
||||
|
|
|
|||
72
test/fixtures/fetch_mocks/104410921027210069.json
vendored
Normal file
72
test/fixtures/fetch_mocks/104410921027210069.json
vendored
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
{
|
||||
"@context" : [
|
||||
"https://www.w3.org/ns/activitystreams",
|
||||
{
|
||||
"atomUri" : "ostatus:atomUri",
|
||||
"conversation" : "ostatus:conversation",
|
||||
"inReplyToAtomUri" : "ostatus:inReplyToAtomUri",
|
||||
"ostatus" : "http://ostatus.org#",
|
||||
"sensitive" : "as:sensitive",
|
||||
"toot" : "http://joinmastodon.org/ns#",
|
||||
"votersCount" : "toot:votersCount"
|
||||
}
|
||||
],
|
||||
"atomUri" : "https://busshi.moe/users/tuxcrafting/statuses/104410921027210069",
|
||||
"attachment" : [],
|
||||
"attributedTo" : "https://busshi.moe/users/tuxcrafting",
|
||||
"cc" : [
|
||||
"https://busshi.moe/users/tuxcrafting/followers",
|
||||
"https://stereophonic.space/users/fixpoint",
|
||||
"https://blob.cat/users/blobyoumu",
|
||||
"https://cawfee.club/users/grips",
|
||||
"https://jaeger.website/users/igel"
|
||||
],
|
||||
"content" : "<p><span class=\"h-card\"><a href=\"https://stereophonic.space/users/fixpoint\" class=\"u-url mention\">@<span>fixpoint</span></a></span> <span class=\"h-card\"><a href=\"https://blob.cat/users/blobyoumu\" class=\"u-url mention\">@<span>blobyoumu</span></a></span> <span class=\"h-card\"><a href=\"https://cawfee.club/users/grips\" class=\"u-url mention\">@<span>grips</span></a></span> <span class=\"h-card\"><a href=\"https://jaeger.website/users/igel\" class=\"u-url mention\">@<span>igel</span></a></span> there's a difference between not liking nukes and not liking nuclear power<br />nukes are pretty bad as are all WMDs in general but disliking nuclear power just indicates you are unable of thought</p>",
|
||||
"contentMap" : {
|
||||
"en" : "<p><span class=\"h-card\"><a href=\"https://stereophonic.space/users/fixpoint\" class=\"u-url mention\">@<span>fixpoint</span></a></span> <span class=\"h-card\"><a href=\"https://blob.cat/users/blobyoumu\" class=\"u-url mention\">@<span>blobyoumu</span></a></span> <span class=\"h-card\"><a href=\"https://cawfee.club/users/grips\" class=\"u-url mention\">@<span>grips</span></a></span> <span class=\"h-card\"><a href=\"https://jaeger.website/users/igel\" class=\"u-url mention\">@<span>igel</span></a></span> there's a difference between not liking nukes and not liking nuclear power<br />nukes are pretty bad as are all WMDs in general but disliking nuclear power just indicates you are unable of thought</p>"
|
||||
},
|
||||
"conversation" : "https://cawfee.club/contexts/ad6c73d8-efc2-4e74-84ea-2dacf1a27a5e",
|
||||
"id" : "https://busshi.moe/users/tuxcrafting/statuses/104410921027210069",
|
||||
"inReplyTo" : "https://stereophonic.space/objects/02997b83-3ea7-4b63-94af-ef3aa2d4ed17",
|
||||
"inReplyToAtomUri" : "https://stereophonic.space/objects/02997b83-3ea7-4b63-94af-ef3aa2d4ed17",
|
||||
"published" : "2020-06-26T15:10:19Z",
|
||||
"replies" : {
|
||||
"first" : {
|
||||
"items" : [],
|
||||
"next" : "https://busshi.moe/users/tuxcrafting/statuses/104410921027210069/replies?only_other_accounts=true&page=true",
|
||||
"partOf" : "https://busshi.moe/users/tuxcrafting/statuses/104410921027210069/replies",
|
||||
"type" : "CollectionPage"
|
||||
},
|
||||
"id" : "https://busshi.moe/users/tuxcrafting/statuses/104410921027210069/replies",
|
||||
"type" : "Collection"
|
||||
},
|
||||
"sensitive" : false,
|
||||
"summary" : null,
|
||||
"tag" : [
|
||||
{
|
||||
"href" : "https://stereophonic.space/users/fixpoint",
|
||||
"name" : "@fixpoint@stereophonic.space",
|
||||
"type" : "Mention"
|
||||
},
|
||||
{
|
||||
"href" : "https://blob.cat/users/blobyoumu",
|
||||
"name" : "@blobyoumu@blob.cat",
|
||||
"type" : "Mention"
|
||||
},
|
||||
{
|
||||
"href" : "https://cawfee.club/users/grips",
|
||||
"name" : "@grips@cawfee.club",
|
||||
"type" : "Mention"
|
||||
},
|
||||
{
|
||||
"href" : "https://jaeger.website/users/igel",
|
||||
"name" : "@igel@jaeger.website",
|
||||
"type" : "Mention"
|
||||
}
|
||||
],
|
||||
"to" : [
|
||||
"https://www.w3.org/ns/activitystreams#Public"
|
||||
],
|
||||
"type" : "Note",
|
||||
"url" : "https://busshi.moe/@tuxcrafting/104410921027210069"
|
||||
}
|
||||
59
test/fixtures/fetch_mocks/9wTkLEnuq47B25EehM.json
vendored
Normal file
59
test/fixtures/fetch_mocks/9wTkLEnuq47B25EehM.json
vendored
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
{
|
||||
"@context" : [
|
||||
"https://www.w3.org/ns/activitystreams",
|
||||
"https://social.sakamoto.gq/schemas/litepub-0.1.jsonld",
|
||||
{
|
||||
"@language" : "und"
|
||||
}
|
||||
],
|
||||
"actor" : "https://social.sakamoto.gq/users/eal",
|
||||
"attachment" : [],
|
||||
"attributedTo" : "https://social.sakamoto.gq/users/eal",
|
||||
"cc" : [
|
||||
"https://social.sakamoto.gq/users/eal/followers"
|
||||
],
|
||||
"content" : "<span class=\"h-card\"><a data-user=\"9uw2wH0iTYAMV7XnLU\" class=\"u-url mention\" href=\"https://busshi.moe/@tuxcrafting\" rel=\"ugc\">@<span>tuxcrafting</span></a></span> <span class=\"h-card\"><a data-user=\"9r5l8j8x23NI9KUFu4\" class=\"u-url mention\" href=\"https://stereophonic.space/users/fixpoint\" rel=\"ugc\">@<span>fixpoint</span></a></span> <span class=\"h-card\"><a data-user=\"9orDK545JwjY4Lxjge\" class=\"u-url mention\" href=\"https://blob.cat/users/blobyoumu\" rel=\"ugc\">@<span>blobyoumu</span></a></span> <span class=\"h-card\"><a data-user=\"68184\" class=\"u-url mention\" href=\"https://cawfee.club/users/grips\" rel=\"ugc\">@<span>grips</span></a></span> <span class=\"h-card\"><a data-user=\"9sAmMgHVKjTXKpgx84\" class=\"u-url mention\" href=\"https://jaeger.website/users/igel\" rel=\"ugc\">@<span>igel</span></a></span> What's bad about nukes?",
|
||||
"context" : "https://cawfee.club/contexts/ad6c73d8-efc2-4e74-84ea-2dacf1a27a5e",
|
||||
"conversation" : "https://cawfee.club/contexts/ad6c73d8-efc2-4e74-84ea-2dacf1a27a5e",
|
||||
"id" : "https://social.sakamoto.gq/objects/f20f2497-66d9-4a52-a2e1-1be2a39c32c1",
|
||||
"inReplyTo" : "https://busshi.moe/users/tuxcrafting/statuses/104410921027210069",
|
||||
"published" : "2020-06-26T15:20:15.975737Z",
|
||||
"sensitive" : false,
|
||||
"summary" : "",
|
||||
"tag" : [
|
||||
{
|
||||
"href" : "https://blob.cat/users/blobyoumu",
|
||||
"name" : "@blobyoumu@blob.cat",
|
||||
"type" : "Mention"
|
||||
},
|
||||
{
|
||||
"href" : "https://busshi.moe/users/tuxcrafting",
|
||||
"name" : "@tuxcrafting@busshi.moe",
|
||||
"type" : "Mention"
|
||||
},
|
||||
{
|
||||
"href" : "https://cawfee.club/users/grips",
|
||||
"name" : "@grips@cawfee.club",
|
||||
"type" : "Mention"
|
||||
},
|
||||
{
|
||||
"href" : "https://jaeger.website/users/igel",
|
||||
"name" : "@igel@jaeger.website",
|
||||
"type" : "Mention"
|
||||
},
|
||||
{
|
||||
"href" : "https://stereophonic.space/users/fixpoint",
|
||||
"name" : "@fixpoint@stereophonic.space",
|
||||
"type" : "Mention"
|
||||
}
|
||||
],
|
||||
"to" : [
|
||||
"https://busshi.moe/users/tuxcrafting",
|
||||
"https://www.w3.org/ns/activitystreams#Public",
|
||||
"https://blob.cat/users/blobyoumu",
|
||||
"https://stereophonic.space/users/fixpoint",
|
||||
"https://cawfee.club/users/grips",
|
||||
"https://jaeger.website/users/igel"
|
||||
],
|
||||
"type" : "Note"
|
||||
}
|
||||
43
test/fixtures/fetch_mocks/eal.json
vendored
Normal file
43
test/fixtures/fetch_mocks/eal.json
vendored
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
{
|
||||
"@context" : [
|
||||
"https://www.w3.org/ns/activitystreams",
|
||||
"https://social.sakamoto.gq/schemas/litepub-0.1.jsonld",
|
||||
{
|
||||
"@language" : "und"
|
||||
}
|
||||
],
|
||||
"attachment" : [],
|
||||
"discoverable" : true,
|
||||
"endpoints" : {
|
||||
"oauthAuthorizationEndpoint" : "https://social.sakamoto.gq/oauth/authorize",
|
||||
"oauthRegistrationEndpoint" : "https://social.sakamoto.gq/api/v1/apps",
|
||||
"oauthTokenEndpoint" : "https://social.sakamoto.gq/oauth/token",
|
||||
"sharedInbox" : "https://social.sakamoto.gq/inbox",
|
||||
"uploadMedia" : "https://social.sakamoto.gq/api/ap/upload_media"
|
||||
},
|
||||
"followers" : "https://social.sakamoto.gq/users/eal/followers",
|
||||
"following" : "https://social.sakamoto.gq/users/eal/following",
|
||||
"icon" : {
|
||||
"type" : "Image",
|
||||
"url" : "https://social.sakamoto.gq/media/f1cb6f79bf6839f3223ca240441f766056b74ddd23c69bcaf8bb1ba1ecff6eec.jpg"
|
||||
},
|
||||
"id" : "https://social.sakamoto.gq/users/eal",
|
||||
"image" : {
|
||||
"type" : "Image",
|
||||
"url" : "https://social.sakamoto.gq/media/e5cccf26421e8366f4e34be3c9d5042b8bc8dcceccc7c8e89785fa312dd9632c.jpg"
|
||||
},
|
||||
"inbox" : "https://social.sakamoto.gq/users/eal/inbox",
|
||||
"manuallyApprovesFollowers" : false,
|
||||
"name" : "ìì",
|
||||
"outbox" : "https://social.sakamoto.gq/users/eal/outbox",
|
||||
"preferredUsername" : "eal",
|
||||
"publicKey" : {
|
||||
"id" : "https://social.sakamoto.gq/users/eal#main-key",
|
||||
"owner" : "https://social.sakamoto.gq/users/eal",
|
||||
"publicKeyPem" : "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAz3pF85YOhhv2Zaxv9YQ7\nrCe1aEhetCMVHtrK63tUVGoGdsblyKnVeJNbFcr6k3y35OpHS3HXIi6GzgihYcTu\nONLP4eQMHTnLUNAQZi03mjJA4iIq8v/tm8ZkL2mXsQSAbWj6Iq518mHNN7OvCoNt\n3Xjepl/0kgkc2gsund7m8r+Wu0Fusx6UlUyyAk3PexdDRdSSlVLeskqtP8jtdQDo\nL70pMyL+VD+Qb9RKFdtgJ+M4OqYP+7FVzCqXN0QIPhFf/kvHSLr+c4Y3Wm0nAKHU\n9CwXWXz5Xqscpv41KlgnUCOkTXb5eBSt23lNulae5srVzWBiFb6guiCpNzBGa+Sq\nrwIDAQAB\n-----END PUBLIC KEY-----\n\n"
|
||||
},
|
||||
"summary" : "Pizza napoletana supremacist.<br><br>Any artworks posted here that are good are not mine.",
|
||||
"tag" : [],
|
||||
"type" : "Person",
|
||||
"url" : "https://social.sakamoto.gq/users/eal"
|
||||
}
|
||||
59
test/fixtures/fetch_mocks/tuxcrafting.json
vendored
Normal file
59
test/fixtures/fetch_mocks/tuxcrafting.json
vendored
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
{
|
||||
"@context" : [
|
||||
"https://www.w3.org/ns/activitystreams",
|
||||
"https://w3id.org/security/v1",
|
||||
{
|
||||
"IdentityProof" : "toot:IdentityProof",
|
||||
"PropertyValue" : "schema:PropertyValue",
|
||||
"alsoKnownAs" : {
|
||||
"@id" : "as:alsoKnownAs",
|
||||
"@type" : "@id"
|
||||
},
|
||||
"discoverable" : "toot:discoverable",
|
||||
"featured" : {
|
||||
"@id" : "toot:featured",
|
||||
"@type" : "@id"
|
||||
},
|
||||
"focalPoint" : {
|
||||
"@container" : "@list",
|
||||
"@id" : "toot:focalPoint"
|
||||
},
|
||||
"manuallyApprovesFollowers" : "as:manuallyApprovesFollowers",
|
||||
"movedTo" : {
|
||||
"@id" : "as:movedTo",
|
||||
"@type" : "@id"
|
||||
},
|
||||
"schema" : "http://schema.org#",
|
||||
"toot" : "http://joinmastodon.org/ns#",
|
||||
"value" : "schema:value"
|
||||
}
|
||||
],
|
||||
"attachment" : [],
|
||||
"discoverable" : true,
|
||||
"endpoints" : {
|
||||
"sharedInbox" : "https://busshi.moe/inbox"
|
||||
},
|
||||
"featured" : "https://busshi.moe/users/tuxcrafting/collections/featured",
|
||||
"followers" : "https://busshi.moe/users/tuxcrafting/followers",
|
||||
"following" : "https://busshi.moe/users/tuxcrafting/following",
|
||||
"icon" : {
|
||||
"mediaType" : "image/jpeg",
|
||||
"type" : "Image",
|
||||
"url" : "https://blobcdn.busshi.moe/busshifiles/accounts/avatars/000/046/872/original/054f0806ccb303d0.jpg"
|
||||
},
|
||||
"id" : "https://busshi.moe/users/tuxcrafting",
|
||||
"inbox" : "https://busshi.moe/users/tuxcrafting/inbox",
|
||||
"manuallyApprovesFollowers" : true,
|
||||
"name" : "@tuxcrafting@localhost:8080",
|
||||
"outbox" : "https://busshi.moe/users/tuxcrafting/outbox",
|
||||
"preferredUsername" : "tuxcrafting",
|
||||
"publicKey" : {
|
||||
"id" : "https://busshi.moe/users/tuxcrafting#main-key",
|
||||
"owner" : "https://busshi.moe/users/tuxcrafting",
|
||||
"publicKeyPem" : "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwqWWTBf9OizsBiBhGS/M\nQTT6fB1VvQP6vvxouGZ5cGg1a97V67ouhjJ+nGMuWr++DNYjJYkk2TOynfykk0H/\n8rRSujSe3BNRKYGNzdnRJu/4XxgIE847Fqx5SijSP23JGYcn8TjeSUsN2u2YYVXK\n+Eb3Bu7DjGiqwNon6YB0h5qkGjkMSMVIFn0hZx6Z21bkfYWgra96Ok5OWf7Ck3je\nCuErlCMZcbQcHtFpBueJAxYchjNvm6fqwZxLX/NtaHdr7Fm2kin89mqzliapBlFH\nCXk7Jln6xV5I6ryggPAMzm3fuHzeo0RWlu8lrxLfARBVwaQQZS99bwqp6N9O2aUp\nYwIDAQAB\n-----END PUBLIC KEY-----\n"
|
||||
},
|
||||
"summary" : "<p>expert procrastinator</p><p>trans(humanist|gender|istorized)</p><p>web: <a href=\"https://tuxcrafting.port0.org\" rel=\"nofollow noopener noreferrer\" target=\"_blank\"><span class=\"invisible\">https://</span><span class=\"\">tuxcrafting.port0.org</span><span class=\"invisible\"></span></a><br />pronouns: she/they<br />languages: french (native)/english (fluent)/hebrew (ok-ish)/esperanto (barely)</p>",
|
||||
"tag" : [],
|
||||
"type" : "Person",
|
||||
"url" : "https://busshi.moe/@tuxcrafting"
|
||||
}
|
||||
1
test/fixtures/preload_static/instance/panel.html
vendored
Normal file
1
test/fixtures/preload_static/instance/panel.html
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
HEY!
|
||||
File diff suppressed because one or more lines are too long
188
test/fixtures/tesla_mock/peertube.moe-vid.json
vendored
188
test/fixtures/tesla_mock/peertube.moe-vid.json
vendored
File diff suppressed because one or more lines are too long
|
|
@ -237,5 +237,19 @@ defmodule Pleroma.HTMLTest do
|
|||
|
||||
assert {:ok, nil} = HTML.extract_first_external_url(object, object.data["content"])
|
||||
end
|
||||
|
||||
test "skips attachment links" do
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{
|
||||
status:
|
||||
"<a href=\"https://pleroma.gov/media/d24caa3a498e21e0298377a9ca0149a4f4f8b767178aacf837542282e2d94fb1.png?name=image.png\" class=\"attachment\">image.png</a>"
|
||||
})
|
||||
|
||||
object = Object.normalize(activity)
|
||||
|
||||
assert {:ok, nil} = HTML.extract_first_external_url(object, object.data["content"])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -22,6 +22,16 @@ defmodule Pleroma.NotificationTest do
|
|||
alias Pleroma.Web.Streamer
|
||||
|
||||
describe "create_notifications" do
|
||||
test "never returns nil" do
|
||||
user = insert(:user)
|
||||
other_user = insert(:user, %{invisible: true})
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "yeah"})
|
||||
{:ok, activity} = CommonAPI.react_with_emoji(activity.id, other_user, "☕")
|
||||
|
||||
refute {:ok, [nil]} == Notification.create_notifications(activity)
|
||||
end
|
||||
|
||||
test "creates a notification for an emoji reaction" do
|
||||
user = insert(:user)
|
||||
other_user = insert(:user)
|
||||
|
|
|
|||
|
|
@ -26,6 +26,46 @@ defmodule Pleroma.Object.FetcherTest do
|
|||
:ok
|
||||
end
|
||||
|
||||
describe "error cases" do
|
||||
setup do
|
||||
mock(fn
|
||||
%{method: :get, url: "https://social.sakamoto.gq/notice/9wTkLEnuq47B25EehM"} ->
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
body: File.read!("test/fixtures/fetch_mocks/9wTkLEnuq47B25EehM.json")
|
||||
}
|
||||
|
||||
%{method: :get, url: "https://social.sakamoto.gq/users/eal"} ->
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
body: File.read!("test/fixtures/fetch_mocks/eal.json")
|
||||
}
|
||||
|
||||
%{method: :get, url: "https://busshi.moe/users/tuxcrafting/statuses/104410921027210069"} ->
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
body: File.read!("test/fixtures/fetch_mocks/104410921027210069.json")
|
||||
}
|
||||
|
||||
%{method: :get, url: "https://busshi.moe/users/tuxcrafting"} ->
|
||||
%Tesla.Env{
|
||||
status: 500
|
||||
}
|
||||
end)
|
||||
|
||||
:ok
|
||||
end
|
||||
|
||||
@tag capture_log: true
|
||||
test "it works when fetching the OP actor errors out" do
|
||||
# Here we simulate a case where the author of the OP can't be read
|
||||
assert {:ok, _} =
|
||||
Fetcher.fetch_object_from_id(
|
||||
"https://social.sakamoto.gq/notice/9wTkLEnuq47B25EehM"
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
describe "max thread distance restriction" do
|
||||
@ap_id "http://mastodon.example.org/@admin/99541947525187367"
|
||||
setup do: clear_config([:instance, :federation_incoming_replies_max_depth])
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ defmodule Pleroma.Factory do
|
|||
data = %{
|
||||
"type" => "Note",
|
||||
"content" => text,
|
||||
"source" => text,
|
||||
"id" => Pleroma.Web.ActivityPub.Utils.generate_object_id(),
|
||||
"actor" => user.ap_id,
|
||||
"to" => ["https://www.w3.org/ns/activitystreams#Public"],
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ defmodule Pleroma.UserSearchTest do
|
|||
describe "User.search" do
|
||||
setup do: clear_config([:instance, :limit_to_local_content])
|
||||
|
||||
test "excluded invisible users from results" do
|
||||
test "excludes invisible users from results" do
|
||||
user = insert(:user, %{nickname: "john t1000"})
|
||||
insert(:user, %{invisible: true, nickname: "john t800"})
|
||||
|
||||
|
|
@ -25,6 +25,15 @@ defmodule Pleroma.UserSearchTest do
|
|||
assert found_user.id == user.id
|
||||
end
|
||||
|
||||
test "excludes service actors from results" do
|
||||
insert(:user, actor_type: "Application", nickname: "user1")
|
||||
service = insert(:user, actor_type: "Service", nickname: "user2")
|
||||
person = insert(:user, actor_type: "Person", nickname: "user3")
|
||||
|
||||
assert [found_user1, found_user2] = User.search("user")
|
||||
assert [found_user1.id, found_user2.id] -- [service.id, person.id] == []
|
||||
end
|
||||
|
||||
test "accepts limit parameter" do
|
||||
Enum.each(0..4, &insert(:user, %{nickname: "john#{&1}"}))
|
||||
assert length(User.search("john", limit: 3)) == 3
|
||||
|
|
|
|||
|
|
@ -597,6 +597,31 @@ defmodule Pleroma.UserTest do
|
|||
refute user.last_refreshed_at == orig_user.last_refreshed_at
|
||||
end
|
||||
|
||||
test "if nicknames clash, the old user gets a prefix with the old id to the nickname" do
|
||||
a_week_ago = NaiveDateTime.add(NaiveDateTime.utc_now(), -604_800)
|
||||
|
||||
orig_user =
|
||||
insert(
|
||||
:user,
|
||||
local: false,
|
||||
nickname: "admin@mastodon.example.org",
|
||||
ap_id: "http://mastodon.example.org/users/harinezumigari",
|
||||
last_refreshed_at: a_week_ago
|
||||
)
|
||||
|
||||
assert orig_user.last_refreshed_at == a_week_ago
|
||||
|
||||
{:ok, user} = User.get_or_fetch_by_ap_id("http://mastodon.example.org/users/admin")
|
||||
|
||||
assert user.inbox
|
||||
|
||||
refute user.id == orig_user.id
|
||||
|
||||
orig_user = User.get_by_id(orig_user.id)
|
||||
|
||||
assert orig_user.nickname == "#{orig_user.id}.admin@mastodon.example.org"
|
||||
end
|
||||
|
||||
@tag capture_log: true
|
||||
test "it returns the old user if stale, but unfetchable" do
|
||||
a_week_ago = NaiveDateTime.add(NaiveDateTime.utc_now(), -604_800)
|
||||
|
|
|
|||
|
|
@ -589,10 +589,29 @@ defmodule Pleroma.Web.ActivityPub.SideEffectsTest do
|
|||
end
|
||||
|
||||
test "it streams out the announce", %{announce: announce} do
|
||||
with_mock Pleroma.Web.ActivityPub.ActivityPub, [:passthrough], stream_out: fn _ -> nil end do
|
||||
with_mocks([
|
||||
{
|
||||
Pleroma.Web.Streamer,
|
||||
[],
|
||||
[
|
||||
stream: fn _, _ -> nil end
|
||||
]
|
||||
},
|
||||
{
|
||||
Pleroma.Web.Push,
|
||||
[],
|
||||
[
|
||||
send: fn _ -> nil end
|
||||
]
|
||||
}
|
||||
]) do
|
||||
{:ok, announce, _} = SideEffects.handle(announce)
|
||||
|
||||
assert called(Pleroma.Web.ActivityPub.ActivityPub.stream_out(announce))
|
||||
assert called(
|
||||
Pleroma.Web.Streamer.stream(["user", "list", "public", "public:local"], announce)
|
||||
)
|
||||
|
||||
assert called(Pleroma.Web.Push.send(:_))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -491,6 +491,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
object = Object.normalize(activity)
|
||||
|
||||
assert object.data["content"] == "<p><b>2hu</b></p>alert('xss')"
|
||||
assert object.data["source"] == post
|
||||
end
|
||||
|
||||
test "it filters out obviously bad tags when accepting a post as Markdown" do
|
||||
|
|
@ -507,6 +508,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
object = Object.normalize(activity)
|
||||
|
||||
assert object.data["content"] == "<p><b>2hu</b></p>alert('xss')"
|
||||
assert object.data["source"] == post
|
||||
end
|
||||
|
||||
test "it does not allow replies to direct messages that are not direct messages themselves" do
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ defmodule Pleroma.Web.MastodonAPI.MastoFEController do
|
|||
assert _result = json_response(conn, 200)
|
||||
|
||||
user = User.get_cached_by_ap_id(user.ap_id)
|
||||
assert user.settings == %{"programming" => "socks"}
|
||||
assert user.mastofe_settings == %{"programming" => "socks"}
|
||||
end
|
||||
|
||||
describe "index/2 redirections" do
|
||||
|
|
|
|||
|
|
@ -216,20 +216,10 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController.UpdateCredentialsTest do
|
|||
filename: "an_image.jpg"
|
||||
}
|
||||
|
||||
res =
|
||||
conn
|
||||
|> patch("/api/v1/accounts/update_credentials", %{"avatar" => new_avatar})
|
||||
conn = patch(conn, "/api/v1/accounts/update_credentials", %{"avatar" => new_avatar})
|
||||
|
||||
assert user_response = json_response_and_validate_schema(res, 200)
|
||||
assert user_response = json_response_and_validate_schema(conn, 200)
|
||||
assert user_response["avatar"] != User.avatar_url(user)
|
||||
|
||||
# Also removes it
|
||||
res =
|
||||
conn
|
||||
|> patch("/api/v1/accounts/update_credentials", %{"avatar" => nil})
|
||||
|
||||
assert user_response = json_response_and_validate_schema(res, 200)
|
||||
assert user_response["avatar"] == User.avatar_url(user)
|
||||
end
|
||||
|
||||
test "updates the user's banner", %{user: user, conn: conn} do
|
||||
|
|
@ -239,21 +229,10 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController.UpdateCredentialsTest do
|
|||
filename: "an_image.jpg"
|
||||
}
|
||||
|
||||
res =
|
||||
conn
|
||||
|> patch("/api/v1/accounts/update_credentials", %{"header" => new_header})
|
||||
conn = patch(conn, "/api/v1/accounts/update_credentials", %{"header" => new_header})
|
||||
|
||||
assert user_response = json_response_and_validate_schema(res, 200)
|
||||
assert user_response = json_response_and_validate_schema(conn, 200)
|
||||
assert user_response["header"] != User.banner_url(user)
|
||||
|
||||
# Also removes it
|
||||
|
||||
res =
|
||||
conn
|
||||
|> patch("/api/v1/accounts/update_credentials", %{"header" => nil})
|
||||
|
||||
assert user_response = json_response_and_validate_schema(res, 200)
|
||||
assert user_response["header"] == User.banner_url(user)
|
||||
end
|
||||
|
||||
test "updates the user's background", %{conn: conn} do
|
||||
|
|
@ -263,25 +242,13 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController.UpdateCredentialsTest do
|
|||
filename: "an_image.jpg"
|
||||
}
|
||||
|
||||
res =
|
||||
conn
|
||||
|> patch("/api/v1/accounts/update_credentials", %{
|
||||
conn =
|
||||
patch(conn, "/api/v1/accounts/update_credentials", %{
|
||||
"pleroma_background_image" => new_header
|
||||
})
|
||||
|
||||
assert user_response = json_response_and_validate_schema(res, 200)
|
||||
assert user_response = json_response_and_validate_schema(conn, 200)
|
||||
assert user_response["pleroma"]["background_image"]
|
||||
|
||||
# Also removes it
|
||||
|
||||
res =
|
||||
conn
|
||||
|> patch("/api/v1/accounts/update_credentials", %{
|
||||
"pleroma_background_image" => nil
|
||||
})
|
||||
|
||||
assert user_response = json_response_and_validate_schema(res, 200)
|
||||
refute user_response["pleroma"]["background_image"]
|
||||
end
|
||||
|
||||
test "requires 'write:accounts' permission" do
|
||||
|
|
|
|||
|
|
@ -780,7 +780,6 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
|
||||
assert %{"id" => _id, "muting" => true, "muting_notifications" => true} =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("/api/v1/accounts/#{other_user.id}/mute")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
|
|
|
|||
|
|
@ -35,8 +35,10 @@ defmodule Pleroma.Web.MastodonAPI.InstanceControllerTest do
|
|||
"background_image" => _
|
||||
} = result
|
||||
|
||||
assert result["pleroma"]["metadata"]["account_activation_required"] != nil
|
||||
assert result["pleroma"]["metadata"]["features"]
|
||||
assert result["pleroma"]["metadata"]["federation"]
|
||||
assert result["pleroma"]["metadata"]["fields_limits"]
|
||||
assert result["pleroma"]["vapid_public_key"]
|
||||
|
||||
assert email == from_config_email
|
||||
|
|
|
|||
|
|
@ -79,6 +79,7 @@ defmodule Pleroma.Web.MastodonAPI.SearchControllerTest do
|
|||
assert status["id"] == to_string(activity.id)
|
||||
end
|
||||
|
||||
@tag capture_log: true
|
||||
test "constructs hashtags from search query", %{conn: conn} do
|
||||
results =
|
||||
conn
|
||||
|
|
@ -318,11 +319,13 @@ defmodule Pleroma.Web.MastodonAPI.SearchControllerTest do
|
|||
test "search fetches remote accounts", %{conn: conn} do
|
||||
user = insert(:user)
|
||||
|
||||
query = URI.encode_query(%{q: " mike@osada.macgirvin.com ", resolve: true})
|
||||
|
||||
results =
|
||||
conn
|
||||
|> assign(:user, user)
|
||||
|> assign(:token, insert(:oauth_token, user: user, scopes: ["read"]))
|
||||
|> get("/api/v1/search?q=mike@osada.macgirvin.com&resolve=true")
|
||||
|> get("/api/v1/search?#{query}")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
[account] = results["accounts"]
|
||||
|
|
|
|||
|
|
@ -760,13 +760,18 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||
test "when you created it" do
|
||||
%{user: author, conn: conn} = oauth_access(["write:statuses"])
|
||||
activity = insert(:note_activity, user: author)
|
||||
object = Object.normalize(activity)
|
||||
|
||||
conn =
|
||||
content = object.data["content"]
|
||||
source = object.data["source"]
|
||||
|
||||
result =
|
||||
conn
|
||||
|> assign(:user, author)
|
||||
|> delete("/api/v1/statuses/#{activity.id}")
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
assert %{} = json_response_and_validate_schema(conn, 200)
|
||||
assert match?(%{"content" => ^content, "text" => ^source}, result)
|
||||
|
||||
refute Activity.get_by_id(activity.id)
|
||||
end
|
||||
|
|
@ -789,7 +794,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||
|
||||
conn = delete(conn, "/api/v1/statuses/#{activity.id}")
|
||||
|
||||
assert %{"error" => _} = json_response_and_validate_schema(conn, 403)
|
||||
assert %{"error" => "Record not found"} == json_response_and_validate_schema(conn, 404)
|
||||
|
||||
assert Activity.get_by_id(activity.id) == activity
|
||||
end
|
||||
|
|
|
|||
|
|
@ -183,6 +183,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
|
|||
card: nil,
|
||||
reblog: nil,
|
||||
content: HTML.filter_tags(object_data["content"]),
|
||||
text: nil,
|
||||
created_at: created_at,
|
||||
reblogs_count: 0,
|
||||
replies_count: 0,
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ defmodule Pleroma.Web.Preload.Providers.InstanceTest do
|
|||
|
||||
setup do: {:ok, Instance.generate_terms(nil)}
|
||||
|
||||
test "it renders the info", %{"/api/v1/instance": info} do
|
||||
test "it renders the info", %{"/api/v1/instance" => info} do
|
||||
assert %{
|
||||
description: description,
|
||||
email: "admin@example.com",
|
||||
|
|
@ -18,14 +18,25 @@ defmodule Pleroma.Web.Preload.Providers.InstanceTest do
|
|||
assert String.equivalent?(description, "Pleroma: An efficient and flexible fediverse server")
|
||||
end
|
||||
|
||||
test "it renders the panel", %{"/instance/panel.html": panel} do
|
||||
test "it renders the panel", %{"/instance/panel.html" => panel} do
|
||||
assert String.contains?(
|
||||
panel,
|
||||
"<p>Welcome to <a href=\"https://pleroma.social\" target=\"_blank\">Pleroma!</a></p>"
|
||||
)
|
||||
end
|
||||
|
||||
test "it renders the node_info", %{"/nodeinfo/2.0": nodeinfo} do
|
||||
test "it works with overrides" do
|
||||
clear_config([:instance, :static_dir], "test/fixtures/preload_static")
|
||||
|
||||
%{"/instance/panel.html" => panel} = Instance.generate_terms(nil)
|
||||
|
||||
assert String.contains?(
|
||||
panel,
|
||||
"HEY!"
|
||||
)
|
||||
end
|
||||
|
||||
test "it renders the node_info", %{"/nodeinfo/2.0.json" => nodeinfo} do
|
||||
%{
|
||||
metadata: metadata,
|
||||
version: "2.0"
|
||||
|
|
|
|||
|
|
@ -8,7 +8,8 @@ defmodule Pleroma.Web.Preload.Providers.StatusNetTest do
|
|||
|
||||
setup do: {:ok, StatusNet.generate_terms(nil)}
|
||||
|
||||
test "it renders the info", %{"/api/statusnet/config.json": info} do
|
||||
assert info =~ "<name>Pleroma</name>"
|
||||
test "it renders the info", %{"/api/statusnet/config.json" => info} do
|
||||
assert {:ok, res} = Jason.decode(info)
|
||||
assert res["site"]
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ defmodule Pleroma.Web.Preload.Providers.TimelineTest do
|
|||
alias Pleroma.Web.CommonAPI
|
||||
alias Pleroma.Web.Preload.Providers.Timelines
|
||||
|
||||
@public_url :"/api/v1/timelines/public"
|
||||
@public_url "/api/v1/timelines/public"
|
||||
|
||||
describe "unauthenticated timeliness when restricted" do
|
||||
setup do
|
||||
|
|
|
|||
|
|
@ -9,13 +9,11 @@ defmodule Pleroma.Web.Preload.Providers.UserTest do
|
|||
|
||||
describe "returns empty when user doesn't exist" do
|
||||
test "nil user specified" do
|
||||
refute User.generate_terms(%{user: nil})
|
||||
|> Map.has_key?("/api/v1/accounts")
|
||||
assert User.generate_terms(%{user: nil}) == %{}
|
||||
end
|
||||
|
||||
test "missing user specified" do
|
||||
refute User.generate_terms(%{user: :not_a_user})
|
||||
|> Map.has_key?("/api/v1/accounts")
|
||||
assert User.generate_terms(%{user: :not_a_user}) == %{}
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -23,11 +21,13 @@ defmodule Pleroma.Web.Preload.Providers.UserTest do
|
|||
setup do
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, User.generate_terms(%{user: user})}
|
||||
terms = User.generate_terms(%{user: user})
|
||||
%{terms: terms, user: user}
|
||||
end
|
||||
|
||||
test "account is rendered", %{"/api/v1/accounts": accounts} do
|
||||
assert %{acct: user, username: user} = accounts
|
||||
test "account is rendered", %{terms: terms, user: user} do
|
||||
account = terms["/api/v1/accounts/#{user.id}"]
|
||||
assert %{acct: user, username: user} = account
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -116,6 +116,35 @@ defmodule Pleroma.Web.StreamerTest do
|
|||
refute Streamer.filtered_by_user?(user, announce)
|
||||
end
|
||||
|
||||
test "it does not stream announces of the user's own posts in the 'user' stream", %{
|
||||
user: user
|
||||
} do
|
||||
Streamer.get_topic_and_add_socket("user", user)
|
||||
|
||||
other_user = insert(:user)
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "hey"})
|
||||
{:ok, announce} = CommonAPI.repeat(activity.id, other_user)
|
||||
|
||||
assert Streamer.filtered_by_user?(user, announce)
|
||||
end
|
||||
|
||||
test "it does stream notifications announces of the user's own posts in the 'user' stream", %{
|
||||
user: user
|
||||
} do
|
||||
Streamer.get_topic_and_add_socket("user", user)
|
||||
|
||||
other_user = insert(:user)
|
||||
{:ok, activity} = CommonAPI.post(user, %{status: "hey"})
|
||||
{:ok, announce} = CommonAPI.repeat(activity.id, other_user)
|
||||
|
||||
notification =
|
||||
Pleroma.Notification
|
||||
|> Repo.get_by(%{user_id: user.id, activity_id: announce.id})
|
||||
|> Repo.preload(:activity)
|
||||
|
||||
refute Streamer.filtered_by_user?(user, notification)
|
||||
end
|
||||
|
||||
test "it streams boosts of mastodon user in the 'user' stream", %{user: user} do
|
||||
Streamer.get_topic_and_add_socket("user", user)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue