aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/fixtures/test.txt1
-rw-r--r--test/support/factory.ex20
-rw-r--r--test/upload_test.exs26
-rw-r--r--test/web/activity_pub/activity_pub_controller_test.exs26
4 files changed, 73 insertions, 0 deletions
diff --git a/test/fixtures/test.txt b/test/fixtures/test.txt
new file mode 100644
index 000000000..e9ea42a12
--- /dev/null
+++ b/test/fixtures/test.txt
@@ -0,0 +1 @@
+this is a text file
diff --git a/test/support/factory.ex b/test/support/factory.ex
index 6c48d390f..4f5060abf 100644
--- a/test/support/factory.ex
+++ b/test/support/factory.ex
@@ -92,6 +92,26 @@ defmodule Pleroma.Factory do
}
end
+ def announce_activity_factory do
+ note_activity = insert(:note_activity)
+ user = insert(:user)
+
+ data = %{
+ "type" => "Announce",
+ "actor" => note_activity.actor,
+ "object" => note_activity.data["id"],
+ "to" => [user.follower_address, note_activity.data["actor"]],
+ "cc" => ["https://www.w3.org/ns/activitystreams#Public"],
+ "context" => note_activity.data["context"]
+ }
+
+ %Pleroma.Activity{
+ data: data,
+ actor: user.ap_id,
+ recipients: data["to"]
+ }
+ end
+
def like_activity_factory do
note_activity = insert(:note_activity)
user = insert(:user)
diff --git a/test/upload_test.exs b/test/upload_test.exs
index 09aa5e068..d273ea5f6 100644
--- a/test/upload_test.exs
+++ b/test/upload_test.exs
@@ -56,5 +56,31 @@ defmodule Pleroma.UploadTest do
data = Upload.store(file, false)
assert data["name"] == "an [image.jpg"
end
+
+ test "fixes incorrect file extension" do
+ File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg")
+
+ file = %Plug.Upload{
+ content_type: "image/jpg",
+ path: Path.absname("test/fixtures/image_tmp.jpg"),
+ filename: "an [image.blah"
+ }
+
+ data = Upload.store(file, false)
+ assert data["name"] == "an [image.jpg"
+ end
+
+ test "don't modify filename of an unknown type" do
+ File.cp("test/fixtures/test.txt", "test/fixtures/test_tmp.txt")
+
+ file = %Plug.Upload{
+ content_type: "text/plain",
+ path: Path.absname("test/fixtures/test_tmp.txt"),
+ filename: "test.txt"
+ }
+
+ data = Upload.store(file, false)
+ assert data["name"] == "test.txt"
+ end
end
end
diff --git a/test/web/activity_pub/activity_pub_controller_test.exs b/test/web/activity_pub/activity_pub_controller_test.exs
index bbf89136b..3ed7be402 100644
--- a/test/web/activity_pub/activity_pub_controller_test.exs
+++ b/test/web/activity_pub/activity_pub_controller_test.exs
@@ -62,6 +62,32 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
end
end
+ describe "/users/:nickname/outbox" 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"])
+
+ conn =
+ conn
+ |> put_req_header("accept", "application/activity+json")
+ |> get("/users/#{user.nickname}/outbox")
+
+ 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
test "it returns the followers in a collection", %{conn: conn} do
user = insert(:user)