# -*-perl-*- use strict; use Test::More tests => 11; use lib "$ENV{LJHOME}/cgi-bin"; require 'ljlib.pl'; %LJ::POST_WITHOUT_AUTH = ( "10.9.177.23" => { # code.sixapart.com "changelog" => [qw(brad whitaker)], }, "192.168.116." => { "*" => sub { my ($journal, $poster) = @_; my $pu = LJ::load_user($poster); return 1 if $poster eq "pbob"; return 1 if $journal eq "jbob"; return 0; }, }, "1.2.3.4" => {"*" => 1, "denied" => 0}, "1.2.3.10" => {"*"=> 0}, ); $LJ::_T_FAKE_IP = "1.2.4.5"; ok(!LJ::run_hook("post_noauth", { user => "brad" }), "no, as normal"); $LJ::_T_FAKE_IP = "10.9.177.23"; ok(!LJ::run_hook("post_noauth", { user => "brad" }), "no, wrong community"); ok(LJ::run_hook("post_noauth", { user => "brad", usejournal => "changelog" }), "no pass needed"); ok(LJ::run_hook("post_noauth", { user => "whitaker", usejournal => "changelog",}), "no pass needed"); $LJ::_T_FAKE_IP = "192.168.116.2"; ok(!LJ::run_hook("post_noauth", { user => "brad" }), "no, as normal"); ok(LJ::run_hook("post_noauth", { user => "pbob" }), "pbob's cool"); ok(LJ::run_hook("post_noauth", { user => "brad", usejournal => "jbob" }), "jbob's cool"); ok(LJ::run_hook("post_noauth", { user => "jbob" }), "journal inherits"); $LJ::_T_FAKE_IP = "1.2.3.4"; ok(LJ::run_hook("post_noauth", { }), "good IP"); ok(!LJ::run_hook("post_noauth", { usejournal => "denied" }), "can't to denied"); $LJ::_T_FAKE_IP = "1.2.3.10"; ok(!LJ::run_hook("post_noauth", { }), "bad IP");