fix ticketing system error on bootstrap of new install
[freeside.git] / rt / t / web / basic_auth.t
1 use strict;
2 use warnings;
3 use RT;
4 use RT::Test tests => 9;
5
6 RT->Config->Set( DevelMode => 0 );
7 RT->Config->Set( WebRemoteUserAuth => 1 );
8
9 my ( $url, $m ) = RT::Test->started_ok( basic_auth => 1 );
10
11 # This tests the plack middleware, not RT
12 $m->get($url);
13 is($m->status, 401, "Initial request with no creds gets 401");
14
15 # This tests the plack middleware, not RT
16 $m->get($url, $m->auth_header( root => "wrong" ));
17 is($m->status, 401, "Request with wrong creds gets 401");
18
19 $m->get($url, $m->auth_header( root => "password" ));
20 is($m->status, 200, "Request with right creds gets 200");
21
22 $m->content_like(
23     qr{<span class="current-user">\Qroot\E</span>}i,
24     "Has user on the page"
25 );
26 $m->content_unlike(qr/Logout/i, "Has no logout button, no WebFallbackToRTLogin");
27
28 # Again, testing the plack middleware
29 $m->get($url);
30 is($m->status, 401, "Subsequent requests without credentials aren't still logged in");
31
32
33 # Put the credentials back for the warnings check at the end
34 $m->auth( root => "password" );