2020-04-01 00:55:05 -06:00
|
|
|
# Pleroma: A lightweight social networking server
|
|
|
|
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
defmodule Pleroma.Web.MetadataTest do
|
|
|
|
use Pleroma.DataCase, async: true
|
|
|
|
|
|
|
|
import Pleroma.Factory
|
|
|
|
|
|
|
|
describe "restrict indexing remote users" do
|
|
|
|
test "for remote user" do
|
|
|
|
user = insert(:user, local: false)
|
|
|
|
|
|
|
|
assert Pleroma.Web.Metadata.build_tags(%{user: user}) =~
|
|
|
|
"<meta content=\"noindex, noarchive\" name=\"robots\">"
|
|
|
|
end
|
|
|
|
|
|
|
|
test "for local user" do
|
2020-09-17 10:32:40 -06:00
|
|
|
user = insert(:user, discoverable: false)
|
2020-04-01 00:55:05 -06:00
|
|
|
|
2020-09-14 11:18:11 -06:00
|
|
|
assert Pleroma.Web.Metadata.build_tags(%{user: user}) =~
|
|
|
|
"<meta content=\"noindex, noarchive\" name=\"robots\">"
|
|
|
|
end
|
|
|
|
|
|
|
|
test "for local user set to discoverable" do
|
|
|
|
user = insert(:user, discoverable: true)
|
|
|
|
|
2020-04-01 00:55:05 -06:00
|
|
|
refute Pleroma.Web.Metadata.build_tags(%{user: user}) =~
|
|
|
|
"<meta content=\"noindex, noarchive\" name=\"robots\">"
|
|
|
|
end
|
|
|
|
end
|
2020-08-31 13:35:22 -06:00
|
|
|
|
|
|
|
describe "no metadata for private instances" do
|
2020-09-14 11:18:11 -06:00
|
|
|
test "for local user set to discoverable" do
|
2020-09-07 06:06:06 -06:00
|
|
|
clear_config([:instance, :public], false)
|
2020-09-14 11:18:11 -06:00
|
|
|
user = insert(:user, bio: "This is my secret fedi account bio", discoverable: true)
|
2020-08-31 13:35:22 -06:00
|
|
|
|
|
|
|
assert "" = Pleroma.Web.Metadata.build_tags(%{user: user})
|
|
|
|
end
|
2020-09-14 11:18:11 -06:00
|
|
|
|
|
|
|
test "search exclusion metadata is included" do
|
|
|
|
clear_config([:instance, :public], false)
|
2020-09-17 10:32:40 -06:00
|
|
|
user = insert(:user, bio: "This is my secret fedi account bio", discoverable: false)
|
2020-09-14 11:18:11 -06:00
|
|
|
|
2020-09-14 11:55:49 -06:00
|
|
|
assert ~s(<meta content="noindex, noarchive" name="robots">) ==
|
2020-09-14 11:18:11 -06:00
|
|
|
Pleroma.Web.Metadata.build_tags(%{user: user})
|
|
|
|
end
|
2020-08-31 13:35:22 -06:00
|
|
|
end
|
2020-04-01 00:55:05 -06:00
|
|
|
end
|