File: basic_auth.t

package info (click to toggle)
request-tracker4 4.4.7%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 62,888 kB
  • sloc: javascript: 130,444; perl: 65,442; sh: 1,350; makefile: 480; python: 37; php: 30
file content (34 lines) | stat: -rw-r--r-- 1,004 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
use strict;
use warnings;
use RT;
use RT::Test tests => 9;

RT->Config->Set( DevelMode => 0 );
RT->Config->Set( WebRemoteUserAuth => 1 );

my ( $url, $m ) = RT::Test->started_ok( basic_auth => 1 );

# This tests the plack middleware, not RT
$m->get($url);
is($m->status, 401, "Initial request with no creds gets 401");

# This tests the plack middleware, not RT
$m->get($url, $m->auth_header( root => "wrong" ));
is($m->status, 401, "Request with wrong creds gets 401");

$m->get($url, $m->auth_header( root => "password" ));
is($m->status, 200, "Request with right creds gets 200");

$m->content_like(
    qr{<span class="current-user">\Qroot\E</span>}i,
    "Has user on the page"
);
$m->content_unlike(qr/Logout/i, "Has no logout button, no WebFallbackToRTLogin");

# Again, testing the plack middleware
$m->get($url);
is($m->status, 401, "Subsequent requests without credentials aren't still logged in");


# Put the credentials back for the warnings check at the end
$m->auth( root => "password" );