summaryrefslogtreecommitdiff
path: root/test/web
diff options
context:
space:
mode:
Diffstat (limited to 'test/web')
-rw-r--r--test/web/ostatus/incoming_documents/delete_handling_test.exs5
-rw-r--r--test/web/ostatus/ostatus_test.exs7
-rw-r--r--test/web/salmon/salmon_test.exs6
-rw-r--r--test/web/twitter_api/representers/activity_representer_test.exs7
-rw-r--r--test/web/twitter_api/twitter_api_controller_test.exs16
-rw-r--r--test/web/twitter_api/twitter_api_utils_test.exs6
-rw-r--r--test/web/twitter_api/views/user_view_test.exs8
-rw-r--r--test/web/web_finger/web_finger_test.exs25
8 files changed, 70 insertions, 10 deletions
diff --git a/test/web/ostatus/incoming_documents/delete_handling_test.exs b/test/web/ostatus/incoming_documents/delete_handling_test.exs
index 8cd6e295e..989c87afa 100644
--- a/test/web/ostatus/incoming_documents/delete_handling_test.exs
+++ b/test/web/ostatus/incoming_documents/delete_handling_test.exs
@@ -9,12 +9,17 @@ defmodule Pleroma.Web.OStatus.DeleteHandlingTest do
test "it removes the mentioned activity" do
note = insert(:note_activity)
second_note = insert(:note_activity)
+ user = insert(:user)
+ object = Object.get_by_ap_id(note.data["object"]["id"])
+
+ {:ok, like, object} = Pleroma.Web.ActivityPub.ActivityPub.like(user, object)
incoming = File.read!("test/fixtures/delete.xml")
|> String.replace("tag:mastodon.sdf.org,2017-06-10:objectId=310513:objectType=Status", note.data["object"]["id"])
{:ok, []} = OStatus.handle_incoming(incoming)
refute Repo.get(Activity, note.id)
+ refute Repo.get(Activity, like.id)
refute Object.get_by_ap_id(note.data["object"]["id"])
assert Repo.get(Activity, second_note.id)
assert Object.get_by_ap_id(second_note.data["object"]["id"])
diff --git a/test/web/ostatus/ostatus_test.exs b/test/web/ostatus/ostatus_test.exs
index 44d687d8e..8dd3c3b54 100644
--- a/test/web/ostatus/ostatus_test.exs
+++ b/test/web/ostatus/ostatus_test.exs
@@ -346,4 +346,11 @@ defmodule Pleroma.Web.OStatusTest do
assert {:ok, %User{}} = OStatus.insert_or_update_user(data)
end
+
+ test "it doesn't add nil in the do field" do
+ incoming = File.read!("test/fixtures/nil_mention_entry.xml")
+ {:ok, [activity]} = OStatus.handle_incoming(incoming)
+
+ assert activity.data["to"] == ["http://localhost:4001/users/atarifrosch@social.stopwatchingus-heidelberg.de/followers", "https://www.w3.org/ns/activitystreams#Public"]
+ end
end
diff --git a/test/web/salmon/salmon_test.exs b/test/web/salmon/salmon_test.exs
index e722f08ef..f2b729da9 100644
--- a/test/web/salmon/salmon_test.exs
+++ b/test/web/salmon/salmon_test.exs
@@ -8,6 +8,8 @@ defmodule Pleroma.Web.Salmon.SalmonTest do
@wrong_magickey "RSA.pu0s-halox4tu7wmES1FVSx6u-4wc0YrUFXcqWXZG4-27UmbCOpMQftRCldNRfyA-qLbz-eqiwQhh-1EwUvjsD4cYbAHNGHwTvDOyx5AKthQUP44ykPv7kjKGh3DWKySJvcs9tlUG87hlo7AvnMo9pwRS_Zz2CacQ-MKaXyDepk=.AQAA"
+ @magickey_friendica "RSA.AMwa8FUs2fWEjX0xN7yRQgegQffhBpuKNC6fa5VNSVorFjGZhRrlPMn7TQOeihlc9lBz2OsHlIedbYn2uJ7yCs0.AQAB"
+
test "decodes a salmon" do
{:ok, salmon} = File.read("test/fixtures/salmon.xml")
{:ok, doc} = Salmon.decode_and_validate(@magickey, salmon)
@@ -32,6 +34,10 @@ defmodule Pleroma.Web.Salmon.SalmonTest do
assert @magickey == magic_key
end
+ test "it decodes a friendica public key" do
+ key = Salmon.decode_key(@magickey_friendica)
+ end
+
test "returns a public and private key from a pem" do
pem = File.read!("test/fixtures/private_key.pem")
{:ok, private, public} = Salmon.keys_from_pem(pem)
diff --git a/test/web/twitter_api/representers/activity_representer_test.exs b/test/web/twitter_api/representers/activity_representer_test.exs
index e9f6a1915..4f090ee8e 100644
--- a/test/web/twitter_api/representers/activity_representer_test.exs
+++ b/test/web/twitter_api/representers/activity_representer_test.exs
@@ -27,6 +27,7 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do
assert status["statusnet_conversation_id"] == retweeted_status["statusnet_conversation_id"]
assert status["retweeted_status"] == retweeted_status
+ assert status["activity_type"] == "repeat"
end
test "a like activity" do
@@ -44,6 +45,7 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do
activity_actor = Repo.get_by(User, ap_id: note_activity.data["actor"])
liked_status = ActivityRepresenter.to_map(note_activity, %{user: activity_actor, for: user})
assert liked_status["favorited"] == true
+ assert status["activity_type"] == "like"
end
test "an activity" do
@@ -127,7 +129,9 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do
"favorited" => false,
"repeated" => false,
"external_url" => "some url",
- "tags" => ["content", "mentioning", "nsfw"]
+ "tags" => ["content", "mentioning", "nsfw"],
+ "activity_type" => "post",
+ "possibly_sensitive" => true
}
assert ActivityRepresenter.to_map(activity, %{user: user, for: follower, mentioned: [mentioned_user]}) == expected_status
@@ -142,5 +146,6 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do
map = ActivityRepresenter.to_map(unfollow, %{user: follower})
assert map["is_post_verb"] == false
+ assert map["activity_type"] == "undo"
end
end
diff --git a/test/web/twitter_api/twitter_api_controller_test.exs b/test/web/twitter_api/twitter_api_controller_test.exs
index 8c689d7d3..89b8c2eeb 100644
--- a/test/web/twitter_api/twitter_api_controller_test.exs
+++ b/test/web/twitter_api/twitter_api_controller_test.exs
@@ -455,6 +455,22 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
end
end
+ describe "POST /api/account/update_profile.json" do
+ test "it updates a user's profile" do
+ user = insert(:user)
+
+ conn = conn
+ |> assign(:user, user)
+ |> post("/api/account/update_profile.json", %{"name" => "new name", "description" => "new description"})
+
+ user = Repo.get!(User, user.id)
+ assert user.name == "new name"
+ assert user.bio == "new description"
+
+ assert json_response(conn, 200) == UserView.render("user.json", %{user: user, for: user})
+ end
+ end
+
defp valid_user(_context) do
user = insert(:user)
[user: user]
diff --git a/test/web/twitter_api/twitter_api_utils_test.exs b/test/web/twitter_api/twitter_api_utils_test.exs
index 62aa7843b..ff03414d6 100644
--- a/test/web/twitter_api/twitter_api_utils_test.exs
+++ b/test/web/twitter_api/twitter_api_utils_test.exs
@@ -3,12 +3,14 @@ defmodule Pleroma.Web.TwitterAPI.UtilsTest do
use Pleroma.DataCase
test "it adds attachment links to a given text and attachment set" do
+ name = "Sakura%20Mana%20%E2%80%93%20Turned%20on%20by%20a%20Senior%20OL%20with%20a%20Temptating%20Tight%20Skirt-s%20Full%20Hipline%20and%20Panty%20Shot-%20Beautiful%20Thick%20Thighs-%20and%20Erotic%20Ass-%20-2015-%20--%20Oppaitime%208-28-2017%206-50-33%20PM.png"
+
attachment = %{
- "url" => [%{"href" => "http://heise.de/i\"m a boy.png"}]
+ "url" => [%{"href" => name}]
}
res = Utils.add_attachments("", [attachment])
- assert res == "<br>\n<a href=\"http://heise.de/i%22m%20a%20boy.png\" class='attachment'>i\"m a boy.png</a>"
+ assert res == "<br>\n<a href=\"#{name}\" class='attachment'>Sakura Mana – Turned on by a Se…</a>"
end
end
diff --git a/test/web/twitter_api/views/user_view_test.exs b/test/web/twitter_api/views/user_view_test.exs
index b81d3d64d..7b3289422 100644
--- a/test/web/twitter_api/views/user_view_test.exs
+++ b/test/web/twitter_api/views/user_view_test.exs
@@ -50,7 +50,9 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do
"profile_image_url_original" => image,
"following" => false,
"rights" => %{},
- "statusnet_profile_url" => user.ap_id
+ "statusnet_profile_url" => user.ap_id,
+ "cover_photo" => nil,
+ "background_image" => nil
}
assert represented == UserView.render("show.json", %{user: user})
@@ -76,7 +78,9 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do
"profile_image_url_original" => image,
"following" => true,
"rights" => %{},
- "statusnet_profile_url" => user.ap_id
+ "statusnet_profile_url" => user.ap_id,
+ "cover_photo" => nil,
+ "background_image" => nil
}
assert represented == UserView.render("show.json", %{user: user, for: follower})
diff --git a/test/web/web_finger/web_finger_test.exs b/test/web/web_finger/web_finger_test.exs
index 495d3d50b..38640b6d3 100644
--- a/test/web/web_finger/web_finger_test.exs
+++ b/test/web/web_finger/web_finger_test.exs
@@ -31,17 +31,32 @@ defmodule Pleroma.Web.WebFingerTest do
test "returns the info for a user" do
user = "shp@social.heldscal.la"
- getter = fn(_url, _headers, [params: [resource: ^user]]) ->
- {:ok, %{status_code: 200, body: File.read!("test/fixtures/webfinger.xml")}}
- end
-
- {:ok, data} = WebFinger.finger(user, getter)
+ {:ok, data} = WebFinger.finger(user)
assert data["magic_key"] == "RSA.wQ3i9UA0qmAxZ0WTIp4a-waZn_17Ez1pEEmqmqoooRsG1_BvpmOvLN0G2tEcWWxl2KOtdQMCiPptmQObeZeuj48mdsDZ4ArQinexY2hCCTcbV8Xpswpkb8K05RcKipdg07pnI7tAgQ0VWSZDImncL6YUGlG5YN8b5TjGOwk2VG8=.AQAB"
assert data["topic"] == "https://social.heldscal.la/api/statuses/user_timeline/29191.atom"
assert data["subject"] == "acct:shp@social.heldscal.la"
assert data["salmon"] == "https://social.heldscal.la/main/salmon/user/29191"
end
+
+ test "it works for friendica" do
+ user = "lain@squeet.me"
+
+ {:ok, data} = WebFinger.finger(user)
+
+ end
+
+ test "it gets the xrd endpoint" do
+ {:ok, template} = WebFinger.find_lrdd_template("social.heldscal.la")
+
+ assert template == "https://social.heldscal.la/.well-known/webfinger?resource={uri}"
+ end
+
+ test "it gets the xrd endpoint for hubzilla" do
+ {:ok, template} = WebFinger.find_lrdd_template("macgirvin.com")
+
+ assert template == "https://macgirvin.com/xrd/?uri={uri}"
+ end
end
describe "ensure_keys_present" do