Changeset 13791 for trunk/UnitTestContrib/test/unit/AccessControlTests.pm
- Timestamp:
- 01/23/12 06:00:05 (4 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UnitTestContrib/test/unit/AccessControlTests.pm
r13730 r13791 3 3 use warnings; 4 4 5 use FoswikiFnTestCase ;5 use FoswikiFnTestCase(); 6 6 our @ISA = qw( FoswikiFnTestCase ); 7 7 … … 41 41 $this->SUPER::set_up(); 42 42 43 my $topicObject = Foswiki::Meta->new( 44 $this->{session}, 45 $Foswiki::cfg{UsersWebName}, 46 $Foswiki::cfg{DefaultUserWikiName}, '' 47 ); 48 $topicObject->save(); 43 my ($topicObject) = Foswiki::Func::readTopic( $Foswiki::cfg{UsersWebName}, 44 $Foswiki::cfg{DefaultUserWikiName} ); 45 $topicObject->text(''); 46 $topicObject->save(); 47 $topicObject->finish(); 49 48 $this->registerUser( 'white', 'Mr', "White", 'white@example.com' ); 50 49 $MrWhite = $this->{session}->{users}->getCanonicalUserID('white'); … … 58 57 $MrYellow = $this->{session}->{users}->getCanonicalUserID('yellow'); 59 58 60 $topicObject = 61 Foswiki::Meta->new( $this->{session}, $this->{users_web}, 62 "ReservoirDogsGroup", <<"THIS"); 59 $this->createNewFoswikiSession(); 60 ($topicObject) = 61 Foswiki::Func::readTopic( $this->{users_web}, "ReservoirDogsGroup" ); 62 $topicObject->text(<<"THIS"); 63 63 * Set GROUP = MrWhite, $this->{users_web}.MrBlue 64 64 THIS 65 65 $topicObject->save(); 66 67 return; 68 } 69 70 sub tear_down { 71 my $this = shift; 72 $this->SUPER::tear_down(); 66 $topicObject->finish(); 73 67 74 68 return; … … 79 73 $web ||= $this->{test_web}; 80 74 $topic ||= $this->{test_topic}; 81 my $topicObject = Foswiki::Meta->load( $this->{session},$web, $topic );75 my ($topicObject) = Foswiki::Func::readTopic( $web, $topic ); 82 76 $this->assert( !$topicObject->haveAccess( $mode, $user ), 83 77 "$user $mode $web.$topic" ); … … 106 100 ); 107 101 } 102 $topicObject->finish(); 108 103 109 104 return; … … 114 109 $web ||= $this->{test_web}; 115 110 $topic ||= $this->{test_topic}; 116 my $topicObject = Foswiki::Meta->load( $this->{session},$web, $topic );111 my ($topicObject) = Foswiki::Func::readTopic( $web, $topic ); 117 112 $this->assert( $topicObject->haveAccess( $mode, $user ), 118 113 "$user $mode $web.$topic" ); … … 141 136 ); 142 137 } 138 $topicObject->finish(); 143 139 144 140 return; … … 152 148 sub test_denytopic { 153 149 my $this = shift; 154 my $topicObject=155 Foswiki:: Meta->new( $this->{session}, $this->{test_web},156 $this->{test_topic},<<"THIS");150 my ($topicObject) = 151 Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 152 $topicObject->text(<<"THIS"); 157 153 If DENYTOPIC is set to a list of wikinames 158 154 * people in the list will be DENIED. … … 161 157 THIS 162 158 $topicObject->save(); 163 164 $this->{session}->finish(); 165 $this->{session} = Foswiki->new(); 166 159 $topicObject->finish(); 160 161 $this->createNewFoswikiSession(); 167 162 $this->PERMITTED( "VIEW", $MrGreen ); 168 163 $this->DENIED( "VIEW", $MrYellow ); … … 177 172 sub test_empty_denytopic { 178 173 my $this = shift; 179 my $topicObject=180 Foswiki:: Meta->new( $this->{session}, $this->{test_web},181 $this->{test_topic},<<'THIS');174 my ($topicObject) = 175 Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 176 $topicObject->text(<<'THIS'); 182 177 If DENYTOPIC is set to empty ( i.e. Set DENYTOPIC = ) 183 178 * access is PERMITTED _i.e _ no-one is denied access to this topic … … 185 180 THIS 186 181 $topicObject->save(); 187 188 $this->{session}->finish(); 189 $this-> {session} = Foswiki->new();182 $topicObject->finish(); 183 184 $this->createNewFoswikiSession(); 190 185 $this->PERMITTED( "VIEW", $MrGreen ); 191 186 $this->PERMITTED( "VIEW", $MrYellow ); … … 200 195 sub test_whitespace_denytopic { 201 196 my $this = shift; 202 my $topicObject=203 Foswiki:: Meta->new( $this->{session}, $this->{test_web},204 $this->{test_topic},<<'THIS');197 my ($topicObject) = 198 Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 199 $topicObject->text(<<'THIS'); 205 200 If DENYTOPIC is set to empty ( i.e. Set DENYTOPIC = ) 206 201 * access is PERMITTED _i.e _ no-one is denied access to this topic … … 208 203 THIS 209 204 $topicObject->save(); 210 211 $this->{session}->finish(); 212 $this-> {session} = Foswiki->new();205 $topicObject->finish(); 206 207 $this->createNewFoswikiSession(); 213 208 $this->PERMITTED( "VIEW", $MrGreen ); 214 209 $this->PERMITTED( "VIEW", $MrYellow ); … … 223 218 sub test_denytopic_whitespace { 224 219 my $this = shift; 225 my $topicObject=226 Foswiki:: Meta->new( $this->{session}, $this->{test_web},227 $this->{test_topic},<<'THIS');220 my ($topicObject) = 221 Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 222 $topicObject->text(<<'THIS'); 228 223 If DENYTOPIC is set to empty ( i.e. Set DENYTOPIC = ) 229 224 * access is PERMITTED _i.e _ no-one is denied access to this topic … … 231 226 THIS 232 227 $topicObject->save(); 233 234 $this->{session}->finish(); 235 $this-> {session} = Foswiki->new();228 $topicObject->finish(); 229 230 $this->createNewFoswikiSession(); 236 231 $this->PERMITTED( "VIEW", $MrGreen ); 237 232 $this->PERMITTED( "VIEW", $MrYellow ); … … 246 241 sub test_allowtopic { 247 242 my $this = shift; 248 my $topicObject=249 Foswiki:: Meta->new( $this->{session}, $this->{test_web},250 $this->{test_topic},<<'THIS');243 my ($topicObject) = 244 Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 245 $topicObject->text(<<'THIS'); 251 246 If ALLOWTOPIC is set 252 247 1. people in the list are PERMITTED … … 255 250 THIS 256 251 $topicObject->save(); 257 258 $this->{session}->finish(); 259 $this-> {session} = Foswiki->new();252 $topicObject->finish(); 253 254 $this->createNewFoswikiSession(); 260 255 $this->PERMITTED( "VIEW", $MrOrange ); 261 256 $this->DENIED( "VIEW", $MrGreen ); … … 271 266 sub test_allowtopic_a { 272 267 my $this = shift; 273 my $topicObject=274 Foswiki:: Meta->new( $this->{session}, $this->{test_web},275 $this->{test_topic},<<'THIS');268 my ($topicObject) = 269 Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 270 $topicObject->text(<<'THIS'); 276 271 If ALLOWTOPIC is set 277 272 1. people in the list are PERMITTED … … 280 275 THIS 281 276 $topicObject->save(); 277 $topicObject->finish(); 282 278 283 279 my $topicquery = Unit::Request->new(""); … … 285 281 286 282 # renew Foswiki, so WebPreferences gets re-read 287 $this->{session}->finish(); 288 $this->{session} = Foswiki->new( undef, $topicquery ); 283 $this->createNewFoswikiSession(); 289 284 $this->PERMITTED( "VIEW", $MrOrange ); 290 $this->{session}->finish(); 291 $this->{session} = Foswiki->new( undef, $topicquery ); 285 $this->createNewFoswikiSession( undef, $topicquery ); 292 286 $this->DENIED( "VIEW", $MrGreen ); 293 $this->{session}->finish(); 294 $this->{session} = Foswiki->new( undef, $topicquery ); 287 $this->createNewFoswikiSession( undef, $topicquery ); 295 288 $this->DENIED( "VIEW", $MrYellow ); 296 $this->{session}->finish(); 297 $this->{session} = Foswiki->new( undef, $topicquery ); 289 $this->createNewFoswikiSession( undef, $topicquery ); 298 290 $this->DENIED( "VIEW", $MrWhite ); 299 $this->{session}->finish(); 300 $this->{session} = Foswiki->new( undef, $topicquery ); 291 $this->createNewFoswikiSession( undef, $topicquery ); 301 292 $this->DENIED( "view", $MrBlue ); 302 293 … … 309 300 sub test_allowtopic_b { 310 301 my $this = shift; 311 my $topicObject=312 Foswiki:: Meta->new( $this->{session}, $this->{test_web},313 $this->{test_topic},<<'THIS');302 my ($topicObject) = 303 Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 304 $topicObject->text(<<'THIS'); 314 305 If ALLOWTOPIC is set 315 306 1. people in the list are PERMITTED … … 318 309 THIS 319 310 $topicObject->save(); 311 $topicObject->finish(); 320 312 321 313 # renew Foswiki, so WebPreferences gets re-read 322 $this->{session}->finish(); 323 $this->{session} = Foswiki->new(); 314 $this->createNewFoswikiSession(); 324 315 $this->PERMITTED( "VIEW", $MrOrange ); 325 $this->{session}->finish(); 326 $this->{session} = Foswiki->new(); 316 $this->createNewFoswikiSession(); 327 317 $this->DENIED( "VIEW", $MrGreen ); 328 $this->{session}->finish(); 329 $this->{session} = Foswiki->new(); 318 $this->createNewFoswikiSession(); 330 319 $this->DENIED( "VIEW", $MrYellow ); 331 $this->{session}->finish(); 332 $this->{session} = Foswiki->new(); 320 $this->createNewFoswikiSession(); 333 321 $this->DENIED( "VIEW", $MrWhite ); 334 $this->{session}->finish(); 335 $this->{session} = Foswiki->new(); 322 $this->createNewFoswikiSession(); 336 323 $this->DENIED( "view", $MrBlue ); 337 324 … … 343 330 sub test_allowtopic_c { 344 331 my $this = shift; 345 my $topicObject=346 Foswiki:: Meta->new( $this->{session}, $this->{test_web},347 $this->{test_topic},<<'THIS');332 my ($topicObject) = 333 Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 334 $topicObject->text(<<'THIS'); 348 335 If ALLOWTOPIC is set 349 336 1. people in the list are PERMITTED … … 360 347 ); 361 348 $topicObject->save(); 349 $topicObject->finish(); 362 350 363 351 # renew Foswiki, so WebPreferences gets re-read 364 $this->{session}->finish(); 365 $this->{session} = Foswiki->new(); 352 $this->createNewFoswikiSession(); 366 353 $this->PERMITTED( "VIEW", $MrOrange ); 367 $this->{session}->finish(); 368 $this->{session} = Foswiki->new(); 354 $this->createNewFoswikiSession(); 369 355 $this->DENIED( "VIEW", $MrGreen ); 370 $this->{session}->finish(); 371 $this->{session} = Foswiki->new(); 356 $this->createNewFoswikiSession(); 372 357 $this->PERMITTED( "VIEW", $MrYellow ); 373 $this->{session}->finish(); 374 $this->{session} = Foswiki->new(); 358 $this->createNewFoswikiSession(); 375 359 $this->DENIED( "VIEW", $MrWhite ); 376 $this->{session}->finish(); 377 $this->{session} = Foswiki->new(); 360 $this->createNewFoswikiSession(); 378 361 $this->DENIED( "view", $MrBlue ); 379 362 … … 384 367 sub test_denyweb { 385 368 my $this = shift; 386 my $topicObject = 387 Foswiki::Meta->new( $this->{session}, $this->{test_web}, 388 $Foswiki::cfg{WebPrefsTopicName}, <<"THIS"); 369 my ($topicObject) = 370 Foswiki::Func::readTopic( $this->{test_web}, 371 $Foswiki::cfg{WebPrefsTopicName} ); 372 $topicObject->text(<<"THIS"); 389 373 If DENYWEB is set to a list of wikiname 390 374 * people in the list are DENIED access … … 392 376 THIS 393 377 $topicObject->save(); 378 $topicObject->finish(); 394 379 395 380 # renew Foswiki, so WebPreferences gets re-read 396 $this-> {session}->finish();397 $this->{session} = Foswiki->new();398 $topicObject = Foswiki::Meta->new(399 $this->{session}, $this->{test_web},400 $this->{test_topic}, "Null points"401 );402 $topicObject->save(); 381 $this->createNewFoswikiSession(); 382 ($topicObject) = 383 Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 384 $topicObject->text("Null points"); 385 $topicObject->save(); 386 $topicObject->finish(); 387 403 388 $this->DENIED( "VIEW", $MrOrange ); 404 389 $this->PERMITTED( "VIEW", $MrGreen ); … … 412 397 # Test that ALLOWWEB works in a top-level web with no finalisation 413 398 sub test_allow_web { 414 my $this = shift; 415 my $topicObject = Foswiki::Meta->new( 416 $this->{session}, 417 $this->{test_web}, $Foswiki::cfg{WebPrefsTopicName}, 399 my $this = shift; 400 my ($topicObject) = 401 Foswiki::Func::readTopic( $this->{test_web}, 402 $Foswiki::cfg{WebPrefsTopicName} ); 403 $topicObject->text( 418 404 <<'THIS' 419 405 If ALLOWWEB is set to a list of wikinames … … 422 408 * Set ALLOWWEBVIEW = MrGreen MrYellow MrWhite 423 409 THIS 424 , undef425 );426 $topicObject-> save();410 ); 411 $topicObject->save(); 412 $topicObject->finish(); 427 413 428 414 # renew Foswiki, so WebPreferences gets re-read 429 $this->{session}->finish(); 430 $this->{session} = Foswiki->new(); 431 $topicObject = Foswiki::Meta->new( 432 $this->{session}, $this->{test_web}, 433 $this->{test_topic}, "Null points" 434 ); 435 $topicObject->save(); 415 $this->createNewFoswikiSession(); 416 ($topicObject) = 417 Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 418 $topicObject->text("Null points"); 419 $topicObject->save(); 420 $topicObject->finish(); 436 421 $this->DENIED( "VIEW", $MrOrange ); 437 422 $this->PERMITTED( "VIEW", $MrGreen ); … … 445 430 # Test that Web.UserName is equivalent to UserName in ACLs 446 431 sub test_webDotUserName { 447 my $this = shift; 448 my $topicObject = Foswiki::Meta->new( 449 $this->{session}, $this->{test_web}, $this->{test_topic}, 432 my $this = shift; 433 my ($topicObject) = 434 Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 435 $topicObject->text( 450 436 <<'THIS' 451 437 If ALLOWTOPIC is set … … 454 440 * Set ALLOWTOPICVIEW = MrYellow,%USERSWEB%.MrOrange,Nosuchweb.MrGreen,%MAINWEB%.MrBlue,%SYSTEMWEB%.MrWhite 455 441 THIS 456 , undef 457 ); 458 $topicObject->save(); 459 $this->{session}->finish(); 460 $this->{session} = Foswiki->new(); 442 ); 443 $topicObject->save(); 444 $topicObject->finish(); 445 $this->createNewFoswikiSession(); 461 446 $this->PERMITTED( "VIEW", $MrOrange ); 462 447 $this->DENIED( "VIEW", $MrGreen ); … … 502 487 * Set ALLOWTOPICVIEW = %USERSWEB%.MrGreen 503 488 THIS 504 my $topicObject = 505 Foswiki::Meta->new( $this->{session}, $this->{test_web}, 506 $this->{test_topic}, $text ); 507 $topicObject->save(); 508 $this->{session}->finish(); 509 510 $this->{session} = Foswiki->new(); 511 $topicObject = 512 Foswiki::Meta->new( $this->{session}, $this->{test_web}, 513 $this->{test_topic} ); 489 my ($topicObject) = 490 Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 491 $topicObject->text($text); 492 $topicObject->save(); 493 $topicObject->finish(); 494 $this->createNewFoswikiSession(); 495 496 ($topicObject) = 497 Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 514 498 $this->_checkSettings($topicObject); 499 $topicObject->finish(); 515 500 516 501 return; … … 521 506 my $this = shift; 522 507 523 my $topicObject=524 Foswiki:: Meta->new( $this->{session}, $this->{test_web},525 $this->{test_topic}, 'Empty');508 my ($topicObject) = 509 Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 510 $topicObject->text('Empty'); 526 511 my $args = { 527 512 name => 'ALLOWTOPICVIEW', … … 532 517 $topicObject->putKeyed( 'PREFERENCE', $args ); 533 518 $topicObject->save(); 534 $this->{session}->finish(); 535 536 $this->{session} = Foswiki->new(); 537 $topicObject = 538 Foswiki::Meta->new( $this->{session}, $this->{test_web}, 539 $this->{test_topic} ); 519 $topicObject->finish(); 520 $this->createNewFoswikiSession(); 521 522 ($topicObject) = 523 Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 540 524 541 525 $this->_checkSettings($topicObject); 526 $topicObject->finish(); 542 527 543 528 return; … … 551 536 * Set ALLOWTOPICVIEW = %USERSWEB%.MrOrange 552 537 THIS 553 my $topicObject=554 Foswiki:: Meta->new( $this->{session}, $this->{test_web},555 $this->{test_topic}, $text);538 my ($topicObject) = 539 Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 540 $topicObject->text($text); 556 541 my $args = { 557 542 name => 'ALLOWTOPICVIEW', … … 562 547 $topicObject->putKeyed( 'PREFERENCE', $args ); 563 548 $topicObject->save(); 564 $this->{session}->finish(); 565 566 $this->{session} = Foswiki->new(); 567 $topicObject = 568 Foswiki::Meta->new( $this->{session}, $this->{test_web}, 569 $this->{test_topic} ); 549 $topicObject->finish(); 550 $this->createNewFoswikiSession(); 551 552 ($topicObject) = 553 Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 570 554 $this->_checkSettings($topicObject); 555 $topicObject->finish(); 571 556 572 557 return; … … 581 566 582 567 # First build a parent web with view restricted to MrGreen 583 my $topicObject = 584 Foswiki::Meta->new( $this->{session}, $this->{test_web}, 585 $this->{test_topic}, "Nowt" ); 586 $topicObject->save(); 587 588 $topicObject = 589 Foswiki::Meta->new( $this->{session}, $this->{test_web}, 590 $Foswiki::cfg{WebPrefsTopicName}, <<'THIS'); 568 my ($topicObject) = 569 Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} ); 570 $topicObject->text("Nowt"); 571 $topicObject->save(); 572 $topicObject->finish(); 573 574 ($topicObject) = 575 Foswiki::Func::readTopic( $this->{test_web}, 576 $Foswiki::cfg{WebPrefsTopicName} ); 577 $topicObject->text(<<'THIS'); 591 578 * Set ALLOWWEBVIEW = MrGreen 592 579 THIS 593 580 $topicObject->save(); 581 $topicObject->finish(); 594 582 595 583 # Now build a subweb with view restricted to MrOrange 596 584 my $webObject = Foswiki::Meta->new( $this->{session}, $subweb ); 597 585 $webObject->populateNewWeb(); 598 $topicObject = 599 Foswiki::Meta->new( $this->{session}, $subweb, 600 $Foswiki::cfg{WebPrefsTopicName}, <<'THIS'); 586 $webObject->finish(); 587 ($topicObject) = 588 Foswiki::Func::readTopic( $subweb, $Foswiki::cfg{WebPrefsTopicName} ); 589 $topicObject->text(<<'THIS'); 601 590 * Set ALLOWWEBVIEW = MrOrange 602 591 THIS 603 592 $topicObject->save(); 604 $t his->{session}->finish();593 $topicObject->finish(); 605 594 606 595 # Ensure that MrOrange can read the subweb and MrGreen the parent web 607 $this-> {session} = Foswiki->new();596 $this->createNewFoswikiSession(); 608 597 $this->PERMITTED( "VIEW", $MrOrange, $subweb ); 609 598 $this->DENIED( "VIEW", $MrGreen, $subweb ); … … 623 612 # First build a parent web with view restricted to MrGreen, and 624 613 # finalise the setting 625 my $topicObject = 626 Foswiki::Meta->new( $this->{session}, $this->{test_web}, 627 $Foswiki::cfg{WebPrefsTopicName}, <<'THIS'); 614 my ($topicObject) = 615 Foswiki::Func::readTopic( $this->{test_web}, 616 $Foswiki::cfg{WebPrefsTopicName} ); 617 $topicObject->text(<<'THIS'); 628 618 * Set ALLOWWEBVIEW = MrGreen 629 619 * Set FINALPREFERENCES = ALLOWWEBVIEW 630 620 THIS 631 621 $topicObject->save(); 622 $topicObject->finish(); 632 623 633 624 # Now build a subweb with no restrictions 634 625 my $webObject = Foswiki::Meta->new( $this->{session}, $subweb ); 635 626 $webObject->populateNewWeb(); 636 $topicObject = 637 Foswiki::Meta->new( $this->{session}, $subweb, 638 $Foswiki::cfg{WebPrefsTopicName}, <<'THIS'); 639 THIS 640 $topicObject->save(); 641 $this->{session}->finish(); 642 643 $this->{session} = Foswiki->new(); 627 $webObject->finish(); 628 ($topicObject) = 629 Foswiki::Func::readTopic( $subweb, $Foswiki::cfg{WebPrefsTopicName} ); 630 $topicObject->text(<<'THIS'); 631 THIS 632 $topicObject->save(); 633 $topicObject->finish(); 634 635 $this->createNewFoswikiSession(); 644 636 $this->PERMITTED( "VIEW", $MrGreen, $subweb ); 645 637 $this->DENIED( "VIEW", $MrOrange, $subweb ); … … 659 651 # First build a parent web with view restricted to MrGreen, and 660 652 # finalise the setting 661 my $topicObject = 662 Foswiki::Meta->new( $this->{session}, $this->{test_web}, 663 $Foswiki::cfg{WebPrefsTopicName}, <<'THIS'); 653 my ($topicObject) = 654 Foswiki::Func::readTopic( $this->{test_web}, 655 $Foswiki::cfg{WebPrefsTopicName} ); 656 $topicObject->text(<<'THIS'); 664 657 * Set ALLOWWEBVIEW = MrGreen 665 658 * Set FINALPREFERENCES = ALLOWWEBVIEW 666 659 THIS 667 660 $topicObject->save(); 661 $topicObject->finish(); 668 662 669 663 # Now build a subweb with view restricted to MrOrange 670 664 my $webObject = Foswiki::Meta->new( $this->{session}, $subweb ); 671 665 $webObject->populateNewWeb(); 672 $topicObject = 673 Foswiki::Meta->new( $this->{session}, $subweb, 674 $Foswiki::cfg{WebPrefsTopicName}, <<'THIS'); 666 $webObject->finish(); 667 ($topicObject) = 668 Foswiki::Func::readTopic( $subweb, $Foswiki::cfg{WebPrefsTopicName} ); 669 $topicObject->text(<<'THIS'); 675 670 * Set ALLOWWEBVIEW = MrOrange 676 671 THIS 677 672 $topicObject->save(); 678 $t his->{session}->finish();679 680 $this->{session} = Foswiki->new(); 673 $topicObject->finish(); 674 $this->createNewFoswikiSession(); 675 681 676 $this->DENIED( "VIEW", $MrOrange, $subweb ); 682 677 $this->PERMITTED( "VIEW", $MrGreen, $subweb ); … … 696 691 697 692 # Create a topic with an anchor, viewable only by MrYellow 698 my $topicObject = Foswiki::Meta->new(699 $this->{session}, $this->{test_web}, $test_topic,700 <<'THIS'693 my ($topicObject) = 694 Foswiki::Func::readTopic( $this->{test_web}, $test_topic ); 695 $topicObject->text(<<'THIS'); 701 696 If there is an anchor, and some access restrictions, 702 697 anchor is preserved after login. … … 704 699 * Set ALLOWTOPICVIEW = MrYellow 705 700 THIS 706 , undef 707 ); 708 $topicObject->save(); 701 $topicObject->save(); 702 $topicObject->finish(); 709 703 710 704 # Request the page with the full UI … … 720 714 my $viewUrl = 721 715 $this->{session} 722 ->getScriptUrl( '0', 'view', $this->{test_web}, $test_topic );716 ->getScriptUrl( 0, 'view', $this->{test_web}, $test_topic ); 723 717 $query->uri("$viewUrl"); 718 $this->finishFoswikiSession(); 724 719 my ($text) = $this->capture( 725 720 sub { 726 $Foswiki::Plugins::SESSION->{response} = 727 Foswiki::UI::handleRequest($query); 721 my $response = Foswiki::UI::handleRequest($query); 722 $this->createNewFoswikiSession( undef, $query ); 723 $this->{session}{response} = $response; 728 724 } 729 725 ); … … 732 728 my $loginUrl = 733 729 $this->{session} 734 ->getScriptUrl( '0', 'login', $this->{test_web}, $test_topic );730 ->getScriptUrl( 0, 'login', $this->{test_web}, $test_topic ); 735 731 736 732 # Item11121: the test doesn't tolerate ShortURLs, for example. … … 748 744 749 745 # Check the redirect contains the login url + view to this topic 750 $this->assert_matches( 751 qr#^$loginUrl.*/view/$this->{test_web}/$test_topic$#, 752 $redirect_to, 753 "Login did not redirect to a page with the proper anchor:\n" 746 my $regex = qr#^\Q$loginUrl\E.*/view/$this->{test_web}/$test_topic$#; 747 $this->assert_matches( $regex, $redirect_to, 748 "Login did not redirect to a page with the proper anchor:\n" 754 749 . "Location: $redirect_to\n" 755 . "Expected: ^$loginUrl.*\%23anchor\$" 756 ); 750 . "Expected: $regex" ); 757 751 758 752 # Get the redirected page after login
Note: See TracChangeset
for help on using the changeset viewer.
