mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-10 03:17:51 +00:00
update test
This commit is contained in:
parent
80bfdb4e7d
commit
7ec64ac33f
6 changed files with 75 additions and 16 deletions
|
@ -23,6 +23,34 @@ defmodule HttpRequestMock do
|
|||
#
|
||||
def get(url, query \\ [], body \\ [], headers \\ [])
|
||||
|
||||
def get("http://gs.example.org:4040/index.php/user/1", _, _, Accept: "application/activity+json") do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
body: "{\"id\": 1}"
|
||||
}}
|
||||
end
|
||||
|
||||
def get("https://squeet.me/xrd/?uri=lain@squeet.me", _, _,
|
||||
Accept: "application/xrd+xml,application/jrd+json"
|
||||
) do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
body: File.read!("test/fixtures/httpoison_mock/lain_squeet.me_webfinger.xml")
|
||||
}}
|
||||
end
|
||||
|
||||
def get("https://mst3k.interlinked.me/users/luciferMysticus", _, _,
|
||||
Accept: "application/activity+json"
|
||||
) do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
body: File.read!("test/fixtures/httpoison_mock/lucifermysticus.json")
|
||||
}}
|
||||
end
|
||||
|
||||
def get("https://prismo.news/@mxb", _, _, _) do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
|
@ -31,8 +59,9 @@ defmodule HttpRequestMock do
|
|||
}}
|
||||
end
|
||||
|
||||
def get("https://hubzilla.example.org/channel/kaniini",
|
||||
_, _, [Accept: "application/activity+json"]) do
|
||||
def get("https://hubzilla.example.org/channel/kaniini", _, _,
|
||||
Accept: "application/activity+json"
|
||||
) do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
|
@ -40,7 +69,7 @@ defmodule HttpRequestMock do
|
|||
}}
|
||||
end
|
||||
|
||||
def get("https://niu.moe/users/rye", _, _, [Accept: "application/activity+json"]) do
|
||||
def get("https://niu.moe/users/rye", _, _, Accept: "application/activity+json") do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
|
@ -52,13 +81,14 @@ defmodule HttpRequestMock do
|
|||
{:ok,
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
body: File.read!(
|
||||
"test/fixtures/httpoison_mock/http___mastodon.example.org_users_admin_status_1234.json"
|
||||
)
|
||||
body:
|
||||
File.read!(
|
||||
"test/fixtures/httpoison_mock/http___mastodon.example.org_users_admin_status_1234.json"
|
||||
)
|
||||
}}
|
||||
end
|
||||
|
||||
def get("https://puckipedia.com/", _, _, [Accept: "application/activity+json"]) do
|
||||
def get("https://puckipedia.com/", _, _, Accept: "application/activity+json") do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
|
@ -66,7 +96,6 @@ defmodule HttpRequestMock do
|
|||
}}
|
||||
end
|
||||
|
||||
|
||||
def get("https://peertube.moe/accounts/7even", _, _, _) do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
|
@ -99,8 +128,7 @@ defmodule HttpRequestMock do
|
|||
}}
|
||||
end
|
||||
|
||||
|
||||
def get("http://mastodon.example.org/users/admin", _, _, [Accept: "application/activity+json"]) do
|
||||
def get("http://mastodon.example.org/users/admin", _, _, Accept: "application/activity+json") do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
|
@ -108,8 +136,9 @@ defmodule HttpRequestMock do
|
|||
}}
|
||||
end
|
||||
|
||||
def get("http://mastodon.example.org/@admin/99541947525187367",
|
||||
_, _, [Accept: "application/activity+json"]) do
|
||||
def get("http://mastodon.example.org/@admin/99541947525187367", _, _,
|
||||
Accept: "application/activity+json"
|
||||
) do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
|
@ -125,7 +154,7 @@ defmodule HttpRequestMock do
|
|||
}}
|
||||
end
|
||||
|
||||
def get("https://mstdn.io/users/mayuutann", _, _, [Accept: "application/activity+json"]) do
|
||||
def get("https://mstdn.io/users/mayuutann", _, _, Accept: "application/activity+json") do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
|
@ -133,8 +162,9 @@ defmodule HttpRequestMock do
|
|||
}}
|
||||
end
|
||||
|
||||
def get("https://mstdn.io/users/mayuutann/statuses/99568293732299394",
|
||||
_, _, [Accept: "application/activity+json"]) do
|
||||
def get("https://mstdn.io/users/mayuutann/statuses/99568293732299394", _, _,
|
||||
Accept: "application/activity+json"
|
||||
) do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
|
@ -142,7 +172,6 @@ defmodule HttpRequestMock do
|
|||
}}
|
||||
end
|
||||
|
||||
|
||||
def get("https://pleroma.soykaf.com/users/lain/feed.atom", _, _, _) do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
|
|
|
@ -4,6 +4,12 @@ defmodule Pleroma.Web.HTTPSignaturesTest do
|
|||
use Pleroma.DataCase
|
||||
alias Pleroma.Web.HTTPSignatures
|
||||
import Pleroma.Factory
|
||||
import Tesla.Mock
|
||||
|
||||
setup do
|
||||
mock(fn env -> apply(HttpRequestMock, :request, [env]) end)
|
||||
:ok
|
||||
end
|
||||
|
||||
@private_key hd(:public_key.pem_decode(File.read!("test/web/http_sigs/priv.key")))
|
||||
|> :public_key.pem_entry_decode()
|
||||
|
|
|
@ -8,6 +8,12 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
|
|||
|
||||
import Pleroma.Factory
|
||||
import ExUnit.CaptureLog
|
||||
import Tesla.Mock
|
||||
|
||||
setup do
|
||||
mock(fn env -> apply(HttpRequestMock, :request, [env]) end)
|
||||
:ok
|
||||
end
|
||||
|
||||
test "the home timeline", %{conn: conn} do
|
||||
user = insert(:user)
|
||||
|
|
|
@ -6,6 +6,12 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do
|
|||
alias Pleroma.Web.OStatus
|
||||
alias Pleroma.Web.CommonAPI
|
||||
import Pleroma.Factory
|
||||
import Tesla.Mock
|
||||
|
||||
setup do
|
||||
mock(fn env -> apply(HttpRequestMock, :request, [env]) end)
|
||||
:ok
|
||||
end
|
||||
|
||||
test "a note with null content" do
|
||||
note = insert(:note_activity)
|
||||
|
|
|
@ -7,6 +7,12 @@ defmodule Pleroma.Web.OStatus.ActivityRepresenterTest do
|
|||
alias Pleroma.Web.OStatus
|
||||
|
||||
import Pleroma.Factory
|
||||
import Tesla.Mock
|
||||
|
||||
setup do
|
||||
mock(fn env -> apply(HttpRequestMock, :request, [env]) end)
|
||||
:ok
|
||||
end
|
||||
|
||||
test "an external note activity" do
|
||||
incoming = File.read!("test/fixtures/mastodon-note-cw.xml")
|
||||
|
|
|
@ -4,6 +4,12 @@ defmodule Pleroma.Web.OStatus.OStatusControllerTest do
|
|||
alias Pleroma.{User, Repo}
|
||||
alias Pleroma.Web.CommonAPI
|
||||
alias Pleroma.Web.OStatus.ActivityRepresenter
|
||||
import Tesla.Mock
|
||||
|
||||
setup do
|
||||
mock(fn env -> apply(HttpRequestMock, :request, [env]) end)
|
||||
:ok
|
||||
end
|
||||
|
||||
test "decodes a salmon", %{conn: conn} do
|
||||
user = insert(:user)
|
||||
|
|
Loading…
Reference in a new issue