-#!/usr/bin/perl
use strict;
use warnings;
-use RT::Test tests => 120;
+use RT::Test tests => 122;
my ($baseurl, $agent) = RT::Test->started_ok;
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
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'));
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
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");
}
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);
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");
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;