projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Additional validation so we don't get caught off guard with a nil response
[akkoma]
/
test
/
pleroma
/
web
/
mastodon_api
/
update_credentials_test.exs
diff --git
a/test/pleroma/web/mastodon_api/update_credentials_test.exs
b/test/pleroma/web/mastodon_api/update_credentials_test.exs
index 0d49eb3343fff793805c8008e98325c239cf4f2d..cfbe6cf0e373d60e9567b3bbfd7d8e29f81ce84a 100644
(file)
--- 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
# Pleroma: A lightweight social networking server
-# Copyright © 2017-202
0
Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-202
1
Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.MastodonAPI.UpdateCredentialsTest do
# 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
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
describe "updating credentials" do
setup do: oauth_access(["write:accounts"])
setup :request_content_type
@@
-230,9
+228,18
@@
defmodule Pleroma.Web.MastodonAPI.UpdateCredentialsTest do
assert user_data["pleroma"]["also_known_as"] == ["https://mushroom.kingdom/users/mario"]
end
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{
test "updates the user's avatar", %{user: user, conn: conn} do
new_avatar = %Plug.Upload{
- content_type: "image/jpg",
+ content_type: "image/jp
e
g",
path: Path.absname("test/fixtures/image.jpg"),
filename: "an_image.jpg"
}
path: Path.absname("test/fixtures/image.jpg"),
filename: "an_image.jpg"
}
@@
-256,7
+263,7
@@
defmodule Pleroma.Web.MastodonAPI.UpdateCredentialsTest do
test "updates the user's banner", %{user: user, conn: conn} do
new_header = %Plug.Upload{
test "updates the user's banner", %{user: user, conn: conn} do
new_header = %Plug.Upload{
- content_type: "image/jpg",
+ content_type: "image/jp
e
g",
path: Path.absname("test/fixtures/image.jpg"),
filename: "an_image.jpg"
}
path: Path.absname("test/fixtures/image.jpg"),
filename: "an_image.jpg"
}
@@
-275,7
+282,7
@@
defmodule Pleroma.Web.MastodonAPI.UpdateCredentialsTest do
test "updates the user's background", %{conn: conn, user: user} do
new_header = %Plug.Upload{
test "updates the user's background", %{conn: conn, user: user} do
new_header = %Plug.Upload{
- content_type: "image/jpg",
+ content_type: "image/jp
e
g",
path: Path.absname("test/fixtures/image.jpg"),
filename: "an_image.jpg"
}
path: Path.absname("test/fixtures/image.jpg"),
filename: "an_image.jpg"
}
@@
-456,7
+463,7
@@
defmodule Pleroma.Web.MastodonAPI.UpdateCredentialsTest do
|> patch("/api/v1/accounts/update_credentials", %{"fields_attributes" => fields})
|> json_response_and_validate_schema(403)
|> 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"},
fields = [
%{"name" => "foo", "value" => "bar"},