changes after rebase
This commit is contained in:
parent
1d0e130cb3
commit
c4c5caedd8
17 changed files with 2 additions and 3 deletions
101
test/pleroma/gun/connection_pool_test.exs
Normal file
101
test/pleroma/gun/connection_pool_test.exs
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Gun.ConnectionPoolTest do
|
||||
use Pleroma.DataCase
|
||||
|
||||
import Mox
|
||||
import ExUnit.CaptureLog
|
||||
alias Pleroma.Config
|
||||
alias Pleroma.Gun.ConnectionPool
|
||||
|
||||
defp gun_mock(_) do
|
||||
Pleroma.GunMock
|
||||
|> stub(:open, fn _, _, _ -> Task.start_link(fn -> Process.sleep(100) end) end)
|
||||
|> stub(:await_up, fn _, _ -> {:ok, :http} end)
|
||||
|> stub(:set_owner, fn _, _ -> :ok end)
|
||||
|
||||
:ok
|
||||
end
|
||||
|
||||
setup :set_mox_from_context
|
||||
setup :gun_mock
|
||||
|
||||
test "gives the same connection to 2 concurrent requests" do
|
||||
Enum.map(
|
||||
[
|
||||
"http://www.korean-books.com.kp/KBMbooks/en/periodic/pictorial/20200530163914.pdf",
|
||||
"http://www.korean-books.com.kp/KBMbooks/en/periodic/pictorial/20200528183427.pdf"
|
||||
],
|
||||
fn uri ->
|
||||
uri = URI.parse(uri)
|
||||
task_parent = self()
|
||||
|
||||
Task.start_link(fn ->
|
||||
{:ok, conn} = ConnectionPool.get_conn(uri, [])
|
||||
ConnectionPool.release_conn(conn)
|
||||
send(task_parent, conn)
|
||||
end)
|
||||
end
|
||||
)
|
||||
|
||||
[pid, pid] =
|
||||
for _ <- 1..2 do
|
||||
receive do
|
||||
pid -> pid
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
test "connection limit is respected with concurrent requests" do
|
||||
clear_config([:connections_pool, :max_connections]) do
|
||||
Config.put([:connections_pool, :max_connections], 1)
|
||||
# The supervisor needs a reboot to apply the new config setting
|
||||
Process.exit(Process.whereis(Pleroma.Gun.ConnectionPool.WorkerSupervisor), :kill)
|
||||
|
||||
on_exit(fn ->
|
||||
Process.exit(Process.whereis(Pleroma.Gun.ConnectionPool.WorkerSupervisor), :kill)
|
||||
end)
|
||||
end
|
||||
|
||||
capture_log(fn ->
|
||||
Enum.map(
|
||||
[
|
||||
"https://ninenines.eu/",
|
||||
"https://youtu.be/PFGwMiDJKNY"
|
||||
],
|
||||
fn uri ->
|
||||
uri = URI.parse(uri)
|
||||
task_parent = self()
|
||||
|
||||
Task.start_link(fn ->
|
||||
result = ConnectionPool.get_conn(uri, [])
|
||||
# Sleep so that we don't end up with a situation,
|
||||
# where request from the second process gets processed
|
||||
# only after the first process already released the connection
|
||||
Process.sleep(50)
|
||||
|
||||
case result do
|
||||
{:ok, pid} ->
|
||||
ConnectionPool.release_conn(pid)
|
||||
|
||||
_ ->
|
||||
nil
|
||||
end
|
||||
|
||||
send(task_parent, result)
|
||||
end)
|
||||
end
|
||||
)
|
||||
|
||||
[{:error, :pool_full}, {:ok, _pid}] =
|
||||
for _ <- 1..2 do
|
||||
receive do
|
||||
result -> result
|
||||
end
|
||||
end
|
||||
|> Enum.sort()
|
||||
end)
|
||||
end
|
||||
end
|
||||
72
test/pleroma/repo/migrations/autolinker_to_linkify_test.exs
Normal file
72
test/pleroma/repo/migrations/autolinker_to_linkify_test.exs
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Repo.Migrations.AutolinkerToLinkifyTest do
|
||||
use Pleroma.DataCase
|
||||
import Pleroma.Factory
|
||||
import Pleroma.Tests.Helpers
|
||||
alias Pleroma.ConfigDB
|
||||
|
||||
setup do: clear_config(Pleroma.Formatter)
|
||||
setup_all do: require_migration("20200716195806_autolinker_to_linkify")
|
||||
|
||||
test "change/0 converts auto_linker opts for Pleroma.Formatter", %{migration: migration} do
|
||||
autolinker_opts = [
|
||||
extra: true,
|
||||
validate_tld: true,
|
||||
class: false,
|
||||
strip_prefix: false,
|
||||
new_window: false,
|
||||
rel: "testing"
|
||||
]
|
||||
|
||||
insert(:config, group: :auto_linker, key: :opts, value: autolinker_opts)
|
||||
|
||||
migration.change()
|
||||
|
||||
assert nil == ConfigDB.get_by_params(%{group: :auto_linker, key: :opts})
|
||||
|
||||
%{value: new_opts} = ConfigDB.get_by_params(%{group: :pleroma, key: Pleroma.Formatter})
|
||||
|
||||
assert new_opts == [
|
||||
class: false,
|
||||
extra: true,
|
||||
new_window: false,
|
||||
rel: "testing",
|
||||
strip_prefix: false
|
||||
]
|
||||
|
||||
Pleroma.Config.put(Pleroma.Formatter, new_opts)
|
||||
assert new_opts == Pleroma.Config.get(Pleroma.Formatter)
|
||||
|
||||
{text, _mentions, []} =
|
||||
Pleroma.Formatter.linkify(
|
||||
"https://www.businessinsider.com/walmart-will-close-stores-on-thanksgiving-ending-black-friday-tradition-2020-7\n\nOmg will COVID finally end Black Friday???"
|
||||
)
|
||||
|
||||
assert text ==
|
||||
"<a href=\"https://www.businessinsider.com/walmart-will-close-stores-on-thanksgiving-ending-black-friday-tradition-2020-7\" rel=\"testing\">https://www.businessinsider.com/walmart-will-close-stores-on-thanksgiving-ending-black-friday-tradition-2020-7</a>\n\nOmg will COVID finally end Black Friday???"
|
||||
end
|
||||
|
||||
test "transform_opts/1 returns a list of compatible opts", %{migration: migration} do
|
||||
old_opts = [
|
||||
extra: true,
|
||||
validate_tld: true,
|
||||
class: false,
|
||||
strip_prefix: false,
|
||||
new_window: false,
|
||||
rel: "qqq"
|
||||
]
|
||||
|
||||
expected_opts = [
|
||||
class: false,
|
||||
extra: true,
|
||||
new_window: false,
|
||||
rel: "qqq",
|
||||
strip_prefix: false
|
||||
]
|
||||
|
||||
assert migration.transform_opts(old_opts) == expected_opts
|
||||
end
|
||||
end
|
||||
28
test/pleroma/repo/migrations/fix_legacy_tags_test.exs
Normal file
28
test/pleroma/repo/migrations/fix_legacy_tags_test.exs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Repo.Migrations.FixLegacyTagsTest do
|
||||
alias Pleroma.User
|
||||
use Pleroma.DataCase
|
||||
import Pleroma.Factory
|
||||
import Pleroma.Tests.Helpers
|
||||
|
||||
setup_all do: require_migration("20200802170532_fix_legacy_tags")
|
||||
|
||||
test "change/0 converts legacy user tags into correct values", %{migration: migration} do
|
||||
user = insert(:user, tags: ["force_nsfw", "force_unlisted", "verified"])
|
||||
user2 = insert(:user)
|
||||
|
||||
assert :ok == migration.change()
|
||||
|
||||
fixed_user = User.get_by_id(user.id)
|
||||
fixed_user2 = User.get_by_id(user2.id)
|
||||
|
||||
assert fixed_user.tags == ["mrf_tag:media-force-nsfw", "mrf_tag:force-unlisted", "verified"]
|
||||
assert fixed_user2.tags == []
|
||||
|
||||
# user2 should not have been updated
|
||||
assert fixed_user2.updated_at == fixed_user2.inserted_at
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Repo.Migrations.FixMalformedFormatterConfigTest do
|
||||
use Pleroma.DataCase
|
||||
import Pleroma.Factory
|
||||
import Pleroma.Tests.Helpers
|
||||
alias Pleroma.ConfigDB
|
||||
|
||||
setup do: clear_config(Pleroma.Formatter)
|
||||
setup_all do: require_migration("20200722185515_fix_malformed_formatter_config")
|
||||
|
||||
test "change/0 converts a map into a list", %{migration: migration} do
|
||||
incorrect_opts = %{
|
||||
class: false,
|
||||
extra: true,
|
||||
new_window: false,
|
||||
rel: "F",
|
||||
strip_prefix: false
|
||||
}
|
||||
|
||||
insert(:config, group: :pleroma, key: Pleroma.Formatter, value: incorrect_opts)
|
||||
|
||||
assert :ok == migration.change()
|
||||
|
||||
%{value: new_opts} = ConfigDB.get_by_params(%{group: :pleroma, key: Pleroma.Formatter})
|
||||
|
||||
assert new_opts == [
|
||||
class: false,
|
||||
extra: true,
|
||||
new_window: false,
|
||||
rel: "F",
|
||||
strip_prefix: false
|
||||
]
|
||||
|
||||
Pleroma.Config.put(Pleroma.Formatter, new_opts)
|
||||
assert new_opts == Pleroma.Config.get(Pleroma.Formatter)
|
||||
|
||||
{text, _mentions, []} =
|
||||
Pleroma.Formatter.linkify(
|
||||
"https://www.businessinsider.com/walmart-will-close-stores-on-thanksgiving-ending-black-friday-tradition-2020-7\n\nOmg will COVID finally end Black Friday???"
|
||||
)
|
||||
|
||||
assert text ==
|
||||
"<a href=\"https://www.businessinsider.com/walmart-will-close-stores-on-thanksgiving-ending-black-friday-tradition-2020-7\" rel=\"F\">https://www.businessinsider.com/walmart-will-close-stores-on-thanksgiving-ending-black-friday-tradition-2020-7</a>\n\nOmg will COVID finally end Black Friday???"
|
||||
end
|
||||
|
||||
test "change/0 skips if Pleroma.Formatter config is already a list", %{migration: migration} do
|
||||
opts = [
|
||||
class: false,
|
||||
extra: true,
|
||||
new_window: false,
|
||||
rel: "ugc",
|
||||
strip_prefix: false
|
||||
]
|
||||
|
||||
insert(:config, group: :pleroma, key: Pleroma.Formatter, value: opts)
|
||||
|
||||
assert :skipped == migration.change()
|
||||
|
||||
%{value: new_opts} = ConfigDB.get_by_params(%{group: :pleroma, key: Pleroma.Formatter})
|
||||
|
||||
assert new_opts == opts
|
||||
end
|
||||
|
||||
test "change/0 skips if Pleroma.Formatter is empty", %{migration: migration} do
|
||||
assert :skipped == migration.change()
|
||||
end
|
||||
end
|
||||
144
test/pleroma/repo/migrations/move_welcome_settings_test.exs
Normal file
144
test/pleroma/repo/migrations/move_welcome_settings_test.exs
Normal file
|
|
@ -0,0 +1,144 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Repo.Migrations.MoveWelcomeSettingsTest do
|
||||
use Pleroma.DataCase
|
||||
import Pleroma.Factory
|
||||
import Pleroma.Tests.Helpers
|
||||
alias Pleroma.ConfigDB
|
||||
|
||||
setup_all do: require_migration("20200724133313_move_welcome_settings")
|
||||
|
||||
describe "up/0" do
|
||||
test "converts welcome settings", %{migration: migration} do
|
||||
insert(:config,
|
||||
group: :pleroma,
|
||||
key: :instance,
|
||||
value: [
|
||||
welcome_message: "Test message",
|
||||
welcome_user_nickname: "jimm",
|
||||
name: "Pleroma"
|
||||
]
|
||||
)
|
||||
|
||||
migration.up()
|
||||
instance_config = ConfigDB.get_by_params(%{group: :pleroma, key: :instance})
|
||||
welcome_config = ConfigDB.get_by_params(%{group: :pleroma, key: :welcome})
|
||||
|
||||
assert instance_config.value == [name: "Pleroma"]
|
||||
|
||||
assert welcome_config.value == [
|
||||
direct_message: %{
|
||||
enabled: true,
|
||||
message: "Test message",
|
||||
sender_nickname: "jimm"
|
||||
},
|
||||
email: %{
|
||||
enabled: false,
|
||||
html: "Welcome to <%= instance_name %>",
|
||||
sender: nil,
|
||||
subject: "Welcome to <%= instance_name %>",
|
||||
text: "Welcome to <%= instance_name %>"
|
||||
}
|
||||
]
|
||||
end
|
||||
|
||||
test "does nothing when message empty", %{migration: migration} do
|
||||
insert(:config,
|
||||
group: :pleroma,
|
||||
key: :instance,
|
||||
value: [
|
||||
welcome_message: "",
|
||||
welcome_user_nickname: "jimm",
|
||||
name: "Pleroma"
|
||||
]
|
||||
)
|
||||
|
||||
migration.up()
|
||||
instance_config = ConfigDB.get_by_params(%{group: :pleroma, key: :instance})
|
||||
refute ConfigDB.get_by_params(%{group: :pleroma, key: :welcome})
|
||||
assert instance_config.value == [name: "Pleroma"]
|
||||
end
|
||||
|
||||
test "does nothing when welcome_message not set", %{migration: migration} do
|
||||
insert(:config,
|
||||
group: :pleroma,
|
||||
key: :instance,
|
||||
value: [welcome_user_nickname: "jimm", name: "Pleroma"]
|
||||
)
|
||||
|
||||
migration.up()
|
||||
instance_config = ConfigDB.get_by_params(%{group: :pleroma, key: :instance})
|
||||
refute ConfigDB.get_by_params(%{group: :pleroma, key: :welcome})
|
||||
assert instance_config.value == [name: "Pleroma"]
|
||||
end
|
||||
end
|
||||
|
||||
describe "down/0" do
|
||||
test "revert new settings to old when instance setting not exists", %{migration: migration} do
|
||||
insert(:config,
|
||||
group: :pleroma,
|
||||
key: :welcome,
|
||||
value: [
|
||||
direct_message: %{
|
||||
enabled: true,
|
||||
message: "Test message",
|
||||
sender_nickname: "jimm"
|
||||
},
|
||||
email: %{
|
||||
enabled: false,
|
||||
html: "Welcome to <%= instance_name %>",
|
||||
sender: nil,
|
||||
subject: "Welcome to <%= instance_name %>",
|
||||
text: "Welcome to <%= instance_name %>"
|
||||
}
|
||||
]
|
||||
)
|
||||
|
||||
migration.down()
|
||||
|
||||
refute ConfigDB.get_by_params(%{group: :pleroma, key: :welcome})
|
||||
instance_config = ConfigDB.get_by_params(%{group: :pleroma, key: :instance})
|
||||
|
||||
assert instance_config.value == [
|
||||
welcome_user_nickname: "jimm",
|
||||
welcome_message: "Test message"
|
||||
]
|
||||
end
|
||||
|
||||
test "revert new settings to old when instance setting exists", %{migration: migration} do
|
||||
insert(:config, group: :pleroma, key: :instance, value: [name: "Pleroma App"])
|
||||
|
||||
insert(:config,
|
||||
group: :pleroma,
|
||||
key: :welcome,
|
||||
value: [
|
||||
direct_message: %{
|
||||
enabled: true,
|
||||
message: "Test message",
|
||||
sender_nickname: "jimm"
|
||||
},
|
||||
email: %{
|
||||
enabled: false,
|
||||
html: "Welcome to <%= instance_name %>",
|
||||
sender: nil,
|
||||
subject: "Welcome to <%= instance_name %>",
|
||||
text: "Welcome to <%= instance_name %>"
|
||||
}
|
||||
]
|
||||
)
|
||||
|
||||
migration.down()
|
||||
|
||||
refute ConfigDB.get_by_params(%{group: :pleroma, key: :welcome})
|
||||
instance_config = ConfigDB.get_by_params(%{group: :pleroma, key: :instance})
|
||||
|
||||
assert instance_config.value == [
|
||||
name: "Pleroma App",
|
||||
welcome_user_nickname: "jimm",
|
||||
welcome_message: "Test message"
|
||||
]
|
||||
end
|
||||
end
|
||||
end
|
||||
16
test/pleroma/report_note_test.exs
Normal file
16
test/pleroma/report_note_test.exs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.ReportNoteTest do
|
||||
alias Pleroma.ReportNote
|
||||
use Pleroma.DataCase
|
||||
import Pleroma.Factory
|
||||
|
||||
test "create/3" do
|
||||
user = insert(:user)
|
||||
report = insert(:report_activity)
|
||||
assert {:ok, note} = ReportNote.create(user.id, report.id, "naughty boy")
|
||||
assert note.content == "naughty boy"
|
||||
end
|
||||
end
|
||||
35
test/pleroma/user/welcome_chat_message_test.exs
Normal file
35
test/pleroma/user/welcome_chat_message_test.exs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.User.WelcomeChatMessageTest do
|
||||
use Pleroma.DataCase
|
||||
|
||||
alias Pleroma.Config
|
||||
alias Pleroma.User.WelcomeChatMessage
|
||||
|
||||
import Pleroma.Factory
|
||||
|
||||
setup do: clear_config([:welcome])
|
||||
|
||||
describe "post_message/1" do
|
||||
test "send a chat welcome message" do
|
||||
welcome_user = insert(:user, name: "mewmew")
|
||||
user = insert(:user)
|
||||
|
||||
Config.put([:welcome, :chat_message, :enabled], true)
|
||||
Config.put([:welcome, :chat_message, :sender_nickname], welcome_user.nickname)
|
||||
|
||||
Config.put(
|
||||
[:welcome, :chat_message, :message],
|
||||
"Hello, welcome to Blob/Cat!"
|
||||
)
|
||||
|
||||
{:ok, %Pleroma.Activity{} = activity} = WelcomeChatMessage.post_message(user)
|
||||
|
||||
assert user.ap_id in activity.recipients
|
||||
assert Pleroma.Object.normalize(activity).data["type"] == "ChatMessage"
|
||||
assert Pleroma.Object.normalize(activity).data["content"] == "Hello, welcome to Blob/Cat!"
|
||||
end
|
||||
end
|
||||
end
|
||||
61
test/pleroma/user/welcome_email_test.exs
Normal file
61
test/pleroma/user/welcome_email_test.exs
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.User.WelcomeEmailTest do
|
||||
use Pleroma.DataCase
|
||||
|
||||
alias Pleroma.Config
|
||||
alias Pleroma.Tests.ObanHelpers
|
||||
alias Pleroma.User.WelcomeEmail
|
||||
|
||||
import Pleroma.Factory
|
||||
import Swoosh.TestAssertions
|
||||
|
||||
setup do: clear_config([:welcome])
|
||||
|
||||
describe "send_email/1" do
|
||||
test "send a welcome email" do
|
||||
user = insert(:user, name: "Jimm")
|
||||
|
||||
Config.put([:welcome, :email, :enabled], true)
|
||||
Config.put([:welcome, :email, :sender], "welcome@pleroma.app")
|
||||
|
||||
Config.put(
|
||||
[:welcome, :email, :subject],
|
||||
"Hello, welcome to pleroma: <%= instance_name %>"
|
||||
)
|
||||
|
||||
Config.put(
|
||||
[:welcome, :email, :html],
|
||||
"<h1>Hello <%= user.name %>.</h1> <p>Welcome to <%= instance_name %></p>"
|
||||
)
|
||||
|
||||
instance_name = Config.get([:instance, :name])
|
||||
|
||||
{:ok, _job} = WelcomeEmail.send_email(user)
|
||||
|
||||
ObanHelpers.perform_all()
|
||||
|
||||
assert_email_sent(
|
||||
from: {instance_name, "welcome@pleroma.app"},
|
||||
to: {user.name, user.email},
|
||||
subject: "Hello, welcome to pleroma: #{instance_name}",
|
||||
html_body: "<h1>Hello #{user.name}.</h1> <p>Welcome to #{instance_name}</p>"
|
||||
)
|
||||
|
||||
Config.put([:welcome, :email, :sender], {"Pleroma App", "welcome@pleroma.app"})
|
||||
|
||||
{:ok, _job} = WelcomeEmail.send_email(user)
|
||||
|
||||
ObanHelpers.perform_all()
|
||||
|
||||
assert_email_sent(
|
||||
from: {"Pleroma App", "welcome@pleroma.app"},
|
||||
to: {user.name, user.email},
|
||||
subject: "Hello, welcome to pleroma: #{instance_name}",
|
||||
html_body: "<h1>Hello #{user.name}.</h1> <p>Welcome to #{instance_name}</p>"
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
34
test/pleroma/user/welcome_message_test.exs
Normal file
34
test/pleroma/user/welcome_message_test.exs
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.User.WelcomeMessageTest do
|
||||
use Pleroma.DataCase
|
||||
|
||||
alias Pleroma.Config
|
||||
alias Pleroma.User.WelcomeMessage
|
||||
|
||||
import Pleroma.Factory
|
||||
|
||||
setup do: clear_config([:welcome])
|
||||
|
||||
describe "post_message/1" do
|
||||
test "send a direct welcome message" do
|
||||
welcome_user = insert(:user)
|
||||
user = insert(:user, name: "Jimm")
|
||||
|
||||
Config.put([:welcome, :direct_message, :enabled], true)
|
||||
Config.put([:welcome, :direct_message, :sender_nickname], welcome_user.nickname)
|
||||
|
||||
Config.put(
|
||||
[:welcome, :direct_message, :message],
|
||||
"Hello. Welcome to Pleroma"
|
||||
)
|
||||
|
||||
{:ok, %Pleroma.Activity{} = activity} = WelcomeMessage.post_message(user)
|
||||
assert user.ap_id in activity.recipients
|
||||
assert activity.data["directMessage"] == true
|
||||
assert Pleroma.Object.normalize(activity).data["content"] =~ "Hello. Welcome to Pleroma"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Web.ActivityPub.ObjectValidators.AcceptValidationTest do
|
||||
use Pleroma.DataCase
|
||||
|
||||
alias Pleroma.Web.ActivityPub.Builder
|
||||
alias Pleroma.Web.ActivityPub.ObjectValidator
|
||||
alias Pleroma.Web.ActivityPub.Pipeline
|
||||
|
||||
import Pleroma.Factory
|
||||
|
||||
setup do
|
||||
follower = insert(:user)
|
||||
followed = insert(:user, local: false)
|
||||
|
||||
{:ok, follow_data, _} = Builder.follow(follower, followed)
|
||||
{:ok, follow_activity, _} = Pipeline.common_pipeline(follow_data, local: true)
|
||||
|
||||
{:ok, accept_data, _} = Builder.accept(followed, follow_activity)
|
||||
|
||||
%{accept_data: accept_data, followed: followed}
|
||||
end
|
||||
|
||||
test "it validates a basic 'accept'", %{accept_data: accept_data} do
|
||||
assert {:ok, _, _} = ObjectValidator.validate(accept_data, [])
|
||||
end
|
||||
|
||||
test "it fails when the actor doesn't exist", %{accept_data: accept_data} do
|
||||
accept_data =
|
||||
accept_data
|
||||
|> Map.put("actor", "https://gensokyo.2hu/users/raymoo")
|
||||
|
||||
assert {:error, _} = ObjectValidator.validate(accept_data, [])
|
||||
end
|
||||
|
||||
test "it fails when the accepted activity doesn't exist", %{accept_data: accept_data} do
|
||||
accept_data =
|
||||
accept_data
|
||||
|> Map.put("object", "https://gensokyo.2hu/users/raymoo/follows/1")
|
||||
|
||||
assert {:error, _} = ObjectValidator.validate(accept_data, [])
|
||||
end
|
||||
|
||||
test "for an accepted follow, it only validates if the actor of the accept is the followed actor",
|
||||
%{accept_data: accept_data} do
|
||||
stranger = insert(:user)
|
||||
|
||||
accept_data =
|
||||
accept_data
|
||||
|> Map.put("actor", stranger.ap_id)
|
||||
|
||||
assert {:error, _} = ObjectValidator.validate(accept_data, [])
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Web.ActivityPub.ObjectValidators.RejectValidationTest do
|
||||
use Pleroma.DataCase
|
||||
|
||||
alias Pleroma.Web.ActivityPub.Builder
|
||||
alias Pleroma.Web.ActivityPub.ObjectValidator
|
||||
alias Pleroma.Web.ActivityPub.Pipeline
|
||||
|
||||
import Pleroma.Factory
|
||||
|
||||
setup do
|
||||
follower = insert(:user)
|
||||
followed = insert(:user, local: false)
|
||||
|
||||
{:ok, follow_data, _} = Builder.follow(follower, followed)
|
||||
{:ok, follow_activity, _} = Pipeline.common_pipeline(follow_data, local: true)
|
||||
|
||||
{:ok, reject_data, _} = Builder.reject(followed, follow_activity)
|
||||
|
||||
%{reject_data: reject_data, followed: followed}
|
||||
end
|
||||
|
||||
test "it validates a basic 'reject'", %{reject_data: reject_data} do
|
||||
assert {:ok, _, _} = ObjectValidator.validate(reject_data, [])
|
||||
end
|
||||
|
||||
test "it fails when the actor doesn't exist", %{reject_data: reject_data} do
|
||||
reject_data =
|
||||
reject_data
|
||||
|> Map.put("actor", "https://gensokyo.2hu/users/raymoo")
|
||||
|
||||
assert {:error, _} = ObjectValidator.validate(reject_data, [])
|
||||
end
|
||||
|
||||
test "it fails when the rejected activity doesn't exist", %{reject_data: reject_data} do
|
||||
reject_data =
|
||||
reject_data
|
||||
|> Map.put("object", "https://gensokyo.2hu/users/raymoo/follows/1")
|
||||
|
||||
assert {:error, _} = ObjectValidator.validate(reject_data, [])
|
||||
end
|
||||
|
||||
test "for an rejected follow, it only validates if the actor of the reject is the followed actor",
|
||||
%{reject_data: reject_data} do
|
||||
stranger = insert(:user)
|
||||
|
||||
reject_data =
|
||||
reject_data
|
||||
|> Map.put("actor", stranger.ap_id)
|
||||
|
||||
assert {:error, _} = ObjectValidator.validate(reject_data, [])
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Web.ActivityPub.Transmogrifier.AcceptHandlingTest do
|
||||
use Pleroma.DataCase
|
||||
|
||||
alias Pleroma.User
|
||||
alias Pleroma.Web.ActivityPub.Transmogrifier
|
||||
alias Pleroma.Web.CommonAPI
|
||||
|
||||
import Pleroma.Factory
|
||||
|
||||
test "it works for incoming accepts which were pre-accepted" do
|
||||
follower = insert(:user)
|
||||
followed = insert(:user)
|
||||
|
||||
{:ok, follower} = User.follow(follower, followed)
|
||||
assert User.following?(follower, followed) == true
|
||||
|
||||
{:ok, _, _, follow_activity} = CommonAPI.follow(follower, followed)
|
||||
|
||||
accept_data =
|
||||
File.read!("test/fixtures/mastodon-accept-activity.json")
|
||||
|> Poison.decode!()
|
||||
|> Map.put("actor", followed.ap_id)
|
||||
|
||||
object =
|
||||
accept_data["object"]
|
||||
|> Map.put("actor", follower.ap_id)
|
||||
|> Map.put("id", follow_activity.data["id"])
|
||||
|
||||
accept_data = Map.put(accept_data, "object", object)
|
||||
|
||||
{:ok, activity} = Transmogrifier.handle_incoming(accept_data)
|
||||
refute activity.local
|
||||
|
||||
assert activity.data["object"] == follow_activity.data["id"]
|
||||
|
||||
assert activity.data["id"] == accept_data["id"]
|
||||
|
||||
follower = User.get_cached_by_id(follower.id)
|
||||
|
||||
assert User.following?(follower, followed) == true
|
||||
end
|
||||
|
||||
test "it works for incoming accepts which are referenced by IRI only" do
|
||||
follower = insert(:user)
|
||||
followed = insert(:user, locked: true)
|
||||
|
||||
{:ok, _, _, follow_activity} = CommonAPI.follow(follower, followed)
|
||||
|
||||
accept_data =
|
||||
File.read!("test/fixtures/mastodon-accept-activity.json")
|
||||
|> Poison.decode!()
|
||||
|> Map.put("actor", followed.ap_id)
|
||||
|> Map.put("object", follow_activity.data["id"])
|
||||
|
||||
{:ok, activity} = Transmogrifier.handle_incoming(accept_data)
|
||||
assert activity.data["object"] == follow_activity.data["id"]
|
||||
|
||||
follower = User.get_cached_by_id(follower.id)
|
||||
|
||||
assert User.following?(follower, followed) == true
|
||||
|
||||
follower = User.get_by_id(follower.id)
|
||||
assert follower.following_count == 1
|
||||
|
||||
followed = User.get_by_id(followed.id)
|
||||
assert followed.follower_count == 1
|
||||
end
|
||||
|
||||
test "it fails for incoming accepts which cannot be correlated" do
|
||||
follower = insert(:user)
|
||||
followed = insert(:user, locked: true)
|
||||
|
||||
accept_data =
|
||||
File.read!("test/fixtures/mastodon-accept-activity.json")
|
||||
|> Poison.decode!()
|
||||
|> Map.put("actor", followed.ap_id)
|
||||
|
||||
accept_data =
|
||||
Map.put(accept_data, "object", Map.put(accept_data["object"], "actor", follower.ap_id))
|
||||
|
||||
{:error, _} = Transmogrifier.handle_incoming(accept_data)
|
||||
|
||||
follower = User.get_cached_by_id(follower.id)
|
||||
|
||||
refute User.following?(follower, followed) == true
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Web.ActivityPub.Transmogrifier.AnswerHandlingTest do
|
||||
use Pleroma.DataCase
|
||||
|
||||
alias Pleroma.Activity
|
||||
alias Pleroma.Object
|
||||
alias Pleroma.Web.ActivityPub.Transmogrifier
|
||||
alias Pleroma.Web.CommonAPI
|
||||
|
||||
import Pleroma.Factory
|
||||
|
||||
setup_all do
|
||||
Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
|
||||
:ok
|
||||
end
|
||||
|
||||
test "incoming, rewrites Note to Answer and increments vote counters" do
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, activity} =
|
||||
CommonAPI.post(user, %{
|
||||
status: "suya...",
|
||||
poll: %{options: ["suya", "suya.", "suya.."], expires_in: 10}
|
||||
})
|
||||
|
||||
object = Object.normalize(activity)
|
||||
|
||||
data =
|
||||
File.read!("test/fixtures/mastodon-vote.json")
|
||||
|> Poison.decode!()
|
||||
|> Kernel.put_in(["to"], user.ap_id)
|
||||
|> Kernel.put_in(["object", "inReplyTo"], object.data["id"])
|
||||
|> Kernel.put_in(["object", "to"], user.ap_id)
|
||||
|
||||
{:ok, %Activity{local: false} = activity} = Transmogrifier.handle_incoming(data)
|
||||
answer_object = Object.normalize(activity)
|
||||
assert answer_object.data["type"] == "Answer"
|
||||
assert answer_object.data["inReplyTo"] == object.data["id"]
|
||||
|
||||
new_object = Object.get_by_ap_id(object.data["id"])
|
||||
assert new_object.data["replies_count"] == object.data["replies_count"]
|
||||
|
||||
assert Enum.any?(
|
||||
new_object.data["oneOf"],
|
||||
fn
|
||||
%{"name" => "suya..", "replies" => %{"totalItems" => 1}} -> true
|
||||
_ -> false
|
||||
end
|
||||
)
|
||||
end
|
||||
|
||||
test "outgoing, rewrites Answer to Note" do
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, poll_activity} =
|
||||
CommonAPI.post(user, %{
|
||||
status: "suya...",
|
||||
poll: %{options: ["suya", "suya.", "suya.."], expires_in: 10}
|
||||
})
|
||||
|
||||
poll_object = Object.normalize(poll_activity)
|
||||
# TODO: Replace with CommonAPI vote creation when implemented
|
||||
data =
|
||||
File.read!("test/fixtures/mastodon-vote.json")
|
||||
|> Poison.decode!()
|
||||
|> Kernel.put_in(["to"], user.ap_id)
|
||||
|> Kernel.put_in(["object", "inReplyTo"], poll_object.data["id"])
|
||||
|> Kernel.put_in(["object", "to"], user.ap_id)
|
||||
|
||||
{:ok, %Activity{local: false} = activity} = Transmogrifier.handle_incoming(data)
|
||||
{:ok, data} = Transmogrifier.prepare_outgoing(activity.data)
|
||||
|
||||
assert data["object"]["type"] == "Note"
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,176 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Web.ActivityPub.Transmogrifier.QuestionHandlingTest do
|
||||
use Pleroma.DataCase
|
||||
|
||||
alias Pleroma.Activity
|
||||
alias Pleroma.Object
|
||||
alias Pleroma.Web.ActivityPub.Transmogrifier
|
||||
alias Pleroma.Web.CommonAPI
|
||||
|
||||
import Pleroma.Factory
|
||||
|
||||
setup_all do
|
||||
Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
|
||||
:ok
|
||||
end
|
||||
|
||||
test "Mastodon Question activity" do
|
||||
data = File.read!("test/fixtures/mastodon-question-activity.json") |> Poison.decode!()
|
||||
|
||||
{:ok, %Activity{local: false} = activity} = Transmogrifier.handle_incoming(data)
|
||||
|
||||
object = Object.normalize(activity, false)
|
||||
|
||||
assert object.data["url"] == "https://mastodon.sdf.org/@rinpatch/102070944809637304"
|
||||
|
||||
assert object.data["closed"] == "2019-05-11T09:03:36Z"
|
||||
|
||||
assert object.data["context"] == activity.data["context"]
|
||||
|
||||
assert object.data["context"] ==
|
||||
"tag:mastodon.sdf.org,2019-05-10:objectId=15095122:objectType=Conversation"
|
||||
|
||||
assert object.data["context_id"]
|
||||
|
||||
assert object.data["anyOf"] == []
|
||||
|
||||
assert Enum.sort(object.data["oneOf"]) ==
|
||||
Enum.sort([
|
||||
%{
|
||||
"name" => "25 char limit is dumb",
|
||||
"replies" => %{"totalItems" => 0, "type" => "Collection"},
|
||||
"type" => "Note"
|
||||
},
|
||||
%{
|
||||
"name" => "Dunno",
|
||||
"replies" => %{"totalItems" => 0, "type" => "Collection"},
|
||||
"type" => "Note"
|
||||
},
|
||||
%{
|
||||
"name" => "Everyone knows that!",
|
||||
"replies" => %{"totalItems" => 1, "type" => "Collection"},
|
||||
"type" => "Note"
|
||||
},
|
||||
%{
|
||||
"name" => "I can't even fit a funny",
|
||||
"replies" => %{"totalItems" => 1, "type" => "Collection"},
|
||||
"type" => "Note"
|
||||
}
|
||||
])
|
||||
|
||||
user = insert(:user)
|
||||
|
||||
{:ok, reply_activity} = CommonAPI.post(user, %{status: "hewwo", in_reply_to_id: activity.id})
|
||||
|
||||
reply_object = Object.normalize(reply_activity, false)
|
||||
|
||||
assert reply_object.data["context"] == object.data["context"]
|
||||
assert reply_object.data["context_id"] == object.data["context_id"]
|
||||
end
|
||||
|
||||
test "Mastodon Question activity with HTML tags in plaintext" do
|
||||
options = [
|
||||
%{
|
||||
"type" => "Note",
|
||||
"name" => "<input type=\"date\">",
|
||||
"replies" => %{"totalItems" => 0, "type" => "Collection"}
|
||||
},
|
||||
%{
|
||||
"type" => "Note",
|
||||
"name" => "<input type=\"date\"/>",
|
||||
"replies" => %{"totalItems" => 0, "type" => "Collection"}
|
||||
},
|
||||
%{
|
||||
"type" => "Note",
|
||||
"name" => "<input type=\"date\" />",
|
||||
"replies" => %{"totalItems" => 1, "type" => "Collection"}
|
||||
},
|
||||
%{
|
||||
"type" => "Note",
|
||||
"name" => "<input type=\"date\"></input>",
|
||||
"replies" => %{"totalItems" => 1, "type" => "Collection"}
|
||||
}
|
||||
]
|
||||
|
||||
data =
|
||||
File.read!("test/fixtures/mastodon-question-activity.json")
|
||||
|> Poison.decode!()
|
||||
|> Kernel.put_in(["object", "oneOf"], options)
|
||||
|
||||
{:ok, %Activity{local: false} = activity} = Transmogrifier.handle_incoming(data)
|
||||
object = Object.normalize(activity, false)
|
||||
|
||||
assert Enum.sort(object.data["oneOf"]) == Enum.sort(options)
|
||||
end
|
||||
|
||||
test "Mastodon Question activity with custom emojis" do
|
||||
options = [
|
||||
%{
|
||||
"type" => "Note",
|
||||
"name" => ":blobcat:",
|
||||
"replies" => %{"totalItems" => 0, "type" => "Collection"}
|
||||
},
|
||||
%{
|
||||
"type" => "Note",
|
||||
"name" => ":blobfox:",
|
||||
"replies" => %{"totalItems" => 0, "type" => "Collection"}
|
||||
}
|
||||
]
|
||||
|
||||
tag = [
|
||||
%{
|
||||
"icon" => %{
|
||||
"type" => "Image",
|
||||
"url" => "https://blob.cat/emoji/custom/blobcats/blobcat.png"
|
||||
},
|
||||
"id" => "https://blob.cat/emoji/custom/blobcats/blobcat.png",
|
||||
"name" => ":blobcat:",
|
||||
"type" => "Emoji",
|
||||
"updated" => "1970-01-01T00:00:00Z"
|
||||
},
|
||||
%{
|
||||
"icon" => %{"type" => "Image", "url" => "https://blob.cat/emoji/blobfox/blobfox.png"},
|
||||
"id" => "https://blob.cat/emoji/blobfox/blobfox.png",
|
||||
"name" => ":blobfox:",
|
||||
"type" => "Emoji",
|
||||
"updated" => "1970-01-01T00:00:00Z"
|
||||
}
|
||||
]
|
||||
|
||||
data =
|
||||
File.read!("test/fixtures/mastodon-question-activity.json")
|
||||
|> Poison.decode!()
|
||||
|> Kernel.put_in(["object", "oneOf"], options)
|
||||
|> Kernel.put_in(["object", "tag"], tag)
|
||||
|
||||
{:ok, %Activity{local: false} = activity} = Transmogrifier.handle_incoming(data)
|
||||
object = Object.normalize(activity, false)
|
||||
|
||||
assert object.data["oneOf"] == options
|
||||
|
||||
assert object.data["emoji"] == %{
|
||||
"blobcat" => "https://blob.cat/emoji/custom/blobcats/blobcat.png",
|
||||
"blobfox" => "https://blob.cat/emoji/blobfox/blobfox.png"
|
||||
}
|
||||
end
|
||||
|
||||
test "returns same activity if received a second time" do
|
||||
data = File.read!("test/fixtures/mastodon-question-activity.json") |> Poison.decode!()
|
||||
|
||||
assert {:ok, %Activity{local: false} = activity} = Transmogrifier.handle_incoming(data)
|
||||
|
||||
assert {:ok, ^activity} = Transmogrifier.handle_incoming(data)
|
||||
end
|
||||
|
||||
test "accepts a Question with no content" do
|
||||
data =
|
||||
File.read!("test/fixtures/mastodon-question-activity.json")
|
||||
|> Poison.decode!()
|
||||
|> Kernel.put_in(["object", "content"], "")
|
||||
|
||||
assert {:ok, %Activity{local: false}} = Transmogrifier.handle_incoming(data)
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Web.ActivityPub.Transmogrifier.RejectHandlingTest do
|
||||
use Pleroma.DataCase
|
||||
|
||||
alias Pleroma.Activity
|
||||
alias Pleroma.User
|
||||
alias Pleroma.Web.ActivityPub.Transmogrifier
|
||||
alias Pleroma.Web.CommonAPI
|
||||
|
||||
import Pleroma.Factory
|
||||
|
||||
test "it fails for incoming rejects which cannot be correlated" do
|
||||
follower = insert(:user)
|
||||
followed = insert(:user, locked: true)
|
||||
|
||||
accept_data =
|
||||
File.read!("test/fixtures/mastodon-reject-activity.json")
|
||||
|> Poison.decode!()
|
||||
|> Map.put("actor", followed.ap_id)
|
||||
|
||||
accept_data =
|
||||
Map.put(accept_data, "object", Map.put(accept_data["object"], "actor", follower.ap_id))
|
||||
|
||||
{:error, _} = Transmogrifier.handle_incoming(accept_data)
|
||||
|
||||
follower = User.get_cached_by_id(follower.id)
|
||||
|
||||
refute User.following?(follower, followed) == true
|
||||
end
|
||||
|
||||
test "it works for incoming rejects which are referenced by IRI only" do
|
||||
follower = insert(:user)
|
||||
followed = insert(:user, locked: true)
|
||||
|
||||
{:ok, follower} = User.follow(follower, followed)
|
||||
{:ok, _, _, follow_activity} = CommonAPI.follow(follower, followed)
|
||||
|
||||
assert User.following?(follower, followed) == true
|
||||
|
||||
reject_data =
|
||||
File.read!("test/fixtures/mastodon-reject-activity.json")
|
||||
|> Poison.decode!()
|
||||
|> Map.put("actor", followed.ap_id)
|
||||
|> Map.put("object", follow_activity.data["id"])
|
||||
|
||||
{:ok, %Activity{data: _}} = Transmogrifier.handle_incoming(reject_data)
|
||||
|
||||
follower = User.get_cached_by_id(follower.id)
|
||||
|
||||
assert User.following?(follower, followed) == false
|
||||
end
|
||||
|
||||
test "it rejects activities without a valid ID" do
|
||||
user = insert(:user)
|
||||
|
||||
data =
|
||||
File.read!("test/fixtures/mastodon-follow-activity.json")
|
||||
|> Poison.decode!()
|
||||
|> Map.put("object", user.ap_id)
|
||||
|> Map.put("id", "")
|
||||
|
||||
:error = Transmogrifier.handle_incoming(data)
|
||||
end
|
||||
end
|
||||
56
test/pleroma/web/plugs/frontend_static_plug_test.exs
Normal file
56
test/pleroma/web/plugs/frontend_static_plug_test.exs
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Web.Plugs.FrontendStaticPlugTest do
|
||||
use Pleroma.Web.ConnCase
|
||||
|
||||
@dir "test/tmp/instance_static"
|
||||
|
||||
setup do
|
||||
File.mkdir_p!(@dir)
|
||||
on_exit(fn -> File.rm_rf(@dir) end)
|
||||
end
|
||||
|
||||
setup do: clear_config([:instance, :static_dir], @dir)
|
||||
|
||||
test "init will give a static plug config + the frontend type" do
|
||||
opts =
|
||||
[
|
||||
at: "/admin",
|
||||
frontend_type: :admin
|
||||
]
|
||||
|> Pleroma.Web.Plugs.FrontendStatic.init()
|
||||
|
||||
assert opts[:at] == ["admin"]
|
||||
assert opts[:frontend_type] == :admin
|
||||
end
|
||||
|
||||
test "overrides existing static files", %{conn: conn} do
|
||||
name = "pelmora"
|
||||
ref = "uguu"
|
||||
|
||||
clear_config([:frontends, :primary], %{"name" => name, "ref" => ref})
|
||||
path = "#{@dir}/frontends/#{name}/#{ref}"
|
||||
|
||||
File.mkdir_p!(path)
|
||||
File.write!("#{path}/index.html", "from frontend plug")
|
||||
|
||||
index = get(conn, "/")
|
||||
assert html_response(index, 200) == "from frontend plug"
|
||||
end
|
||||
|
||||
test "overrides existing static files for the `pleroma/admin` path", %{conn: conn} do
|
||||
name = "pelmora"
|
||||
ref = "uguu"
|
||||
|
||||
clear_config([:frontends, :admin], %{"name" => name, "ref" => ref})
|
||||
path = "#{@dir}/frontends/#{name}/#{ref}"
|
||||
|
||||
File.mkdir_p!(path)
|
||||
File.write!("#{path}/index.html", "from frontend plug")
|
||||
|
||||
index = get(conn, "/pleroma/admin/")
|
||||
assert html_response(index, 200) == "from frontend plug"
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue