|
|
|
@ -52,13 +52,13 @@ defmodule Mix.Tasks.Pleroma.UserTest do
|
|
|
|
|
"--admin"
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
assert_received {:mix_shell, :info, [message]}
|
|
|
|
|
assert_receive {:mix_shell, :info, [message]}
|
|
|
|
|
assert message =~ "user will be created"
|
|
|
|
|
|
|
|
|
|
assert_received {:mix_shell, :prompt, [message]}
|
|
|
|
|
assert_receive {:mix_shell, :prompt, [message]}
|
|
|
|
|
assert message =~ "Continue"
|
|
|
|
|
|
|
|
|
|
assert_received {:mix_shell, :info, [message]}
|
|
|
|
|
assert_receive {:mix_shell, :info, [message]}
|
|
|
|
|
assert message =~ "created"
|
|
|
|
|
|
|
|
|
|
user = User.get_cached_by_nickname(unsaved.nickname)
|
|
|
|
@ -77,13 +77,13 @@ defmodule Mix.Tasks.Pleroma.UserTest do
|
|
|
|
|
|
|
|
|
|
Mix.Tasks.Pleroma.User.run(["new", unsaved.nickname, unsaved.email])
|
|
|
|
|
|
|
|
|
|
assert_received {:mix_shell, :info, [message]}
|
|
|
|
|
assert_receive {:mix_shell, :info, [message]}
|
|
|
|
|
assert message =~ "user will be created"
|
|
|
|
|
|
|
|
|
|
assert_received {:mix_shell, :prompt, [message]}
|
|
|
|
|
assert_receive {:mix_shell, :prompt, [message]}
|
|
|
|
|
assert message =~ "Continue"
|
|
|
|
|
|
|
|
|
|
assert_received {:mix_shell, :info, [message]}
|
|
|
|
|
assert_receive {:mix_shell, :info, [message]}
|
|
|
|
|
assert message =~ "will not be created"
|
|
|
|
|
|
|
|
|
|
refute User.get_cached_by_nickname(unsaved.nickname)
|
|
|
|
@ -100,7 +100,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do
|
|
|
|
|
Mix.Tasks.Pleroma.User.run(["rm", user.nickname])
|
|
|
|
|
ObanHelpers.perform_all()
|
|
|
|
|
|
|
|
|
|
assert_received {:mix_shell, :info, [message]}
|
|
|
|
|
assert_receive {:mix_shell, :info, [message]}
|
|
|
|
|
assert message =~ " deleted"
|
|
|
|
|
assert %{is_active: false} = User.get_by_nickname(user.nickname)
|
|
|
|
|
|
|
|
|
@ -138,7 +138,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do
|
|
|
|
|
Mix.Tasks.Pleroma.User.run(["rm", user.nickname])
|
|
|
|
|
ObanHelpers.perform_all()
|
|
|
|
|
|
|
|
|
|
assert_received {:mix_shell, :info, [message]}
|
|
|
|
|
assert_receive {:mix_shell, :info, [message]}
|
|
|
|
|
assert message =~ " deleted"
|
|
|
|
|
assert %{is_active: false} = User.get_by_nickname(user.nickname)
|
|
|
|
|
|
|
|
|
@ -152,7 +152,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do
|
|
|
|
|
test "no user to delete" do
|
|
|
|
|
Mix.Tasks.Pleroma.User.run(["rm", "nonexistent"])
|
|
|
|
|
|
|
|
|
|
assert_received {:mix_shell, :error, [message]}
|
|
|
|
|
assert_receive {:mix_shell, :error, [message]}
|
|
|
|
|
assert message =~ "No local user"
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
@ -169,7 +169,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do
|
|
|
|
|
Mix.Tasks.Pleroma.User.run(["deactivate", user.nickname])
|
|
|
|
|
|
|
|
|
|
# Note that the task has delay :timer.sleep(500)
|
|
|
|
|
assert_received {:mix_shell, :info, [message]}
|
|
|
|
|
assert_receive {:mix_shell, :info, [message]}
|
|
|
|
|
|
|
|
|
|
assert message ==
|
|
|
|
|
"Successfully deactivated #{user.nickname} and unsubscribed all local followers"
|
|
|
|
@ -183,7 +183,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do
|
|
|
|
|
%{id: id, nickname: nickname} = insert(:user, is_active: false)
|
|
|
|
|
|
|
|
|
|
assert :ok = Mix.Tasks.Pleroma.User.run(["deactivate", nickname])
|
|
|
|
|
assert_received {:mix_shell, :info, [message]}
|
|
|
|
|
assert_receive {:mix_shell, :info, [message]}
|
|
|
|
|
assert message == "User #{nickname} already deactivated"
|
|
|
|
|
|
|
|
|
|
user = Repo.get(User, id)
|
|
|
|
@ -193,7 +193,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do
|
|
|
|
|
test "no user to deactivate" do
|
|
|
|
|
Mix.Tasks.Pleroma.User.run(["deactivate", "nonexistent"])
|
|
|
|
|
|
|
|
|
|
assert_received {:mix_shell, :error, [message]}
|
|
|
|
|
assert_receive {:mix_shell, :error, [message]}
|
|
|
|
|
assert message =~ "No user"
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
@ -211,16 +211,16 @@ defmodule Mix.Tasks.Pleroma.UserTest do
|
|
|
|
|
"--moderator"
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
assert_received {:mix_shell, :info, [message]}
|
|
|
|
|
assert_receive {:mix_shell, :info, [message]}
|
|
|
|
|
assert message =~ ~r/Admin status .* true/
|
|
|
|
|
|
|
|
|
|
assert_received {:mix_shell, :info, [message]}
|
|
|
|
|
assert_receive {:mix_shell, :info, [message]}
|
|
|
|
|
assert message =~ ~r/Confirmation status.* true/
|
|
|
|
|
|
|
|
|
|
assert_received {:mix_shell, :info, [message]}
|
|
|
|
|
assert_receive {:mix_shell, :info, [message]}
|
|
|
|
|
assert message =~ ~r/Locked status .* true/
|
|
|
|
|
|
|
|
|
|
assert_received {:mix_shell, :info, [message]}
|
|
|
|
|
assert_receive {:mix_shell, :info, [message]}
|
|
|
|
|
assert message =~ ~r/Moderator status .* true/
|
|
|
|
|
|
|
|
|
|
user = User.get_cached_by_nickname(user.nickname)
|
|
|
|
@ -248,16 +248,16 @@ defmodule Mix.Tasks.Pleroma.UserTest do
|
|
|
|
|
"--no-moderator"
|
|
|
|
|
])
|
|
|
|
|
|
|
|
|
|
assert_received {:mix_shell, :info, [message]}
|
|
|
|
|
assert_receive {:mix_shell, :info, [message]}
|
|
|
|
|
assert message =~ ~r/Admin status .* false/
|
|
|
|
|
|
|
|
|
|
assert_received {:mix_shell, :info, [message]}
|
|
|
|
|
assert_receive {:mix_shell, :info, [message]}
|
|
|
|
|
assert message =~ ~r/Confirmation status.* false/
|
|
|
|
|
|
|
|
|
|
assert_received {:mix_shell, :info, [message]}
|
|
|
|
|
assert_receive {:mix_shell, :info, [message]}
|
|
|
|
|
assert message =~ ~r/Locked status .* false/
|
|
|
|
|
|
|
|
|
|
assert_received {:mix_shell, :info, [message]}
|
|
|
|
|
assert_receive {:mix_shell, :info, [message]}
|
|
|
|
|
assert message =~ ~r/Moderator status .* false/
|
|
|
|
|
|
|
|
|
|
user = User.get_cached_by_nickname(user.nickname)
|
|
|
|
@ -270,7 +270,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do
|
|
|
|
|
test "no user to set status" do
|
|
|
|
|
Mix.Tasks.Pleroma.User.run(["set", "nonexistent", "--moderator"])
|
|
|
|
|
|
|
|
|
|
assert_received {:mix_shell, :error, [message]}
|
|
|
|
|
assert_receive {:mix_shell, :error, [message]}
|
|
|
|
|
assert message =~ "No local user"
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
@ -283,14 +283,14 @@ defmodule Mix.Tasks.Pleroma.UserTest do
|
|
|
|
|
Mix.Tasks.Pleroma.User.run(["reset_password", user.nickname])
|
|
|
|
|
end) =~ "URL:"
|
|
|
|
|
|
|
|
|
|
assert_received {:mix_shell, :info, [message]}
|
|
|
|
|
assert_receive {:mix_shell, :info, [message]}
|
|
|
|
|
assert message =~ "Generated"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test "no user to reset password" do
|
|
|
|
|
Mix.Tasks.Pleroma.User.run(["reset_password", "nonexistent"])
|
|
|
|
|
|
|
|
|
|
assert_received {:mix_shell, :error, [message]}
|
|
|
|
|
assert_receive {:mix_shell, :error, [message]}
|
|
|
|
|
assert message =~ "No local user"
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
@ -307,7 +307,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do
|
|
|
|
|
|
|
|
|
|
Mix.Tasks.Pleroma.User.run(["reset_mfa", user.nickname])
|
|
|
|
|
|
|
|
|
|
assert_received {:mix_shell, :info, [message]}
|
|
|
|
|
assert_receive {:mix_shell, :info, [message]}
|
|
|
|
|
assert message == "Multi-Factor Authentication disabled for #{user.nickname}"
|
|
|
|
|
|
|
|
|
|
assert %{enabled: false, totp: false} ==
|
|
|
|
@ -319,7 +319,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do
|
|
|
|
|
test "no user to reset MFA" do
|
|
|
|
|
Mix.Tasks.Pleroma.User.run(["reset_password", "nonexistent"])
|
|
|
|
|
|
|
|
|
|
assert_received {:mix_shell, :error, [message]}
|
|
|
|
|
assert_receive {:mix_shell, :error, [message]}
|
|
|
|
|
assert message =~ "No local user"
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
@ -330,7 +330,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do
|
|
|
|
|
Mix.Tasks.Pleroma.User.run(["invite"])
|
|
|
|
|
end) =~ "http"
|
|
|
|
|
|
|
|
|
|
assert_received {:mix_shell, :info, [message]}
|
|
|
|
|
assert_receive {:mix_shell, :info, [message]}
|
|
|
|
|
assert message =~ "Generated user invite token one time"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
@ -343,7 +343,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do
|
|
|
|
|
])
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
assert_received {:mix_shell, :info, [message]}
|
|
|
|
|
assert_receive {:mix_shell, :info, [message]}
|
|
|
|
|
assert message =~ "Generated user invite token date limited"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
@ -356,7 +356,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do
|
|
|
|
|
])
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
assert_received {:mix_shell, :info, [message]}
|
|
|
|
|
assert_receive {:mix_shell, :info, [message]}
|
|
|
|
|
assert message =~ "Generated user invite token reusable"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
@ -371,7 +371,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do
|
|
|
|
|
])
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
assert_received {:mix_shell, :info, [message]}
|
|
|
|
|
assert_receive {:mix_shell, :info, [message]}
|
|
|
|
|
assert message =~ "Generated user invite token reusable date limited"
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
@ -390,9 +390,9 @@ defmodule Mix.Tasks.Pleroma.UserTest do
|
|
|
|
|
|
|
|
|
|
# end)
|
|
|
|
|
|
|
|
|
|
assert_received {:mix_shell, :info, [message]}
|
|
|
|
|
assert_received {:mix_shell, :info, [message2]}
|
|
|
|
|
assert_received {:mix_shell, :info, [message3]}
|
|
|
|
|
assert_receive {:mix_shell, :info, [message]}
|
|
|
|
|
assert_receive {:mix_shell, :info, [message2]}
|
|
|
|
|
assert_receive {:mix_shell, :info, [message3]}
|
|
|
|
|
assert message =~ "Invites list:"
|
|
|
|
|
assert message2 =~ invite.invite_type
|
|
|
|
|
assert message3 =~ invite2.invite_type
|
|
|
|
@ -410,7 +410,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do
|
|
|
|
|
])
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
assert_received {:mix_shell, :info, [message]}
|
|
|
|
|
assert_receive {:mix_shell, :info, [message]}
|
|
|
|
|
assert message =~ "Invite for token #{invite.token} was revoked."
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
@ -420,14 +420,14 @@ defmodule Mix.Tasks.Pleroma.UserTest do
|
|
|
|
|
%{nickname: nickname} = insert(:user)
|
|
|
|
|
|
|
|
|
|
assert :ok == Mix.Tasks.Pleroma.User.run(["delete_activities", nickname])
|
|
|
|
|
assert_received {:mix_shell, :info, [message]}
|
|
|
|
|
assert_receive {:mix_shell, :info, [message]}
|
|
|
|
|
assert message == "User #{nickname} statuses deleted."
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test "it prints an error message when user is not exist" do
|
|
|
|
|
Mix.Tasks.Pleroma.User.run(["delete_activities", "foo"])
|
|
|
|
|
|
|
|
|
|
assert_received {:mix_shell, :error, [message]}
|
|
|
|
|
assert_receive {:mix_shell, :error, [message]}
|
|
|
|
|
assert message =~ "No local user"
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
@ -437,7 +437,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do
|
|
|
|
|
%{id: id, nickname: nickname} = insert(:user, is_confirmed: true)
|
|
|
|
|
|
|
|
|
|
assert :ok = Mix.Tasks.Pleroma.User.run(["confirm", nickname])
|
|
|
|
|
assert_received {:mix_shell, :info, [message]}
|
|
|
|
|
assert_receive {:mix_shell, :info, [message]}
|
|
|
|
|
assert message == "#{nickname} doesn't need confirmation."
|
|
|
|
|
|
|
|
|
|
user = Repo.get(User, id)
|
|
|
|
@ -450,7 +450,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do
|
|
|
|
|
insert(:user, is_confirmed: false, confirmation_token: "some token")
|
|
|
|
|
|
|
|
|
|
assert :ok = Mix.Tasks.Pleroma.User.run(["confirm", nickname])
|
|
|
|
|
assert_received {:mix_shell, :info, [message]}
|
|
|
|
|
assert_receive {:mix_shell, :info, [message]}
|
|
|
|
|
assert message == "#{nickname} doesn't need confirmation."
|
|
|
|
|
|
|
|
|
|
user = Repo.get(User, id)
|
|
|
|
@ -461,7 +461,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do
|
|
|
|
|
test "it prints an error message when user is not exist" do
|
|
|
|
|
Mix.Tasks.Pleroma.User.run(["confirm", "foo"])
|
|
|
|
|
|
|
|
|
|
assert_received {:mix_shell, :error, [message]}
|
|
|
|
|
assert_receive {:mix_shell, :error, [message]}
|
|
|
|
|
assert message =~ "No local user"
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
@ -471,7 +471,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do
|
|
|
|
|
%{id: id, nickname: nickname} = insert(:user, is_active: true)
|
|
|
|
|
|
|
|
|
|
assert :ok = Mix.Tasks.Pleroma.User.run(["activate", nickname])
|
|
|
|
|
assert_received {:mix_shell, :info, [message]}
|
|
|
|
|
assert_receive {:mix_shell, :info, [message]}
|
|
|
|
|
assert message == "User #{nickname} already activated"
|
|
|
|
|
|
|
|
|
|
user = Repo.get(User, id)
|
|
|
|
@ -482,7 +482,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do
|
|
|
|
|
%{id: id, nickname: nickname} = insert(:user, is_active: false)
|
|
|
|
|
|
|
|
|
|
assert :ok = Mix.Tasks.Pleroma.User.run(["activate", nickname])
|
|
|
|
|
assert_received {:mix_shell, :info, [message]}
|
|
|
|
|
assert_receive {:mix_shell, :info, [message]}
|
|
|
|
|
assert message == "Successfully activated #{nickname}"
|
|
|
|
|
|
|
|
|
|
user = Repo.get(User, id)
|
|
|
|
@ -492,7 +492,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do
|
|
|
|
|
test "no user to activate" do
|
|
|
|
|
Mix.Tasks.Pleroma.User.run(["activate", "foo"])
|
|
|
|
|
|
|
|
|
|
assert_received {:mix_shell, :error, [message]}
|
|
|
|
|
assert_receive {:mix_shell, :error, [message]}
|
|
|
|
|
assert message =~ "No user"
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
@ -536,7 +536,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do
|
|
|
|
|
test "it prints an error message when user is not exist" do
|
|
|
|
|
Mix.Tasks.Pleroma.User.run(["sign_out", "foo"])
|
|
|
|
|
|
|
|
|
|
assert_received {:mix_shell, :error, [message]}
|
|
|
|
|
assert_receive {:mix_shell, :error, [message]}
|
|
|
|
|
assert message =~ "No local user"
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
@ -554,7 +554,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do
|
|
|
|
|
test "it prints an error message when user is not exist" do
|
|
|
|
|
Mix.Tasks.Pleroma.User.run(["tag", "foo"])
|
|
|
|
|
|
|
|
|
|
assert_received {:mix_shell, :error, [message]}
|
|
|
|
|
assert_receive {:mix_shell, :error, [message]}
|
|
|
|
|
assert message =~ "Could not change user tags"
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
@ -573,7 +573,7 @@ defmodule Mix.Tasks.Pleroma.UserTest do
|
|
|
|
|
test "it prints an error message when user is not exist" do
|
|
|
|
|
Mix.Tasks.Pleroma.User.run(["untag", "foo"])
|
|
|
|
|
|
|
|
|
|
assert_received {:mix_shell, :error, [message]}
|
|
|
|
|
assert_receive {:mix_shell, :error, [message]}
|
|
|
|
|
assert message =~ "Could not change user tags"
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|