summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/pleroma/docs/generator_test.exs2
-rw-r--r--test/pleroma/web/activity_pub/mrf/object_age_policy_test.exs1
-rw-r--r--test/pleroma/web/admin_api/controllers/frontend_controller_test.exs14
-rw-r--r--test/pleroma/web/twitter_api/util_controller_test.exs131
4 files changed, 73 insertions, 75 deletions
diff --git a/test/pleroma/docs/generator_test.exs b/test/pleroma/docs/generator_test.exs
index a9b09e577..8574c1d5e 100644
--- a/test/pleroma/docs/generator_test.exs
+++ b/test/pleroma/docs/generator_test.exs
@@ -23,7 +23,7 @@ defmodule Pleroma.Docs.GeneratorTest do
key: :filters,
type: {:list, :module},
description: "",
- suggestions: {:list_behaviour_implementations, Pleroma.Web.ActivityPub.MRF}
+ suggestions: {:list_behaviour_implementations, Pleroma.Web.ActivityPub.MRF.Policy}
},
%{
key: Pleroma.Upload,
diff --git a/test/pleroma/web/activity_pub/mrf/object_age_policy_test.exs b/test/pleroma/web/activity_pub/mrf/object_age_policy_test.exs
index 137aafd39..2f649a0a4 100644
--- a/test/pleroma/web/activity_pub/mrf/object_age_policy_test.exs
+++ b/test/pleroma/web/activity_pub/mrf/object_age_policy_test.exs
@@ -22,6 +22,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.ObjectAgePolicyTest do
defp get_old_message do
File.read!("test/fixtures/mastodon-post-activity.json")
|> Jason.decode!()
+ |> Map.drop(["published"])
end
defp get_new_message do
diff --git a/test/pleroma/web/admin_api/controllers/frontend_controller_test.exs b/test/pleroma/web/admin_api/controllers/frontend_controller_test.exs
index bc827cc12..200682ba9 100644
--- a/test/pleroma/web/admin_api/controllers/frontend_controller_test.exs
+++ b/test/pleroma/web/admin_api/controllers/frontend_controller_test.exs
@@ -42,6 +42,20 @@ defmodule Pleroma.Web.AdminAPI.FrontendControllerTest do
refute Enum.any?(response, fn frontend -> frontend["installed"] == true end)
end
+
+ test "it lists available frontends when no frontend folder was created yet", %{conn: conn} do
+ File.rm_rf(@dir)
+
+ response =
+ conn
+ |> get("/api/pleroma/admin/frontends")
+ |> json_response_and_validate_schema(:ok)
+
+ assert Enum.map(response, & &1["name"]) ==
+ Enum.map(Config.get([:frontends, :available]), fn {_, map} -> map["name"] end)
+
+ refute Enum.any?(response, fn frontend -> frontend["installed"] == true end)
+ end
end
describe "POST /api/pleroma/admin/frontends/install" do
diff --git a/test/pleroma/web/twitter_api/util_controller_test.exs b/test/pleroma/web/twitter_api/util_controller_test.exs
index cc17940b5..f030483d8 100644
--- a/test/pleroma/web/twitter_api/util_controller_test.exs
+++ b/test/pleroma/web/twitter_api/util_controller_test.exs
@@ -261,11 +261,8 @@ defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do
conn =
conn
|> assign(:token, nil)
- |> post(
- "/api/pleroma/change_email?#{
- URI.encode_query(%{password: "hi", email: "test@test.com"})
- }"
- )
+ |> put_req_header("content-type", "multipart/form-data")
+ |> post("/api/pleroma/change_email", %{password: "hi", email: "test@test.com"})
assert json_response_and_validate_schema(conn, 403) == %{
"error" => "Insufficient permissions: write:accounts."
@@ -274,12 +271,9 @@ defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do
test "with proper permissions and invalid password", %{conn: conn} do
conn =
- post(
- conn,
- "/api/pleroma/change_email?#{
- URI.encode_query(%{password: "hi", email: "test@test.com"})
- }"
- )
+ conn
+ |> put_req_header("content-type", "multipart/form-data")
+ |> post("/api/pleroma/change_email", %{password: "hi", email: "test@test.com"})
assert json_response_and_validate_schema(conn, 200) == %{"error" => "Invalid password."}
end
@@ -288,10 +282,9 @@ defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do
conn: conn
} do
conn =
- post(
- conn,
- "/api/pleroma/change_email?#{URI.encode_query(%{password: "test", email: "foobar"})}"
- )
+ conn
+ |> put_req_header("content-type", "multipart/form-data")
+ |> post("/api/pleroma/change_email", %{password: "test", email: "foobar"})
assert json_response_and_validate_schema(conn, 200) == %{
"error" => "Email has invalid format."
@@ -301,7 +294,10 @@ defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do
test "with proper permissions, valid password and no email", %{
conn: conn
} do
- conn = post(conn, "/api/pleroma/change_email?#{URI.encode_query(%{password: "test"})}")
+ conn =
+ conn
+ |> put_req_header("content-type", "multipart/form-data")
+ |> post("/api/pleroma/change_email", %{password: "test"})
assert %{"error" => "Missing field: email."} = json_response_and_validate_schema(conn, 400)
end
@@ -310,10 +306,9 @@ defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do
conn: conn
} do
conn =
- post(
- conn,
- "/api/pleroma/change_email?#{URI.encode_query(%{password: "test", email: ""})}"
- )
+ conn
+ |> put_req_header("content-type", "multipart/form-data")
+ |> post("/api/pleroma/change_email", %{password: "test", email: ""})
assert json_response_and_validate_schema(conn, 200) == %{"error" => "Email can't be blank."}
end
@@ -324,10 +319,9 @@ defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do
user = insert(:user)
conn =
- post(
- conn,
- "/api/pleroma/change_email?#{URI.encode_query(%{password: "test", email: user.email})}"
- )
+ conn
+ |> put_req_header("content-type", "multipart/form-data")
+ |> post("/api/pleroma/change_email", %{password: "test", email: user.email})
assert json_response_and_validate_schema(conn, 200) == %{
"error" => "Email has already been taken."
@@ -338,12 +332,9 @@ defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do
conn: conn
} do
conn =
- post(
- conn,
- "/api/pleroma/change_email?#{
- URI.encode_query(%{password: "test", email: "cofe@foobar.com"})
- }"
- )
+ conn
+ |> put_req_header("content-type", "multipart/form-data")
+ |> post("/api/pleroma/change_email", %{password: "test", email: "cofe@foobar.com"})
assert json_response_and_validate_schema(conn, 200) == %{"status" => "success"}
end
@@ -356,15 +347,12 @@ defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do
conn =
conn
|> assign(:token, nil)
- |> post(
- "/api/pleroma/change_password?#{
- URI.encode_query(%{
- password: "hi",
- new_password: "newpass",
- new_password_confirmation: "newpass"
- })
- }"
- )
+ |> put_req_header("content-type", "multipart/form-data")
+ |> post("/api/pleroma/change_password", %{
+ "password" => "hi",
+ "new_password" => "newpass",
+ "new_password_confirmation" => "newpass"
+ })
assert json_response_and_validate_schema(conn, 403) == %{
"error" => "Insufficient permissions: write:accounts."
@@ -373,16 +361,13 @@ defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do
test "with proper permissions and invalid password", %{conn: conn} do
conn =
- post(
- conn,
- "/api/pleroma/change_password?#{
- URI.encode_query(%{
- password: "hi",
- new_password: "newpass",
- new_password_confirmation: "newpass"
- })
- }"
- )
+ conn
+ |> put_req_header("content-type", "multipart/form-data")
+ |> post("/api/pleroma/change_password", %{
+ "password" => "hi",
+ "new_password" => "newpass",
+ "new_password_confirmation" => "newpass"
+ })
assert json_response_and_validate_schema(conn, 200) == %{"error" => "Invalid password."}
end
@@ -392,16 +377,13 @@ defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do
conn: conn
} do
conn =
- post(
- conn,
- "/api/pleroma/change_password?#{
- URI.encode_query(%{
- password: "test",
- new_password: "newpass",
- new_password_confirmation: "notnewpass"
- })
- }"
- )
+ conn
+ |> put_req_header("content-type", "multipart/form-data")
+ |> post("/api/pleroma/change_password", %{
+ "password" => "test",
+ "new_password" => "newpass",
+ "new_password_confirmation" => "notnewpass"
+ })
assert json_response_and_validate_schema(conn, 200) == %{
"error" => "New password does not match confirmation."
@@ -412,12 +394,13 @@ defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do
conn: conn
} do
conn =
- post(
- conn,
- "/api/pleroma/change_password?#{
- URI.encode_query(%{password: "test", new_password: "", new_password_confirmation: ""})
- }"
- )
+ conn
+ |> put_req_header("content-type", "multipart/form-data")
+ |> post("/api/pleroma/change_password", %{
+ password: "test",
+ new_password: "",
+ new_password_confirmation: ""
+ })
assert json_response_and_validate_schema(conn, 200) == %{
"error" => "New password can't be blank."
@@ -429,15 +412,15 @@ defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do
user: user
} do
conn =
- post(
- conn,
- "/api/pleroma/change_password?#{
- URI.encode_query(%{
- password: "test",
- new_password: "newpass",
- new_password_confirmation: "newpass"
- })
- }"
+ conn
+ |> put_req_header("content-type", "multipart/form-data")
+ |> post(
+ "/api/pleroma/change_password",
+ %{
+ password: "test",
+ new_password: "newpass",
+ new_password_confirmation: "newpass"
+ }
)
assert json_response_and_validate_schema(conn, 200) == %{"status" => "success"}