-
-
icon-cancel0xe800
-
icon-upload0xe801
-
icon-star0xe802
-
icon-star-empty0xe803
-
-
-
icon-retweet0xe804
-
icon-eye-off0xe805
-
icon-search0xe806
-
icon-cog0xe807
-
-
-
icon-logout0xe808
-
icon-down-open0xe809
-
icon-attach0xe80a
-
icon-picture0xe80b
-
-
-
icon-video0xe80c
-
icon-right-open0xe80d
-
icon-left-open0xe80e
-
icon-up-open0xe80f
-
-
-
icon-bell-ringing-o0xe810
-
icon-lock0xe811
-
icon-globe0xe812
-
icon-brush0xe813
-
-
-
icon-attention0xe814
-
icon-plus0xe815
-
icon-adjust0xe816
-
icon-edit0xe817
-
-
-
icon-pencil0xe818
-
icon-pin0xe819
-
icon-wrench0xe81a
-
icon-chart-bar0xe81b
-
-
-
icon-zoom-in0xe81c
-
icon-spin30xe832
-
icon-spin40xe834
-
icon-link-ext0xf08e
-
-
-
icon-link-ext-alt0xf08f
-
icon-menu0xf0c9
-
icon-mail-alt0xf0e0
-
icon-gauge0xf0e4
-
-
-
icon-comment-empty0xf0e5
-
icon-bell-alt0xf0f3
-
icon-plus-squared0xf0fe
-
icon-reply0xf112
-
-
-
icon-smile0xf118
-
icon-lock-open-alt0xf13e
-
icon-ellipsis0xf141
-
icon-play-circled0xf144
-
-
-
icon-thumbs-up-alt0xf164
-
icon-binoculars0xf1e5
-
icon-user-plus0xf234
-
-
-
-
-
\ No newline at end of file
diff --git a/priv/static/static/font/font/fontello.woff2 b/priv/static/static/font/font/fontello.woff2
deleted file mode 100755
index 078991eb8..000000000
Binary files a/priv/static/static/font/font/fontello.woff2 and /dev/null differ
diff --git a/priv/static/static/font/font/fontello.eot b/priv/static/static/font/fontello.1576166651574.eot
old mode 100755
new mode 100644
similarity index 99%
rename from priv/static/static/font/font/fontello.eot
rename to priv/static/static/font/fontello.1576166651574.eot
index 1703fd97f..fb27d4037
Binary files a/priv/static/static/font/font/fontello.eot and b/priv/static/static/font/fontello.1576166651574.eot differ
diff --git a/priv/static/static/font/font/fontello.svg b/priv/static/static/font/fontello.1576166651574.svg
similarity index 100%
rename from priv/static/static/font/font/fontello.svg
rename to priv/static/static/font/fontello.1576166651574.svg
diff --git a/priv/static/static/font/font/fontello.ttf b/priv/static/static/font/fontello.1576166651574.ttf
old mode 100755
new mode 100644
similarity index 99%
rename from priv/static/static/font/font/fontello.ttf
rename to priv/static/static/font/fontello.1576166651574.ttf
index e9ed78031..c49743ec6
Binary files a/priv/static/static/font/font/fontello.ttf and b/priv/static/static/font/fontello.1576166651574.ttf differ
diff --git a/priv/static/static/font/font/fontello.woff b/priv/static/static/font/fontello.1576166651574.woff
old mode 100755
new mode 100644
similarity index 98%
rename from priv/static/static/font/font/fontello.woff
rename to priv/static/static/font/fontello.1576166651574.woff
index 1d5025d3c..bbffd6413
Binary files a/priv/static/static/font/font/fontello.woff and b/priv/static/static/font/fontello.1576166651574.woff differ
diff --git a/priv/static/static/font/fontello.1576166651574.woff2 b/priv/static/static/font/fontello.1576166651574.woff2
new file mode 100644
index 000000000..d35dce862
Binary files /dev/null and b/priv/static/static/font/fontello.1576166651574.woff2 differ
diff --git a/priv/static/static/fontello.1576166651574.css b/priv/static/static/fontello.1576166651574.css
new file mode 100644
index 000000000..54f9fe05f
Binary files /dev/null and b/priv/static/static/fontello.1576166651574.css differ
diff --git a/priv/static/static/font/config.json b/priv/static/static/fontello.json
similarity index 100%
rename from priv/static/static/font/config.json
rename to priv/static/static/fontello.json
diff --git a/priv/static/static/js/app.4ab7097a5650339b9e3d.js b/priv/static/static/js/app.4ab7097a5650339b9e3d.js
deleted file mode 100644
index 33141e412..000000000
Binary files a/priv/static/static/js/app.4ab7097a5650339b9e3d.js and /dev/null differ
diff --git a/priv/static/static/js/app.4ab7097a5650339b9e3d.js.map b/priv/static/static/js/app.4ab7097a5650339b9e3d.js.map
deleted file mode 100644
index b47e90c09..000000000
Binary files a/priv/static/static/js/app.4ab7097a5650339b9e3d.js.map and /dev/null differ
diff --git a/priv/static/static/js/app.a9b3f4c3e79baf3fa8b7.js b/priv/static/static/js/app.a9b3f4c3e79baf3fa8b7.js
new file mode 100644
index 000000000..124f284be
Binary files /dev/null and b/priv/static/static/js/app.a9b3f4c3e79baf3fa8b7.js differ
diff --git a/priv/static/static/js/app.a9b3f4c3e79baf3fa8b7.js.map b/priv/static/static/js/app.a9b3f4c3e79baf3fa8b7.js.map
new file mode 100644
index 000000000..7c369185e
Binary files /dev/null and b/priv/static/static/js/app.a9b3f4c3e79baf3fa8b7.js.map differ
diff --git a/priv/static/static/js/app.d20ca27d22d74eb7bce0.js b/priv/static/static/js/app.d20ca27d22d74eb7bce0.js
deleted file mode 100644
index 7abf2ec28..000000000
Binary files a/priv/static/static/js/app.d20ca27d22d74eb7bce0.js and /dev/null differ
diff --git a/priv/static/static/js/app.d20ca27d22d74eb7bce0.js.map b/priv/static/static/js/app.d20ca27d22d74eb7bce0.js.map
deleted file mode 100644
index 6c96ca5b2..000000000
Binary files a/priv/static/static/js/app.d20ca27d22d74eb7bce0.js.map and /dev/null differ
diff --git a/priv/static/static/js/vendors~app.76db8e4cdf29decd5cab.js b/priv/static/static/js/vendors~app.3f1ed7a4fdfc37ee27a7.js
similarity index 95%
rename from priv/static/static/js/vendors~app.76db8e4cdf29decd5cab.js
rename to priv/static/static/js/vendors~app.3f1ed7a4fdfc37ee27a7.js
index 135bdebb3..a64eee9a9 100644
Binary files a/priv/static/static/js/vendors~app.76db8e4cdf29decd5cab.js and b/priv/static/static/js/vendors~app.3f1ed7a4fdfc37ee27a7.js differ
diff --git a/priv/static/static/js/vendors~app.76db8e4cdf29decd5cab.js.map b/priv/static/static/js/vendors~app.3f1ed7a4fdfc37ee27a7.js.map
similarity index 78%
rename from priv/static/static/js/vendors~app.76db8e4cdf29decd5cab.js.map
rename to priv/static/static/js/vendors~app.3f1ed7a4fdfc37ee27a7.js.map
index 6513c0a0b..2e88b3ce2 100644
Binary files a/priv/static/static/js/vendors~app.76db8e4cdf29decd5cab.js.map and b/priv/static/static/js/vendors~app.3f1ed7a4fdfc37ee27a7.js.map differ
diff --git a/priv/static/sw-pleroma.js b/priv/static/sw-pleroma.js
index 276af8173..4738f3391 100644
Binary files a/priv/static/sw-pleroma.js and b/priv/static/sw-pleroma.js differ
diff --git a/priv/static/sw.js b/priv/static/sw.js
index c2de0cfe0..5605bb05e 100644
Binary files a/priv/static/sw.js and b/priv/static/sw.js differ
diff --git a/test/captcha_test.exs b/test/captcha_test.exs
index 9f395d6b4..393c8219e 100644
--- a/test/captcha_test.exs
+++ b/test/captcha_test.exs
@@ -8,6 +8,7 @@ defmodule Pleroma.CaptchaTest do
import Tesla.Mock
alias Pleroma.Captcha.Kocaptcha
+ alias Pleroma.Captcha.Native
@ets_options [:ordered_set, :private, :named_table, {:read_concurrency, true}]
@@ -43,4 +44,21 @@ test "new and validate" do
) == :ok
end
end
+
+ describe "Native" do
+ test "new and validate" do
+ new = Native.new()
+
+ assert %{
+ answer_data: answer,
+ token: token,
+ type: :native,
+ url: "data:image/png;base64," <> _
+ } = new
+
+ assert is_binary(answer)
+ assert :ok = Native.validate(token, answer, answer)
+ assert {:error, "Invalid CAPTCHA"} == Native.validate(token, answer, answer <> "foobar")
+ end
+ end
end
diff --git a/test/conversation/participation_test.exs b/test/conversation/participation_test.exs
index 9b2c97963..ba81c0d4b 100644
--- a/test/conversation/participation_test.exs
+++ b/test/conversation/participation_test.exs
@@ -5,7 +5,9 @@
defmodule Pleroma.Conversation.ParticipationTest do
use Pleroma.DataCase
import Pleroma.Factory
+ alias Pleroma.Conversation
alias Pleroma.Conversation.Participation
+ alias Pleroma.Repo
alias Pleroma.User
alias Pleroma.Web.CommonAPI
@@ -98,7 +100,9 @@ test "it creates a participation for a conversation and a user" do
assert participation.user_id == user.id
assert participation.conversation_id == conversation.id
+ # Needed because updated_at is accurate down to a second
:timer.sleep(1000)
+
# Creating again returns the same participation
{:ok, %Participation{} = participation_two} =
Participation.create_for_user_and_conversation(user, conversation)
@@ -150,9 +154,7 @@ test "it marks all the user's participations as read" do
test "gets all the participations for a user, ordered by updated at descending" do
user = insert(:user)
{:ok, activity_one} = CommonAPI.post(user, %{"status" => "x", "visibility" => "direct"})
- :timer.sleep(1000)
{:ok, activity_two} = CommonAPI.post(user, %{"status" => "x", "visibility" => "direct"})
- :timer.sleep(1000)
{:ok, activity_three} =
CommonAPI.post(user, %{
@@ -161,6 +163,17 @@ test "gets all the participations for a user, ordered by updated at descending"
"in_reply_to_status_id" => activity_one.id
})
+ # Offset participations because the accuracy of updated_at is down to a second
+
+ for {activity, offset} <- [{activity_two, 1}, {activity_three, 2}] do
+ conversation = Conversation.get_for_ap_id(activity.data["context"])
+ participation = Participation.for_user_and_conversation(user, conversation)
+ updated_at = NaiveDateTime.add(Map.get(participation, :updated_at), offset)
+
+ Ecto.Changeset.change(participation, %{updated_at: updated_at})
+ |> Repo.update!()
+ end
+
assert [participation_one, participation_two] = Participation.for_user(user)
object2 = Pleroma.Object.normalize(activity_two)
diff --git a/test/moderation_log_test.exs b/test/moderation_log_test.exs
index 4240f6a65..f2168b735 100644
--- a/test/moderation_log_test.exs
+++ b/test/moderation_log_test.exs
@@ -214,7 +214,7 @@ test "logging report response", %{moderator: moderator} do
{:ok, _} =
ModerationLog.insert_log(%{
actor: moderator,
- action: "report_response",
+ action: "report_note",
subject: report,
text: "look at this"
})
@@ -222,7 +222,7 @@ test "logging report response", %{moderator: moderator} do
log = Repo.one(ModerationLog)
assert log.data["message"] ==
- "@#{moderator.nickname} responded with 'look at this' to report ##{report.id}"
+ "@#{moderator.nickname} added note 'look at this' to report ##{report.id}"
end
test "logging status sensitivity update", %{moderator: moderator} do
diff --git a/test/notification_test.exs b/test/notification_test.exs
index 34096f0b1..ffa3d4b8c 100644
--- a/test/notification_test.exs
+++ b/test/notification_test.exs
@@ -136,7 +136,10 @@ test "it creates a notification for an activity from a muted thread" do
test "it disables notifications from followers" do
follower = insert(:user)
- followed = insert(:user, notification_settings: %{"followers" => false})
+
+ followed =
+ insert(:user, notification_settings: %Pleroma.User.NotificationSetting{followers: false})
+
User.follow(follower, followed)
{:ok, activity} = CommonAPI.post(follower, %{"status" => "hey @#{followed.nickname}"})
refute Notification.create_notification(activity, followed)
@@ -144,13 +147,20 @@ test "it disables notifications from followers" do
test "it disables notifications from non-followers" do
follower = insert(:user)
- followed = insert(:user, notification_settings: %{"non_followers" => false})
+
+ followed =
+ insert(:user,
+ notification_settings: %Pleroma.User.NotificationSetting{non_followers: false}
+ )
+
{:ok, activity} = CommonAPI.post(follower, %{"status" => "hey @#{followed.nickname}"})
refute Notification.create_notification(activity, followed)
end
test "it disables notifications from people the user follows" do
- follower = insert(:user, notification_settings: %{"follows" => false})
+ follower =
+ insert(:user, notification_settings: %Pleroma.User.NotificationSetting{follows: false})
+
followed = insert(:user)
User.follow(follower, followed)
follower = Repo.get(User, follower.id)
@@ -159,7 +169,9 @@ test "it disables notifications from people the user follows" do
end
test "it disables notifications from people the user does not follow" do
- follower = insert(:user, notification_settings: %{"non_follows" => false})
+ follower =
+ insert(:user, notification_settings: %Pleroma.User.NotificationSetting{non_follows: false})
+
followed = insert(:user)
{:ok, activity} = CommonAPI.post(followed, %{"status" => "hey @#{follower.nickname}"})
refute Notification.create_notification(activity, follower)
@@ -643,13 +655,7 @@ test "move activity generates a notification" do
Pleroma.Web.ActivityPub.ActivityPub.move(old_user, new_user)
ObanHelpers.perform_all()
- assert [
- %{
- activity: %{
- data: %{"type" => "Move", "actor" => ^old_ap_id, "target" => ^new_ap_id}
- }
- }
- ] = Notification.for_user(follower)
+ assert [] = Notification.for_user(follower)
assert [
%{
@@ -657,7 +663,17 @@ test "move activity generates a notification" do
data: %{"type" => "Move", "actor" => ^old_ap_id, "target" => ^new_ap_id}
}
}
- ] = Notification.for_user(other_follower)
+ ] = Notification.for_user(follower, %{with_move: true})
+
+ assert [] = Notification.for_user(other_follower)
+
+ assert [
+ %{
+ activity: %{
+ data: %{"type" => "Move", "actor" => ^old_ap_id, "target" => ^new_ap_id}
+ }
+ }
+ ] = Notification.for_user(other_follower, %{with_move: true})
end
end
diff --git a/test/plugs/oauth_scopes_plug_test.exs b/test/plugs/oauth_scopes_plug_test.exs
index be6d1340b..89f32f43a 100644
--- a/test/plugs/oauth_scopes_plug_test.exs
+++ b/test/plugs/oauth_scopes_plug_test.exs
@@ -224,4 +224,42 @@ test "filters scopes which directly match or are ancestors of supported scopes"
assert f.(["admin:read"], ["write", "admin"]) == ["admin:read"]
end
end
+
+ describe "transform_scopes/2" do
+ clear_config([:auth, :enforce_oauth_admin_scope_usage])
+
+ setup do
+ {:ok, %{f: &OAuthScopesPlug.transform_scopes/2}}
+ end
+
+ test "with :admin option, prefixes all requested scopes with `admin:` " <>
+ "and [optionally] keeps only prefixed scopes, " <>
+ "depending on `[:auth, :enforce_oauth_admin_scope_usage]` setting",
+ %{f: f} do
+ Pleroma.Config.put([:auth, :enforce_oauth_admin_scope_usage], false)
+
+ assert f.(["read"], %{admin: true}) == ["admin:read", "read"]
+
+ assert f.(["read", "write"], %{admin: true}) == [
+ "admin:read",
+ "read",
+ "admin:write",
+ "write"
+ ]
+
+ Pleroma.Config.put([:auth, :enforce_oauth_admin_scope_usage], true)
+
+ assert f.(["read:accounts"], %{admin: true}) == ["admin:read:accounts"]
+
+ assert f.(["read", "write:reports"], %{admin: true}) == [
+ "admin:read",
+ "admin:write:reports"
+ ]
+ end
+
+ test "with no supported options, returns unmodified scopes", %{f: f} do
+ assert f.(["read"], %{}) == ["read"]
+ assert f.(["read", "write"], %{}) == ["read", "write"]
+ end
+ end
end
diff --git a/test/plugs/rate_limiter_test.exs b/test/plugs/rate_limiter_test.exs
index 49f63c424..78f1ea9e4 100644
--- a/test/plugs/rate_limiter_test.exs
+++ b/test/plugs/rate_limiter_test.exs
@@ -145,9 +145,9 @@ test "are restricted based on remote IP" do
test "can have limits seperate from unauthenticated connections" do
limiter_name = :test_authenticated
- scale = 1000
+ scale = 50
limit = 5
- Pleroma.Config.put([:rate_limit, limiter_name], [{1, 10}, {scale, limit}])
+ Pleroma.Config.put([:rate_limit, limiter_name], [{1000, 1}, {scale, limit}])
opts = RateLimiter.init(name: limiter_name)
@@ -164,16 +164,6 @@ test "can have limits seperate from unauthenticated connections" do
assert %{"error" => "Throttled"} = Phoenix.ConnTest.json_response(conn, :too_many_requests)
assert conn.halted
-
- Process.sleep(1550)
-
- conn = conn(:get, "/") |> assign(:user, user)
- conn = RateLimiter.call(conn, opts)
- assert {1, 4} = RateLimiter.inspect_bucket(conn, limiter_name, opts)
-
- refute conn.status == Plug.Conn.Status.code(:too_many_requests)
- refute conn.resp_body
- refute conn.halted
end
test "diffrerent users are counted independently" do
diff --git a/test/plugs/user_is_admin_plug_test.exs b/test/plugs/user_is_admin_plug_test.exs
index 136dcc54e..bc6fcd73c 100644
--- a/test/plugs/user_is_admin_plug_test.exs
+++ b/test/plugs/user_is_admin_plug_test.exs
@@ -8,36 +8,116 @@ defmodule Pleroma.Plugs.UserIsAdminPlugTest do
alias Pleroma.Plugs.UserIsAdminPlug
import Pleroma.Factory
- test "accepts a user that is admin" do
- user = insert(:user, is_admin: true)
+ describe "unless [:auth, :enforce_oauth_admin_scope_usage]," do
+ clear_config([:auth, :enforce_oauth_admin_scope_usage]) do
+ Pleroma.Config.put([:auth, :enforce_oauth_admin_scope_usage], false)
+ end
- conn =
- build_conn()
- |> assign(:user, user)
+ test "accepts a user that is an admin" do
+ user = insert(:user, is_admin: true)
- ret_conn =
- conn
- |> UserIsAdminPlug.call(%{})
+ conn = assign(build_conn(), :user, user)
- assert conn == ret_conn
+ ret_conn = UserIsAdminPlug.call(conn, %{})
+
+ assert conn == ret_conn
+ end
+
+ test "denies a user that isn't an admin" do
+ user = insert(:user)
+
+ conn =
+ build_conn()
+ |> assign(:user, user)
+ |> UserIsAdminPlug.call(%{})
+
+ assert conn.status == 403
+ end
+
+ test "denies when a user isn't set" do
+ conn = UserIsAdminPlug.call(build_conn(), %{})
+
+ assert conn.status == 403
+ end
end
- test "denies a user that isn't admin" do
- user = insert(:user)
+ describe "with [:auth, :enforce_oauth_admin_scope_usage]," do
+ clear_config([:auth, :enforce_oauth_admin_scope_usage]) do
+ Pleroma.Config.put([:auth, :enforce_oauth_admin_scope_usage], true)
+ end
- conn =
- build_conn()
- |> assign(:user, user)
- |> UserIsAdminPlug.call(%{})
+ setup do
+ admin_user = insert(:user, is_admin: true)
+ non_admin_user = insert(:user, is_admin: false)
+ blank_user = nil
- assert conn.status == 403
- end
+ {:ok, %{users: [admin_user, non_admin_user, blank_user]}}
+ end
- test "denies when a user isn't set" do
- conn =
- build_conn()
- |> UserIsAdminPlug.call(%{})
+ test "if token has any of admin scopes, accepts a user that is an admin", %{conn: conn} do
+ user = insert(:user, is_admin: true)
+ token = insert(:oauth_token, user: user, scopes: ["admin:something"])
- assert conn.status == 403
+ conn =
+ conn
+ |> assign(:user, user)
+ |> assign(:token, token)
+
+ ret_conn = UserIsAdminPlug.call(conn, %{})
+
+ assert conn == ret_conn
+ end
+
+ test "if token has any of admin scopes, denies a user that isn't an admin", %{conn: conn} do
+ user = insert(:user, is_admin: false)
+ token = insert(:oauth_token, user: user, scopes: ["admin:something"])
+
+ conn =
+ conn
+ |> assign(:user, user)
+ |> assign(:token, token)
+ |> UserIsAdminPlug.call(%{})
+
+ assert conn.status == 403
+ end
+
+ test "if token has any of admin scopes, denies when a user isn't set", %{conn: conn} do
+ token = insert(:oauth_token, scopes: ["admin:something"])
+
+ conn =
+ conn
+ |> assign(:user, nil)
+ |> assign(:token, token)
+ |> UserIsAdminPlug.call(%{})
+
+ assert conn.status == 403
+ end
+
+ test "if token lacks admin scopes, denies users regardless of is_admin flag",
+ %{users: users} do
+ for user <- users do
+ token = insert(:oauth_token, user: user)
+
+ conn =
+ build_conn()
+ |> assign(:user, user)
+ |> assign(:token, token)
+ |> UserIsAdminPlug.call(%{})
+
+ assert conn.status == 403
+ end
+ end
+
+ test "if token is missing, denies users regardless of is_admin flag", %{users: users} do
+ for user <- users do
+ conn =
+ build_conn()
+ |> assign(:user, user)
+ |> assign(:token, nil)
+ |> UserIsAdminPlug.call(%{})
+
+ assert conn.status == 403
+ end
+ end
end
end
diff --git a/test/support/builders/user_builder.ex b/test/support/builders/user_builder.ex
index 6da16f71a..fcfea666f 100644
--- a/test/support/builders/user_builder.ex
+++ b/test/support/builders/user_builder.ex
@@ -10,7 +10,8 @@ def build(data \\ %{}) do
password_hash: Comeonin.Pbkdf2.hashpwsalt("test"),
bio: "A tester.",
ap_id: "some id",
- last_digest_emailed_at: NaiveDateTime.truncate(NaiveDateTime.utc_now(), :second)
+ last_digest_emailed_at: NaiveDateTime.truncate(NaiveDateTime.utc_now(), :second),
+ notification_settings: %Pleroma.User.NotificationSetting{}
}
Map.merge(user, data)
diff --git a/test/support/channel_case.ex b/test/support/channel_case.ex
index 466d8986f..4a4585844 100644
--- a/test/support/channel_case.ex
+++ b/test/support/channel_case.ex
@@ -23,6 +23,7 @@ defmodule Pleroma.Web.ChannelCase do
quote do
# Import conveniences for testing with channels
use Phoenix.ChannelTest
+ use Pleroma.Tests.Helpers
# The default endpoint for testing
@endpoint Pleroma.Web.Endpoint
diff --git a/test/support/factory.ex b/test/support/factory.ex
index 35ba523a1..314f26ec9 100644
--- a/test/support/factory.ex
+++ b/test/support/factory.ex
@@ -31,7 +31,8 @@ def user_factory do
nickname: sequence(:nickname, &"nick#{&1}"),
password_hash: Comeonin.Pbkdf2.hashpwsalt("test"),
bio: sequence(:bio, &"Tester Number #{&1}"),
- last_digest_emailed_at: NaiveDateTime.utc_now()
+ last_digest_emailed_at: NaiveDateTime.utc_now(),
+ notification_settings: %Pleroma.User.NotificationSetting{}
}
%{
diff --git a/test/tasks/config_test.exs b/test/tasks/config_test.exs
index 9cd47380c..fab9d6e9a 100644
--- a/test/tasks/config_test.exs
+++ b/test/tasks/config_test.exs
@@ -63,4 +63,84 @@ test "settings are migrated to file and deleted from db", %{temp_file: temp_file
assert file =~ "config :pleroma, :setting_first,"
assert file =~ "config :pleroma, :setting_second,"
end
+
+ test "load a settings with large values and pass to file", %{temp_file: temp_file} do
+ Config.create(%{
+ group: "pleroma",
+ key: ":instance",
+ value: [
+ name: "Pleroma",
+ email: "example@example.com",
+ notify_email: "noreply@example.com",
+ description: "A Pleroma instance, an alternative fediverse server",
+ limit: 5_000,
+ chat_limit: 5_000,
+ remote_limit: 100_000,
+ upload_limit: 16_000_000,
+ avatar_upload_limit: 2_000_000,
+ background_upload_limit: 4_000_000,
+ banner_upload_limit: 4_000_000,
+ poll_limits: %{
+ max_options: 20,
+ max_option_chars: 200,
+ min_expiration: 0,
+ max_expiration: 365 * 24 * 60 * 60
+ },
+ registrations_open: true,
+ federating: true,
+ federation_incoming_replies_max_depth: 100,
+ federation_reachability_timeout_days: 7,
+ federation_publisher_modules: [Pleroma.Web.ActivityPub.Publisher],
+ allow_relay: true,
+ rewrite_policy: Pleroma.Web.ActivityPub.MRF.NoOpPolicy,
+ public: true,
+ quarantined_instances: [],
+ managed_config: true,
+ static_dir: "instance/static/",
+ allowed_post_formats: ["text/plain", "text/html", "text/markdown", "text/bbcode"],
+ mrf_transparency: true,
+ mrf_transparency_exclusions: [],
+ autofollowed_nicknames: [],
+ max_pinned_statuses: 1,
+ no_attachment_links: true,
+ welcome_user_nickname: nil,
+ welcome_message: nil,
+ max_report_comment_size: 1000,
+ safe_dm_mentions: false,
+ healthcheck: false,
+ remote_post_retention_days: 90,
+ skip_thread_containment: true,
+ limit_to_local_content: :unauthenticated,
+ dynamic_configuration: false,
+ user_bio_length: 5000,
+ user_name_length: 100,
+ max_account_fields: 10,
+ max_remote_account_fields: 20,
+ account_field_name_length: 512,
+ account_field_value_length: 2048,
+ external_user_synchronization: true,
+ extended_nickname_format: true,
+ multi_factor_authentication: [
+ totp: [
+ # digits 6 or 8
+ digits: 6,
+ period: 30
+ ],
+ backup_codes: [
+ number: 2,
+ length: 6
+ ]
+ ]
+ ]
+ })
+
+ Mix.Tasks.Pleroma.Config.run(["migrate_from_db", "temp", "true"])
+
+ assert Repo.all(Config) == []
+ assert File.exists?(temp_file)
+ {:ok, file} = File.read(temp_file)
+
+ assert file ==
+ "use Mix.Config\n\nconfig :pleroma, :instance,\n name: \"Pleroma\",\n email: \"example@example.com\",\n notify_email: \"noreply@example.com\",\n description: \"A Pleroma instance, an alternative fediverse server\",\n limit: 5000,\n chat_limit: 5000,\n remote_limit: 100_000,\n upload_limit: 16_000_000,\n avatar_upload_limit: 2_000_000,\n background_upload_limit: 4_000_000,\n banner_upload_limit: 4_000_000,\n poll_limits: %{\n max_expiration: 31_536_000,\n max_option_chars: 200,\n max_options: 20,\n min_expiration: 0\n },\n registrations_open: true,\n federating: true,\n federation_incoming_replies_max_depth: 100,\n federation_reachability_timeout_days: 7,\n federation_publisher_modules: [Pleroma.Web.ActivityPub.Publisher],\n allow_relay: true,\n rewrite_policy: Pleroma.Web.ActivityPub.MRF.NoOpPolicy,\n public: true,\n quarantined_instances: [],\n managed_config: true,\n static_dir: \"instance/static/\",\n allowed_post_formats: [\"text/plain\", \"text/html\", \"text/markdown\", \"text/bbcode\"],\n mrf_transparency: true,\n mrf_transparency_exclusions: [],\n autofollowed_nicknames: [],\n max_pinned_statuses: 1,\n no_attachment_links: true,\n welcome_user_nickname: nil,\n welcome_message: nil,\n max_report_comment_size: 1000,\n safe_dm_mentions: false,\n healthcheck: false,\n remote_post_retention_days: 90,\n skip_thread_containment: true,\n limit_to_local_content: :unauthenticated,\n dynamic_configuration: false,\n user_bio_length: 5000,\n user_name_length: 100,\n max_account_fields: 10,\n max_remote_account_fields: 20,\n account_field_name_length: 512,\n account_field_value_length: 2048,\n external_user_synchronization: true,\n extended_nickname_format: true,\n multi_factor_authentication: [\n totp: [digits: 6, period: 30],\n backup_codes: [number: 2, length: 6]\n ]\n"
+ end
end
diff --git a/test/user/notification_setting_test.exs b/test/user/notification_setting_test.exs
new file mode 100644
index 000000000..4744d7b4a
--- /dev/null
+++ b/test/user/notification_setting_test.exs
@@ -0,0 +1,21 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2019 Pleroma Authors