File: 60-Lemonldap-NG-Handler-PSGI-unprotected.t

package info (click to toggle)
lemonldap-ng 2.21.2%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 28,024 kB
  • sloc: perl: 77,414; javascript: 25,284; xml: 6,473; makefile: 1,303; sh: 453; sql: 159; python: 53; php: 26
file content (30 lines) | stat: -rw-r--r-- 743 bytes parent folder | download | duplicates (2)
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
use Test::More;
use JSON;
use MIME::Base64;
use Data::Dumper;
use URI::Escape;

require 't/test-psgi-lib.pm';

init( 'Lemonldap::NG::Handler::PSGI', { protection => 'none' } );

my $res;
my $SKIPUSER = 0;

# Unauthentified query
# --------------------
ok( $res = $client->_get('/'), 'Unauthentified query' );
is( $res->[0],      200,     "Unprotected request succeeds" );
is( $res->[2]->[0], "Hello", "Expected content" );
count(3);
done_testing( count() );

clean();

sub Lemonldap::NG::Handler::PSGI::handler {
    my ( $self, $req ) = @_;
    ok( !$req->env->{HTTP_AUTH_USER}, 'No HTTP_AUTH_USER' )
      or explain( $req->env->{HTTP_AUTH_USER}, '<empty>' );
    count(1);
    return [ 200, [ 'Content-Type', 'text/plain' ], ['Hello'] ];
}