aboutsummaryrefslogtreecommitdiff
path: root/test/support
diff options
context:
space:
mode:
Diffstat (limited to 'test/support')
-rw-r--r--test/support/factory.ex38
-rw-r--r--test/support/httpoison_mock.ex22
2 files changed, 57 insertions, 3 deletions
diff --git a/test/support/factory.ex b/test/support/factory.ex
index e9b4beb7d..4f5060abf 100644
--- a/test/support/factory.ex
+++ b/test/support/factory.ex
@@ -45,6 +45,33 @@ defmodule Pleroma.Factory do
}
end
+ def direct_note_factory do
+ user2 = insert(:user)
+
+ %Pleroma.Object{data: data} = note_factory()
+ %Pleroma.Object{data: Map.merge(data, %{"to" => [user2.ap_id]})}
+ end
+
+ def direct_note_activity_factory do
+ dm = insert(:direct_note)
+
+ data = %{
+ "id" => Pleroma.Web.ActivityPub.Utils.generate_activity_id(),
+ "type" => "Create",
+ "actor" => dm.data["actor"],
+ "to" => dm.data["to"],
+ "object" => dm.data,
+ "published" => DateTime.utc_now() |> DateTime.to_iso8601(),
+ "context" => dm.data["context"]
+ }
+
+ %Pleroma.Activity{
+ data: data,
+ actor: data["actor"],
+ recipients: data["to"]
+ }
+ end
+
def note_activity_factory do
note = insert(:note)
@@ -139,4 +166,15 @@ defmodule Pleroma.Factory do
subscribers: []
}
end
+
+ def oauth_app_factory do
+ %Pleroma.Web.OAuth.App{
+ client_name: "Some client",
+ redirect_uris: "https://example.com/callback",
+ scopes: "read",
+ website: "https://example.com",
+ client_id: "aaabbb==",
+ client_secret: "aaa;/&bbb"
+ }
+ end
end
diff --git a/test/support/httpoison_mock.ex b/test/support/httpoison_mock.ex
index 6e8336a93..a52d44ed6 100644
--- a/test/support/httpoison_mock.ex
+++ b/test/support/httpoison_mock.ex
@@ -4,7 +4,7 @@ defmodule HTTPoisonMock do
def get(url, body \\ [], headers \\ [])
def get(
- "http://gerzilla.de/.well-known/webfinger?resource=acct:kaniini@gerzilla.de",
+ "https://gerzilla.de/.well-known/webfinger?resource=acct:kaniini@gerzilla.de",
[Accept: "application/xrd+xml,application/jrd+json"],
follow_redirect: true
) do
@@ -16,7 +16,7 @@ defmodule HTTPoisonMock do
end
def get(
- "http://framatube.org/.well-known/webfinger?resource=acct:framasoft@framatube.org",
+ "https://framatube.org/.well-known/webfinger?resource=acct:framasoft@framatube.org",
[Accept: "application/xrd+xml,application/jrd+json"],
follow_redirect: true
) do
@@ -28,7 +28,7 @@ defmodule HTTPoisonMock do
end
def get(
- "http://gnusocial.de/.well-known/webfinger?resource=acct:winterdienst@gnusocial.de",
+ "https://gnusocial.de/.well-known/webfinger?resource=acct:winterdienst@gnusocial.de",
[Accept: "application/xrd+xml,application/jrd+json"],
follow_redirect: true
) do
@@ -736,6 +736,22 @@ defmodule HTTPoisonMock do
}}
end
+ def get("https://baptiste.gelez.xyz/~/PlumeDevelopment/this-month-in-plume-june-2018/", _, _) do
+ {:ok,
+ %Response{
+ status_code: 200,
+ body: File.read!("test/fixtures/httpoison_mock/baptiste.gelex.xyz-article.json")
+ }}
+ end
+
+ def get("https://baptiste.gelez.xyz/@/BaptisteGelez", _, _) do
+ {:ok,
+ %Response{
+ status_code: 200,
+ body: File.read!("test/fixtures/httpoison_mock/baptiste.gelex.xyz-user.json")
+ }}
+ end
+
def get(url, body, headers) do
{:error,
"Not implemented the mock response for get #{inspect(url)}, #{inspect(body)}, #{