mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2024-11-05 16:39:47 +00:00
Test that the target account is re-fetched in move_account
Ref: emit-move
This commit is contained in:
parent
eb383ef8d3
commit
3fd13b70ec
5 changed files with 127 additions and 0 deletions
1
test/fixtures/tesla_mock/https___lm.kazv.moe_users_mewmew.xml
vendored
Normal file
1
test/fixtures/tesla_mock/https___lm.kazv.moe_users_mewmew.xml
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?><XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0"><Subject>acct:mewmew@lm.kazv.moe</Subject><Alias>https://lm.kazv.moe/users/mewmew</Alias><Alias>https://lm.kazv.moe/users/tester</Alias><Alias>https://lm.kazv.moe/users/testuser</Alias><Link href="https://lm.kazv.moe/users/mewmew" rel="http://webfinger.net/rel/profile-page" type="text/html" /><Link href="https://lm.kazv.moe/users/mewmew" rel="self" type="application/activity+json" /><Link href="https://lm.kazv.moe/users/mewmew" rel="self" type="application/ld+json; profile="https://www.w3.org/ns/activitystreams"" /><Link rel="http://ostatus.org/schema/1.0/subscribe" template="https://lm.kazv.moe/ostatus_subscribe?acct={uri}" /></XRD>
|
1
test/fixtures/tesla_mock/lm.kazv.moe_host_meta
vendored
Normal file
1
test/fixtures/tesla_mock/lm.kazv.moe_host_meta
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?><XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0"><Link rel="lrdd" template="https://lm.kazv.moe/.well-known/webfinger?resource={uri}" type="application/xrd+xml" /></XRD>
|
1
test/fixtures/tesla_mock/mewmew@lm.kazv.moe.json
vendored
Normal file
1
test/fixtures/tesla_mock/mewmew@lm.kazv.moe.json
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
{"@context":["https://www.w3.org/ns/activitystreams","https://lm.kazv.moe/schemas/litepub-0.1.jsonld",{"@language":"und"}],"alsoKnownAs":["https://lm.kazv.moe/users/tester","https://lm.kazv.moe/users/testuser"],"attachment":[],"capabilities":{"acceptsChatMessages":true},"discoverable":false,"endpoints":{"oauthAuthorizationEndpoint":"https://lm.kazv.moe/oauth/authorize","oauthRegistrationEndpoint":"https://lm.kazv.moe/api/v1/apps","oauthTokenEndpoint":"https://lm.kazv.moe/oauth/token","sharedInbox":"https://lm.kazv.moe/inbox","uploadMedia":"https://lm.kazv.moe/api/ap/upload_media"},"featured":"https://lm.kazv.moe/users/mewmew/collections/featured","followers":"https://lm.kazv.moe/users/mewmew/followers","following":"https://lm.kazv.moe/users/mewmew/following","id":"https://lm.kazv.moe/users/mewmew","inbox":"https://lm.kazv.moe/users/mewmew/inbox","manuallyApprovesFollowers":false,"name":"mew","outbox":"https://lm.kazv.moe/users/mewmew/outbox","preferredUsername":"mewmew","publicKey":{"id":"https://lm.kazv.moe/users/mewmew#main-key","owner":"https://lm.kazv.moe/users/mewmew","publicKeyPem":"-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0nT3IVUwx799FSJyJEOY\n5D2c5zgtt2Z+BD9417eVLmVQF5fJlWgcKS4pbFc76zkYoBkZtV7XbzvN9KTNulpa\nUGNOM0/UdEoQLB8xbVCMm0ABUU8vbTWoMTxp93bfVHBz+33FPYdH1JHX4TCU/mJF\nX4UJMvFmMn5BFjSQm9GG6Eq2j6SAUsaTa8+Rrd8FzS6zb/dk3N/Llz0tfsZYS0sq\nEy9OYhsKOQ6eegULFJOF3Hz04vzwftmeXFsbb3aO2zKz3uAMYZglWHNBYJAePBtJ\ng362kqdJwgT14TFnZ0K2ziDPbkRULG1Kke/lsqw2rPF6Q6P4PeO1shCEDthoDoID\newIDAQAB\n-----END PUBLIC KEY-----\n\n"},"summary":"","tag":[],"type":"Person","url":"https://lm.kazv.moe/users/mewmew"}
|
|
@ -592,6 +592,79 @@ defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do
|
|||
}
|
||||
end
|
||||
|
||||
test "with proper permissions, valid password, remote target account aliases this and local cache does not exist",
|
||||
%{} do
|
||||
user = insert(:user, ap_id: "https://lm.kazv.moe/users/testuser")
|
||||
%{user: _user, conn: conn} = oauth_access(["write:accounts"], user: user)
|
||||
|
||||
target_nick = "mewmew@lm.kazv.moe"
|
||||
|
||||
conn =
|
||||
conn
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> post("/api/pleroma/move_account", %{
|
||||
"password" => "test",
|
||||
"target_account" => target_nick
|
||||
})
|
||||
|
||||
assert json_response_and_validate_schema(conn, 200) == %{"status" => "success"}
|
||||
end
|
||||
|
||||
test "with proper permissions, valid password, remote target account aliases this and local cache does not alias this",
|
||||
%{} do
|
||||
user = insert(:user, ap_id: "https://lm.kazv.moe/users/testuser")
|
||||
%{user: _user, conn: conn} = oauth_access(["write:accounts"], user: user)
|
||||
|
||||
target_user =
|
||||
insert(
|
||||
:user,
|
||||
ap_id: "https://lm.kazv.moe/users/mewmew",
|
||||
nickname: "mewmew@lm.kazv.moe",
|
||||
local: false
|
||||
)
|
||||
|
||||
target_nick = target_user |> User.full_nickname()
|
||||
|
||||
conn =
|
||||
conn
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> post("/api/pleroma/move_account", %{
|
||||
"password" => "test",
|
||||
"target_account" => target_nick
|
||||
})
|
||||
|
||||
assert json_response_and_validate_schema(conn, 200) == %{"status" => "success"}
|
||||
end
|
||||
|
||||
test "with proper permissions, valid password, remote target account does not alias this and local cache aliases this",
|
||||
%{
|
||||
user: user,
|
||||
conn: conn
|
||||
} do
|
||||
target_user =
|
||||
insert(
|
||||
:user,
|
||||
ap_id: "https://lm.kazv.moe/users/mewmew",
|
||||
nickname: "mewmew@lm.kazv.moe",
|
||||
local: false,
|
||||
also_known_as: [user.ap_id]
|
||||
)
|
||||
|
||||
target_nick = target_user |> User.full_nickname()
|
||||
|
||||
conn =
|
||||
conn
|
||||
|> put_req_header("content-type", "multipart/form-data")
|
||||
|> post("/api/pleroma/move_account", %{
|
||||
"password" => "test",
|
||||
"target_account" => target_nick
|
||||
})
|
||||
|
||||
assert json_response_and_validate_schema(conn, 200) == %{
|
||||
"error" => "Target account must have the origin in `alsoKnownAs`"
|
||||
}
|
||||
end
|
||||
|
||||
test "with proper permissions, valid password and target account aliases this", %{
|
||||
conn: conn,
|
||||
user: user
|
||||
|
|
|
@ -1133,6 +1133,57 @@ defmodule HttpRequestMock do
|
|||
}}
|
||||
end
|
||||
|
||||
def get("http://lm.kazv.moe/.well-known/host-meta", _, _, _) do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
body: File.read!("test/fixtures/tesla_mock/lm.kazv.moe_host_meta")
|
||||
}}
|
||||
end
|
||||
|
||||
def get("https://lm.kazv.moe/.well-known/host-meta", _, _, _) do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
body: File.read!("test/fixtures/tesla_mock/lm.kazv.moe_host_meta")
|
||||
}}
|
||||
end
|
||||
|
||||
def get(
|
||||
"https://lm.kazv.moe/.well-known/webfinger?resource=acct:mewmew@lm.kazv.moe",
|
||||
_,
|
||||
_,
|
||||
[{"accept", "application/xrd+xml,application/jrd+json"}]
|
||||
) do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
body: File.read!("test/fixtures/tesla_mock/https___lm.kazv.moe_users_mewmew.xml"),
|
||||
headers: [{"content-type", "application/xrd+xml"}]
|
||||
}}
|
||||
end
|
||||
|
||||
def get("https://lm.kazv.moe/users/mewmew", _, _, _) do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
body: File.read!("test/fixtures/tesla_mock/mewmew@lm.kazv.moe.json"),
|
||||
headers: activitypub_object_headers()
|
||||
}}
|
||||
end
|
||||
|
||||
def get("https://lm.kazv.moe/users/mewmew/collections/featured", _, _, _) do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
body:
|
||||
File.read!("test/fixtures/users_mock/masto_featured.json")
|
||||
|> String.replace("{{domain}}", "lm.kazv.moe")
|
||||
|> String.replace("{{nickname}}", "mewmew"),
|
||||
headers: [{"content-type", "application/activity+json"}]
|
||||
}}
|
||||
end
|
||||
|
||||
def get("https://info.pleroma.site/activity.json", _, _, [
|
||||
{"accept", "application/activity+json"}
|
||||
]) do
|
||||
|
|
Loading…
Reference in a new issue