Merge remote-tracking branch 'remotes/origin/develop' into 1559-follow-request-notifications
# Conflicts: # CHANGELOG.md
This commit is contained in:
commit
6e6f95c6ae
128 changed files with 2622 additions and 880 deletions
|
|
@ -16,6 +16,7 @@ defmodule Pleroma.Config.TransferTaskTest do
|
|||
refute Application.get_env(:pleroma, :test_key)
|
||||
refute Application.get_env(:idna, :test_key)
|
||||
refute Application.get_env(:quack, :test_key)
|
||||
initial = Application.get_env(:logger, :level)
|
||||
|
||||
ConfigDB.create(%{
|
||||
group: ":pleroma",
|
||||
|
|
@ -35,16 +36,20 @@ defmodule Pleroma.Config.TransferTaskTest do
|
|||
value: [:test_value1, :test_value2]
|
||||
})
|
||||
|
||||
ConfigDB.create(%{group: ":logger", key: ":level", value: :debug})
|
||||
|
||||
TransferTask.start_link([])
|
||||
|
||||
assert Application.get_env(:pleroma, :test_key) == [live: 2, com: 3]
|
||||
assert Application.get_env(:idna, :test_key) == [live: 15, com: 35]
|
||||
assert Application.get_env(:quack, :test_key) == [:test_value1, :test_value2]
|
||||
assert Application.get_env(:logger, :level) == :debug
|
||||
|
||||
on_exit(fn ->
|
||||
Application.delete_env(:pleroma, :test_key)
|
||||
Application.delete_env(:idna, :test_key)
|
||||
Application.delete_env(:quack, :test_key)
|
||||
Application.put_env(:logger, :level, initial)
|
||||
end)
|
||||
end
|
||||
|
||||
|
|
@ -78,8 +83,8 @@ defmodule Pleroma.Config.TransferTaskTest do
|
|||
end
|
||||
|
||||
test "transfer config values with full subkey update" do
|
||||
emoji = Application.get_env(:pleroma, :emoji)
|
||||
assets = Application.get_env(:pleroma, :assets)
|
||||
clear_config(:emoji)
|
||||
clear_config(:assets)
|
||||
|
||||
ConfigDB.create(%{
|
||||
group: ":pleroma",
|
||||
|
|
@ -99,11 +104,6 @@ defmodule Pleroma.Config.TransferTaskTest do
|
|||
assert emoji_env[:groups] == [a: 1, b: 2]
|
||||
assets_env = Application.get_env(:pleroma, :assets)
|
||||
assert assets_env[:mascots] == [a: 1, b: 2]
|
||||
|
||||
on_exit(fn ->
|
||||
Application.put_env(:pleroma, :emoji, emoji)
|
||||
Application.put_env(:pleroma, :assets, assets)
|
||||
end)
|
||||
end
|
||||
|
||||
describe "pleroma restart" do
|
||||
|
|
@ -112,8 +112,7 @@ defmodule Pleroma.Config.TransferTaskTest do
|
|||
end
|
||||
|
||||
test "don't restart if no reboot time settings were changed" do
|
||||
emoji = Application.get_env(:pleroma, :emoji)
|
||||
on_exit(fn -> Application.put_env(:pleroma, :emoji, emoji) end)
|
||||
clear_config(:emoji)
|
||||
|
||||
ConfigDB.create(%{
|
||||
group: ":pleroma",
|
||||
|
|
@ -128,8 +127,7 @@ defmodule Pleroma.Config.TransferTaskTest do
|
|||
end
|
||||
|
||||
test "on reboot time key" do
|
||||
chat = Application.get_env(:pleroma, :chat)
|
||||
on_exit(fn -> Application.put_env(:pleroma, :chat, chat) end)
|
||||
clear_config(:chat)
|
||||
|
||||
ConfigDB.create(%{
|
||||
group: ":pleroma",
|
||||
|
|
@ -141,8 +139,7 @@ defmodule Pleroma.Config.TransferTaskTest do
|
|||
end
|
||||
|
||||
test "on reboot time subkey" do
|
||||
captcha = Application.get_env(:pleroma, Pleroma.Captcha)
|
||||
on_exit(fn -> Application.put_env(:pleroma, Pleroma.Captcha, captcha) end)
|
||||
clear_config(Pleroma.Captcha)
|
||||
|
||||
ConfigDB.create(%{
|
||||
group: ":pleroma",
|
||||
|
|
@ -154,13 +151,8 @@ defmodule Pleroma.Config.TransferTaskTest do
|
|||
end
|
||||
|
||||
test "don't restart pleroma on reboot time key and subkey if there is false flag" do
|
||||
chat = Application.get_env(:pleroma, :chat)
|
||||
captcha = Application.get_env(:pleroma, Pleroma.Captcha)
|
||||
|
||||
on_exit(fn ->
|
||||
Application.put_env(:pleroma, :chat, chat)
|
||||
Application.put_env(:pleroma, Pleroma.Captcha, captcha)
|
||||
end)
|
||||
clear_config(:chat)
|
||||
clear_config(Pleroma.Captcha)
|
||||
|
||||
ConfigDB.create(%{
|
||||
group: ":pleroma",
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Emoji.FormatterTest do
|
||||
alias Pleroma.Emoji
|
||||
alias Pleroma.Emoji.Formatter
|
||||
use Pleroma.DataCase
|
||||
|
||||
|
|
@ -32,30 +31,19 @@ defmodule Pleroma.Emoji.FormatterTest do
|
|||
end
|
||||
end
|
||||
|
||||
describe "get_emoji" do
|
||||
describe "get_emoji_map" do
|
||||
test "it returns the emoji used in the text" do
|
||||
text = "I love :firefox:"
|
||||
|
||||
assert Formatter.get_emoji(text) == [
|
||||
{"firefox",
|
||||
%Emoji{
|
||||
code: "firefox",
|
||||
file: "/emoji/Firefox.gif",
|
||||
tags: ["Gif", "Fun"],
|
||||
safe_code: "firefox",
|
||||
safe_file: "/emoji/Firefox.gif"
|
||||
}}
|
||||
]
|
||||
assert Formatter.get_emoji_map("I love :firefox:") == %{
|
||||
"firefox" => "http://localhost:4001/emoji/Firefox.gif"
|
||||
}
|
||||
end
|
||||
|
||||
test "it returns a nice empty result when no emojis are present" do
|
||||
text = "I love moominamma"
|
||||
assert Formatter.get_emoji(text) == []
|
||||
assert Formatter.get_emoji_map("I love moominamma") == %{}
|
||||
end
|
||||
|
||||
test "it doesn't die when text is absent" do
|
||||
text = nil
|
||||
assert Formatter.get_emoji(text) == []
|
||||
assert Formatter.get_emoji_map(nil) == %{}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -15,28 +15,28 @@ defmodule Pleroma.FollowingRelationshipTest do
|
|||
test "returns following addresses without internal.fetch" do
|
||||
user = insert(:user)
|
||||
fetch_actor = InternalFetchActor.get_actor()
|
||||
FollowingRelationship.follow(fetch_actor, user, "accept")
|
||||
FollowingRelationship.follow(fetch_actor, user, :follow_accept)
|
||||
assert FollowingRelationship.following(fetch_actor) == [user.follower_address]
|
||||
end
|
||||
|
||||
test "returns following addresses without relay" do
|
||||
user = insert(:user)
|
||||
relay_actor = Relay.get_actor()
|
||||
FollowingRelationship.follow(relay_actor, user, "accept")
|
||||
FollowingRelationship.follow(relay_actor, user, :follow_accept)
|
||||
assert FollowingRelationship.following(relay_actor) == [user.follower_address]
|
||||
end
|
||||
|
||||
test "returns following addresses without remote user" do
|
||||
user = insert(:user)
|
||||
actor = insert(:user, local: false)
|
||||
FollowingRelationship.follow(actor, user, "accept")
|
||||
FollowingRelationship.follow(actor, user, :follow_accept)
|
||||
assert FollowingRelationship.following(actor) == [user.follower_address]
|
||||
end
|
||||
|
||||
test "returns following addresses with local user" do
|
||||
user = insert(:user)
|
||||
actor = insert(:user, local: true)
|
||||
FollowingRelationship.follow(actor, user, "accept")
|
||||
FollowingRelationship.follow(actor, user, :follow_accept)
|
||||
|
||||
assert FollowingRelationship.following(actor) == [
|
||||
actor.follower_address,
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ defmodule Pleroma.FormatterTest do
|
|||
archaeme =
|
||||
insert(:user,
|
||||
nickname: "archa_eme_",
|
||||
source_data: %{"url" => "https://archeme/@archa_eme_"}
|
||||
uri: "https://archeme/@archa_eme_"
|
||||
)
|
||||
|
||||
archaeme_remote = insert(:user, %{nickname: "archaeme@archae.me"})
|
||||
|
|
@ -150,13 +150,13 @@ defmodule Pleroma.FormatterTest do
|
|||
assert length(mentions) == 3
|
||||
|
||||
expected_text =
|
||||
~s(<span class="h-card"><a data-user="#{gsimg.id}" class="u-url mention" href="#{
|
||||
~s(<span class="h-card"><a class="u-url mention" data-user="#{gsimg.id}" href="#{
|
||||
gsimg.ap_id
|
||||
}" rel="ugc">@<span>gsimg</span></a></span> According to <span class="h-card"><a data-user="#{
|
||||
}" rel="ugc">@<span>gsimg</span></a></span> According to <span class="h-card"><a class="u-url mention" data-user="#{
|
||||
archaeme.id
|
||||
}" class="u-url mention" href="#{"https://archeme/@archa_eme_"}" rel="ugc">@<span>archa_eme_</span></a></span>, that is @daggsy. Also hello <span class="h-card"><a data-user="#{
|
||||
}" href="#{"https://archeme/@archa_eme_"}" rel="ugc">@<span>archa_eme_</span></a></span>, that is @daggsy. Also hello <span class="h-card"><a class="u-url mention" data-user="#{
|
||||
archaeme_remote.id
|
||||
}" class="u-url mention" href="#{archaeme_remote.ap_id}" rel="ugc">@<span>archaeme</span></a></span>)
|
||||
}" href="#{archaeme_remote.ap_id}" rel="ugc">@<span>archaeme</span></a></span>)
|
||||
|
||||
assert expected_text == text
|
||||
end
|
||||
|
|
@ -171,7 +171,7 @@ defmodule Pleroma.FormatterTest do
|
|||
assert length(mentions) == 1
|
||||
|
||||
expected_text =
|
||||
~s(<span class="h-card"><a data-user="#{mike.id}" class="u-url mention" href="#{
|
||||
~s(<span class="h-card"><a class="u-url mention" data-user="#{mike.id}" href="#{
|
||||
mike.ap_id
|
||||
}" rel="ugc">@<span>mike</span></a></span> test)
|
||||
|
||||
|
|
@ -187,7 +187,7 @@ defmodule Pleroma.FormatterTest do
|
|||
assert length(mentions) == 1
|
||||
|
||||
expected_text =
|
||||
~s(<span class="h-card"><a data-user="#{o.id}" class="u-url mention" href="#{o.ap_id}" rel="ugc">@<span>o</span></a></span> hi)
|
||||
~s(<span class="h-card"><a class="u-url mention" data-user="#{o.id}" href="#{o.ap_id}" rel="ugc">@<span>o</span></a></span> hi)
|
||||
|
||||
assert expected_text == text
|
||||
end
|
||||
|
|
@ -209,17 +209,13 @@ defmodule Pleroma.FormatterTest do
|
|||
assert mentions == [{"@#{user.nickname}", user}, {"@#{other_user.nickname}", other_user}]
|
||||
|
||||
assert expected_text ==
|
||||
~s(<span class="h-card"><a data-user="#{user.id}" class="u-url mention" href="#{
|
||||
~s(<span class="h-card"><a class="u-url mention" data-user="#{user.id}" href="#{
|
||||
user.ap_id
|
||||
}" rel="ugc">@<span>#{user.nickname}</span></a></span> <span class="h-card"><a data-user="#{
|
||||
}" rel="ugc">@<span>#{user.nickname}</span></a></span> <span class="h-card"><a class="u-url mention" data-user="#{
|
||||
other_user.id
|
||||
}" class="u-url mention" href="#{other_user.ap_id}" rel="ugc">@<span>#{
|
||||
other_user.nickname
|
||||
}</span></a></span> hey dudes i hate <span class="h-card"><a data-user="#{
|
||||
}" href="#{other_user.ap_id}" rel="ugc">@<span>#{other_user.nickname}</span></a></span> hey dudes i hate <span class="h-card"><a class="u-url mention" data-user="#{
|
||||
third_user.id
|
||||
}" class="u-url mention" href="#{third_user.ap_id}" rel="ugc">@<span>#{
|
||||
third_user.nickname
|
||||
}</span></a></span>)
|
||||
}" href="#{third_user.ap_id}" rel="ugc">@<span>#{third_user.nickname}</span></a></span>)
|
||||
end
|
||||
|
||||
test "given the 'safe_mention' option, it will still work without any mention" do
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ defmodule Pleroma.Plugs.OAuthScopesPlugTest do
|
|||
|
||||
alias Pleroma.Plugs.EnsurePublicOrAuthenticatedPlug
|
||||
alias Pleroma.Plugs.OAuthScopesPlug
|
||||
alias Pleroma.Plugs.PlugHelper
|
||||
alias Pleroma.Repo
|
||||
|
||||
import Mock
|
||||
|
|
@ -16,6 +17,18 @@ defmodule Pleroma.Plugs.OAuthScopesPlugTest do
|
|||
:ok
|
||||
end
|
||||
|
||||
test "is not performed if marked as skipped", %{conn: conn} do
|
||||
with_mock OAuthScopesPlug, [:passthrough], perform: &passthrough([&1, &2]) do
|
||||
conn =
|
||||
conn
|
||||
|> PlugHelper.append_to_skipped_plugs(OAuthScopesPlug)
|
||||
|> OAuthScopesPlug.call(%{scopes: ["random_scope"]})
|
||||
|
||||
refute called(OAuthScopesPlug.perform(:_, :_))
|
||||
refute conn.halted
|
||||
end
|
||||
end
|
||||
|
||||
test "if `token.scopes` fulfills specified 'any of' conditions, " <>
|
||||
"proceeds with no op",
|
||||
%{conn: conn} do
|
||||
|
|
|
|||
|
|
@ -5,8 +5,10 @@
|
|||
defmodule Pleroma.Plugs.RateLimiterTest do
|
||||
use Pleroma.Web.ConnCase
|
||||
|
||||
alias Phoenix.ConnTest
|
||||
alias Pleroma.Config
|
||||
alias Pleroma.Plugs.RateLimiter
|
||||
alias Plug.Conn
|
||||
|
||||
import Pleroma.Factory
|
||||
import Pleroma.Tests.Helpers, only: [clear_config: 1, clear_config: 2]
|
||||
|
|
@ -36,8 +38,15 @@ defmodule Pleroma.Plugs.RateLimiterTest do
|
|||
end
|
||||
|
||||
test "it is disabled if it remote ip plug is enabled but no remote ip is found" do
|
||||
Config.put([Pleroma.Web.Endpoint, :http, :ip], {127, 0, 0, 1})
|
||||
assert RateLimiter.disabled?(Plug.Conn.assign(build_conn(), :remote_ip_found, false))
|
||||
assert RateLimiter.disabled?(Conn.assign(build_conn(), :remote_ip_found, false))
|
||||
end
|
||||
|
||||
test "it is enabled if remote ip found" do
|
||||
refute RateLimiter.disabled?(Conn.assign(build_conn(), :remote_ip_found, true))
|
||||
end
|
||||
|
||||
test "it is enabled if remote_ip_found flag doesn't exist" do
|
||||
refute RateLimiter.disabled?(build_conn())
|
||||
end
|
||||
|
||||
test "it restricts based on config values" do
|
||||
|
|
@ -58,7 +67,7 @@ defmodule Pleroma.Plugs.RateLimiterTest do
|
|||
end
|
||||
|
||||
conn = RateLimiter.call(conn, plug_opts)
|
||||
assert %{"error" => "Throttled"} = Phoenix.ConnTest.json_response(conn, :too_many_requests)
|
||||
assert %{"error" => "Throttled"} = ConnTest.json_response(conn, :too_many_requests)
|
||||
assert conn.halted
|
||||
|
||||
Process.sleep(50)
|
||||
|
|
@ -68,7 +77,7 @@ defmodule Pleroma.Plugs.RateLimiterTest do
|
|||
conn = RateLimiter.call(conn, plug_opts)
|
||||
assert {1, 4} = RateLimiter.inspect_bucket(conn, limiter_name, plug_opts)
|
||||
|
||||
refute conn.status == Plug.Conn.Status.code(:too_many_requests)
|
||||
refute conn.status == Conn.Status.code(:too_many_requests)
|
||||
refute conn.resp_body
|
||||
refute conn.halted
|
||||
end
|
||||
|
|
@ -98,7 +107,7 @@ defmodule Pleroma.Plugs.RateLimiterTest do
|
|||
plug_opts = RateLimiter.init(name: limiter_name, params: ["id"])
|
||||
|
||||
conn = build_conn(:get, "/?id=1")
|
||||
conn = Plug.Conn.fetch_query_params(conn)
|
||||
conn = Conn.fetch_query_params(conn)
|
||||
conn_2 = build_conn(:get, "/?id=2")
|
||||
|
||||
RateLimiter.call(conn, plug_opts)
|
||||
|
|
@ -119,7 +128,7 @@ defmodule Pleroma.Plugs.RateLimiterTest do
|
|||
id = "100"
|
||||
|
||||
conn = build_conn(:get, "/?id=#{id}")
|
||||
conn = Plug.Conn.fetch_query_params(conn)
|
||||
conn = Conn.fetch_query_params(conn)
|
||||
conn_2 = build_conn(:get, "/?id=#{101}")
|
||||
|
||||
RateLimiter.call(conn, plug_opts)
|
||||
|
|
@ -147,13 +156,13 @@ defmodule Pleroma.Plugs.RateLimiterTest do
|
|||
|
||||
conn = RateLimiter.call(conn, plug_opts)
|
||||
|
||||
assert %{"error" => "Throttled"} = Phoenix.ConnTest.json_response(conn, :too_many_requests)
|
||||
assert %{"error" => "Throttled"} = ConnTest.json_response(conn, :too_many_requests)
|
||||
assert conn.halted
|
||||
|
||||
conn_2 = RateLimiter.call(conn_2, plug_opts)
|
||||
assert {1, 4} = RateLimiter.inspect_bucket(conn_2, limiter_name, plug_opts)
|
||||
|
||||
refute conn_2.status == Plug.Conn.Status.code(:too_many_requests)
|
||||
refute conn_2.status == Conn.Status.code(:too_many_requests)
|
||||
refute conn_2.resp_body
|
||||
refute conn_2.halted
|
||||
end
|
||||
|
|
@ -187,7 +196,7 @@ defmodule Pleroma.Plugs.RateLimiterTest do
|
|||
|
||||
conn = RateLimiter.call(conn, plug_opts)
|
||||
|
||||
assert %{"error" => "Throttled"} = Phoenix.ConnTest.json_response(conn, :too_many_requests)
|
||||
assert %{"error" => "Throttled"} = ConnTest.json_response(conn, :too_many_requests)
|
||||
assert conn.halted
|
||||
end
|
||||
|
||||
|
|
@ -210,12 +219,12 @@ defmodule Pleroma.Plugs.RateLimiterTest do
|
|||
end
|
||||
|
||||
conn = RateLimiter.call(conn, plug_opts)
|
||||
assert %{"error" => "Throttled"} = Phoenix.ConnTest.json_response(conn, :too_many_requests)
|
||||
assert %{"error" => "Throttled"} = ConnTest.json_response(conn, :too_many_requests)
|
||||
assert conn.halted
|
||||
|
||||
conn_2 = RateLimiter.call(conn_2, plug_opts)
|
||||
assert {1, 4} = RateLimiter.inspect_bucket(conn_2, limiter_name, plug_opts)
|
||||
refute conn_2.status == Plug.Conn.Status.code(:too_many_requests)
|
||||
refute conn_2.status == Conn.Status.code(:too_many_requests)
|
||||
refute conn_2.resp_body
|
||||
refute conn_2.halted
|
||||
end
|
||||
|
|
|
|||
|
|
@ -19,12 +19,7 @@ defmodule Pleroma.SignatureTest do
|
|||
|
||||
@private_key "-----BEGIN RSA PRIVATE KEY-----\nMIIEpQIBAAKCAQEA48qb4v6kqigZutO9Ot0wkp27GIF2LiVaADgxQORZozZR63jH\nTaoOrS3Xhngbgc8SSOhfXET3omzeCLqaLNfXnZ8OXmuhJfJSU6mPUvmZ9QdT332j\nfN/g3iWGhYMf/M9ftCKh96nvFVO/tMruzS9xx7tkrfJjehdxh/3LlJMMImPtwcD7\nkFXwyt1qZTAU6Si4oQAJxRDQXHp1ttLl3Ob829VM7IKkrVmY8TD+JSlV0jtVJPj6\n1J19ytKTx/7UaucYvb9HIiBpkuiy5n/irDqKLVf5QEdZoNCdojOZlKJmTLqHhzKP\n3E9TxsUjhrf4/EqegNc/j982RvOxeu4i40zMQwIDAQABAoIBAQDH5DXjfh21i7b4\ncXJuw0cqget617CDUhemdakTDs9yH+rHPZd3mbGDWuT0hVVuFe4vuGpmJ8c+61X0\nRvugOlBlavxK8xvYlsqTzAmPgKUPljyNtEzQ+gz0I+3mH2jkin2rL3D+SksZZgKm\nfiYMPIQWB2WUF04gB46DDb2mRVuymGHyBOQjIx3WC0KW2mzfoFUFRlZEF+Nt8Ilw\nT+g/u0aZ1IWoszbsVFOEdghgZET0HEarum0B2Je/ozcPYtwmU10iBANGMKdLqaP/\nj954BPunrUf6gmlnLZKIKklJj0advx0NA+cL79+zeVB3zexRYSA5o9q0WPhiuTwR\n/aedWHnBAoGBAP0sDWBAM1Y4TRAf8ZI9PcztwLyHPzfEIqzbObJJnx1icUMt7BWi\n+/RMOnhrlPGE1kMhOqSxvXYN3u+eSmWTqai2sSH5Hdw2EqnrISSTnwNUPINX7fHH\njEkgmXQ6ixE48SuBZnb4w1EjdB/BA6/sjL+FNhggOc87tizLTkMXmMtTAoGBAOZV\n+wPuAMBDBXmbmxCuDIjoVmgSlgeRunB1SA8RCPAFAiUo3+/zEgzW2Oz8kgI+xVwM\n33XkLKrWG1Orhpp6Hm57MjIc5MG+zF4/YRDpE/KNG9qU1tiz0UD5hOpIU9pP4bR/\ngxgPxZzvbk4h5BfHWLpjlk8UUpgk6uxqfti48c1RAoGBALBOKDZ6HwYRCSGMjUcg\n3NPEUi84JD8qmFc2B7Tv7h2he2ykIz9iFAGpwCIyETQsJKX1Ewi0OlNnD3RhEEAy\nl7jFGQ+mkzPSeCbadmcpYlgIJmf1KN/x7fDTAepeBpCEzfZVE80QKbxsaybd3Dp8\nCfwpwWUFtBxr4c7J+gNhAGe/AoGAPn8ZyqkrPv9wXtyfqFjxQbx4pWhVmNwrkBPi\nZ2Qh3q4dNOPwTvTO8vjghvzIyR8rAZzkjOJKVFgftgYWUZfM5gE7T2mTkBYq8W+U\n8LetF+S9qAM2gDnaDx0kuUTCq7t87DKk6URuQ/SbI0wCzYjjRD99KxvChVGPBHKo\n1DjqMuECgYEAgJGNm7/lJCS2wk81whfy/ttKGsEIkyhPFYQmdGzSYC5aDc2gp1R3\nxtOkYEvdjfaLfDGEa4UX8CHHF+w3t9u8hBtcdhMH6GYb9iv6z0VBTt4A/11HUR49\n3Z7TQ18Iyh3jAUCzFV9IJlLIExq5Y7P4B3ojWFBN607sDCt8BMPbDYs=\n-----END RSA PRIVATE KEY-----"
|
||||
|
||||
@public_key %{
|
||||
"id" => "https://mastodon.social/users/lambadalambda#main-key",
|
||||
"owner" => "https://mastodon.social/users/lambadalambda",
|
||||
"publicKeyPem" =>
|
||||
"-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAw0P/Tq4gb4G/QVuMGbJo\nC/AfMNcv+m7NfrlOwkVzcU47jgESuYI4UtJayissCdBycHUnfVUd9qol+eznSODz\nCJhfJloqEIC+aSnuEPGA0POtWad6DU0E6/Ho5zQn5WAWUwbRQqowbrsm/GHo2+3v\neR5jGenwA6sYhINg/c3QQbksyV0uJ20Umyx88w8+TJuv53twOfmyDWuYNoQ3y5cc\nHKOZcLHxYOhvwg3PFaGfFHMFiNmF40dTXt9K96r7sbzc44iLD+VphbMPJEjkMuf8\nPGEFOBzy8pm3wJZw2v32RNW2VESwMYyqDzwHXGSq1a73cS7hEnc79gXlELsK04L9\nQQIDAQAB\n-----END PUBLIC KEY-----\n"
|
||||
}
|
||||
@public_key "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAw0P/Tq4gb4G/QVuMGbJo\nC/AfMNcv+m7NfrlOwkVzcU47jgESuYI4UtJayissCdBycHUnfVUd9qol+eznSODz\nCJhfJloqEIC+aSnuEPGA0POtWad6DU0E6/Ho5zQn5WAWUwbRQqowbrsm/GHo2+3v\neR5jGenwA6sYhINg/c3QQbksyV0uJ20Umyx88w8+TJuv53twOfmyDWuYNoQ3y5cc\nHKOZcLHxYOhvwg3PFaGfFHMFiNmF40dTXt9K96r7sbzc44iLD+VphbMPJEjkMuf8\nPGEFOBzy8pm3wJZw2v32RNW2VESwMYyqDzwHXGSq1a73cS7hEnc79gXlELsK04L9\nQQIDAQAB\n-----END PUBLIC KEY-----\n"
|
||||
|
||||
@rsa_public_key {
|
||||
:RSAPublicKey,
|
||||
|
|
@ -42,7 +37,7 @@ defmodule Pleroma.SignatureTest do
|
|||
test "it returns key" do
|
||||
expected_result = {:ok, @rsa_public_key}
|
||||
|
||||
user = insert(:user, source_data: %{"publicKey" => @public_key})
|
||||
user = insert(:user, public_key: @public_key)
|
||||
|
||||
assert Signature.fetch_public_key(make_fake_conn(user.ap_id)) == expected_result
|
||||
end
|
||||
|
|
@ -53,8 +48,8 @@ defmodule Pleroma.SignatureTest do
|
|||
end) =~ "[error] Could not decode user"
|
||||
end
|
||||
|
||||
test "it returns error if public key is empty" do
|
||||
user = insert(:user, source_data: %{"publicKey" => %{}})
|
||||
test "it returns error if public key is nil" do
|
||||
user = insert(:user, public_key: nil)
|
||||
|
||||
assert Signature.fetch_public_key(make_fake_conn(user.ap_id)) == {:error, :error}
|
||||
end
|
||||
|
|
|
|||
|
|
@ -294,7 +294,7 @@ defmodule Pleroma.Factory do
|
|||
|
||||
def oauth_app_factory do
|
||||
%Pleroma.Web.OAuth.App{
|
||||
client_name: "Some client",
|
||||
client_name: sequence(:client_name, &"Some client #{&1}"),
|
||||
redirect_uris: "https://example.com/callback",
|
||||
scopes: ["read", "write", "follow", "push", "admin"],
|
||||
website: "https://example.com",
|
||||
|
|
|
|||
65
test/tasks/app_test.exs
Normal file
65
test/tasks/app_test.exs
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Mix.Tasks.Pleroma.AppTest do
|
||||
use Pleroma.DataCase, async: true
|
||||
|
||||
setup_all do
|
||||
Mix.shell(Mix.Shell.Process)
|
||||
|
||||
on_exit(fn ->
|
||||
Mix.shell(Mix.Shell.IO)
|
||||
end)
|
||||
end
|
||||
|
||||
describe "creates new app" do
|
||||
test "with default scopes" do
|
||||
name = "Some name"
|
||||
redirect = "https://example.com"
|
||||
Mix.Tasks.Pleroma.App.run(["create", "-n", name, "-r", redirect])
|
||||
|
||||
assert_app(name, redirect, ["read", "write", "follow", "push"])
|
||||
end
|
||||
|
||||
test "with custom scopes" do
|
||||
name = "Another name"
|
||||
redirect = "https://example.com"
|
||||
|
||||
Mix.Tasks.Pleroma.App.run([
|
||||
"create",
|
||||
"-n",
|
||||
name,
|
||||
"-r",
|
||||
redirect,
|
||||
"-s",
|
||||
"read,write,follow,push,admin"
|
||||
])
|
||||
|
||||
assert_app(name, redirect, ["read", "write", "follow", "push", "admin"])
|
||||
end
|
||||
end
|
||||
|
||||
test "with errors" do
|
||||
Mix.Tasks.Pleroma.App.run(["create"])
|
||||
{:mix_shell, :error, ["Creating failed:"]}
|
||||
{:mix_shell, :error, ["name: can't be blank"]}
|
||||
{:mix_shell, :error, ["redirect_uris: can't be blank"]}
|
||||
end
|
||||
|
||||
defp assert_app(name, redirect, scopes) do
|
||||
app = Repo.get_by(Pleroma.Web.OAuth.App, client_name: name)
|
||||
|
||||
assert_received {:mix_shell, :info, [message]}
|
||||
assert message == "#{name} successfully created:"
|
||||
|
||||
assert_received {:mix_shell, :info, [message]}
|
||||
assert message == "App client_id: #{app.client_id}"
|
||||
|
||||
assert_received {:mix_shell, :info, [message]}
|
||||
assert message == "App client_secret: #{app.client_secret}"
|
||||
|
||||
assert app.scopes == scopes
|
||||
assert app.redirect_uris == redirect
|
||||
end
|
||||
end
|
||||
|
|
@ -140,7 +140,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do
|
|||
test "user is unsubscribed" do
|
||||
followed = insert(:user)
|
||||
user = insert(:user)
|
||||
User.follow(user, followed, "accept")
|
||||
User.follow(user, followed, :follow_accept)
|
||||
|
||||
Mix.Tasks.Pleroma.User.run(["unsubscribe", user.nickname])
|
||||
|
||||
|
|
|
|||
|
|
@ -194,7 +194,8 @@ defmodule Pleroma.UserTest do
|
|||
CommonAPI.follow(pending_follower, locked)
|
||||
CommonAPI.follow(pending_follower, locked)
|
||||
CommonAPI.follow(accepted_follower, locked)
|
||||
Pleroma.FollowingRelationship.update(accepted_follower, locked, "accept")
|
||||
|
||||
Pleroma.FollowingRelationship.update(accepted_follower, locked, :follow_accept)
|
||||
|
||||
assert [^pending_follower] = User.get_follow_requests(locked)
|
||||
end
|
||||
|
|
@ -319,7 +320,7 @@ defmodule Pleroma.UserTest do
|
|||
following_address: "http://localhost:4001/users/fuser2/following"
|
||||
})
|
||||
|
||||
{:ok, user} = User.follow(user, followed, "accept")
|
||||
{:ok, user} = User.follow(user, followed, :follow_accept)
|
||||
|
||||
{:ok, user, _activity} = User.unfollow(user, followed)
|
||||
|
||||
|
|
@ -332,7 +333,7 @@ defmodule Pleroma.UserTest do
|
|||
followed = insert(:user)
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, user} = User.follow(user, followed, "accept")
|
||||
{:ok, user} = User.follow(user, followed, :follow_accept)
|
||||
|
||||
assert User.following(user) == [user.follower_address, followed.follower_address]
|
||||
|
||||
|
|
@ -353,7 +354,7 @@ defmodule Pleroma.UserTest do
|
|||
test "test if a user is following another user" do
|
||||
followed = insert(:user)
|
||||
user = insert(:user)
|
||||
User.follow(user, followed, "accept")
|
||||
User.follow(user, followed, :follow_accept)
|
||||
|
||||
assert User.following?(user, followed)
|
||||
refute User.following?(followed, user)
|
||||
|
|
@ -581,7 +582,7 @@ defmodule Pleroma.UserTest do
|
|||
|
||||
{:ok, user} = User.get_or_fetch_by_ap_id("http://mastodon.example.org/users/admin")
|
||||
|
||||
assert user.source_data["endpoints"]
|
||||
assert user.inbox
|
||||
|
||||
refute user.last_refreshed_at == orig_user.last_refreshed_at
|
||||
end
|
||||
|
|
@ -609,7 +610,7 @@ defmodule Pleroma.UserTest do
|
|||
) <> "/followers"
|
||||
end
|
||||
|
||||
describe "remote user creation changeset" do
|
||||
describe "remote user changeset" do
|
||||
@valid_remote %{
|
||||
bio: "hello",
|
||||
name: "Someone",
|
||||
|
|
@ -621,28 +622,28 @@ defmodule Pleroma.UserTest do
|
|||
setup do: clear_config([:instance, :user_name_length])
|
||||
|
||||
test "it confirms validity" do
|
||||
cs = User.remote_user_creation(@valid_remote)
|
||||
cs = User.remote_user_changeset(@valid_remote)
|
||||
assert cs.valid?
|
||||
end
|
||||
|
||||
test "it sets the follower_adress" do
|
||||
cs = User.remote_user_creation(@valid_remote)
|
||||
cs = User.remote_user_changeset(@valid_remote)
|
||||
# remote users get a fake local follower address
|
||||
assert cs.changes.follower_address ==
|
||||
User.ap_followers(%User{nickname: @valid_remote[:nickname]})
|
||||
end
|
||||
|
||||
test "it enforces the fqn format for nicknames" do
|
||||
cs = User.remote_user_creation(%{@valid_remote | nickname: "bla"})
|
||||
cs = User.remote_user_changeset(%{@valid_remote | nickname: "bla"})
|
||||
assert Ecto.Changeset.get_field(cs, :local) == false
|
||||
assert cs.changes.avatar
|
||||
refute cs.valid?
|
||||
end
|
||||
|
||||
test "it has required fields" do
|
||||
[:name, :ap_id]
|
||||
[:ap_id]
|
||||
|> Enum.each(fn field ->
|
||||
cs = User.remote_user_creation(Map.delete(@valid_remote, field))
|
||||
cs = User.remote_user_changeset(Map.delete(@valid_remote, field))
|
||||
refute cs.valid?
|
||||
end)
|
||||
end
|
||||
|
|
@ -1198,58 +1199,6 @@ defmodule Pleroma.UserTest do
|
|||
assert {:ok, _key} = User.get_public_key_for_ap_id("http://mastodon.example.org/users/admin")
|
||||
end
|
||||
|
||||
describe "insert or update a user from given data" do
|
||||
test "with normal data" do
|
||||
user = insert(:user, %{nickname: "nick@name.de"})
|
||||
data = %{ap_id: user.ap_id <> "xxx", name: user.name, nickname: user.nickname}
|
||||
|
||||
assert {:ok, %User{}} = User.insert_or_update_user(data)
|
||||
end
|
||||
|
||||
test "with overly long fields" do
|
||||
current_max_length = Pleroma.Config.get([:instance, :account_field_value_length], 255)
|
||||
user = insert(:user, nickname: "nickname@supergood.domain")
|
||||
|
||||
data = %{
|
||||
ap_id: user.ap_id,
|
||||
name: user.name,
|
||||
nickname: user.nickname,
|
||||
fields: [
|
||||
%{"name" => "myfield", "value" => String.duplicate("h", current_max_length + 1)}
|
||||
]
|
||||
}
|
||||
|
||||
assert {:ok, %User{}} = User.insert_or_update_user(data)
|
||||
end
|
||||
|
||||
test "with an overly long bio" do
|
||||
current_max_length = Pleroma.Config.get([:instance, :user_bio_length], 5000)
|
||||
user = insert(:user, nickname: "nickname@supergood.domain")
|
||||
|
||||
data = %{
|
||||
ap_id: user.ap_id,
|
||||
name: user.name,
|
||||
nickname: user.nickname,
|
||||
bio: String.duplicate("h", current_max_length + 1)
|
||||
}
|
||||
|
||||
assert {:ok, %User{}} = User.insert_or_update_user(data)
|
||||
end
|
||||
|
||||
test "with an overly long display name" do
|
||||
current_max_length = Pleroma.Config.get([:instance, :user_name_length], 100)
|
||||
user = insert(:user, nickname: "nickname@supergood.domain")
|
||||
|
||||
data = %{
|
||||
ap_id: user.ap_id,
|
||||
name: String.duplicate("h", current_max_length + 1),
|
||||
nickname: user.nickname
|
||||
}
|
||||
|
||||
assert {:ok, %User{}} = User.insert_or_update_user(data)
|
||||
end
|
||||
end
|
||||
|
||||
describe "per-user rich-text filtering" do
|
||||
test "html_filter_policy returns default policies, when rich-text is enabled" do
|
||||
user = insert(:user)
|
||||
|
|
@ -1404,7 +1353,7 @@ defmodule Pleroma.UserTest do
|
|||
bio = "A.k.a. @nick@domain.com"
|
||||
|
||||
expected_text =
|
||||
~s(A.k.a. <span class="h-card"><a data-user="#{remote_user.id}" class="u-url mention" href="#{
|
||||
~s(A.k.a. <span class="h-card"><a class="u-url mention" data-user="#{remote_user.id}" href="#{
|
||||
remote_user.ap_id
|
||||
}" rel="ugc">@<span>nick@domain.com</span></a></span>)
|
||||
|
||||
|
|
|
|||
|
|
@ -1239,16 +1239,56 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
|
|||
filename: "an_image.jpg"
|
||||
}
|
||||
|
||||
conn =
|
||||
object =
|
||||
conn
|
||||
|> assign(:user, user)
|
||||
|> post("/api/ap/upload_media", %{"file" => image, "description" => desc})
|
||||
|> json_response(:created)
|
||||
|
||||
assert object = json_response(conn, :created)
|
||||
assert object["name"] == desc
|
||||
assert object["type"] == "Document"
|
||||
assert object["actor"] == user.ap_id
|
||||
assert [%{"href" => object_href, "mediaType" => object_mediatype}] = object["url"]
|
||||
assert is_binary(object_href)
|
||||
assert object_mediatype == "image/jpeg"
|
||||
|
||||
activity_request = %{
|
||||
"@context" => "https://www.w3.org/ns/activitystreams",
|
||||
"type" => "Create",
|
||||
"object" => %{
|
||||
"type" => "Note",
|
||||
"content" => "AP C2S test, attachment",
|
||||
"attachment" => [object]
|
||||
},
|
||||
"to" => "https://www.w3.org/ns/activitystreams#Public",
|
||||
"cc" => []
|
||||
}
|
||||
|
||||
activity_response =
|
||||
conn
|
||||
|> assign(:user, user)
|
||||
|> post("/users/#{user.nickname}/outbox", activity_request)
|
||||
|> json_response(:created)
|
||||
|
||||
assert activity_response["id"]
|
||||
assert activity_response["object"]
|
||||
assert activity_response["actor"] == user.ap_id
|
||||
|
||||
assert %Object{data: %{"attachment" => [attachment]}} =
|
||||
Object.normalize(activity_response["object"])
|
||||
|
||||
assert attachment["type"] == "Document"
|
||||
assert attachment["name"] == desc
|
||||
|
||||
assert [
|
||||
%{
|
||||
"href" => ^object_href,
|
||||
"type" => "Link",
|
||||
"mediaType" => ^object_mediatype
|
||||
}
|
||||
] = attachment["url"]
|
||||
|
||||
# Fails if unauthenticated
|
||||
conn
|
||||
|> post("/api/ap/upload_media", %{"file" => image, "description" => desc})
|
||||
|> json_response(403)
|
||||
|
|
|
|||
|
|
@ -180,7 +180,6 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
{:ok, user} = ActivityPub.make_user_from_ap_id(user_id)
|
||||
assert user.ap_id == user_id
|
||||
assert user.nickname == "admin@mastodon.example.org"
|
||||
assert user.source_data
|
||||
assert user.ap_enabled
|
||||
assert user.follower_address == "http://mastodon.example.org/users/admin/followers"
|
||||
end
|
||||
|
|
|
|||
|
|
@ -48,10 +48,7 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
|
|||
|
||||
describe "determine_inbox/2" do
|
||||
test "it returns sharedInbox for messages involving as:Public in to" do
|
||||
user =
|
||||
insert(:user, %{
|
||||
source_data: %{"endpoints" => %{"sharedInbox" => "http://example.com/inbox"}}
|
||||
})
|
||||
user = insert(:user, %{shared_inbox: "http://example.com/inbox"})
|
||||
|
||||
activity = %Activity{
|
||||
data: %{"to" => [@as_public], "cc" => [user.follower_address]}
|
||||
|
|
@ -61,10 +58,7 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
|
|||
end
|
||||
|
||||
test "it returns sharedInbox for messages involving as:Public in cc" do
|
||||
user =
|
||||
insert(:user, %{
|
||||
source_data: %{"endpoints" => %{"sharedInbox" => "http://example.com/inbox"}}
|
||||
})
|
||||
user = insert(:user, %{shared_inbox: "http://example.com/inbox"})
|
||||
|
||||
activity = %Activity{
|
||||
data: %{"cc" => [@as_public], "to" => [user.follower_address]}
|
||||
|
|
@ -74,11 +68,7 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
|
|||
end
|
||||
|
||||
test "it returns sharedInbox for messages involving multiple recipients in to" do
|
||||
user =
|
||||
insert(:user, %{
|
||||
source_data: %{"endpoints" => %{"sharedInbox" => "http://example.com/inbox"}}
|
||||
})
|
||||
|
||||
user = insert(:user, %{shared_inbox: "http://example.com/inbox"})
|
||||
user_two = insert(:user)
|
||||
user_three = insert(:user)
|
||||
|
||||
|
|
@ -90,11 +80,7 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
|
|||
end
|
||||
|
||||
test "it returns sharedInbox for messages involving multiple recipients in cc" do
|
||||
user =
|
||||
insert(:user, %{
|
||||
source_data: %{"endpoints" => %{"sharedInbox" => "http://example.com/inbox"}}
|
||||
})
|
||||
|
||||
user = insert(:user, %{shared_inbox: "http://example.com/inbox"})
|
||||
user_two = insert(:user)
|
||||
user_three = insert(:user)
|
||||
|
||||
|
|
@ -107,12 +93,10 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
|
|||
|
||||
test "it returns sharedInbox for messages involving multiple recipients in total" do
|
||||
user =
|
||||
insert(:user,
|
||||
source_data: %{
|
||||
"inbox" => "http://example.com/personal-inbox",
|
||||
"endpoints" => %{"sharedInbox" => "http://example.com/inbox"}
|
||||
}
|
||||
)
|
||||
insert(:user, %{
|
||||
shared_inbox: "http://example.com/inbox",
|
||||
inbox: "http://example.com/personal-inbox"
|
||||
})
|
||||
|
||||
user_two = insert(:user)
|
||||
|
||||
|
|
@ -125,12 +109,10 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
|
|||
|
||||
test "it returns inbox for messages involving single recipients in total" do
|
||||
user =
|
||||
insert(:user,
|
||||
source_data: %{
|
||||
"inbox" => "http://example.com/personal-inbox",
|
||||
"endpoints" => %{"sharedInbox" => "http://example.com/inbox"}
|
||||
}
|
||||
)
|
||||
insert(:user, %{
|
||||
shared_inbox: "http://example.com/inbox",
|
||||
inbox: "http://example.com/personal-inbox"
|
||||
})
|
||||
|
||||
activity = %Activity{
|
||||
data: %{"to" => [user.ap_id], "cc" => []}
|
||||
|
|
@ -258,11 +240,11 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
|
|||
[:passthrough],
|
||||
[] do
|
||||
follower =
|
||||
insert(:user,
|
||||
insert(:user, %{
|
||||
local: false,
|
||||
source_data: %{"inbox" => "https://domain.com/users/nick1/inbox"},
|
||||
inbox: "https://domain.com/users/nick1/inbox",
|
||||
ap_enabled: true
|
||||
)
|
||||
})
|
||||
|
||||
actor = insert(:user, follower_address: follower.ap_id)
|
||||
user = insert(:user)
|
||||
|
|
@ -295,14 +277,14 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
|
|||
fetcher =
|
||||
insert(:user,
|
||||
local: false,
|
||||
source_data: %{"inbox" => "https://domain.com/users/nick1/inbox"},
|
||||
inbox: "https://domain.com/users/nick1/inbox",
|
||||
ap_enabled: true
|
||||
)
|
||||
|
||||
another_fetcher =
|
||||
insert(:user,
|
||||
local: false,
|
||||
source_data: %{"inbox" => "https://domain2.com/users/nick1/inbox"},
|
||||
inbox: "https://domain2.com/users/nick1/inbox",
|
||||
ap_enabled: true
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -746,7 +746,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
|
||||
user = User.get_cached_by_ap_id(activity.actor)
|
||||
|
||||
assert User.fields(user) == [
|
||||
assert user.fields == [
|
||||
%{"name" => "foo", "value" => "bar"},
|
||||
%{"name" => "foo1", "value" => "bar1"}
|
||||
]
|
||||
|
|
@ -767,7 +767,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
|
||||
user = User.get_cached_by_ap_id(user.ap_id)
|
||||
|
||||
assert User.fields(user) == [
|
||||
assert user.fields == [
|
||||
%{"name" => "foo", "value" => "updated"},
|
||||
%{"name" => "foo1", "value" => "updated"}
|
||||
]
|
||||
|
|
@ -785,7 +785,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
|
||||
user = User.get_cached_by_ap_id(user.ap_id)
|
||||
|
||||
assert User.fields(user) == [
|
||||
assert user.fields == [
|
||||
%{"name" => "foo", "value" => "updated"},
|
||||
%{"name" => "foo1", "value" => "updated"}
|
||||
]
|
||||
|
|
@ -796,7 +796,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
|
||||
user = User.get_cached_by_ap_id(user.ap_id)
|
||||
|
||||
assert User.fields(user) == []
|
||||
assert user.fields == []
|
||||
end
|
||||
|
||||
test "it works for incoming update activities which lock the account" do
|
||||
|
|
@ -1230,19 +1230,13 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
attachment = %{
|
||||
"type" => "Link",
|
||||
"mediaType" => "video/mp4",
|
||||
"href" =>
|
||||
"https://peertube.moe/static/webseed/df5f464b-be8d-46fb-ad81-2d4c2d1630e3-480.mp4",
|
||||
"mimeType" => "video/mp4",
|
||||
"size" => 5_015_880,
|
||||
"url" => [
|
||||
%{
|
||||
"href" =>
|
||||
"https://peertube.moe/static/webseed/df5f464b-be8d-46fb-ad81-2d4c2d1630e3-480.mp4",
|
||||
"mediaType" => "video/mp4",
|
||||
"type" => "Link"
|
||||
"mediaType" => "video/mp4"
|
||||
}
|
||||
],
|
||||
"width" => 480
|
||||
]
|
||||
}
|
||||
|
||||
assert object.data["url"] ==
|
||||
|
|
@ -1624,7 +1618,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
})
|
||||
|
||||
user_two = insert(:user)
|
||||
Pleroma.FollowingRelationship.follow(user_two, user, "accept")
|
||||
Pleroma.FollowingRelationship.follow(user_two, user, :follow_accept)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "test"})
|
||||
{:ok, unrelated_activity} = CommonAPI.post(user_two, %{"status" => "test"})
|
||||
|
|
@ -2063,11 +2057,7 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
%{
|
||||
"mediaType" => "video/mp4",
|
||||
"url" => [
|
||||
%{
|
||||
"href" => "https://peertube.moe/stat-480.mp4",
|
||||
"mediaType" => "video/mp4",
|
||||
"type" => "Link"
|
||||
}
|
||||
%{"href" => "https://peertube.moe/stat-480.mp4", "mediaType" => "video/mp4"}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
|
@ -2085,23 +2075,13 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
%{
|
||||
"mediaType" => "video/mp4",
|
||||
"url" => [
|
||||
%{
|
||||
"href" => "https://pe.er/stat-480.mp4",
|
||||
"mediaType" => "video/mp4",
|
||||
"type" => "Link"
|
||||
}
|
||||
%{"href" => "https://pe.er/stat-480.mp4", "mediaType" => "video/mp4"}
|
||||
]
|
||||
},
|
||||
%{
|
||||
"href" => "https://pe.er/stat-480.mp4",
|
||||
"mediaType" => "video/mp4",
|
||||
"mimeType" => "video/mp4",
|
||||
"url" => [
|
||||
%{
|
||||
"href" => "https://pe.er/stat-480.mp4",
|
||||
"mediaType" => "video/mp4",
|
||||
"type" => "Link"
|
||||
}
|
||||
%{"href" => "https://pe.er/stat-480.mp4", "mediaType" => "video/mp4"}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
|
@ -2182,4 +2162,18 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
Transmogrifier.set_replies(object.data)["replies"]
|
||||
end
|
||||
end
|
||||
|
||||
test "take_emoji_tags/1" do
|
||||
user = insert(:user, %{emoji: %{"firefox" => "https://example.org/firefox.png"}})
|
||||
|
||||
assert Transmogrifier.take_emoji_tags(user) == [
|
||||
%{
|
||||
"icon" => %{"type" => "Image", "url" => "https://example.org/firefox.png"},
|
||||
"id" => "https://example.org/firefox.png",
|
||||
"name" => ":firefox:",
|
||||
"type" => "Emoji",
|
||||
"updated" => "1970-01-01T00:00:00Z"
|
||||
}
|
||||
]
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ defmodule Pleroma.Web.ActivityPub.UserViewTest do
|
|||
|
||||
{:ok, user} =
|
||||
insert(:user)
|
||||
|> User.upgrade_changeset(%{fields: fields})
|
||||
|> User.update_changeset(%{fields: fields})
|
||||
|> User.update_and_set_cache()
|
||||
|
||||
assert %{
|
||||
|
|
@ -38,7 +38,7 @@ defmodule Pleroma.Web.ActivityPub.UserViewTest do
|
|||
end
|
||||
|
||||
test "Renders with emoji tags" do
|
||||
user = insert(:user, emoji: [%{"bib" => "/test"}])
|
||||
user = insert(:user, emoji: %{"bib" => "/test"})
|
||||
|
||||
assert %{
|
||||
"tag" => [
|
||||
|
|
|
|||
|
|
@ -625,6 +625,39 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
|
||||
assert json_response(conn, :forbidden)
|
||||
end
|
||||
|
||||
test "email with +", %{conn: conn, admin: admin} do
|
||||
recipient_email = "foo+bar@baz.com"
|
||||
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json;charset=utf-8")
|
||||
|> post("/api/pleroma/admin/users/email_invite", %{email: recipient_email})
|
||||
|> json_response(:no_content)
|
||||
|
||||
token_record =
|
||||
Pleroma.UserInviteToken
|
||||
|> Repo.all()
|
||||
|> List.last()
|
||||
|
||||
assert token_record
|
||||
refute token_record.used
|
||||
|
||||
notify_email = Config.get([:instance, :notify_email])
|
||||
instance_name = Config.get([:instance, :name])
|
||||
|
||||
email =
|
||||
Pleroma.Emails.UserEmail.user_invitation_email(
|
||||
admin,
|
||||
token_record,
|
||||
recipient_email
|
||||
)
|
||||
|
||||
Swoosh.TestAssertions.assert_email_sent(
|
||||
from: {instance_name, notify_email},
|
||||
to: recipient_email,
|
||||
html_body: email.html_body
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
describe "POST /api/pleroma/admin/users/email_invite, with invalid config" do
|
||||
|
|
@ -637,7 +670,8 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
|
||||
conn = post(conn, "/api/pleroma/admin/users/email_invite?email=foo@bar.com&name=JD")
|
||||
|
||||
assert json_response(conn, :internal_server_error)
|
||||
assert json_response(conn, :bad_request) ==
|
||||
"To send invites you need to set the `invites_enabled` option to true."
|
||||
end
|
||||
|
||||
test "it returns 500 if `registrations_open` is enabled", %{conn: conn} do
|
||||
|
|
@ -646,7 +680,8 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
|
||||
conn = post(conn, "/api/pleroma/admin/users/email_invite?email=foo@bar.com&name=JD")
|
||||
|
||||
assert json_response(conn, :internal_server_error)
|
||||
assert json_response(conn, :bad_request) ==
|
||||
"To send invites you need to set the `registrations_open` option to false."
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -2075,7 +2110,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
|> get("/api/pleroma/admin/config")
|
||||
|> json_response(200)
|
||||
|
||||
refute Map.has_key?(configs, "need_reboot")
|
||||
assert configs["need_reboot"] == false
|
||||
end
|
||||
|
||||
test "update setting which need reboot, don't change reboot flag until reboot", %{conn: conn} do
|
||||
|
|
@ -2131,7 +2166,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
|> get("/api/pleroma/admin/config")
|
||||
|> json_response(200)
|
||||
|
||||
refute Map.has_key?(configs, "need_reboot")
|
||||
assert configs["need_reboot"] == false
|
||||
end
|
||||
|
||||
test "saving config with nested merge", %{conn: conn} do
|
||||
|
|
@ -2238,13 +2273,17 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
value: :erlang.term_to_binary([])
|
||||
)
|
||||
|
||||
Pleroma.Config.TransferTask.load_and_update_env([], false)
|
||||
|
||||
assert Application.get_env(:logger, :backends) == []
|
||||
|
||||
conn =
|
||||
post(conn, "/api/pleroma/admin/config", %{
|
||||
configs: [
|
||||
%{
|
||||
group: config.group,
|
||||
key: config.key,
|
||||
value: [":console", %{"tuple" => ["ExSyslogger", ":ex_syslogger"]}]
|
||||
value: [":console"]
|
||||
}
|
||||
]
|
||||
})
|
||||
|
|
@ -2255,8 +2294,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
"group" => ":logger",
|
||||
"key" => ":backends",
|
||||
"value" => [
|
||||
":console",
|
||||
%{"tuple" => ["ExSyslogger", ":ex_syslogger"]}
|
||||
":console"
|
||||
],
|
||||
"db" => [":backends"]
|
||||
}
|
||||
|
|
@ -2264,14 +2302,8 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
}
|
||||
|
||||
assert Application.get_env(:logger, :backends) == [
|
||||
:console,
|
||||
{ExSyslogger, :ex_syslogger}
|
||||
:console
|
||||
]
|
||||
|
||||
capture_log(fn ->
|
||||
require Logger
|
||||
Logger.warn("Ooops...")
|
||||
end) =~ "Ooops..."
|
||||
end
|
||||
|
||||
test "saving full setting if value is not keyword", %{conn: conn} do
|
||||
|
|
@ -2829,6 +2861,20 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
end
|
||||
end
|
||||
|
||||
test "need_reboot flag", %{conn: conn} do
|
||||
assert conn
|
||||
|> get("/api/pleroma/admin/need_reboot")
|
||||
|> json_response(200) == %{"need_reboot" => false}
|
||||
|
||||
Restarter.Pleroma.need_reboot()
|
||||
|
||||
assert conn
|
||||
|> get("/api/pleroma/admin/need_reboot")
|
||||
|> json_response(200) == %{"need_reboot" => true}
|
||||
|
||||
on_exit(fn -> Restarter.Pleroma.refresh() end)
|
||||
end
|
||||
|
||||
describe "GET /api/pleroma/admin/statuses" do
|
||||
test "returns all public and unlisted statuses", %{conn: conn, admin: admin} do
|
||||
blocked = insert(:user)
|
||||
|
|
@ -3471,6 +3517,191 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
response["status_visibility"]
|
||||
end
|
||||
end
|
||||
|
||||
describe "POST /api/pleroma/admin/oauth_app" do
|
||||
test "errors", %{conn: conn} do
|
||||
response = conn |> post("/api/pleroma/admin/oauth_app", %{}) |> json_response(200)
|
||||
|
||||
assert response == %{"name" => "can't be blank", "redirect_uris" => "can't be blank"}
|
||||
end
|
||||
|
||||
test "success", %{conn: conn} do
|
||||
base_url = Pleroma.Web.base_url()
|
||||
app_name = "Trusted app"
|
||||
|
||||
response =
|
||||
conn
|
||||
|> post("/api/pleroma/admin/oauth_app", %{
|
||||
name: app_name,
|
||||
redirect_uris: base_url
|
||||
})
|
||||
|> json_response(200)
|
||||
|
||||
assert %{
|
||||
"client_id" => _,
|
||||
"client_secret" => _,
|
||||
"name" => ^app_name,
|
||||
"redirect_uri" => ^base_url,
|
||||
"trusted" => false
|
||||
} = response
|
||||
end
|
||||
|
||||
test "with trusted", %{conn: conn} do
|
||||
base_url = Pleroma.Web.base_url()
|
||||
app_name = "Trusted app"
|
||||
|
||||
response =
|
||||
conn
|
||||
|> post("/api/pleroma/admin/oauth_app", %{
|
||||
name: app_name,
|
||||
redirect_uris: base_url,
|
||||
trusted: true
|
||||
})
|
||||
|> json_response(200)
|
||||
|
||||
assert %{
|
||||
"client_id" => _,
|
||||
"client_secret" => _,
|
||||
"name" => ^app_name,
|
||||
"redirect_uri" => ^base_url,
|
||||
"trusted" => true
|
||||
} = response
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET /api/pleroma/admin/oauth_app" do
|
||||
setup do
|
||||
app = insert(:oauth_app)
|
||||
{:ok, app: app}
|
||||
end
|
||||
|
||||
test "list", %{conn: conn} do
|
||||
response =
|
||||
conn
|
||||
|> get("/api/pleroma/admin/oauth_app")
|
||||
|> json_response(200)
|
||||
|
||||
assert %{"apps" => apps, "count" => count, "page_size" => _} = response
|
||||
|
||||
assert length(apps) == count
|
||||
end
|
||||
|
||||
test "with page size", %{conn: conn} do
|
||||
insert(:oauth_app)
|
||||
page_size = 1
|
||||
|
||||
response =
|
||||
conn
|
||||
|> get("/api/pleroma/admin/oauth_app", %{page_size: to_string(page_size)})
|
||||
|> json_response(200)
|
||||
|
||||
assert %{"apps" => apps, "count" => _, "page_size" => ^page_size} = response
|
||||
|
||||
assert length(apps) == page_size
|
||||
end
|
||||
|
||||
test "search by client name", %{conn: conn, app: app} do
|
||||
response =
|
||||
conn
|
||||
|> get("/api/pleroma/admin/oauth_app", %{name: app.client_name})
|
||||
|> json_response(200)
|
||||
|
||||
assert %{"apps" => [returned], "count" => _, "page_size" => _} = response
|
||||
|
||||
assert returned["client_id"] == app.client_id
|
||||
assert returned["name"] == app.client_name
|
||||
end
|
||||
|
||||
test "search by client id", %{conn: conn, app: app} do
|
||||
response =
|
||||
conn
|
||||
|> get("/api/pleroma/admin/oauth_app", %{client_id: app.client_id})
|
||||
|> json_response(200)
|
||||
|
||||
assert %{"apps" => [returned], "count" => _, "page_size" => _} = response
|
||||
|
||||
assert returned["client_id"] == app.client_id
|
||||
assert returned["name"] == app.client_name
|
||||
end
|
||||
|
||||
test "only trusted", %{conn: conn} do
|
||||
app = insert(:oauth_app, trusted: true)
|
||||
|
||||
response =
|
||||
conn
|
||||
|> get("/api/pleroma/admin/oauth_app", %{trusted: true})
|
||||
|> json_response(200)
|
||||
|
||||
assert %{"apps" => [returned], "count" => _, "page_size" => _} = response
|
||||
|
||||
assert returned["client_id"] == app.client_id
|
||||
assert returned["name"] == app.client_name
|
||||
end
|
||||
end
|
||||
|
||||
describe "DELETE /api/pleroma/admin/oauth_app/:id" do
|
||||
test "with id", %{conn: conn} do
|
||||
app = insert(:oauth_app)
|
||||
|
||||
response =
|
||||
conn
|
||||
|> delete("/api/pleroma/admin/oauth_app/" <> to_string(app.id))
|
||||
|> json_response(:no_content)
|
||||
|
||||
assert response == ""
|
||||
end
|
||||
|
||||
test "with non existance id", %{conn: conn} do
|
||||
response =
|
||||
conn
|
||||
|> delete("/api/pleroma/admin/oauth_app/0")
|
||||
|> json_response(:bad_request)
|
||||
|
||||
assert response == ""
|
||||
end
|
||||
end
|
||||
|
||||
describe "PATCH /api/pleroma/admin/oauth_app/:id" do
|
||||
test "with id", %{conn: conn} do
|
||||
app = insert(:oauth_app)
|
||||
|
||||
name = "another name"
|
||||
url = "https://example.com"
|
||||
scopes = ["admin"]
|
||||
id = app.id
|
||||
website = "http://website.com"
|
||||
|
||||
response =
|
||||
conn
|
||||
|> patch("/api/pleroma/admin/oauth_app/" <> to_string(app.id), %{
|
||||
name: name,
|
||||
trusted: true,
|
||||
redirect_uris: url,
|
||||
scopes: scopes,
|
||||
website: website
|
||||
})
|
||||
|> json_response(200)
|
||||
|
||||
assert %{
|
||||
"client_id" => _,
|
||||
"client_secret" => _,
|
||||
"id" => ^id,
|
||||
"name" => ^name,
|
||||
"redirect_uri" => ^url,
|
||||
"trusted" => true,
|
||||
"website" => ^website
|
||||
} = response
|
||||
end
|
||||
|
||||
test "without id", %{conn: conn} do
|
||||
response =
|
||||
conn
|
||||
|> patch("/api/pleroma/admin/oauth_app/0")
|
||||
|> json_response(:bad_request)
|
||||
|
||||
assert response == ""
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Needed for testing
|
||||
|
|
|
|||
45
test/web/api_spec/app_operation_test.exs
Normal file
45
test/web/api_spec/app_operation_test.exs
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Web.ApiSpec.AppOperationTest do
|
||||
use Pleroma.Web.ConnCase, async: true
|
||||
|
||||
alias Pleroma.Web.ApiSpec
|
||||
alias Pleroma.Web.ApiSpec.Schemas.AppCreateRequest
|
||||
alias Pleroma.Web.ApiSpec.Schemas.AppCreateResponse
|
||||
|
||||
import OpenApiSpex.TestAssertions
|
||||
import Pleroma.Factory
|
||||
|
||||
test "AppCreateRequest example matches schema" do
|
||||
api_spec = ApiSpec.spec()
|
||||
schema = AppCreateRequest.schema()
|
||||
assert_schema(schema.example, "AppCreateRequest", api_spec)
|
||||
end
|
||||
|
||||
test "AppCreateResponse example matches schema" do
|
||||
api_spec = ApiSpec.spec()
|
||||
schema = AppCreateResponse.schema()
|
||||
assert_schema(schema.example, "AppCreateResponse", api_spec)
|
||||
end
|
||||
|
||||
test "AppController produces a AppCreateResponse", %{conn: conn} do
|
||||
api_spec = ApiSpec.spec()
|
||||
app_attrs = build(:oauth_app)
|
||||
|
||||
json =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post(
|
||||
"/api/v1/apps",
|
||||
Jason.encode!(%{
|
||||
client_name: app_attrs.client_name,
|
||||
redirect_uris: app_attrs.redirect_uris
|
||||
})
|
||||
)
|
||||
|> json_response(200)
|
||||
|
||||
assert_schema(json, "AppCreateResponse", api_spec)
|
||||
end
|
||||
end
|
||||
49
test/web/auth/oauth_test_controller_test.exs
Normal file
49
test/web/auth/oauth_test_controller_test.exs
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Tests.OAuthTestControllerTest do
|
||||
use Pleroma.Web.ConnCase
|
||||
|
||||
import Pleroma.Factory
|
||||
|
||||
setup %{conn: conn} do
|
||||
user = insert(:user)
|
||||
conn = assign(conn, :user, user)
|
||||
%{conn: conn, user: user}
|
||||
end
|
||||
|
||||
test "missed_oauth", %{conn: conn} do
|
||||
res =
|
||||
conn
|
||||
|> get("/test/authenticated_api/missed_oauth")
|
||||
|> json_response(403)
|
||||
|
||||
assert res ==
|
||||
%{
|
||||
"error" =>
|
||||
"Security violation: OAuth scopes check was neither handled nor explicitly skipped."
|
||||
}
|
||||
end
|
||||
|
||||
test "skipped_oauth", %{conn: conn} do
|
||||
conn
|
||||
|> assign(:token, nil)
|
||||
|> get("/test/authenticated_api/skipped_oauth")
|
||||
|> json_response(200)
|
||||
end
|
||||
|
||||
test "performed_oauth", %{user: user} do
|
||||
%{conn: good_token_conn} = oauth_access(["read"], user: user)
|
||||
|
||||
good_token_conn
|
||||
|> get("/test/authenticated_api/performed_oauth")
|
||||
|> json_response(200)
|
||||
|
||||
%{conn: bad_token_conn} = oauth_access(["follow"], user: user)
|
||||
|
||||
bad_token_conn
|
||||
|> get("/test/authenticated_api/performed_oauth")
|
||||
|> json_response(403)
|
||||
end
|
||||
end
|
||||
|
|
@ -97,18 +97,6 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
assert Object.normalize(activity).data["emoji"]["firefox"]
|
||||
end
|
||||
|
||||
test "it adds emoji when updating profiles" do
|
||||
user = insert(:user, %{name: ":firefox:"})
|
||||
|
||||
{:ok, activity} = CommonAPI.update(user)
|
||||
user = User.get_cached_by_ap_id(user.ap_id)
|
||||
[firefox] = user.source_data["tag"]
|
||||
|
||||
assert firefox["name"] == ":firefox:"
|
||||
|
||||
assert Pleroma.Constants.as_public() in activity.recipients
|
||||
end
|
||||
|
||||
describe "posting" do
|
||||
test "it supports explicit addressing" do
|
||||
user = insert(:user)
|
||||
|
|
@ -565,7 +553,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
assert {:ok, follower, followed, %{id: activity_id, data: %{"state" => "pending"}}} =
|
||||
CommonAPI.follow(follower, followed)
|
||||
|
||||
assert User.get_follow_state(follower, followed) == "pending"
|
||||
assert User.get_follow_state(follower, followed) == :follow_pending
|
||||
assert {:ok, follower} = CommonAPI.unfollow(follower, followed)
|
||||
assert User.get_follow_state(follower, followed) == nil
|
||||
|
||||
|
|
@ -587,7 +575,7 @@ defmodule Pleroma.Web.CommonAPITest do
|
|||
assert {:ok, follower, followed, %{id: activity_id, data: %{"state" => "pending"}}} =
|
||||
CommonAPI.follow(follower, followed)
|
||||
|
||||
assert User.get_follow_state(follower, followed) == "pending"
|
||||
assert User.get_follow_state(follower, followed) == :follow_pending
|
||||
assert {:ok, follower} = CommonAPI.unfollow(follower, followed)
|
||||
assert User.get_follow_state(follower, followed) == nil
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ defmodule Pleroma.Web.CommonAPI.UtilsTest do
|
|||
alias Pleroma.Object
|
||||
alias Pleroma.Web.CommonAPI
|
||||
alias Pleroma.Web.CommonAPI.Utils
|
||||
alias Pleroma.Web.Endpoint
|
||||
use Pleroma.DataCase
|
||||
|
||||
import ExUnit.CaptureLog
|
||||
|
|
@ -42,28 +41,6 @@ defmodule Pleroma.Web.CommonAPI.UtilsTest do
|
|||
end
|
||||
end
|
||||
|
||||
test "parses emoji from name and bio" do
|
||||
{:ok, user} = UserBuilder.insert(%{name: ":blank:", bio: ":firefox:"})
|
||||
|
||||
expected = [
|
||||
%{
|
||||
"type" => "Emoji",
|
||||
"icon" => %{"type" => "Image", "url" => "#{Endpoint.url()}/emoji/Firefox.gif"},
|
||||
"name" => ":firefox:"
|
||||
},
|
||||
%{
|
||||
"type" => "Emoji",
|
||||
"icon" => %{
|
||||
"type" => "Image",
|
||||
"url" => "#{Endpoint.url()}/emoji/blank.png"
|
||||
},
|
||||
"name" => ":blank:"
|
||||
}
|
||||
]
|
||||
|
||||
assert expected == Utils.emoji_from_profile(user)
|
||||
end
|
||||
|
||||
describe "format_input/3" do
|
||||
test "works for bare text/plain" do
|
||||
text = "hello world!"
|
||||
|
|
@ -159,11 +136,11 @@ defmodule Pleroma.Web.CommonAPI.UtilsTest do
|
|||
{output, _, _} = Utils.format_input(text, "text/markdown")
|
||||
|
||||
assert output ==
|
||||
~s(<p><strong>hello world</strong></p><p><em>another <span class="h-card"><a data-user="#{
|
||||
~s(<p><strong>hello world</strong></p><p><em>another <span class="h-card"><a class="u-url mention" data-user="#{
|
||||
user.id
|
||||
}" class="u-url mention" href="http://foo.com/user__test" rel="ugc">@<span>user__test</span></a></span> and <span class="h-card"><a data-user="#{
|
||||
}" href="http://foo.com/user__test" rel="ugc">@<span>user__test</span></a></span> and <span class="h-card"><a class="u-url mention" data-user="#{
|
||||
user.id
|
||||
}" class="u-url mention" href="http://foo.com/user__test" rel="ugc">@<span>user__test</span></a></span> <a href="http://google.com" rel="ugc">google.com</a> paragraph</em></p>)
|
||||
}" href="http://foo.com/user__test" rel="ugc">@<span>user__test</span></a></span> <a href="http://google.com" rel="ugc">google.com</a> paragraph</em></p>)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ defmodule Pleroma.Web.FederatorTest do
|
|||
local: false,
|
||||
nickname: "nick1@domain.com",
|
||||
ap_id: "https://domain.com/users/nick1",
|
||||
source_data: %{"inbox" => inbox1},
|
||||
inbox: inbox1,
|
||||
ap_enabled: true
|
||||
})
|
||||
|
||||
|
|
@ -86,7 +86,7 @@ defmodule Pleroma.Web.FederatorTest do
|
|||
local: false,
|
||||
nickname: "nick2@domain2.com",
|
||||
ap_id: "https://domain2.com/users/nick2",
|
||||
source_data: %{"inbox" => inbox2},
|
||||
inbox: inbox2,
|
||||
ap_enabled: true
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -150,8 +150,8 @@ defmodule Pleroma.Web.Feed.TagControllerTest do
|
|||
obj2 = Object.normalize(activity2)
|
||||
|
||||
assert xpath(xml, ~x"//channel/item/description/text()"sl) == [
|
||||
HtmlEntities.decode(FeedView.activity_content(obj2)),
|
||||
HtmlEntities.decode(FeedView.activity_content(obj1))
|
||||
HtmlEntities.decode(FeedView.activity_content(obj2.data)),
|
||||
HtmlEntities.decode(FeedView.activity_content(obj1.data))
|
||||
]
|
||||
|
||||
response =
|
||||
|
|
|
|||
|
|
@ -82,9 +82,9 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIController.UpdateCredentialsTest do
|
|||
assert user_data = json_response(conn, 200)
|
||||
|
||||
assert user_data["note"] ==
|
||||
~s(I drink <a class="hashtag" data-tag="cofe" href="http://localhost:4001/tag/cofe">#cofe</a> with <span class="h-card"><a data-user="#{
|
||||
~s(I drink <a class="hashtag" data-tag="cofe" href="http://localhost:4001/tag/cofe">#cofe</a> with <span class="h-card"><a class="u-url mention" data-user="#{
|
||||
user2.id
|
||||
}" class="u-url mention" href="#{user2.ap_id}" rel="ugc">@<span>#{user2.nickname}</span></a></span><br/><br/>suya..)
|
||||
}" href="#{user2.ap_id}" rel="ugc">@<span>#{user2.nickname}</span></a></span><br/><br/>suya..)
|
||||
end
|
||||
|
||||
test "updates the user's locking status", %{conn: conn} do
|
||||
|
|
|
|||
|
|
@ -794,7 +794,9 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
|
||||
test "Account registration via Application", %{conn: conn} do
|
||||
conn =
|
||||
post(conn, "/api/v1/apps", %{
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("/api/v1/apps", %{
|
||||
client_name: "client_name",
|
||||
redirect_uris: "urn:ietf:wg:oauth:2.0:oob",
|
||||
scopes: "read, write, follow"
|
||||
|
|
@ -942,6 +944,73 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
res = post(conn, "/api/v1/accounts", valid_params)
|
||||
assert json_response(res, 403) == %{"error" => "Invalid credentials"}
|
||||
end
|
||||
|
||||
test "registration from trusted app" do
|
||||
clear_config([Pleroma.Captcha, :enabled], true)
|
||||
app = insert(:oauth_app, trusted: true, scopes: ["read", "write", "follow", "push"])
|
||||
|
||||
conn =
|
||||
build_conn()
|
||||
|> post("/oauth/token", %{
|
||||
"grant_type" => "client_credentials",
|
||||
"client_id" => app.client_id,
|
||||
"client_secret" => app.client_secret
|
||||
})
|
||||
|
||||
assert %{"access_token" => token, "token_type" => "Bearer"} = json_response(conn, 200)
|
||||
|
||||
response =
|
||||
build_conn()
|
||||
|> Plug.Conn.put_req_header("authorization", "Bearer " <> token)
|
||||
|> post("/api/v1/accounts", %{
|
||||
nickname: "nickanme",
|
||||
agreement: true,
|
||||
email: "email@example.com",
|
||||
fullname: "Lain",
|
||||
username: "Lain",
|
||||
password: "some_password",
|
||||
confirm: "some_password"
|
||||
})
|
||||
|> json_response(200)
|
||||
|
||||
assert %{
|
||||
"access_token" => access_token,
|
||||
"created_at" => _,
|
||||
"scope" => ["read", "write", "follow", "push"],
|
||||
"token_type" => "Bearer"
|
||||
} = response
|
||||
|
||||
response =
|
||||
build_conn()
|
||||
|> Plug.Conn.put_req_header("authorization", "Bearer " <> access_token)
|
||||
|> get("/api/v1/accounts/verify_credentials")
|
||||
|> json_response(200)
|
||||
|
||||
assert %{
|
||||
"acct" => "Lain",
|
||||
"bot" => false,
|
||||
"display_name" => "Lain",
|
||||
"follow_requests_count" => 0,
|
||||
"followers_count" => 0,
|
||||
"following_count" => 0,
|
||||
"locked" => false,
|
||||
"note" => "",
|
||||
"source" => %{
|
||||
"fields" => [],
|
||||
"note" => "",
|
||||
"pleroma" => %{
|
||||
"actor_type" => "Person",
|
||||
"discoverable" => false,
|
||||
"no_rich_text" => false,
|
||||
"show_role" => true
|
||||
},
|
||||
"privacy" => "public",
|
||||
"sensitive" => false
|
||||
},
|
||||
"statuses_count" => 0,
|
||||
"username" => "Lain"
|
||||
} = response
|
||||
end
|
||||
end
|
||||
|
||||
describe "create account by app / rate limit" do
|
||||
|
|
|
|||
|
|
@ -16,8 +16,7 @@ defmodule Pleroma.Web.MastodonAPI.AppControllerTest do
|
|||
|
||||
conn =
|
||||
conn
|
||||
|> assign(:user, token.user)
|
||||
|> assign(:token, token)
|
||||
|> put_req_header("authorization", "Bearer #{token.token}")
|
||||
|> get("/api/v1/apps/verify_credentials")
|
||||
|
||||
app = Repo.preload(token, :app).app
|
||||
|
|
@ -37,6 +36,7 @@ defmodule Pleroma.Web.MastodonAPI.AppControllerTest do
|
|||
|
||||
conn =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> assign(:user, user)
|
||||
|> post("/api/v1/apps", %{
|
||||
client_name: app_attrs.client_name,
|
||||
|
|
|
|||
|
|
@ -6,20 +6,29 @@ defmodule Pleroma.Web.MastodonAPI.DomainBlockControllerTest do
|
|||
use Pleroma.Web.ConnCase
|
||||
|
||||
alias Pleroma.User
|
||||
alias Pleroma.Web.ApiSpec
|
||||
alias Pleroma.Web.ApiSpec.Schemas.DomainBlocksResponse
|
||||
|
||||
import Pleroma.Factory
|
||||
import OpenApiSpex.TestAssertions
|
||||
|
||||
test "blocking / unblocking a domain" do
|
||||
%{user: user, conn: conn} = oauth_access(["write:blocks"])
|
||||
other_user = insert(:user, %{ap_id: "https://dogwhistle.zone/@pundit"})
|
||||
|
||||
ret_conn = post(conn, "/api/v1/domain_blocks", %{"domain" => "dogwhistle.zone"})
|
||||
ret_conn =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("/api/v1/domain_blocks", %{"domain" => "dogwhistle.zone"})
|
||||
|
||||
assert %{} = json_response(ret_conn, 200)
|
||||
user = User.get_cached_by_ap_id(user.ap_id)
|
||||
assert User.blocks?(user, other_user)
|
||||
|
||||
ret_conn = delete(conn, "/api/v1/domain_blocks", %{"domain" => "dogwhistle.zone"})
|
||||
ret_conn =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> delete("/api/v1/domain_blocks", %{"domain" => "dogwhistle.zone"})
|
||||
|
||||
assert %{} = json_response(ret_conn, 200)
|
||||
user = User.get_cached_by_ap_id(user.ap_id)
|
||||
|
|
@ -41,5 +50,12 @@ defmodule Pleroma.Web.MastodonAPI.DomainBlockControllerTest do
|
|||
|
||||
assert "bad.site" in domain_blocks
|
||||
assert "even.worse.site" in domain_blocks
|
||||
assert_schema(domain_blocks, "DomainBlocksResponse", ApiSpec.spec())
|
||||
end
|
||||
|
||||
test "DomainBlocksResponse example matches schema" do
|
||||
api_spec = ApiSpec.spec()
|
||||
schema = DomainBlocksResponse.schema()
|
||||
assert_schema(schema.example, "DomainBlocksResponse", api_spec)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ defmodule Pleroma.Web.MastodonAPI.FollowRequestControllerTest do
|
|||
other_user = insert(:user)
|
||||
|
||||
{:ok, _activity} = ActivityPub.follow(other_user, user)
|
||||
{:ok, other_user} = User.follow(other_user, user, "pending")
|
||||
{:ok, other_user} = User.follow(other_user, user, :follow_pending)
|
||||
|
||||
assert User.following?(other_user, user) == false
|
||||
|
||||
|
|
@ -35,7 +35,7 @@ defmodule Pleroma.Web.MastodonAPI.FollowRequestControllerTest do
|
|||
other_user = insert(:user)
|
||||
|
||||
{:ok, _activity} = ActivityPub.follow(other_user, user)
|
||||
{:ok, other_user} = User.follow(other_user, user, "pending")
|
||||
{:ok, other_user} = User.follow(other_user, user, :follow_pending)
|
||||
|
||||
user = User.get_cached_by_id(user.id)
|
||||
other_user = User.get_cached_by_id(other_user.id)
|
||||
|
|
|
|||
|
|
@ -12,6 +12,26 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do
|
|||
|
||||
import Pleroma.Factory
|
||||
|
||||
test "does NOT render account/pleroma/relationship if this is disabled by default" do
|
||||
clear_config([:extensions, :output_relationships_in_statuses_by_default], false)
|
||||
|
||||
%{user: user, conn: conn} = oauth_access(["read:notifications"])
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(other_user, %{"status" => "hi @#{user.nickname}"})
|
||||
{:ok, [_notification]} = Notification.create_notifications(activity)
|
||||
|
||||
response =
|
||||
conn
|
||||
|> assign(:user, user)
|
||||
|> get("/api/v1/notifications")
|
||||
|> json_response(200)
|
||||
|
||||
assert Enum.all?(response, fn n ->
|
||||
get_in(n, ["account", "pleroma", "relationship"]) == %{}
|
||||
end)
|
||||
end
|
||||
|
||||
test "list of notifications" do
|
||||
%{user: user, conn: conn} = oauth_access(["read:notifications"])
|
||||
other_user = insert(:user)
|
||||
|
|
@ -26,7 +46,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do
|
|||
|> get("/api/v1/notifications")
|
||||
|
||||
expected_response =
|
||||
"hi <span class=\"h-card\"><a data-user=\"#{user.id}\" class=\"u-url mention\" href=\"#{
|
||||
"hi <span class=\"h-card\"><a class=\"u-url mention\" data-user=\"#{user.id}\" href=\"#{
|
||||
user.ap_id
|
||||
}\" rel=\"ugc\">@<span>#{user.nickname}</span></a></span>"
|
||||
|
||||
|
|
@ -45,7 +65,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do
|
|||
conn = get(conn, "/api/v1/notifications/#{notification.id}")
|
||||
|
||||
expected_response =
|
||||
"hi <span class=\"h-card\"><a data-user=\"#{user.id}\" class=\"u-url mention\" href=\"#{
|
||||
"hi <span class=\"h-card\"><a class=\"u-url mention\" data-user=\"#{user.id}\" href=\"#{
|
||||
user.ap_id
|
||||
}\" rel=\"ugc\">@<span>#{user.nickname}</span></a></span>"
|
||||
|
||||
|
|
@ -53,6 +73,22 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do
|
|||
assert response == expected_response
|
||||
end
|
||||
|
||||
test "dismissing a single notification (deprecated endpoint)" do
|
||||
%{user: user, conn: conn} = oauth_access(["write:notifications"])
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(other_user, %{"status" => "hi @#{user.nickname}"})
|
||||
|
||||
{:ok, [notification]} = Notification.create_notifications(activity)
|
||||
|
||||
conn =
|
||||
conn
|
||||
|> assign(:user, user)
|
||||
|> post("/api/v1/notifications/dismiss", %{"id" => notification.id})
|
||||
|
||||
assert %{} = json_response(conn, 200)
|
||||
end
|
||||
|
||||
test "dismissing a single notification" do
|
||||
%{user: user, conn: conn} = oauth_access(["write:notifications"])
|
||||
other_user = insert(:user)
|
||||
|
|
@ -64,7 +100,7 @@ defmodule Pleroma.Web.MastodonAPI.NotificationControllerTest do
|
|||
conn =
|
||||
conn
|
||||
|> assign(:user, user)
|
||||
|> post("/api/v1/notifications/dismiss", %{"id" => notification.id})
|
||||
|> post("/api/v1/notifications/#{notification.id}/dismiss")
|
||||
|
||||
assert %{} = json_response(conn, 200)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1047,6 +1047,8 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||
end
|
||||
|
||||
test "bookmarks" do
|
||||
bookmarks_uri = "/api/v1/bookmarks?with_relationships=true"
|
||||
|
||||
%{conn: conn} = oauth_access(["write:bookmarks", "read:bookmarks"])
|
||||
author = insert(:user)
|
||||
|
||||
|
|
@ -1068,7 +1070,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||
|
||||
assert json_response(response2, 200)["bookmarked"] == true
|
||||
|
||||
bookmarks = get(conn, "/api/v1/bookmarks")
|
||||
bookmarks = get(conn, bookmarks_uri)
|
||||
|
||||
assert [json_response(response2, 200), json_response(response1, 200)] ==
|
||||
json_response(bookmarks, 200)
|
||||
|
|
@ -1077,7 +1079,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusControllerTest do
|
|||
|
||||
assert json_response(response1, 200)["bookmarked"] == false
|
||||
|
||||
bookmarks = get(conn, "/api/v1/bookmarks")
|
||||
bookmarks = get(conn, bookmarks_uri)
|
||||
|
||||
assert [json_response(response2, 200)] == json_response(bookmarks, 200)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -7,34 +7,8 @@ defmodule Pleroma.Web.MastodonAPI.SuggestionControllerTest do
|
|||
|
||||
alias Pleroma.Config
|
||||
|
||||
import Pleroma.Factory
|
||||
import Tesla.Mock
|
||||
|
||||
setup do: oauth_access(["read"])
|
||||
|
||||
setup %{user: user} do
|
||||
other_user = insert(:user)
|
||||
host = Config.get([Pleroma.Web.Endpoint, :url, :host])
|
||||
url500 = "http://test500?#{host}&#{user.nickname}"
|
||||
url200 = "http://test200?#{host}&#{user.nickname}"
|
||||
|
||||
mock(fn
|
||||
%{method: :get, url: ^url500} ->
|
||||
%Tesla.Env{status: 500, body: "bad request"}
|
||||
|
||||
%{method: :get, url: ^url200} ->
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
body:
|
||||
~s([{"acct":"yj455","avatar":"https://social.heldscal.la/avatar/201.jpeg","avatar_static":"https://social.heldscal.la/avatar/s/201.jpeg"}, {"acct":"#{
|
||||
other_user.ap_id
|
||||
}","avatar":"https://social.heldscal.la/avatar/202.jpeg","avatar_static":"https://social.heldscal.la/avatar/s/202.jpeg"}])
|
||||
}
|
||||
end)
|
||||
|
||||
[other_user: other_user]
|
||||
end
|
||||
|
||||
test "returns empty result", %{conn: conn} do
|
||||
res =
|
||||
conn
|
||||
|
|
|
|||
|
|
@ -20,7 +20,30 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
|
|||
describe "home" do
|
||||
setup do: oauth_access(["read:statuses"])
|
||||
|
||||
test "does NOT render account/pleroma/relationship if this is disabled by default", %{
|
||||
user: user,
|
||||
conn: conn
|
||||
} do
|
||||
clear_config([:extensions, :output_relationships_in_statuses_by_default], false)
|
||||
|
||||
other_user = insert(:user)
|
||||
|
||||
{:ok, _} = CommonAPI.post(other_user, %{"status" => "hi @#{user.nickname}"})
|
||||
|
||||
response =
|
||||
conn
|
||||
|> assign(:user, user)
|
||||
|> get("/api/v1/timelines/home")
|
||||
|> json_response(200)
|
||||
|
||||
assert Enum.all?(response, fn n ->
|
||||
get_in(n, ["account", "pleroma", "relationship"]) == %{}
|
||||
end)
|
||||
end
|
||||
|
||||
test "the home timeline", %{user: user, conn: conn} do
|
||||
uri = "/api/v1/timelines/home?with_relationships=true"
|
||||
|
||||
following = insert(:user, nickname: "followed")
|
||||
third_user = insert(:user, nickname: "repeated")
|
||||
|
||||
|
|
@ -28,13 +51,13 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
|
|||
{:ok, activity} = CommonAPI.post(third_user, %{"status" => "repeated post"})
|
||||
{:ok, _, _} = CommonAPI.repeat(activity.id, following)
|
||||
|
||||
ret_conn = get(conn, "/api/v1/timelines/home")
|
||||
ret_conn = get(conn, uri)
|
||||
|
||||
assert Enum.empty?(json_response(ret_conn, :ok))
|
||||
|
||||
{:ok, _user} = User.follow(user, following)
|
||||
|
||||
ret_conn = get(conn, "/api/v1/timelines/home")
|
||||
ret_conn = get(conn, uri)
|
||||
|
||||
assert [
|
||||
%{
|
||||
|
|
@ -59,7 +82,7 @@ defmodule Pleroma.Web.MastodonAPI.TimelineControllerTest do
|
|||
|
||||
{:ok, _user} = User.follow(third_user, user)
|
||||
|
||||
ret_conn = get(conn, "/api/v1/timelines/home")
|
||||
ret_conn = get(conn, uri)
|
||||
|
||||
assert [
|
||||
%{
|
||||
|
|
|
|||
|
|
@ -19,16 +19,6 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
|
|||
end
|
||||
|
||||
test "Represent a user account" do
|
||||
source_data = %{
|
||||
"tag" => [
|
||||
%{
|
||||
"type" => "Emoji",
|
||||
"icon" => %{"url" => "/file.png"},
|
||||
"name" => ":karjalanpiirakka:"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
background_image = %{
|
||||
"url" => [%{"href" => "https://example.com/images/asuka_hospital.png"}]
|
||||
}
|
||||
|
|
@ -37,13 +27,13 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
|
|||
insert(:user, %{
|
||||
follower_count: 3,
|
||||
note_count: 5,
|
||||
source_data: source_data,
|
||||
background: background_image,
|
||||
nickname: "shp@shitposter.club",
|
||||
name: ":karjalanpiirakka: shp",
|
||||
bio:
|
||||
"<script src=\"invalid-html\"></script><span>valid html</span>. a<br>b<br/>c<br >d<br />f",
|
||||
inserted_at: ~N[2017-08-15 15:47:06.597036]
|
||||
inserted_at: ~N[2017-08-15 15:47:06.597036],
|
||||
emoji: %{"karjalanpiirakka" => "/file.png"}
|
||||
})
|
||||
|
||||
expected = %{
|
||||
|
|
@ -117,7 +107,6 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
|
|||
insert(:user, %{
|
||||
follower_count: 3,
|
||||
note_count: 5,
|
||||
source_data: %{},
|
||||
actor_type: "Service",
|
||||
nickname: "shp@shitposter.club",
|
||||
inserted_at: ~N[2017-08-15 15:47:06.597036]
|
||||
|
|
@ -311,7 +300,6 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
|
|||
insert(:user, %{
|
||||
follower_count: 0,
|
||||
note_count: 5,
|
||||
source_data: %{},
|
||||
actor_type: "Service",
|
||||
nickname: "shp@shitposter.club",
|
||||
inserted_at: ~N[2017-08-15 15:47:06.597036]
|
||||
|
|
|
|||
|
|
@ -169,6 +169,23 @@ defmodule Pleroma.Web.PleromaAPI.PleromaAPIControllerTest do
|
|||
id_one = activity.id
|
||||
id_two = activity_two.id
|
||||
assert [%{"id" => ^id_one}, %{"id" => ^id_two}] = result
|
||||
|
||||
{:ok, %{id: id_three}} =
|
||||
CommonAPI.post(other_user, %{
|
||||
"status" => "Bye!",
|
||||
"in_reply_to_status_id" => activity.id,
|
||||
"in_reply_to_conversation_id" => participation.id
|
||||
})
|
||||
|
||||
assert [%{"id" => ^id_two}, %{"id" => ^id_three}] =
|
||||
conn
|
||||
|> get("/api/v1/pleroma/conversations/#{participation.id}/statuses?limit=2")
|
||||
|> json_response(:ok)
|
||||
|
||||
assert [%{"id" => ^id_three}] =
|
||||
conn
|
||||
|> get("/api/v1/pleroma/conversations/#{participation.id}/statuses?min_id=#{id_two}")
|
||||
|> json_response(:ok)
|
||||
end
|
||||
|
||||
test "PATCH /api/v1/pleroma/conversations/:id" do
|
||||
|
|
@ -203,7 +220,7 @@ defmodule Pleroma.Web.PleromaAPI.PleromaAPIControllerTest do
|
|||
|
||||
test "POST /api/v1/pleroma/conversations/read" do
|
||||
user = insert(:user)
|
||||
%{user: other_user, conn: conn} = oauth_access(["write:notifications"])
|
||||
%{user: other_user, conn: conn} = oauth_access(["write:conversations"])
|
||||
|
||||
{:ok, _activity} =
|
||||
CommonAPI.post(user, %{"status" => "Hi @#{other_user.nickname}", "visibility" => "direct"})
|
||||
|
|
|
|||
|
|
@ -209,7 +209,7 @@ defmodule Pleroma.Web.StreamerTest do
|
|||
Pleroma.Config.put([:instance, :skip_thread_containment], false)
|
||||
author = insert(:user)
|
||||
user = insert(:user)
|
||||
User.follow(user, author, "accept")
|
||||
User.follow(user, author, :follow_accept)
|
||||
|
||||
activity =
|
||||
insert(:note_activity,
|
||||
|
|
@ -232,7 +232,7 @@ defmodule Pleroma.Web.StreamerTest do
|
|||
Pleroma.Config.put([:instance, :skip_thread_containment], true)
|
||||
author = insert(:user)
|
||||
user = insert(:user)
|
||||
User.follow(user, author, "accept")
|
||||
User.follow(user, author, :follow_accept)
|
||||
|
||||
activity =
|
||||
insert(:note_activity,
|
||||
|
|
@ -255,7 +255,7 @@ defmodule Pleroma.Web.StreamerTest do
|
|||
Pleroma.Config.put([:instance, :skip_thread_containment], false)
|
||||
author = insert(:user)
|
||||
user = insert(:user, skip_thread_containment: true)
|
||||
User.follow(user, author, "accept")
|
||||
User.follow(user, author, :follow_accept)
|
||||
|
||||
activity =
|
||||
insert(:note_activity,
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
|
|||
{:ok, user2} = TwitterAPI.register_user(data2)
|
||||
|
||||
expected_text =
|
||||
~s(<span class="h-card"><a data-user="#{user1.id}" class="u-url mention" href="#{
|
||||
~s(<span class="h-card"><a class="u-url mention" data-user="#{user1.id}" href="#{
|
||||
user1.ap_id
|
||||
}" rel="ugc">@<span>john</span></a></span> test)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue