diff options
author | kaniini <ariadne@dereferenced.org> | 2019-07-29 16:28:53 +0000 |
---|---|---|
committer | kaniini <ariadne@dereferenced.org> | 2019-07-29 16:28:53 +0000 |
commit | ce6dfb6f066616553d8594fd6ffadcc96ad1daff (patch) | |
tree | b7b4022f45fd01233bf76138d5222b81f16e8ad4 /test | |
parent | 5cb37412a21420509f61027fe486ae66242f800a (diff) | |
parent | d9aacbec4d8e787ff9f62427a120d28366463a7f (diff) | |
download | pleroma-1.0.2.tar.gz |
Merge branch 'release/1.0.2' into 'master'v1.0.2
1.0.2 release
See merge request pleroma/pleroma!1499
Diffstat (limited to 'test')
-rw-r--r-- | test/media_proxy_test.exs | 19 | ||||
-rw-r--r-- | test/notification_test.exs | 58 | ||||
-rw-r--r-- | test/web/common_api/common_api_test.exs | 5 | ||||
-rw-r--r-- | test/web/mastodon_api/mastodon_api_controller_test.exs | 2 | ||||
-rw-r--r-- | test/web/mastodon_api/status_view_test.exs | 2 |
5 files changed, 76 insertions, 10 deletions
diff --git a/test/media_proxy_test.exs b/test/media_proxy_test.exs index b23aeb88b..69e9bc9f4 100644 --- a/test/media_proxy_test.exs +++ b/test/media_proxy_test.exs @@ -96,10 +96,10 @@ defmodule Pleroma.MediaProxyTest do assert decode_url(sig, base64) == {:error, :invalid_signature} end - test "filename_matches matches url encoded paths" do + test "filename_matches preserves the encoded or decoded path" do assert MediaProxyController.filename_matches( true, - "/Hello%20world.jpg", + "/Hello world.jpg", "http://pleroma.social/Hello world.jpg" ) == :ok @@ -108,19 +108,22 @@ defmodule Pleroma.MediaProxyTest do "/Hello%20world.jpg", "http://pleroma.social/Hello%20world.jpg" ) == :ok - end - test "filename_matches matches non-url encoded paths" do assert MediaProxyController.filename_matches( true, - "/Hello world.jpg", - "http://pleroma.social/Hello%20world.jpg" + "/my%2Flong%2Furl%2F2019%2F07%2FS.jpg", + "http://pleroma.social/my%2Flong%2Furl%2F2019%2F07%2FS.jpg" ) == :ok + end + + test "encoded url are tried to match for proxy as `conn.request_path` encodes the url" do + # conn.request_path will return encoded url + request_path = "/ANALYSE-DAI-_-LE-STABLECOIN-100-D%C3%89CENTRALIS%C3%89-BQ.jpg" assert MediaProxyController.filename_matches( true, - "/Hello world.jpg", - "http://pleroma.social/Hello world.jpg" + request_path, + "https://mydomain.com/uploads/2019/07/ANALYSE-DAI-_-LE-STABLECOIN-100-DÉCENTRALISÉ-BQ.jpg" ) == :ok end diff --git a/test/notification_test.exs b/test/notification_test.exs index 1d36f14bf..8fee2bd81 100644 --- a/test/notification_test.exs +++ b/test/notification_test.exs @@ -531,5 +531,63 @@ defmodule Pleroma.NotificationTest do assert Enum.empty?(Notification.for_user(user)) end + + test "notifications are deleted if a local user is deleted" do + user = insert(:user) + other_user = insert(:user) + + {:ok, _activity} = + CommonAPI.post(user, %{"status" => "hi @#{other_user.nickname}", "visibility" => "direct"}) + + refute Enum.empty?(Notification.for_user(other_user)) + + User.delete(user) + + assert Enum.empty?(Notification.for_user(other_user)) + end + + test "notifications are deleted if a remote user is deleted" do + remote_user = insert(:user) + local_user = insert(:user) + + dm_message = %{ + "@context" => "https://www.w3.org/ns/activitystreams", + "type" => "Create", + "actor" => remote_user.ap_id, + "id" => remote_user.ap_id <> "/activities/test", + "to" => [local_user.ap_id], + "cc" => [], + "object" => %{ + "type" => "Note", + "content" => "Hello!", + "tag" => [ + %{ + "type" => "Mention", + "href" => local_user.ap_id, + "name" => "@#{local_user.nickname}" + } + ], + "to" => [local_user.ap_id], + "cc" => [], + "attributedTo" => remote_user.ap_id + } + } + + {:ok, _dm_activity} = Transmogrifier.handle_incoming(dm_message) + + refute Enum.empty?(Notification.for_user(local_user)) + + delete_user_message = %{ + "@context" => "https://www.w3.org/ns/activitystreams", + "id" => remote_user.ap_id <> "/activities/delete", + "actor" => remote_user.ap_id, + "type" => "Delete", + "object" => remote_user.ap_id + } + + {:ok, _delete_activity} = Transmogrifier.handle_incoming(delete_user_message) + + assert Enum.empty?(Notification.for_user(local_user)) + end end end diff --git a/test/web/common_api/common_api_test.exs b/test/web/common_api/common_api_test.exs index e96106f11..6f57bbe1f 100644 --- a/test/web/common_api/common_api_test.exs +++ b/test/web/common_api/common_api_test.exs @@ -188,6 +188,11 @@ defmodule Pleroma.Web.CommonAPITest do assert %User{info: %{pinned_activities: [^id]}} = user end + test "unlisted statuses can be pinned", %{user: user} do + {:ok, activity} = CommonAPI.post(user, %{"status" => "HI!!!", "visibility" => "unlisted"}) + assert {:ok, ^activity} = CommonAPI.pin(activity.id, user) + end + test "only self-authored can be pinned", %{activity: activity} do user = insert(:user) diff --git a/test/web/mastodon_api/mastodon_api_controller_test.exs b/test/web/mastodon_api/mastodon_api_controller_test.exs index 03f57dbfa..152ba8137 100644 --- a/test/web/mastodon_api/mastodon_api_controller_test.exs +++ b/test/web/mastodon_api/mastodon_api_controller_test.exs @@ -3300,7 +3300,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do |> get("/api/v1/polls/#{object.id}") response = json_response(conn, 200) - id = object.id + id = to_string(object.id) assert %{"id" => ^id, "expired" => false, "multiple" => false} = response end diff --git a/test/web/mastodon_api/status_view_test.exs b/test/web/mastodon_api/status_view_test.exs index ec75150ab..0d8eefeb8 100644 --- a/test/web/mastodon_api/status_view_test.exs +++ b/test/web/mastodon_api/status_view_test.exs @@ -361,7 +361,7 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do expected = %{ emojis: [], expired: false, - id: object.id, + id: to_string(object.id), multiple: false, options: [ %{title: "absolutely!", votes_count: 0}, |