# t/console-ban.t # # Test LJ::Console ban command. # # This code was forked from the LiveJournal project owned and operated # by Live Journal, Inc. The code has been modified and expanded by # Dreamwidth Studios, LLC. These files were originally licensed under # the terms of the license supplied by Live Journal, Inc, which can # currently be found at: # # http://code.livejournal.org/trac/livejournal/browser/trunk/LICENSE-LiveJournal.txt # # In accordance with the original license, this code and all its # modifications are provided under the GNU General Public License. # A copy of that license can be found in the LICENSE file included as # part of this distribution. use strict; use warnings; use Test::More tests => 12; BEGIN { $LJ::_T_CONFIG = 1; require "$ENV{LJHOME}/cgi-bin/ljlib.pl"; } use LJ::Console; use LJ::Test qw (temp_user temp_comm); local $LJ::T_NO_COMMAND_PRINT = 1; my $u = temp_user(); my $u2 = temp_user(); my $comm = temp_comm(); my $comm2 = temp_comm(); my $refresh = sub { LJ::start_request(); LJ::set_remote($u); }; my $run = sub { my $cmd = shift; return LJ::Console->run_commands_text($cmd); }; $refresh->(); is( $run->( "ban_set " . $u2->user ), "success: User " . $u2->user . " banned from " . $u->user ); is( $run->( "ban_set " . $u2->user . " from " . $comm->user ), "error: You are not a maintainer of this account" ); is( LJ::set_rel( $comm, $u, 'A' ), '1', "Set user as maintainer" ); $refresh->(); is( $run->( "ban_set " . $u2->user . " from " . $comm->user ), "success: User " . $u2->user . " banned from " . $comm->user ); is( $run->("ban_list"), "info: " . $u2->user ); is( $run->( "ban_list from " . $comm->user ), "info: " . $u2->user ); is( $run->( "ban_unset " . $u2->user ), "success: User " . $u2->user . " unbanned from " . $u->user ); is( $run->( "ban_unset " . $u2->user . " from " . $comm->user ), "success: User " . $u2->user . " unbanned from " . $comm->user ); is( $run->("ban_list"), "info: " . $u->user . " has not banned any other users." ); is( $run->( "ban_list from " . $comm->user ), "info: " . $comm->user . " has not banned any other users." ); is( $run->( "ban_list from " . $comm2->user ), "error: You are not a maintainer of this account" ); $u->grant_priv( "finduser", "" ); is( $run->( "ban_list from " . $comm2->user ), "info: " . $comm2->user . " has not banned any other users." ); $u->revoke_priv( "finduser", "" );