Merge branch 'develop' into 'admin-api-user-credentials-for-remote-users-fix'
# Conflicts: # CHANGELOG.md
This commit is contained in:
commit
4ac6e6283f
42 changed files with 799 additions and 263 deletions
|
|
@ -31,7 +31,7 @@ defmodule Pleroma.Emails.AdminEmailTest do
|
|||
account_url
|
||||
}\">#{account.nickname}</a></p>\n<p>Comment: Test comment\n<p> Statuses:\n <ul>\n <li><a href=\"#{
|
||||
status_url
|
||||
}\">#{status_url}</li>\n </ul>\n</p>\n\n"
|
||||
}\">#{status_url}</li>\n </ul>\n</p>\n\n<p>\n<a href=\"http://localhost:4001/pleroma/admin/#/reports/index\">View Reports in AdminFE</a>\n"
|
||||
end
|
||||
|
||||
test "it works when the reporter is a remote user without email" do
|
||||
|
|
|
|||
301
test/fixtures/tesla_mock/https___osada.macgirvin.com.html
vendored
Normal file
301
test/fixtures/tesla_mock/https___osada.macgirvin.com.html
vendored
Normal file
|
|
@ -0,0 +1,301 @@
|
|||
<!DOCTYPE html >
|
||||
<html prefix="og: http://ogp.me/ns#">
|
||||
<head>
|
||||
<title>Osada</title>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
|
||||
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1, user-scalable=0"/>
|
||||
<meta property="generator" content="osada"/>
|
||||
<link rel="stylesheet" href="http://osada.macgirvin.com/library/fork-awesome/css/fork-awesome.min.css?v=2.3" type="text/css" media="screen">
|
||||
<link rel="stylesheet" href="http://osada.macgirvin.com/vendor/twbs/bootstrap/dist/css/bootstrap.min.css?v=2.3" type="text/css" media="screen">
|
||||
<link rel="stylesheet" href="http://osada.macgirvin.com/library/bootstrap-tagsinput/bootstrap-tagsinput.css?v=2.3" type="text/css" media="screen">
|
||||
<link rel="stylesheet" href="http://osada.macgirvin.com/view/css/bootstrap-red.css?v=2.3" type="text/css" media="screen">
|
||||
<link rel="stylesheet" href="http://osada.macgirvin.com/library/datetimepicker/jquery.datetimepicker.css?v=2.3" type="text/css" media="screen">
|
||||
<link rel="stylesheet" href="http://osada.macgirvin.com/library/bootstrap-colorpicker/dist/css/bootstrap-colorpicker.min.css?v=2.3" type="text/css" media="screen">
|
||||
<link rel="stylesheet" href="http://osada.macgirvin.com/library/tiptip/tipTip.css?v=2.3" type="text/css" media="screen">
|
||||
<link rel="stylesheet" href="http://osada.macgirvin.com/library/jgrowl/jquery.jgrowl.css?v=2.3" type="text/css" media="screen">
|
||||
<link rel="stylesheet" href="http://osada.macgirvin.com/library/jRange/jquery.range.css?v=2.3" type="text/css" media="screen">
|
||||
<link rel="stylesheet" href="http://osada.macgirvin.com/view/css/conversation.css?v=2.3" type="text/css" media="screen">
|
||||
<link rel="stylesheet" href="http://osada.macgirvin.com/view/css/widgets.css?v=2.3" type="text/css" media="screen">
|
||||
<link rel="stylesheet" href="http://osada.macgirvin.com/view/css/colorbox.css?v=2.3" type="text/css" media="screen">
|
||||
<link rel="stylesheet" href="http://osada.macgirvin.com/library/justifiedGallery/justifiedGallery.min.css?v=2.3" type="text/css" media="screen">
|
||||
<link rel="stylesheet" href="http://osada.macgirvin.com/view/css/default.css?v=2.3" type="text/css" media="screen">
|
||||
<link rel="stylesheet" href="http://osada.macgirvin.com/view/css/mod_home.css?v=2.3" type="text/css" media="screen">
|
||||
<link rel="stylesheet" href="http://osada.macgirvin.com/view/theme/redbasic/php/style.pcss?v=2.3" type="text/css" media="screen">
|
||||
|
||||
<script>
|
||||
|
||||
var aStr = {
|
||||
|
||||
'delitem' : "Delete this item?",
|
||||
'comment' : "Comment",
|
||||
'showmore' : "<i class='fa fa-chevron-down'></i> show all",
|
||||
'showfewer' : "<i class='fa fa-chevron-up'></i> show less",
|
||||
'divgrowmore' : "<i class='fa fa-chevron-down'></i> expand",
|
||||
'divgrowless' : "<i class='fa fa-chevron-up'></i> collapse",
|
||||
'pwshort' : "Password too short",
|
||||
'pwnomatch' : "Passwords do not match",
|
||||
'everybody' : "everybody",
|
||||
'passphrase' : "Secret Passphrase",
|
||||
'passhint' : "Passphrase hint",
|
||||
'permschange' : "Notice: Permissions have changed but have not yet been submitted.",
|
||||
'closeAll' : "close all",
|
||||
'nothingnew' : "Nothing new here",
|
||||
'rating_desc' : "Rate This Channel (this is public)",
|
||||
'rating_val' : "Rating",
|
||||
'rating_text' : "Describe (optional)",
|
||||
'submit' : "Submit",
|
||||
'linkurl' : "Please enter a link URL",
|
||||
'leavethispage' : "Unsaved changes. Are you sure you wish to leave this page?",
|
||||
'location' : "Location",
|
||||
'lovely' : "lovely",
|
||||
'wonderful' : "wonderful",
|
||||
'fantastic' : "fantastic",
|
||||
'great' : "great",
|
||||
'nick_invld1' : "Your chosen nickname was either already taken or not valid. Please use our suggestion (",
|
||||
'nick_invld2' : ") or enter a new one.",
|
||||
'nick_valid' : "Thank you, this nickname is valid.",
|
||||
'name_empty' : "A channel name is required.",
|
||||
'name_ok1' : "This is a ",
|
||||
'name_ok2' : " channel name",
|
||||
|
||||
|
||||
|
||||
't01' : "",
|
||||
't02' : "",
|
||||
't03' : "ago",
|
||||
't04' : "from now",
|
||||
't05' : "less than a minute",
|
||||
't06' : "about a minute",
|
||||
't07' : "%d minutes",
|
||||
't08' : "about an hour",
|
||||
't09' : "about %d hours",
|
||||
't10' : "a day",
|
||||
't11' : "%d days",
|
||||
't12' : "about a month",
|
||||
't13' : "%d months",
|
||||
't14' : "about a year",
|
||||
't15' : "%d years",
|
||||
't16' : " ",
|
||||
't17' : "[]",
|
||||
|
||||
'monthNames' : [ "January","February","March","April","May","June","July","August","September","October","November","December" ],
|
||||
'monthNamesShort' : [ "Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec" ],
|
||||
'dayNames' : ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],
|
||||
'dayNamesShort' : ["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],
|
||||
'today' : "today",
|
||||
'month' : "month",
|
||||
'week' : "week",
|
||||
'day' : "day",
|
||||
'allday' : "All day"
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<script src="http://osada.macgirvin.com/view/js/jquery.js?v=2.3"></script>
|
||||
<script src="http://osada.macgirvin.com/library/justifiedGallery/jquery.justifiedGallery.min.js?v=2.3"></script>
|
||||
<script src="http://osada.macgirvin.com/library/sprintf.js/dist/sprintf.min.js?v=2.3"></script>
|
||||
<script src="http://osada.macgirvin.com/library/textcomplete/textcomplete.min.js?v=2.3"></script>
|
||||
<script src="http://osada.macgirvin.com/view/js/autocomplete.js?v=2.3"></script>
|
||||
<script src="http://osada.macgirvin.com/library/jquery.timeago.js?v=2.3"></script>
|
||||
<script src="http://osada.macgirvin.com/library/readmore.js/readmore.js?v=2.3"></script>
|
||||
<script src="http://osada.macgirvin.com/library/sticky-kit/sticky-kit.min.js?v=2.3"></script>
|
||||
<script src="http://osada.macgirvin.com/library/jgrowl/jquery.jgrowl_minimized.js?v=2.3"></script>
|
||||
<script src="http://osada.macgirvin.com/view/js/acl.js?v=2.3"></script>
|
||||
<script src="http://osada.macgirvin.com/view/js/webtoolkit.base64.js?v=2.3"></script>
|
||||
<script src="http://osada.macgirvin.com/library/jRange/jquery.range.js?v=2.3"></script>
|
||||
<script src="http://osada.macgirvin.com/library/colorbox/jquery.colorbox-min.js?v=2.3"></script>
|
||||
<script src="http://osada.macgirvin.com/library/jquery.AreYouSure/jquery.are-you-sure.js?v=2.3"></script>
|
||||
<script src="http://osada.macgirvin.com/library/tableofcontents/jquery.toc.js?v=2.3"></script>
|
||||
<script src="http://osada.macgirvin.com/library/imagesloaded/imagesloaded.pkgd.min.js?v=2.3"></script>
|
||||
<script src="http://osada.macgirvin.com/vendor/twbs/bootstrap/dist/js/bootstrap.bundle.min.js?v=2.3"></script>
|
||||
<script src="http://osada.macgirvin.com/library/bootbox/bootbox.min.js?v=2.3"></script>
|
||||
<script src="http://osada.macgirvin.com/library/bootstrap-tagsinput/bootstrap-tagsinput.js?v=2.3"></script>
|
||||
<script src="http://osada.macgirvin.com/library/datetimepicker/jquery.datetimepicker.js?v=2.3"></script>
|
||||
<script src="http://osada.macgirvin.com/library/bootstrap-colorpicker/dist/js/bootstrap-colorpicker.js?v=2.3"></script>
|
||||
<script src="http://osada.macgirvin.com/view/theme/redbasic/js/redbasic.js?v=2.3"></script>
|
||||
|
||||
|
||||
|
||||
<script>
|
||||
var updateInterval = 80000;
|
||||
var localUser = false;
|
||||
var zid = null;
|
||||
var justifiedGalleryActive = false;
|
||||
var preloadImages = 0;
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
<script>$(document).ready(function() { $("#nav-search-text").search_autocomplete('https://osada.macgirvin.com/acl');});</script><script src="http://osada.macgirvin.com/view/js/main.js?v=2.3"></script>
|
||||
</head>
|
||||
<body>
|
||||
<header></header>
|
||||
<nav class="navbar fixed-top navbar-expand-lg navbar-dark bg-dark"><div class="project-banner" title="Powered by Osada"><a href="https://osada.macgirvin.com/">☸</a></div>
|
||||
<div class="d-lg-none pt-1 pb-1">
|
||||
<a class="btn btn-primary btn-sm text-white" href="#" title="Sign in" id="login_nav_btn_collapse" data-toggle="modal" data-target="#nav-login">
|
||||
Login
|
||||
</a>
|
||||
</div>
|
||||
<div class="navbar-toggler-right">
|
||||
<button id="expand-aside" type="button" class="d-lg-none navbar-toggler border-0" data-toggle="offcanvas" data-target="#region_1">
|
||||
<i class="fa fa-arrow-circle-right" id="expand-aside-icon"></i>
|
||||
</button>
|
||||
<button id="menu-btn" class="navbar-toggler border-0" type="button" data-toggle="collapse" data-target="#navbar-collapse-2">
|
||||
<i class="fa fa-bars"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div class="collapse navbar-collapse" id="navbar-collapse-1">
|
||||
<ul class="navbar-nav mr-auto">
|
||||
<li class="nav-item d-lg-flex">
|
||||
<a class="nav-link" href="#" title="Sign in" id="login_nav_btn" data-toggle="modal" data-target="#nav-login">
|
||||
Login
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div id="banner" class="navbar-text"></div>
|
||||
|
||||
<ul id="nav-right" class="navbar-nav ml-auto">
|
||||
<li class="nav-item collapse clearfix" id="nav-search">
|
||||
<form class="form-inline" method="get" action="search" role="search">
|
||||
<input class="form-control form-control-sm mt-1 mr-2" id="nav-search-text" type="text" value="" placeholder="@name, !forum, #tag, content" name="search" title="Search site @name, !forum, #tag, ?docs, content" onclick="this.submit();" onblur="closeMenu('nav-search'); openMenu('nav-search-btn');"/>
|
||||
</form>
|
||||
<div id="nav-search-spinner" class="spinner-wrapper">
|
||||
<div class="spinner s"></div>
|
||||
</div>
|
||||
</li>
|
||||
<li class="nav-item" id="nav-search-btn">
|
||||
<a class="nav-link" href="#nav-search" title="Search site @name, !forum, #tag, ?docs, content" onclick="openMenu('nav-search'); closeMenu('nav-search-btn'); $('#nav-search-text').focus(); return false;"><i class="fa fa-fw fa-search"></i></a>
|
||||
</li>
|
||||
<li class="nav-item dropdown" id="app-menu">
|
||||
<a class="nav-link" href="#" data-toggle="dropdown"><i class="fa fa-fw fa-bars"></i></a>
|
||||
<div id="dropdown-menu" class="dropdown-menu dropdown-menu-right">
|
||||
<a class="dropdown-item" href="https://osada.macgirvin.com/directory"><i class="generic-icons-nav fa fa-fw fa-sitemap"></i>Directory</a>
|
||||
|
||||
|
||||
<a class="dropdown-item" href="https://osada.macgirvin.com/lang"><i class="generic-icons-nav fa fa-fw fa-language"></i>Language</a>
|
||||
|
||||
|
||||
<a class="dropdown-item" href="https://osada.macgirvin.com/search"><i class="generic-icons-nav fa fa-fw fa-search"></i>Search</a>
|
||||
|
||||
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="collapse d-lg-none" id="navbar-collapse-2">
|
||||
<div class="navbar-nav mr-auto">
|
||||
<a class="nav-link" href="https://osada.macgirvin.com/directory"><i class="generic-icons-nav fa fa-fw fa-sitemap"></i>Directory</a>
|
||||
|
||||
|
||||
<a class="nav-link" href="https://osada.macgirvin.com/lang"><i class="generic-icons-nav fa fa-fw fa-language"></i>Language</a>
|
||||
|
||||
|
||||
<a class="nav-link" href="https://osada.macgirvin.com/search"><i class="generic-icons-nav fa fa-fw fa-search"></i>Search</a>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<main>
|
||||
<aside id="region_1"><div class="aside_spacer"><div id="left_aside_wrapper"></div></div></aside>
|
||||
<section id="region_2"><h1 class="home-welcome">Welcome to Osada</h1><form action="https://osada.macgirvin.com/" id="main-login" method="post">
|
||||
<input type="hidden" name="auth-params" value="login"/>
|
||||
<div id="login-main">
|
||||
<div id="login-input" class="form-group">
|
||||
<div id="id_username_wrapper" class="form-group">
|
||||
<label for="id_username" id="label_username">Login/Email</label>
|
||||
<input class="form-control" name="username" id="id_username" type="text" value="">
|
||||
<small id="help_username" class="form-text text-muted"></small>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="id_password">Password</label>
|
||||
<input class="form-control" type="password" name="password" id="id_password" value=""> <small id="help_password" class="form-text text-muted"></small>
|
||||
</div>
|
||||
<div id="remember_container" class="clearfix form-group checkbox">
|
||||
<label for="id_remember">Remember me</label>
|
||||
<div class="float-right"><input type="checkbox" name="remember" id="id_remember" value="1"/><label class="switchlabel" for="id_remember"> <span class="onoffswitch-inner" data-on="Yes" data-off="No"></span><span class="onoffswitch-switch"></span></label></div>
|
||||
<small class="form-text text-muted"></small>
|
||||
</div>
|
||||
<button type="submit" name="submit" class="btn btn-block btn-primary">Login</button>
|
||||
</div>
|
||||
<div id="login-extra-links">
|
||||
<a href="https://osada.macgirvin.com/pubsites" title="Create an account to access services and applications" id="register-link" class="pull-right">Register</a> <a href="lostpass" title="Forgot your password?" id="lost-password-link">Password Reset</a>
|
||||
</div>
|
||||
<hr>
|
||||
<a href="rmagic" class="btn btn-block btn-outline-success rmagic-button">Remote Authentication</a>
|
||||
</div>
|
||||
<input type="hidden" name="0" value=""/>
|
||||
</form>
|
||||
<script type="text/javascript"> $(document).ready(function() { $("#id_username").focus();} );</script>
|
||||
<div id="nav-login" class="modal" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">Login</h4>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="form-group">
|
||||
<form action="https://osada.macgirvin.com/" id="main-login" method="post">
|
||||
<input type="hidden" name="auth-params" value="login"/>
|
||||
<div id="login-main">
|
||||
<div id="login-input" class="form-group">
|
||||
<div id="id_username_wrapper" class="form-group">
|
||||
<label for="id_username" id="label_username">Login/Email</label>
|
||||
<input class="form-control" name="username" id="id_username" type="text" value="">
|
||||
<small id="help_username" class="form-text text-muted"></small>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="id_password">Password</label>
|
||||
<input class="form-control" type="password" name="password" id="id_password" value=""> <small id="help_password" class="form-text text-muted"></small>
|
||||
</div>
|
||||
<div id="remember_me_container" class="clearfix form-group checkbox">
|
||||
<label for="id_remember_me">Remember me</label>
|
||||
<div class="float-right"><input type="checkbox" name="remember_me" id="id_remember_me" value="1"/><label class="switchlabel" for="id_remember_me"> <span class="onoffswitch-inner" data-on="Yes" data-off="No"></span><span class="onoffswitch-switch"></span></label></div>
|
||||
<small class="form-text text-muted"></small>
|
||||
</div>
|
||||
<button type="submit" name="submit" class="btn btn-block btn-primary">Login</button>
|
||||
</div>
|
||||
<div id="login-extra-links">
|
||||
<a href="https://osada.macgirvin.com/pubsites" title="Create an account to access services and applications" id="register-link" class="pull-right">Register</a> <a href="lostpass" title="Forgot your password?" id="lost-password-link">Password Reset</a>
|
||||
</div>
|
||||
<hr>
|
||||
<a href="rmagic" class="btn btn-block btn-outline-success rmagic-button">Remote Authentication</a>
|
||||
</div>
|
||||
<input type="hidden" name="0" value=""/>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="page-footer"></div>
|
||||
<div id="pause"></div>
|
||||
</section>
|
||||
<aside id="region_3" class="d-none d-xl-table-cell"><div class="aside_spacer"><div id="right_aside_wrapper"></div></div></aside>
|
||||
</main>
|
||||
<footer></footer>
|
||||
</body>
|
||||
</html>
|
||||
<!--
|
||||
FILE ARCHIVED ON 11:49:38 Jan 26, 2019 AND RETRIEVED FROM THE
|
||||
INTERNET ARCHIVE ON 04:27:56 Mar 02, 2020.
|
||||
|
||||
CONTENT MAY BE PROTECTED BY COPYRIGHT (17 U.S.C. SECTION 108(a)(3)).
|
||||
-->
|
||||
<!--
|
||||
playback timings (ms):
|
||||
exclusion.robots: 0.217
|
||||
CDXLines.iter: 14.7 (3)
|
||||
LoadShardBlock: 165.298 (3)
|
||||
esindex: 0.01
|
||||
PetaboxLoader3.datanode: 72.599 (4)
|
||||
exclusion.robots.policy: 0.208
|
||||
RedisCDXSource: 16.804
|
||||
PetaboxLoader3.resolve: 146.316 (4)
|
||||
captures_list: 199.59
|
||||
load_resource: 56.473
|
||||
-->
|
||||
|
|
@ -1342,6 +1342,18 @@ defmodule HttpRequestMock do
|
|||
{:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/relay/relay.json")}}
|
||||
end
|
||||
|
||||
def get("http://localhost:4001/", _, "", Accept: "text/html") do
|
||||
{:ok, %Tesla.Env{status: 200, body: File.read!("test/fixtures/tesla_mock/7369654.html")}}
|
||||
end
|
||||
|
||||
def get("https://osada.macgirvin.com/", _, "", Accept: "text/html") do
|
||||
{:ok,
|
||||
%Tesla.Env{
|
||||
status: 200,
|
||||
body: File.read!("test/fixtures/tesla_mock/https___osada.macgirvin.com.html")
|
||||
}}
|
||||
end
|
||||
|
||||
def get(url, query, body, headers) do
|
||||
{:error,
|
||||
"Mock response not implemented for GET #{inspect(url)}, #{query}, #{inspect(body)}, #{
|
||||
|
|
|
|||
|
|
@ -481,17 +481,17 @@ defmodule Mix.Tasks.Pleroma.UserTest do
|
|||
moot = insert(:user, nickname: "moot")
|
||||
kawen = insert(:user, nickname: "kawen", name: "fediverse expert moon")
|
||||
|
||||
{:ok, user} = User.follow(user, kawen)
|
||||
{:ok, user} = User.follow(user, moon)
|
||||
|
||||
assert [moon.id, kawen.id] == User.Search.search("moon") |> Enum.map(& &1.id)
|
||||
res = User.search("moo") |> Enum.map(& &1.id)
|
||||
assert moon.id in res
|
||||
assert moot.id in res
|
||||
assert kawen.id in res
|
||||
assert [moon.id, kawen.id] == User.Search.search("moon fediverse") |> Enum.map(& &1.id)
|
||||
|
||||
assert [kawen.id, moon.id] ==
|
||||
User.Search.search("moon fediverse", for_user: user) |> Enum.map(& &1.id)
|
||||
res = User.search("moo") |> Enum.map(& &1.id)
|
||||
assert Enum.sort([moon.id, moot.id, kawen.id]) == Enum.sort(res)
|
||||
|
||||
assert [kawen.id, moon.id] == User.Search.search("expert fediverse") |> Enum.map(& &1.id)
|
||||
|
||||
assert [moon.id, kawen.id] ==
|
||||
User.Search.search("expert fediverse", for_user: user) |> Enum.map(& &1.id)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -46,30 +46,49 @@ defmodule Pleroma.UserSearchTest do
|
|||
assert length(User.search("john", limit: 3, offset: 3)) == 2
|
||||
end
|
||||
|
||||
test "finds a user by full or partial nickname" do
|
||||
defp clear_virtual_fields(user) do
|
||||
Map.merge(user, %{search_rank: nil, search_type: nil})
|
||||
end
|
||||
|
||||
test "finds a user by full nickname or its leading fragment" do
|
||||
user = insert(:user, %{nickname: "john"})
|
||||
|
||||
Enum.each(["john", "jo", "j"], fn query ->
|
||||
assert user ==
|
||||
User.search(query)
|
||||
|> List.first()
|
||||
|> Map.put(:search_rank, nil)
|
||||
|> Map.put(:search_type, nil)
|
||||
|> clear_virtual_fields()
|
||||
end)
|
||||
end
|
||||
|
||||
test "finds a user by full or partial name" do
|
||||
test "finds a user by full name or leading fragment(s) of its words" do
|
||||
user = insert(:user, %{name: "John Doe"})
|
||||
|
||||
Enum.each(["John Doe", "JOHN", "doe", "j d", "j", "d"], fn query ->
|
||||
assert user ==
|
||||
User.search(query)
|
||||
|> List.first()
|
||||
|> Map.put(:search_rank, nil)
|
||||
|> Map.put(:search_type, nil)
|
||||
|> clear_virtual_fields()
|
||||
end)
|
||||
end
|
||||
|
||||
test "matches by leading fragment of user domain" do
|
||||
user = insert(:user, %{nickname: "arandom@dude.com"})
|
||||
insert(:user, %{nickname: "iamthedude"})
|
||||
|
||||
assert [user.id] == User.search("dud") |> Enum.map(& &1.id)
|
||||
end
|
||||
|
||||
test "ranks full nickname match higher than full name match" do
|
||||
nicknamed_user = insert(:user, %{nickname: "hj@shigusegubu.club"})
|
||||
named_user = insert(:user, %{nickname: "xyz@sample.com", name: "HJ"})
|
||||
|
||||
results = User.search("hj")
|
||||
|
||||
assert [nicknamed_user.id, named_user.id] == Enum.map(results, & &1.id)
|
||||
assert Enum.at(results, 0).search_rank > Enum.at(results, 1).search_rank
|
||||
end
|
||||
|
||||
test "finds users, considering density of matched tokens" do
|
||||
u1 = insert(:user, %{name: "Bar Bar plus Word Word"})
|
||||
u2 = insert(:user, %{name: "Word Word Bar Bar Bar"})
|
||||
|
|
|
|||
|
|
@ -708,7 +708,10 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
followed = insert(:user)
|
||||
other_user = insert(:user)
|
||||
|
||||
ret_conn = post(conn, "/api/v1/accounts/#{followed.id}/follow?reblogs=false")
|
||||
ret_conn =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("/api/v1/accounts/#{followed.id}/follow", %{reblogs: false})
|
||||
|
||||
assert %{"showing_reblogs" => false} = json_response_and_validate_schema(ret_conn, 200)
|
||||
|
||||
|
|
@ -722,7 +725,8 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
|
||||
assert %{"showing_reblogs" => true} =
|
||||
conn
|
||||
|> post("/api/v1/accounts/#{followed.id}/follow?reblogs=true")
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("/api/v1/accounts/#{followed.id}/follow", %{reblogs: true})
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
assert [%{"id" => ^reblog_id}] =
|
||||
|
|
@ -731,6 +735,35 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
|> json_response(200)
|
||||
end
|
||||
|
||||
test "following with reblogs" do
|
||||
%{conn: conn} = oauth_access(["follow", "read:statuses"])
|
||||
followed = insert(:user)
|
||||
other_user = insert(:user)
|
||||
|
||||
ret_conn = post(conn, "/api/v1/accounts/#{followed.id}/follow")
|
||||
|
||||
assert %{"showing_reblogs" => true} = json_response_and_validate_schema(ret_conn, 200)
|
||||
|
||||
{:ok, activity} = CommonAPI.post(other_user, %{status: "hey"})
|
||||
{:ok, %{id: reblog_id}} = CommonAPI.repeat(activity.id, followed)
|
||||
|
||||
assert [%{"id" => ^reblog_id}] =
|
||||
conn
|
||||
|> get("/api/v1/timelines/home")
|
||||
|> json_response(200)
|
||||
|
||||
assert %{"showing_reblogs" => false} =
|
||||
conn
|
||||
|> put_req_header("content-type", "application/json")
|
||||
|> post("/api/v1/accounts/#{followed.id}/follow", %{reblogs: false})
|
||||
|> json_response_and_validate_schema(200)
|
||||
|
||||
assert [] ==
|
||||
conn
|
||||
|> get("/api/v1/timelines/home")
|
||||
|> json_response(200)
|
||||
end
|
||||
|
||||
test "following / unfollowing errors", %{user: user, conn: conn} do
|
||||
# self follow
|
||||
conn_res = post(conn, "/api/v1/accounts/#{user.id}/follow")
|
||||
|
|
@ -904,7 +937,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
%{
|
||||
"access_token" => token,
|
||||
"created_at" => _created_at,
|
||||
"scope" => _scope,
|
||||
"scope" => ^scope,
|
||||
"token_type" => "Bearer"
|
||||
} = json_response_and_validate_schema(conn, 200)
|
||||
|
||||
|
|
@ -1066,7 +1099,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
assert %{
|
||||
"access_token" => access_token,
|
||||
"created_at" => _,
|
||||
"scope" => ["read", "write", "follow", "push"],
|
||||
"scope" => "read write follow push",
|
||||
"token_type" => "Bearer"
|
||||
} = response
|
||||
|
||||
|
|
@ -1184,7 +1217,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountControllerTest do
|
|||
assert %{
|
||||
"access_token" => access_token,
|
||||
"created_at" => _,
|
||||
"scope" => ["read"],
|
||||
"scope" => "read",
|
||||
"token_type" => "Bearer"
|
||||
} =
|
||||
conn
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
|
||||
use Pleroma.DataCase
|
||||
|
||||
alias Pleroma.Config
|
||||
alias Pleroma.User
|
||||
alias Pleroma.UserRelationship
|
||||
alias Pleroma.Web.CommonAPI
|
||||
|
|
@ -18,6 +19,8 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
|
|||
:ok
|
||||
end
|
||||
|
||||
setup do: clear_config([:instances_favicons, :enabled])
|
||||
|
||||
test "Represent a user account" do
|
||||
background_image = %{
|
||||
"url" => [%{"href" => "https://example.com/images/asuka_hospital.png"}]
|
||||
|
|
@ -75,6 +78,8 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
|
|||
pleroma: %{
|
||||
ap_id: user.ap_id,
|
||||
background_image: "https://example.com/images/asuka_hospital.png",
|
||||
favicon:
|
||||
"https://shitposter.club/plugins/Qvitter/img/gnusocial-favicons/favicon-16x16.png",
|
||||
confirmation_pending: false,
|
||||
tags: [],
|
||||
is_admin: false,
|
||||
|
|
@ -92,6 +97,23 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
|
|||
assert expected == AccountView.render("show.json", %{user: user})
|
||||
end
|
||||
|
||||
test "Favicon is nil when :instances_favicons is disabled" do
|
||||
user = insert(:user)
|
||||
|
||||
Config.put([:instances_favicons, :enabled], true)
|
||||
|
||||
assert %{
|
||||
pleroma: %{
|
||||
favicon:
|
||||
"https://shitposter.club/plugins/Qvitter/img/gnusocial-favicons/favicon-16x16.png"
|
||||
}
|
||||
} = AccountView.render("show.json", %{user: user})
|
||||
|
||||
Config.put([:instances_favicons, :enabled], false)
|
||||
|
||||
assert %{pleroma: %{favicon: nil}} = AccountView.render("show.json", %{user: user})
|
||||
end
|
||||
|
||||
test "Represent the user account for the account owner" do
|
||||
user = insert(:user)
|
||||
|
||||
|
|
@ -152,6 +174,8 @@ defmodule Pleroma.Web.MastodonAPI.AccountViewTest do
|
|||
pleroma: %{
|
||||
ap_id: user.ap_id,
|
||||
background_image: nil,
|
||||
favicon:
|
||||
"https://shitposter.club/plugins/Qvitter/img/gnusocial-favicons/favicon-16x16.png",
|
||||
confirmation_pending: false,
|
||||
tags: [],
|
||||
is_admin: false,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue