AP refactoring.
This commit is contained in:
parent
423194520e
commit
70024632ba
12 changed files with 334 additions and 247 deletions
|
|
@ -2,12 +2,13 @@ defmodule Pleroma.Plugs.AuthenticationPlugTest do
|
|||
use Pleroma.Web.ConnCase, async: true
|
||||
|
||||
alias Pleroma.Plugs.AuthenticationPlug
|
||||
alias Pleroma.User
|
||||
|
||||
defp fetch_nil(_name) do
|
||||
{:ok, nil}
|
||||
end
|
||||
|
||||
@user %{
|
||||
@user %User{
|
||||
id: 1,
|
||||
name: "dude",
|
||||
password_hash: Comeonin.Pbkdf2.hashpwsalt("guy")
|
||||
|
|
@ -129,6 +130,7 @@ defmodule Pleroma.Plugs.AuthenticationPlugTest do
|
|||
assert conn.halted == false
|
||||
end
|
||||
end
|
||||
|
||||
describe "with a user_id in the session for an existing user" do
|
||||
test "it assigns the user", %{conn: conn} do
|
||||
opts = %{
|
||||
|
|
@ -150,4 +152,15 @@ defmodule Pleroma.Plugs.AuthenticationPlugTest do
|
|||
assert conn.halted == false
|
||||
end
|
||||
end
|
||||
|
||||
describe "with an assigned user" do
|
||||
test "it does nothing, returning the incoming conn", %{conn: conn} do
|
||||
conn = conn
|
||||
|> assign(:user, @user)
|
||||
|
||||
conn_result = AuthenticationPlug.call(conn, %{})
|
||||
|
||||
assert conn == conn_result
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ defmodule Pleroma.Builders.ActivityBuilder do
|
|||
def build(data \\ %{}, opts \\ %{}) do
|
||||
user = opts[:user] || Pleroma.Factory.insert(:user)
|
||||
activity = %{
|
||||
"id" => Pleroma.Web.ActivityPub.ActivityPub.generate_object_id,
|
||||
"id" => Pleroma.Web.ActivityPub.Utils.generate_object_id,
|
||||
"actor" => user.ap_id,
|
||||
"to" => ["https://www.w3.org/ns/activitystreams#Public"],
|
||||
"object" => %{
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ defmodule Pleroma.Factory do
|
|||
data = %{
|
||||
"type" => "Note",
|
||||
"content" => text,
|
||||
"id" => Pleroma.Web.ActivityPub.ActivityPub.generate_object_id,
|
||||
"id" => Pleroma.Web.ActivityPub.Utils.generate_object_id,
|
||||
"actor" => user.ap_id,
|
||||
"to" => ["https://www.w3.org/ns/activitystreams#Public"],
|
||||
"published_at" => DateTime.utc_now() |> DateTime.to_iso8601,
|
||||
|
|
@ -36,7 +36,7 @@ defmodule Pleroma.Factory do
|
|||
def note_activity_factory do
|
||||
note = insert(:note)
|
||||
data = %{
|
||||
"id" => Pleroma.Web.ActivityPub.ActivityPub.generate_activity_id,
|
||||
"id" => Pleroma.Web.ActivityPub.Utils.generate_activity_id,
|
||||
"type" => "Create",
|
||||
"actor" => note.data["actor"],
|
||||
"to" => note.data["to"],
|
||||
|
|
@ -55,7 +55,7 @@ defmodule Pleroma.Factory do
|
|||
user = insert(:user)
|
||||
|
||||
data = %{
|
||||
"id" => Pleroma.Web.ActivityPub.ActivityPub.generate_activity_id,
|
||||
"id" => Pleroma.Web.ActivityPub.Utils.generate_activity_id,
|
||||
"actor" => user.ap_id,
|
||||
"type" => "Like",
|
||||
"object" => note_activity.data["object"]["id"],
|
||||
|
|
@ -72,7 +72,7 @@ defmodule Pleroma.Factory do
|
|||
followed = insert(:user)
|
||||
|
||||
data = %{
|
||||
"id" => Pleroma.Web.ActivityPub.ActivityPub.generate_activity_id,
|
||||
"id" => Pleroma.Web.ActivityPub.Utils.generate_activity_id,
|
||||
"actor" => follower.ap_id,
|
||||
"type" => "Follow",
|
||||
"object" => followed.ap_id,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
||||
use Pleroma.DataCase
|
||||
alias Pleroma.Web.ActivityPub.ActivityPub
|
||||
alias Pleroma.Web.ActivityPub.Utils
|
||||
alias Pleroma.{Activity, Object, User}
|
||||
alias Pleroma.Builders.ActivityBuilder
|
||||
|
||||
|
|
@ -216,7 +217,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
follower = Repo.get_by(User, ap_id: activity.data["actor"])
|
||||
followed = Repo.get_by(User, ap_id: activity.data["object"])
|
||||
|
||||
assert activity == ActivityPub.fetch_latest_follow(follower, followed)
|
||||
assert activity == Utils.fetch_latest_follow(follower, followed)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ defmodule Pleroma.Web.Salmon.SalmonTest do
|
|||
mentioned_user = insert(:user, user_data)
|
||||
note = insert(:note)
|
||||
activity_data = %{
|
||||
"id" => Pleroma.Web.ActivityPub.ActivityPub.generate_activity_id,
|
||||
"id" => Pleroma.Web.ActivityPub.Utils.generate_activity_id,
|
||||
"type" => "Create",
|
||||
"actor" => note.data["actor"],
|
||||
"to" => note.data["to"] ++ [mentioned_user.ap_id],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue