Merge branch 'develop' into 'feature/relay'
# Conflicts: # lib/pleroma/web/activity_pub/utils.ex
This commit is contained in:
commit
0f5bff8c66
287 changed files with 1251 additions and 2778 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
@ -257,6 +257,70 @@ 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",
|
||||
|
|
|
|||
|
|
@ -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 =
|
||||
"<img height='32px' width='32px' alt='karjalanpiirakka' title='karjalanpiirakka' src='/file.png' /> 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,9 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do
|
|||
"id" => user.id,
|
||||
"name" => user.name,
|
||||
"screen_name" => user.nickname,
|
||||
"description" => HtmlSanitizeEx.strip_tags(user.bio),
|
||||
"name_html" => user.name,
|
||||
"description" => HtmlSanitizeEx.strip_tags(user.bio |> String.replace("<br>", "\n")),
|
||||
"description_html" => HtmlSanitizeEx.basic_html(user.bio),
|
||||
"created_at" => user.inserted_at |> Utils.format_naive_asctime(),
|
||||
"favourites_count" => 0,
|
||||
"statuses_count" => 1,
|
||||
|
|
@ -77,7 +103,9 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do
|
|||
"id" => user.id,
|
||||
"name" => user.name,
|
||||
"screen_name" => user.nickname,
|
||||
"description" => HtmlSanitizeEx.strip_tags(user.bio),
|
||||
"name_html" => user.name,
|
||||
"description" => HtmlSanitizeEx.strip_tags(user.bio |> String.replace("<br>", "\n")),
|
||||
"description_html" => HtmlSanitizeEx.basic_html(user.bio),
|
||||
"created_at" => user.inserted_at |> Utils.format_naive_asctime(),
|
||||
"favourites_count" => 0,
|
||||
"statuses_count" => 0,
|
||||
|
|
@ -115,7 +143,9 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do
|
|||
"id" => follower.id,
|
||||
"name" => follower.name,
|
||||
"screen_name" => follower.nickname,
|
||||
"description" => HtmlSanitizeEx.strip_tags(follower.bio),
|
||||
"name_html" => follower.name,
|
||||
"description" => HtmlSanitizeEx.strip_tags(follower.bio |> String.replace("<br>", "\n")),
|
||||
"description_html" => HtmlSanitizeEx.basic_html(follower.bio),
|
||||
"created_at" => follower.inserted_at |> Utils.format_naive_asctime(),
|
||||
"favourites_count" => 0,
|
||||
"statuses_count" => 0,
|
||||
|
|
@ -160,7 +190,9 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do
|
|||
"id" => user.id,
|
||||
"name" => user.name,
|
||||
"screen_name" => user.nickname,
|
||||
"description" => HtmlSanitizeEx.strip_tags(user.bio),
|
||||
"name_html" => user.name,
|
||||
"description" => HtmlSanitizeEx.strip_tags(user.bio |> String.replace("<br>", "\n")),
|
||||
"description_html" => HtmlSanitizeEx.basic_html(user.bio),
|
||||
"created_at" => user.inserted_at |> Utils.format_naive_asctime(),
|
||||
"favourites_count" => 0,
|
||||
"statuses_count" => 0,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue