+
+local $ENV{'PATH_INFO'} = '';
+local $ENV{'SCRIPT_NAME'} = '';
+
+Foo->new({
+ form => {},
+ require_auth => 1,
+})->navigate;
+ok($Foo::test_stdout eq "Login Form", "Got the right output");
+
+###----------------------------------------------------------------###
+
+Foo->new({
+ form => {},
+})->navigate_authenticated;
+ok($Foo::test_stdout eq "Login Form", "Got the right output");
+
+###----------------------------------------------------------------###
+
+{
+ package Bar;
+ @Bar::ISA = qw(Foo);
+ sub require_auth { 1 }
+}
+
+Bar->new({
+ form => {},
+})->navigate;
+ok($Foo::test_stdout eq "Login Form", "Got the right output for Bar");
+
+###----------------------------------------------------------------###
+
+{
+ package Bar1;
+ @Bar1::ISA = qw(Foo);
+ sub require_auth { 1 }
+}
+
+my $ok = eval { Bar1->new({
+ form => {},
+})->navigate_authenticated; 1 }; # can't call navigate_authenticated with overwritten require_auth
+ok(! $ok, "Got the right output for Bar1");
+
+###----------------------------------------------------------------###
+
+{
+ package Bar2;
+ @Bar2::ISA = qw(Foo);
+ sub main_require_auth { 1 }
+}
+
+Bar2->new({
+ form => {},
+})->navigate;
+ok($Foo::test_stdout eq "Login Form", "Got the right output for Bar2");
+
+###----------------------------------------------------------------###
+
+{
+ package Bar3;
+ @Bar3::ISA = qw(Foo);
+ sub require_auth { 1 }
+ sub main_require_auth { 0 }
+}
+
+Bar3->new({
+ form => {},
+})->navigate;
+ok($Foo::test_stdout eq "Main Content", "Got the right output for Bar3");
+
+###----------------------------------------------------------------###
+
+Foo->new({
+ form => {},
+ require_auth => {main => 0},
+})->navigate;
+ok($Foo::test_stdout eq "Main Content", "Got the right output");
+
+###----------------------------------------------------------------###
+
+Foo->new({
+ form => {},
+ require_auth => {main => 1},
+})->navigate;
+ok($Foo::test_stdout eq "Login Form", "Got the right output");
+
+###----------------------------------------------------------------###
+
+{
+ package Bar4;
+ @Bar4::ISA = qw(Foo);
+ sub pre_navigate { shift->require_auth(0); 0 }
+}
+
+Bar4->new({
+ form => {},
+})->navigate_authenticated;
+ok($Foo::test_stdout eq "Main Content", "Got the right output for Bar4");
+
+###----------------------------------------------------------------###
+
+{
+ package Bar5;
+ @Bar5::ISA = qw(Foo);
+ sub pre_navigate { shift->require_auth(1); 0 }
+}
+
+Bar5->new({
+ form => {},
+})->navigate;
+ok($Foo::test_stdout eq "Login Form", "Got the right output for Bar5 ($@)");
+
+###----------------------------------------------------------------###
+
+{
+ package Bar6;
+ @Bar6::ISA = qw(Foo);
+ sub pre_navigate { shift->require_auth({main => 1}); 0 }
+}
+
+Bar6->new({
+ form => {},
+})->navigate;
+ok($Foo::test_stdout eq "Login Form", "Got the right output for Bar6 ($@)");