diff options
author | Roger Braun <roger@rogerbraun.net> | 2017-05-16 15:31:11 +0200 |
---|---|---|
committer | Roger Braun <roger@rogerbraun.net> | 2017-05-16 18:19:04 +0200 |
commit | 70024632ba32121bd63a439b2d708d4b4ff1a190 (patch) | |
tree | 7bcdcf637337997cd17d0d6d38d8bce2a77d4752 /test | |
parent | 423194520e3fd1d2b285e7cf34a8ad7476276f5d (diff) | |
download | pleroma-70024632ba32121bd63a439b2d708d4b4ff1a190.tar.gz |
AP refactoring.
Diffstat (limited to 'test')
-rw-r--r-- | test/plugs/authentication_plug_test.exs | 15 | ||||
-rw-r--r-- | test/support/builders/activity_builder.ex | 2 | ||||
-rw-r--r-- | test/support/factory.ex | 8 | ||||
-rw-r--r-- | test/web/activity_pub/activity_pub_test.exs | 3 | ||||
-rw-r--r-- | test/web/salmon/salmon_test.exs | 2 |
5 files changed, 22 insertions, 8 deletions
diff --git a/test/plugs/authentication_plug_test.exs b/test/plugs/authentication_plug_test.exs index 6f1568ec3..9d6c2cd70 100644 --- a/test/plugs/authentication_plug_test.exs +++ b/test/plugs/authentication_plug_test.exs @@ -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 diff --git a/test/support/builders/activity_builder.ex b/test/support/builders/activity_builder.ex index 16011edbf..7ce611f8f 100644 --- a/test/support/builders/activity_builder.ex +++ b/test/support/builders/activity_builder.ex @@ -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" => %{ diff --git a/test/support/factory.ex b/test/support/factory.ex index 5c110c72d..ffc9c56dc 100644 --- a/test/support/factory.ex +++ b/test/support/factory.ex @@ -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, diff --git a/test/web/activity_pub/activity_pub_test.exs b/test/web/activity_pub/activity_pub_test.exs index 2e361ad38..8e7473591 100644 --- a/test/web/activity_pub/activity_pub_test.exs +++ b/test/web/activity_pub/activity_pub_test.exs @@ -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 diff --git a/test/web/salmon/salmon_test.exs b/test/web/salmon/salmon_test.exs index ed26ccf83..65d81e44f 100644 --- a/test/web/salmon/salmon_test.exs +++ b/test/web/salmon/salmon_test.exs @@ -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], |