X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=rt%2Ft%2Fweb%2Fredirect-after-login.t;h=eb2718cf36b73fd4f11624e6762c11d396c14c8f;hb=05c0b947ddba67a8ac2537c010a583277623ff3e;hp=d39bb58c8fc2f4f20d2b9c5c8ac01a002eab463d;hpb=0fb307c305e4bc2c9c27dc25a3308beae3a4d33c;p=freeside.git diff --git a/rt/t/web/redirect-after-login.t b/rt/t/web/redirect-after-login.t index d39bb58c8..eb2718cf3 100644 --- a/rt/t/web/redirect-after-login.t +++ b/rt/t/web/redirect-after-login.t @@ -1,9 +1,8 @@ -#!/usr/bin/perl use strict; use warnings; -use RT::Test tests => 120; +use RT::Test tests => 122; my ($baseurl, $agent) = RT::Test->started_ok; @@ -51,11 +50,9 @@ diag $url if $ENV{TEST_VERBOSE}; ok( $agent->content =~ /Your username or password is incorrect/i, "Found the error message"); like( $agent->uri, qr{/NoAuth/Login\.html$}, "now on /NoAuth/Login.html" ); - $agent->logout(); - - # Handle the warning after we're done with the page, since this leaves us - # with a completely different $mech $agent->warning_like(qr/FAILED LOGIN for root/, "got failed login warning"); + + $agent->logout(); } # test a login from a non-front page, both with a double leading slash and without @@ -116,6 +113,7 @@ for my $path (qw(Prefs/Other.html /Prefs/Other.html)) { ok( $agent->content =~ /Your username or password is incorrect/i, "Found the error message"); like( $agent->uri, qr{/NoAuth/Login\.html$}, "still on /NoAuth/Login.html" ); + $agent->warning_like(qr/FAILED LOGIN for root/, "got failed login warning"); # try to login again ok($agent->current_form->find_input('user')); @@ -136,10 +134,6 @@ for my $path (qw(Prefs/Other.html /Prefs/Other.html)) { is( $agent->uri, $requested, "right URL" ); like( $agent->{redirected_uri}, qr{/NoAuth/Login\.html}, "We redirected from login"); $agent->logout(); - - # Handle the warning after we're done with the page, since this leaves us - # with a completely different $mech - $agent->warning_like(qr/FAILED LOGIN for root/, "got failed login warning"); } # test a login from the main page with query params @@ -163,9 +157,6 @@ for my $path (qw(Prefs/Other.html /Prefs/Other.html)) { ok($agent->current_form->find_input('user')); ok($agent->current_form->find_input('pass')); like($agent->current_form->action, qr{/NoAuth/Login\.html$}, "login form action is correct"); - - # Handle the warning after we're done with the page, since this leaves us - # with a completely different $mech $agent->warning_like(qr/FAILED LOGIN for root/, "got failed login warning"); } @@ -183,6 +174,7 @@ for my $path (qw(Prefs/Other.html /Prefs/Other.html)) { ok($agent->current_form->find_input('next')); like($agent->value('next'), qr/^[a-z0-9]{32}$/i, "next page argument is a hash"); like($agent->current_form->action, qr{/NoAuth/Login\.html$}, "login form action is correct"); + $agent->warning_like(qr/FAILED LOGIN for root/, "got failed login warning"); # Try to login again ok($agent->content =~ /username:/i); @@ -197,38 +189,33 @@ for my $path (qw(Prefs/Other.html /Prefs/Other.html)) { is( $agent->uri, $requested, "right URL" ); like( $agent->{redirected_uri}, qr{/NoAuth/Login\.html}, "We redirected from login"); $agent->logout(); - - # Handle the warning after we're done with the page, since this leaves us - # with a completely different $mech - $agent->warning_like(qr/FAILED LOGIN for root/, "got failed login warning"); } # test REST login response { + $agent = RT::Test::Web->new; my $requested = $url."REST/1.0/?user=root;pass=password"; $agent->get($requested); is($agent->status, 200, "Loaded a page"); is($agent->uri, $requested, "didn't redirect to /NoAuth/Login.html for REST"); - $agent->get_ok($url); - $agent->logout(); + $agent->get_ok($url."REST/1.0"); } # test REST login response for wrong pass { + $agent = RT::Test::Web->new; my $requested = $url."REST/1.0/?user=root;pass=passwrong"; $agent->get_ok($requested); is($agent->status, 200, "Loaded a page"); is($agent->uri, $requested, "didn't redirect to /NoAuth/Login.html for REST"); like($agent->content, qr/401 Credentials required/i, "got error status"); like($agent->content, qr/Your username or password is incorrect/, "got error message"); - - # Handle the warning after we're done with the page, since this leaves us - # with a completely different $mech $agent->warning_like(qr/FAILED LOGIN for root/, "got failed login warning"); } # test REST login response for no creds { + $agent = RT::Test::Web->new; my $requested = $url."REST/1.0/"; $agent->get_ok($requested); is($agent->status, 200, "Loaded a page"); @@ -237,7 +224,7 @@ for my $path (qw(Prefs/Other.html /Prefs/Other.html)) { unlike($agent->content, qr/Your username or password is incorrect/, "didn't get any error message"); } -# XXX TODO: we should also be testing WebExternalAuth here, but we don't have +# XXX TODO: we should also be testing WebRemoteUserAuth here, but we don't have # the framework for dealing with that 1;