Changeset 8245


Ignore:
Timestamp:
07/19/10 20:14:53 (3 years ago)
Author:
GeorgeClark
Message:

Item9318: Restore access checks for Func:: createWeb. This also
requires changes to tests that use Func::createWeb

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/CommentPlugin/test/unit/CommentPlugin/CommentPluginTests.pm

    r7644 r8245  
    2424    $this->{target_web}   = "$this->{test_web}Target"; 
    2525    $this->{target_topic} = "$this->{test_topic}Target"; 
    26     Foswiki::Func::createWeb( $this->{target_web} ); 
     26    my $webObject = Foswiki::Meta->new( $this->{session}, $this->{target_web} ); 
     27    $webObject->populateNewWeb(); 
    2728} 
    2829 
  • trunk/MailerContrib/test/unit/MailerContrib/MailerContribSuite.pm

    r7682 r8245  
    6464 
    6565    # Will get torn down when the parent web dies 
    66     Foswiki::Func::createWeb($testWeb2); 
     66    my $webObject = Foswiki::Meta->new( $this->{session}, $testWeb2 ); 
     67    $webObject->populateNewWeb(); 
    6768 
    6869    $this->registerUser( "tu1", "Test", "User1", "test1\@example.com" ); 
  • trunk/TWikiCompatibilityPlugin/test/unit/TWikiCompatibilityPlugin/TWikiFuncTests.pm

    r7644 r8245  
    2323    $this->{tmpdatafile} = $TWiki::cfg{TempfileDir} . '/tmpity-tmp.gif'; 
    2424    $this->{test_web2}   = $this->{test_web} . 'Extra'; 
    25     $this->assert_null( Foswiki::Func::createWeb( $this->{test_web2} ) ); 
     25    my $webObject = Foswiki::Meta->new( $this->{session}, $this->{test_web2} ); 
     26    $webObject->populateNewWeb(); 
    2627} 
    2728 
     
    3536sub test_web { 
    3637    my $this = shift; 
     38 
     39    $this->{session}->finish(); 
     40    $this->{session} = new Foswiki( $Foswiki::cfg{AdminUserLogin} ); 
    3741 
    3842    TWiki::Func::createWeb( $this->{test_web} . "/Blah" ); 
  • trunk/TwistyPlugin/test/unit/TwistyPlugin/TwistyPluginTests.pm

    r7725 r8245  
    258258 
    259259    my $testWebSubWebPath = $this->{test_web} . '/SubWeb'; 
    260     Foswiki::Func::createWeb($testWebSubWebPath); 
     260    my $webObject = Foswiki::Meta->new( $this->{session}, $testWebSubWebPath ); 
     261    $webObject->populateNewWeb(); 
    261262    my $testTopic         = 'TwistyTestTopic'; 
    262263    my $source            = <<SOURCE; 
  • trunk/UnitTestContrib/test/unit/FuncTests.pm

    r8242 r8245  
    5353    use Foswiki::AccessControlException; 
    5454    $Foswiki::cfg{EnableHierarchicalWebs} = 1; 
     55 
     56    $this->{session}->finish(); 
     57    $this->{session} = new Foswiki( $Foswiki::cfg{AdminUserLogin} ); 
    5558 
    5659    try { 
     
    7073    $Foswiki::cfg{EnableHierarchicalWebs} = 1; 
    7174 
     75    $this->{session}->finish(); 
     76    $this->{session} = new Foswiki( $Foswiki::cfg{AdminUserLogin} ); 
     77 
    7278    try { 
    7379        Foswiki::Func::createWeb($this->{test_web}."InvaliBase", "Invalidbase"); 
     
    8591    $Foswiki::cfg{EnableHierarchicalWebs} = 0; 
    8692 
     93    $this->{session}->finish(); 
     94    $this->{session} = new Foswiki( $Foswiki::cfg{AdminUserLogin} ); 
     95 
    8796    try { 
    8897        Foswiki::Func::createWeb($this->{test_web} . "/Subweb"); 
     
    99108    $Foswiki::cfg{EnableHierarchicalWebs} = 1; 
    100109 
    101     Foswiki::Func::createWeb( $this->{test_web} . 'Blah' ); 
    102     Foswiki::Func::createWeb( $this->{test_web} . 'Blah/SubWeb' ); 
     110    my $webObject = Foswiki::Meta->new( $this->{session}, $this->{test_web} . "Blah"  ); 
     111    $webObject->populateNewWeb(); 
     112    undef $webObject; 
     113    $webObject = Foswiki::Meta->new( $this->{session}, $this->{test_web} . "Blah/SubWeb"  ); 
     114    $webObject->populateNewWeb(); 
     115 
    103116    $this->assert( Foswiki::Func::webExists( $this->{test_web} . 'Blah' ) ); 
    104117    $this->assert( 
     
    497510    my $web = $this->{test_web}."/SubWeb"; 
    498511    #$web = Assert::TAINT($web); 
    499     Foswiki::Func::createWeb( $web ); 
     512    # 
     513    my $webObject = Foswiki::Meta->new( $this->{session}, $web ); 
     514    $webObject->populateNewWeb(); 
    500515 
    501516    my $stream; 
     
    636651    $Foswiki::cfg{EnableHierarchicalWebs} = 1; 
    637652 
    638     Foswiki::Func::createWeb( $this->{test_web} . "/Blah" ); 
     653    my $webObject = Foswiki::Meta->new( $this->{session}, $this->{test_web} . "/Blah"  ); 
     654    $webObject->populateNewWeb(); 
    639655 
    640656    Foswiki::Func::saveTopicText( $this->{test_web}, $topic, 'blah' ); 
  • trunk/UnitTestContrib/test/unit/PrefsTests.pm

    r7327 r8245  
    3939    $topicquery = new Unit::Request(""); 
    4040    $topicquery->path_info("/$this->{test_web}/$this->{test_topic}"); 
     41 
     42 
    4143    try { 
    42         Foswiki::Func::createWeb( $TWiki::cfg{SystemWebName}, $original ); 
     44        my $webObject = Foswiki::Meta->new( $this->{session}, $TWiki::cfg{SystemWebName} ); 
     45        $webObject->populateNewWeb($original); 
    4346        my $m = 
    4447          Foswiki::Meta->load( $this->{session}, $original, 
  • trunk/UnitTestContrib/test/unit/StoreTests.pm

    r8216 r8245  
    3939    $this->SUPER::set_up(); 
    4040 
    41     Foswiki::Func::createWeb($web); 
    42  
    43     #    $this->{session} = new Foswiki($this->{test_user_login}); 
     41    my $testWebObj = Foswiki::Meta->new( $this->{session}, $web ); 
     42    $testWebObj->populateNewWeb(); 
     43 
     44    #  Store doesn't do access checks anyway, so run as admin 
     45    #  so that Func:: works 
     46    $this->{session}->finish(); 
     47    $this->{session} = new Foswiki( $Foswiki::cfg{AdminUserLogin} ); 
    4448 
    4549    open( FILE, ">$Foswiki::cfg{TempfileDir}/testfile.gif" ); 
  • trunk/core/lib/Foswiki/Func.pm

    r8238 r8245  
    12161216        ($baseweb) = _validateWTA($baseweb); 
    12171217    } 
    1218  
    1219     ASSERT($Foswiki::Plugins::SESSION) if DEBUG; 
    1220     # SMELL: check access permissions 
     1218    ASSERT($Foswiki::Plugins::SESSION) if DEBUG; 
     1219 
     1220    my $rootObject = Foswiki::Meta->new( $Foswiki::Plugins::SESSION ); 
     1221    unless ( $rootObject->haveAccess('CHANGE') ) { 
     1222        throw Foswiki::AccessControlException( 'CHANGE', 
     1223            $Foswiki::Plugins::SESSION->{user}, 
     1224            $web, '', $Foswiki::Meta::reason ); 
     1225    } 
     1226 
     1227    my $baseObject = Foswiki::Meta->new( $Foswiki::Plugins::SESSION, $baseweb ); 
     1228    unless ( $baseObject->haveAccess('CHANGE') ) { 
     1229        throw Foswiki::AccessControlException( 'VIEW', 
     1230            $Foswiki::Plugins::SESSION->{user}, 
     1231            $web, '', $Foswiki::Meta::reason ); 
     1232    } 
     1233 
    12211234    my $webObject = Foswiki::Meta->new( $Foswiki::Plugins::SESSION, $web ); 
    12221235    $webObject->populateNewWeb($baseweb); 
     
    19281941        } 
    19291942 
    1930         # SMELL: check access permissions 
    19311943        $from->moveAttachment( $attachment, $to, @opts ); 
    19321944    } 
     
    20102022        } 
    20112023 
    2012         # SMELL: check access permissions 
    20132024        $from->copyAttachment( $attachment, $to, @opts ); 
    20142025    } 
Note: See TracChangeset for help on using the changeset viewer.