X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=test%2Fpleroma%2Fweb%2Fmastodon_api%2Fupdate_credentials_test.exs;h=1d20278998923323feec3335e0c7e95722b4b870;hb=838da53ea72cba73fb4643194a102d55a90ea535;hp=9340b3ae0588c8e15552549faf6ae6715d303c12;hpb=8b20c4d2752d620cbcd8b5d122abe7d143878a97;p=akkoma
diff --git a/test/pleroma/web/mastodon_api/update_credentials_test.exs b/test/pleroma/web/mastodon_api/update_credentials_test.exs
index 9340b3ae0..1d2027899 100644
--- a/test/pleroma/web/mastodon_api/update_credentials_test.exs
+++ b/test/pleroma/web/mastodon_api/update_credentials_test.exs
@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors
+# Copyright © 2017-2021 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.MastodonAPI.UpdateCredentialsTest do
@@ -11,8 +11,6 @@ defmodule Pleroma.Web.MastodonAPI.UpdateCredentialsTest do
import Mock
import Pleroma.Factory
- setup do: clear_config([:instance, :max_account_fields])
-
describe "updating credentials" do
setup do: oauth_access(["write:accounts"])
setup :request_content_type
@@ -37,8 +35,8 @@ defmodule Pleroma.Web.MastodonAPI.UpdateCredentialsTest do
|> assign(:user, user)
|> patch("/api/v1/accounts/update_credentials", %{
"pleroma_settings_store" => %{
- masto_fe: %{
- theme: "bla"
+ soapbox_fe: %{
+ themeMode: "bla"
}
}
})
@@ -48,7 +46,7 @@ defmodule Pleroma.Web.MastodonAPI.UpdateCredentialsTest do
assert user_data["pleroma"]["settings_store"] ==
%{
"pleroma_fe" => %{"theme" => "bla"},
- "masto_fe" => %{"theme" => "bla"}
+ "soapbox_fe" => %{"themeMode" => "bla"}
}
user = Repo.get(User, user_data["id"])
@@ -62,8 +60,8 @@ defmodule Pleroma.Web.MastodonAPI.UpdateCredentialsTest do
|> assign(:user, user)
|> patch("/api/v1/accounts/update_credentials", %{
"pleroma_settings_store" => %{
- masto_fe: %{
- theme: "blub"
+ soapbox_fe: %{
+ themeMode: "blub"
}
}
})
@@ -73,7 +71,7 @@ defmodule Pleroma.Web.MastodonAPI.UpdateCredentialsTest do
assert user_data["pleroma"]["settings_store"] ==
%{
"pleroma_fe" => %{"theme" => "bla"},
- "masto_fe" => %{"theme" => "blub"}
+ "soapbox_fe" => %{"themeMode" => "blub"}
}
assert_called(Pleroma.Web.Federator.publish(:_))
@@ -90,9 +88,7 @@ defmodule Pleroma.Web.MastodonAPI.UpdateCredentialsTest do
assert user_data = json_response_and_validate_schema(conn, 200)
assert user_data["note"] ==
- ~s(I drink #cofe with @#{user2.nickname}
suya..)
+ ~s(I drink #cofe with @#{user2.nickname}
suya..)
assert user_data["source"]["note"] == raw_bio
@@ -102,10 +98,10 @@ defmodule Pleroma.Web.MastodonAPI.UpdateCredentialsTest do
end
test "updates the user's locking status", %{conn: conn} do
- conn = patch(conn, "/api/v1/accounts/update_credentials", %{is_locked: "true"})
+ conn = patch(conn, "/api/v1/accounts/update_credentials", %{locked: "true"})
assert user_data = json_response_and_validate_schema(conn, 200)
- assert user_data["is_locked"] == true
+ assert user_data["locked"] == true
end
test "updates the user's chat acceptance status", %{conn: conn} do
@@ -220,9 +216,28 @@ defmodule Pleroma.Web.MastodonAPI.UpdateCredentialsTest do
assert update_activity.data["object"]["name"] == "markorepairs"
end
+ test "updates the user's AKAs", %{conn: conn} do
+ conn =
+ patch(conn, "/api/v1/accounts/update_credentials", %{
+ "also_known_as" => ["https://mushroom.kingdom/users/mario"]
+ })
+
+ assert user_data = json_response_and_validate_schema(conn, 200)
+ assert user_data["pleroma"]["also_known_as"] == ["https://mushroom.kingdom/users/mario"]
+ end
+
+ test "doesn't update non-url akas", %{conn: conn} do
+ conn =
+ patch(conn, "/api/v1/accounts/update_credentials", %{
+ "also_known_as" => ["aReallyCoolGuy"]
+ })
+
+ assert json_response_and_validate_schema(conn, 403)
+ end
+
test "updates the user's avatar", %{user: user, conn: conn} do
new_avatar = %Plug.Upload{
- content_type: "image/jpg",
+ content_type: "image/jpeg",
path: Path.absname("test/fixtures/image.jpg"),
filename: "an_image.jpg"
}
@@ -246,7 +261,7 @@ defmodule Pleroma.Web.MastodonAPI.UpdateCredentialsTest do
test "updates the user's banner", %{user: user, conn: conn} do
new_header = %Plug.Upload{
- content_type: "image/jpg",
+ content_type: "image/jpeg",
path: Path.absname("test/fixtures/image.jpg"),
filename: "an_image.jpg"
}
@@ -265,7 +280,7 @@ defmodule Pleroma.Web.MastodonAPI.UpdateCredentialsTest do
test "updates the user's background", %{conn: conn, user: user} do
new_header = %Plug.Upload{
- content_type: "image/jpg",
+ content_type: "image/jpeg",
path: Path.absname("test/fixtures/image.jpg"),
filename: "an_image.jpg"
}
@@ -446,7 +461,7 @@ defmodule Pleroma.Web.MastodonAPI.UpdateCredentialsTest do
|> patch("/api/v1/accounts/update_credentials", %{"fields_attributes" => fields})
|> json_response_and_validate_schema(403)
- Pleroma.Config.put([:instance, :max_account_fields], 1)
+ clear_config([:instance, :max_account_fields], 1)
fields = [
%{"name" => "foo", "value" => "bar"},