Scrape instance nodeinfo #251
2 changed files with 27 additions and 7 deletions
|
@ -25,6 +25,7 @@ test "Represent a user account" do
|
|||
|
||||
user =
|
||||
insert(:user, %{
|
||||
ap_id: "https://example.com/users/chikichikibanban",
|
||||
follower_count: 3,
|
||||
note_count: 5,
|
||||
background: background_image,
|
||||
|
@ -38,6 +39,8 @@ test "Represent a user account" do
|
|||
also_known_as: ["https://shitposter.zone/users/shp"]
|
||||
})
|
||||
|
||||
insert(:instance, %{host: "example.com", nodeinfo: %{version: "2.1"}})
|
||||
|
||||
expected = %{
|
||||
id: to_string(user.id),
|
||||
username: "shp",
|
||||
|
@ -50,6 +53,15 @@ test "Represent a user account" do
|
|||
statuses_count: 5,
|
||||
note: "<span>valid html</span>. a<br/>b<br/>c<br/>d<br/>f '&<>"",
|
||||
url: user.ap_id,
|
||||
akkoma: %{
|
||||
instance: %{
|
||||
name: "example.com",
|
||||
nodeinfo: %{
|
||||
"version" => "2.1"
|
||||
},
|
||||
favicon: nil
|
||||
}
|
||||
},
|
||||
avatar: "http://localhost:4001/images/avi.png",
|
||||
avatar_static: "http://localhost:4001/images/avi.png",
|
||||
header: "http://localhost:4001/images/banner.png",
|
||||
|
@ -598,4 +610,10 @@ test "uses mediaproxy urls when it's enabled (regardless of media preview proxy
|
|||
|> assert()
|
||||
end
|
||||
end
|
||||
|
||||
test "returns nil in the instance field when no instance is held locally" do
|
||||
user = insert(:user)
|
||||
view = AccountView.render("show.json", %{user: user, skip_visibility_check: true})
|
||||
assert view[:akkoma][:instance] == nil
|
||||
end
|
||||
end
|
||||
|
|
|
@ -36,6 +36,15 @@ def conversation_factory do
|
|||
}
|
||||
end
|
||||
|
||||
def instance_factory(attrs \\ %{}) do
|
||||
%Pleroma.Instances.Instance{
|
||||
host: attrs[:domain] || "example.com",
|
||||
nodeinfo: %{version: "2.0", openRegistrations: true},
|
||||
unreachable_since: nil
|
||||
}
|
||||
|> Map.merge(attrs)
|
||||
end
|
||||
|
||||
def user_factory(attrs \\ %{}) do
|
||||
pem = Enum.random(@rsa_keys)
|
||||
|
||||
|
@ -522,13 +531,6 @@ def oauth_app_factory do
|
|||
}
|
||||
end
|
||||
|
||||
def instance_factory do
|
||||
%Pleroma.Instances.Instance{
|
||||
host: "domain.com",
|
||||
unreachable_since: nil
|
||||
}
|
||||
end
|
||||
|
||||
def oauth_token_factory(attrs \\ %{}) do
|
||||
scopes = Map.get(attrs, :scopes, ["read"])
|
||||
oauth_app = Map.get_lazy(attrs, :app, fn -> insert(:oauth_app, scopes: scopes) end)
|
||||
|
|
Loading…
Reference in a new issue