From f42ffbe9a855494c182c97f5eb641e800e562aa4 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Tue, 12 Jun 2018 14:52:54 +0300 Subject: Initial invites support + tests. --- test/web/twitter_api/twitter_api_test.exs | 65 ++++++++++++++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) (limited to 'test/web') diff --git a/test/web/twitter_api/twitter_api_test.exs b/test/web/twitter_api/twitter_api_test.exs index edacb312d..ed9158bf5 100644 --- a/test/web/twitter_api/twitter_api_test.exs +++ b/test/web/twitter_api/twitter_api_test.exs @@ -2,7 +2,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do use Pleroma.DataCase alias Pleroma.Builders.UserBuilder alias Pleroma.Web.TwitterAPI.{TwitterAPI, UserView} - alias Pleroma.{Activity, User, Object, Repo} + alias Pleroma.{Activity, User, Object, Repo, UserInviteToken} alias Pleroma.Web.ActivityPub.ActivityPub alias Pleroma.Web.TwitterAPI.ActivityView @@ -246,6 +246,69 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do UserView.render("show.json", %{user: fetched_user}) end + @moduletag skip: "needs 'registrations_open: false' in config" + test "it registers a new user via invite token and returns the user." do + {:ok, token} = UserInviteToken.create_token() + + data = %{ + "nickname" => "vinny", + "email" => "pasta@pizza.vs", + "fullname" => "Vinny Vinesauce", + "bio" => "streamer", + "password" => "hiptofbees", + "confirm" => "hiptofbees", + "token" => token.token + } + + {:ok, user} = TwitterAPI.register_user(data) + + fetched_user = Repo.get_by(User, nickname: "vinny") + token = Repo.get_by(UserInviteToken, token: token.token) + + assert token.used == true + assert UserView.render("show.json", %{user: user}) == + UserView.render("show.json", %{user: fetched_user}) + end + + @moduletag skip: "needs 'registrations_open: false' in config" + test "it returns an error if invalid token submitted" do + data = %{ + "nickname" => "GrimReaper", + "email" => "death@reapers.afterlife", + "fullname" => "Reaper Grim", + "bio" => "Your time has come", + "password" => "scythe", + "confirm" => "scythe", + "token" => "DudeLetMeInImAFairy" + } + + {:error, msg} = TwitterAPI.register_user(data) + + assert msg == "Invalid token" + refute Repo.get_by(User, nickname: "GrimReaper") + end + + @moduletag skip: "needs 'registrations_open: false' in config" + test "it returns an error if expired token submitted" do + {:ok, token} = UserInviteToken.create_token() + UserInviteToken.mark_as_used(token.token) + + data = %{ + "nickname" => "GrimReaper", + "email" => "death@reapers.afterlife", + "fullname" => "Reaper Grim", + "bio" => "Your time has come", + "password" => "scythe", + "confirm" => "scythe", + "token" => token.token + } + + {:error, msg} = TwitterAPI.register_user(data) + + assert msg == "Expired token" + refute Repo.get_by(User, nickname: "GrimReaper") + end + test "it returns the error on registration problems" do data = %{ "nickname" => "lain", -- cgit v1.2.3 From 9c1cf1befb9905282f6b8afcfee3cf3578f41431 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Tue, 12 Jun 2018 15:01:40 +0300 Subject: formatting --- test/web/twitter_api/twitter_api_test.exs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'test/web') diff --git a/test/web/twitter_api/twitter_api_test.exs b/test/web/twitter_api/twitter_api_test.exs index ed9158bf5..bdf2f2885 100644 --- a/test/web/twitter_api/twitter_api_test.exs +++ b/test/web/twitter_api/twitter_api_test.exs @@ -266,8 +266,9 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do token = Repo.get_by(UserInviteToken, token: token.token) assert token.used == true + assert UserView.render("show.json", %{user: user}) == - UserView.render("show.json", %{user: fetched_user}) + UserView.render("show.json", %{user: fetched_user}) end @moduletag skip: "needs 'registrations_open: false' in config" -- cgit v1.2.3 From 9c2afb2e71d7ed072fbb43e2ef002e0d629ca877 Mon Sep 17 00:00:00 2001 From: hakabahitoyo Date: Sat, 21 Jul 2018 01:44:35 +0900 Subject: improve test --- test/web/activity_pub/activity_pub_controller_test.exs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'test/web') diff --git a/test/web/activity_pub/activity_pub_controller_test.exs b/test/web/activity_pub/activity_pub_controller_test.exs index 25b47ee31..b9294efe1 100644 --- a/test/web/activity_pub/activity_pub_controller_test.exs +++ b/test/web/activity_pub/activity_pub_controller_test.exs @@ -50,6 +50,20 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do end end + describe "/users/:nickname/outbox" do + test "it returns a note action in a collection", %{conn: conn} do + note_activity = insert(:note_activity) + user = User.get_cached_by_ap_id(note_activity.data["actor"]) + + conn = + conn + |> put_req_header("Accept", "application/activity+json") + |> get("/users/#{user.nickname}/outbox") + + assert response(conn, 200) =~ note_activity.data["object"]["content"] + end + end + describe "/users/:nickname/followers" do test "it returns the followers in a collection", %{conn: conn} do user = insert(:user) -- cgit v1.2.3 From 908cefd84a6cf9bddd04ad9521be2ff5b7d8f379 Mon Sep 17 00:00:00 2001 From: hakabahitoyo Date: Sat, 21 Jul 2018 02:19:20 +0900 Subject: debug --- test/web/activity_pub/activity_pub_controller_test.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/web') diff --git a/test/web/activity_pub/activity_pub_controller_test.exs b/test/web/activity_pub/activity_pub_controller_test.exs index b9294efe1..1daa5627c 100644 --- a/test/web/activity_pub/activity_pub_controller_test.exs +++ b/test/web/activity_pub/activity_pub_controller_test.exs @@ -57,7 +57,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do conn = conn - |> put_req_header("Accept", "application/activity+json") + |> put_req_header("accept", "application/activity+json") |> get("/users/#{user.nickname}/outbox") assert response(conn, 200) =~ note_activity.data["object"]["content"] -- cgit v1.2.3 From 9c1b6f11c501756362342b5652769c9dfd12e77c Mon Sep 17 00:00:00 2001 From: hakabahitoyo Date: Sat, 21 Jul 2018 02:57:56 +0900 Subject: improve test --- test/web/activity_pub/activity_pub_controller_test.exs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'test/web') diff --git a/test/web/activity_pub/activity_pub_controller_test.exs b/test/web/activity_pub/activity_pub_controller_test.exs index 1daa5627c..8a1c0d361 100644 --- a/test/web/activity_pub/activity_pub_controller_test.exs +++ b/test/web/activity_pub/activity_pub_controller_test.exs @@ -51,7 +51,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do end describe "/users/:nickname/outbox" do - test "it returns a note action in a collection", %{conn: conn} do + test "it returns a note activity in a collection", %{conn: conn} do note_activity = insert(:note_activity) user = User.get_cached_by_ap_id(note_activity.data["actor"]) @@ -62,6 +62,18 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do assert response(conn, 200) =~ note_activity.data["object"]["content"] end + + test "it returns an announce activity in a collection", %{conn: conn} do + announce_activity = insert(:announce_activity) + user = User.get_cached_by_ap_id(announce_activity.data["actor"]) + + conn = + conn + |> put_req_header("accept", "application/activity+json") + |> get("/users/#{user.nickname}/outbox") + + assert response(conn, 200) =~ announce_activity.data["object"] + end end describe "/users/:nickname/followers" do -- cgit v1.2.3 From cee63ad3f725a90fdd1a438520c33377cee8ad81 Mon Sep 17 00:00:00 2001 From: eal Date: Wed, 8 Aug 2018 08:38:25 +0300 Subject: TwitterAPI user view: add screen_name_html and description_html. --- test/web/twitter_api/views/user_view_test.exs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'test/web') diff --git a/test/web/twitter_api/views/user_view_test.exs b/test/web/twitter_api/views/user_view_test.exs index 49f73c2fe..000c589af 100644 --- a/test/web/twitter_api/views/user_view_test.exs +++ b/test/web/twitter_api/views/user_view_test.exs @@ -40,7 +40,9 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do "id" => user.id, "name" => user.name, "screen_name" => user.nickname, + "screen_name_html" => user.nickname, "description" => HtmlSanitizeEx.strip_tags(user.bio), + "description_html" => HtmlSanitizeEx.strip_tags(user.bio), "created_at" => user.inserted_at |> Utils.format_naive_asctime(), "favourites_count" => 0, "statuses_count" => 1, @@ -77,7 +79,9 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do "id" => user.id, "name" => user.name, "screen_name" => user.nickname, + "screen_name_html" => user.nickname, "description" => HtmlSanitizeEx.strip_tags(user.bio), + "description_html" => HtmlSanitizeEx.strip_tags(user.bio), "created_at" => user.inserted_at |> Utils.format_naive_asctime(), "favourites_count" => 0, "statuses_count" => 0, @@ -115,7 +119,9 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do "id" => follower.id, "name" => follower.name, "screen_name" => follower.nickname, + "screen_name_html" => follower.nickname, "description" => HtmlSanitizeEx.strip_tags(follower.bio), + "description_html" => HtmlSanitizeEx.strip_tags(follower.bio), "created_at" => follower.inserted_at |> Utils.format_naive_asctime(), "favourites_count" => 0, "statuses_count" => 0, @@ -160,7 +166,9 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do "id" => user.id, "name" => user.name, "screen_name" => user.nickname, + "screen_name_html" => user.nickname, "description" => HtmlSanitizeEx.strip_tags(user.bio), + "description_html" => HtmlSanitizeEx.strip_tags(user.bio), "created_at" => user.inserted_at |> Utils.format_naive_asctime(), "favourites_count" => 0, "statuses_count" => 0, -- cgit v1.2.3 From ed9738e031e02a9338bedd3a8f3ff73329c101e7 Mon Sep 17 00:00:00 2001 From: eal Date: Wed, 8 Aug 2018 09:24:50 +0300 Subject: Add tests for emoji in user profiles Also use the correct field in TwitterAPI... --- test/web/mastodon_api/account_view_test.exs | 22 ++++++++++++++++-- test/web/twitter_api/views/user_view_test.exs | 32 +++++++++++++++++++++++---- 2 files changed, 48 insertions(+), 6 deletions(-) (limited to 'test/web') diff --git a/test/web/mastodon_api/account_view_test.exs b/test/web/mastodon_api/account_view_test.exs index b93418b3f..8bf194e6b 100644 --- a/test/web/mastodon_api/account_view_test.exs +++ b/test/web/mastodon_api/account_view_test.exs @@ -5,10 +5,21 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do alias Pleroma.User test "Represent a user account" do + source_data = %{ + "tag" => [ + %{ + "type" => "Emoji", + "icon" => %{"url" => "/file.png"}, + "name" => ":karjalanpiirakka:" + } + ] + } + user = insert(:user, %{ - info: %{"note_count" => 5, "follower_count" => 3}, + info: %{"note_count" => 5, "follower_count" => 3, "source_data" => source_data}, nickname: "shp@shitposter.club", + name: ":karjalanpiirakka: shp", inserted_at: ~N[2017-08-15 15:47:06.597036] }) @@ -28,7 +39,14 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do avatar_static: "http://localhost:4001/images/avi.png", header: "http://localhost:4001/images/banner.png", header_static: "http://localhost:4001/images/banner.png", - emojis: [], + emojis: [ + %{ + "static_url" => "/file.png", + "url" => "/file.png", + "shortcode" => "karjalanpiirakka", + "visible_in_picker" => false + } + ], fields: [], source: %{ note: "", diff --git a/test/web/twitter_api/views/user_view_test.exs b/test/web/twitter_api/views/user_view_test.exs index 000c589af..fefb6bdcc 100644 --- a/test/web/twitter_api/views/user_view_test.exs +++ b/test/web/twitter_api/views/user_view_test.exs @@ -20,6 +20,30 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do assert represented["profile_image_url"] == image end + test "A user with emoji in username", %{user: user} do + expected = + "karjalanpiirakka man" + + user = %{ + user + | info: %{ + "source_data" => %{ + "tag" => [ + %{ + "type" => "Emoji", + "icon" => %{"url" => "/file.png"}, + "name" => ":karjalanpiirakka:" + } + ] + } + } + } + + user = %{user | name: ":karjalanpiirakka: man"} + represented = UserView.render("show.json", %{user: user}) + assert represented["name_html"] == expected + end + test "A user" do note_activity = insert(:note_activity) user = User.get_cached_by_ap_id(note_activity.data["actor"]) @@ -40,7 +64,7 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do "id" => user.id, "name" => user.name, "screen_name" => user.nickname, - "screen_name_html" => user.nickname, + "name_html" => user.name, "description" => HtmlSanitizeEx.strip_tags(user.bio), "description_html" => HtmlSanitizeEx.strip_tags(user.bio), "created_at" => user.inserted_at |> Utils.format_naive_asctime(), @@ -79,7 +103,7 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do "id" => user.id, "name" => user.name, "screen_name" => user.nickname, - "screen_name_html" => user.nickname, + "name_html" => user.name, "description" => HtmlSanitizeEx.strip_tags(user.bio), "description_html" => HtmlSanitizeEx.strip_tags(user.bio), "created_at" => user.inserted_at |> Utils.format_naive_asctime(), @@ -119,7 +143,7 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do "id" => follower.id, "name" => follower.name, "screen_name" => follower.nickname, - "screen_name_html" => follower.nickname, + "name_html" => follower.name, "description" => HtmlSanitizeEx.strip_tags(follower.bio), "description_html" => HtmlSanitizeEx.strip_tags(follower.bio), "created_at" => follower.inserted_at |> Utils.format_naive_asctime(), @@ -166,7 +190,7 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do "id" => user.id, "name" => user.name, "screen_name" => user.nickname, - "screen_name_html" => user.nickname, + "name_html" => user.name, "description" => HtmlSanitizeEx.strip_tags(user.bio), "description_html" => HtmlSanitizeEx.strip_tags(user.bio), "created_at" => user.inserted_at |> Utils.format_naive_asctime(), -- cgit v1.2.3 From 7fbcd4caaf877749c13d6755eaaa956ac0ea5012 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Tue, 14 Aug 2018 17:07:01 +0000 Subject: test: add kroeg fixtures --- test/web/activity_pub/transmogrifier_test.exs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'test/web') diff --git a/test/web/activity_pub/transmogrifier_test.exs b/test/web/activity_pub/transmogrifier_test.exs index 838ae169d..e455da39f 100644 --- a/test/web/activity_pub/transmogrifier_test.exs +++ b/test/web/activity_pub/transmogrifier_test.exs @@ -112,6 +112,15 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do "

@lain

" end + test "it works for incoming notices with to/cc not being an array (kroeg)" do + data = File.read!("test/fixtures/kroeg-post-activity.json") |> Poison.decode!() + + {:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data) + + assert data["object"]["content"] == + "

henlo from my Psion netBook

message sent from my Psion netBook

" + end + test "it works for incoming follow requests" do user = insert(:user) -- cgit v1.2.3 From f533daffdbbf2912677868c68f2ca0e28f8db347 Mon Sep 17 00:00:00 2001 From: ensra Date: Tue, 21 Aug 2018 15:24:06 +0100 Subject: sync bio sanitization code in tests --- test/web/twitter_api/views/user_view_test.exs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'test/web') diff --git a/test/web/twitter_api/views/user_view_test.exs b/test/web/twitter_api/views/user_view_test.exs index fefb6bdcc..180b7602e 100644 --- a/test/web/twitter_api/views/user_view_test.exs +++ b/test/web/twitter_api/views/user_view_test.exs @@ -65,8 +65,8 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do "name" => user.name, "screen_name" => user.nickname, "name_html" => user.name, - "description" => HtmlSanitizeEx.strip_tags(user.bio), - "description_html" => HtmlSanitizeEx.strip_tags(user.bio), + "description" => HtmlSanitizeEx.strip_tags(user.bio |> String.replace("
", "\n")), + "description_html" => HtmlSanitizeEx.basic_html(user.bio), "created_at" => user.inserted_at |> Utils.format_naive_asctime(), "favourites_count" => 0, "statuses_count" => 1, @@ -104,8 +104,8 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do "name" => user.name, "screen_name" => user.nickname, "name_html" => user.name, - "description" => HtmlSanitizeEx.strip_tags(user.bio), - "description_html" => HtmlSanitizeEx.strip_tags(user.bio), + "description" => HtmlSanitizeEx.strip_tags(user.bio |> String.replace("
", "\n")), + "description_html" => HtmlSanitizeEx.basic_html(user.bio), "created_at" => user.inserted_at |> Utils.format_naive_asctime(), "favourites_count" => 0, "statuses_count" => 0, @@ -144,8 +144,8 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do "name" => follower.name, "screen_name" => follower.nickname, "name_html" => follower.name, - "description" => HtmlSanitizeEx.strip_tags(follower.bio), - "description_html" => HtmlSanitizeEx.strip_tags(follower.bio), + "description" => HtmlSanitizeEx.strip_tags(user.bio |> String.replace("
", "\n")), + "description_html" => HtmlSanitizeEx.basic_html(user.bio), "created_at" => follower.inserted_at |> Utils.format_naive_asctime(), "favourites_count" => 0, "statuses_count" => 0, @@ -191,8 +191,8 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do "name" => user.name, "screen_name" => user.nickname, "name_html" => user.name, - "description" => HtmlSanitizeEx.strip_tags(user.bio), - "description_html" => HtmlSanitizeEx.strip_tags(user.bio), + "description" => HtmlSanitizeEx.strip_tags(user.bio |> String.replace("
", "\n")), + "description_html" => HtmlSanitizeEx.basic_html(user.bio), "created_at" => user.inserted_at |> Utils.format_naive_asctime(), "favourites_count" => 0, "statuses_count" => 0, -- cgit v1.2.3 From e883587cc3a0c386e3cc3f63c2d8a2d64f7c953b Mon Sep 17 00:00:00 2001 From: ensra Date: Tue, 21 Aug 2018 15:25:21 +0100 Subject: this should be looking at the follower's bio, not the user's bio. fixes test. --- test/web/twitter_api/views/user_view_test.exs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/web') diff --git a/test/web/twitter_api/views/user_view_test.exs b/test/web/twitter_api/views/user_view_test.exs index 180b7602e..24a5c5bca 100644 --- a/test/web/twitter_api/views/user_view_test.exs +++ b/test/web/twitter_api/views/user_view_test.exs @@ -144,8 +144,8 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do "name" => follower.name, "screen_name" => follower.nickname, "name_html" => follower.name, - "description" => HtmlSanitizeEx.strip_tags(user.bio |> String.replace("
", "\n")), - "description_html" => HtmlSanitizeEx.basic_html(user.bio), + "description" => HtmlSanitizeEx.strip_tags(follower.bio |> String.replace("
", "\n")), + "description_html" => HtmlSanitizeEx.basic_html(follower.bio), "created_at" => follower.inserted_at |> Utils.format_naive_asctime(), "favourites_count" => 0, "statuses_count" => 0, -- cgit v1.2.3 From 2b5db840ee9fc6b6e5229983b31c918e4675e4b2 Mon Sep 17 00:00:00 2001 From: ensra Date: Tue, 21 Aug 2018 15:41:32 +0100 Subject: attempt to add html validation to mastodon api test case --- test/web/mastodon_api/account_view_test.exs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'test/web') diff --git a/test/web/mastodon_api/account_view_test.exs b/test/web/mastodon_api/account_view_test.exs index 8bf194e6b..35c8a1fb0 100644 --- a/test/web/mastodon_api/account_view_test.exs +++ b/test/web/mastodon_api/account_view_test.exs @@ -20,6 +20,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do info: %{"note_count" => 5, "follower_count" => 3, "source_data" => source_data}, nickname: "shp@shitposter.club", name: ":karjalanpiirakka: shp", + bio: "valid html", inserted_at: ~N[2017-08-15 15:47:06.597036] }) @@ -33,7 +34,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do followers_count: 3, following_count: 0, statuses_count: 5, - note: user.bio, + note: "valid html", url: user.ap_id, avatar: "http://localhost:4001/images/avi.png", avatar_static: "http://localhost:4001/images/avi.png", -- cgit v1.2.3 From 74c74decf522104cb08c600a96849e6b0fab1780 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Thu, 12 Jul 2018 19:06:28 +0200 Subject: Basic peertube support. --- test/web/activity_pub/activity_pub_test.exs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'test/web') diff --git a/test/web/activity_pub/activity_pub_test.exs b/test/web/activity_pub/activity_pub_test.exs index 90c0bd768..1cf7d6bbc 100644 --- a/test/web/activity_pub/activity_pub_test.exs +++ b/test/web/activity_pub/activity_pub_test.exs @@ -506,6 +506,15 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do end end + test "it can fetch peertube videos" do + {:ok, object} = + ActivityPub.fetch_object_from_id( + "https://peertube.moe/videos/watch/df5f464b-be8d-46fb-ad81-2d4c2d1630e3" + ) + + assert object + end + def data_uri do File.read!("test/fixtures/avatar_data_uri") end -- cgit v1.2.3 From bc36d40bee790c57d8e422d75c1999bdc8f4c031 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Thu, 23 Aug 2018 00:55:41 +0000 Subject: tests: add a testcase for verifying that objects without a valid ID are always rejected --- test/web/activity_pub/transmogrifier_test.exs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test/web') diff --git a/test/web/activity_pub/transmogrifier_test.exs b/test/web/activity_pub/transmogrifier_test.exs index e455da39f..e2926d495 100644 --- a/test/web/activity_pub/transmogrifier_test.exs +++ b/test/web/activity_pub/transmogrifier_test.exs @@ -615,6 +615,18 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do assert User.following?(follower, followed) == false end + + test "it rejects activities without a valid ID" do + user = insert(:user) + + data = + File.read!("test/fixtures/mastodon-follow-activity.json") + |> Poison.decode!() + |> Map.put("object", user.ap_id) + |> Map.put("id", "") + + :error = Transmogrifier.handle_incoming(data) + end end describe "prepare outgoing" do -- cgit v1.2.3 From aab2bdddf4456c99d5d5042183c1225f7e771f56 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Sat, 25 Aug 2018 00:03:25 +0000 Subject: twitter api: provide object descriptions as attachment description field --- test/web/twitter_api/representers/object_representer_test.exs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'test/web') diff --git a/test/web/twitter_api/representers/object_representer_test.exs b/test/web/twitter_api/representers/object_representer_test.exs index ebac051dc..228b2ac42 100644 --- a/test/web/twitter_api/representers/object_representer_test.exs +++ b/test/web/twitter_api/representers/object_representer_test.exs @@ -23,7 +23,8 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ObjectReprenterTest do id: 6, url: "someurl", mimetype: "sometype", - oembed: false + oembed: false, + description: nil } assert expected_object == ObjectRepresenter.to_map(object) @@ -46,7 +47,8 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ObjectReprenterTest do "http://mastodon.example.org/system/media_attachments/files/000/000/001/original/8619f31c6edec470.png", mimetype: "image/png", oembed: false, - id: nil + id: nil, + description: "blabla" } assert expected_object == ObjectRepresenter.to_map(object) -- cgit v1.2.3