X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;ds=sidebyside;f=test%2Fuser_search_test.exs;h=f7ab312872c0c820a8919dd318513e227c47d6db;hb=9aca2cc95d0d8886d35be17e5cdd683004b425d9;hp=1f0162486034104fa43568cebb9eff09e565b1e2;hpb=829e99722396c2372770f50d9fc7cfa40c441005;p=akkoma
diff --git a/test/user_search_test.exs b/test/user_search_test.exs
index 1f0162486..f7ab31287 100644
--- a/test/user_search_test.exs
+++ b/test/user_search_test.exs
@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2018 Pleroma Authors
+# Copyright © 2017-2019 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.UserSearchTest do
@@ -193,7 +193,14 @@ defmodule Pleroma.UserSearchTest do
user = User.get_cached_by_ap_id("http://mastodon.example.org/users/admin")
assert length(results) == 1
- assert user == result |> Map.put(:search_rank, nil) |> Map.put(:search_type, nil)
+
+ expected =
+ result
+ |> Map.put(:search_rank, nil)
+ |> Map.put(:search_type, nil)
+ |> Map.put(:last_digest_emailed_at, nil)
+
+ assert user == expected
end
test "excludes a blocked users from search result" do
@@ -248,5 +255,57 @@ defmodule Pleroma.UserSearchTest do
[result] = User.search("lain@localhost", resolve: true, for_user: user)
assert Map.put(result, :search_rank, nil) |> Map.put(:search_type, nil) == local_user
end
+
+ test "works with idna domains" do
+ user = insert(:user, nickname: "lain@" <> to_string(:idna.encode("zetsubou.ã¿ããª")))
+
+ results = User.search("lain@zetsubou.ã¿ããª", resolve: false, for_user: user)
+
+ result = List.first(results)
+
+ assert user == result |> Map.put(:search_rank, nil) |> Map.put(:search_type, nil)
+ end
+
+ test "works with idna domains converted input" do
+ user = insert(:user, nickname: "lain@" <> to_string(:idna.encode("zetsubou.ã¿ããª")))
+
+ results =
+ User.search("lain@zetsubou." <> to_string(:idna.encode("zetsubou.ã¿ããª")),
+ resolve: false,
+ for_user: user
+ )
+
+ result = List.first(results)
+
+ assert user == result |> Map.put(:search_rank, nil) |> Map.put(:search_type, nil)
+ end
+
+ test "works with idna domains and bad chars in domain" do
+ user = insert(:user, nickname: "lain@" <> to_string(:idna.encode("zetsubou.ã¿ããª")))
+
+ results =
+ User.search("lain@zetsubou!@#$%^&*()+,-/:;<=>?[]'_{}|~`.ã¿ããª",
+ resolve: false,
+ for_user: user
+ )
+
+ result = List.first(results)
+
+ assert user == result |> Map.put(:search_rank, nil) |> Map.put(:search_type, nil)
+ end
+
+ test "works with idna domains and query as link" do
+ user = insert(:user, nickname: "lain@" <> to_string(:idna.encode("zetsubou.ã¿ããª")))
+
+ results =
+ User.search("https://zetsubou.ã¿ããª/users/lain",
+ resolve: false,
+ for_user: user
+ )
+
+ result = List.first(results)
+
+ assert user == result |> Map.put(:search_rank, nil) |> Map.put(:search_type, nil)
+ end
end
end