Add URI escaping in Handler unit tests (#2217)

Moo
Clément OUDOT 5 years ago
parent 1d36f703f7
commit 27ca06136b
  1. 19
      lemonldap-ng-handler/t/60-Lemonldap-NG-Handler-PSGI.t
  2. 14
      lemonldap-ng-handler/t/61-Lemonldap-NG-Handler-PSGI-Server.t
  3. 14
      lemonldap-ng-handler/t/62-Lemonldap-NG-Handler-Nginx.t
  4. 5
      lemonldap-ng-handler/t/67-Lemonldap-NG-Handler-PSGI-vhostoptions.t

@ -2,6 +2,7 @@ use Test::More;
use JSON;
use MIME::Base64;
use Data::Dumper;
use URI::Escape;
require 't/test-psgi-lib.pm';
@ -18,13 +19,13 @@ ok( $res->[0] == 302, ' Code is 302' ) or explain( $res->[0], 302 );
my %h = @{ $res->[1] };
ok(
$h{Location} eq 'http://auth.example.com/?url='
. encode_base64( 'http://test1.example.com/', '' ),
. uri_escape( encode_base64( 'http://test1.example.com/', '' ) ),
'Redirection points to portal'
)
or explain(
\%h,
'Location => http://auth.example.com/?url='
. encode_base64( 'http://test1.example.com/', '' )
. uri_escape( encode_base64( 'http://test1.example.com/', '' ) )
);
count(4);
@ -113,13 +114,14 @@ ok( $res->[0] == 302, ' Code is 302' ) or explain( $res, 302 );
%h = @{ $res->[1] };
ok(
$h{Location} eq 'http://auth.example.com//upgradesession?url='
. encode_base64( 'http://test1.example.com/AuthStrong', '' ),
. uri_escape(
encode_base64( 'http://test1.example.com/AuthStrong', '' ) ),
'Redirection points to http://test1.example.com/AuthStrong'
)
or explain(
\%h,
'http://auth.example.com//upgradesession?url='
. encode_base64( 'http://test1.example.com/AuthStrong', '' )
. uri_escape( encode_base64( 'http://test1.example.com/AuthStrong', '' ) )
);
count(3);
@ -159,13 +161,13 @@ ok( $res->[0] == 302, ' Code is 302' ) or explain( $res, 302 );
%h = @{ $res->[1] };
ok(
$h{Location} eq 'http://auth.example.com//upgradesession?url='
. encode_base64( 'http://test2.example.com/', '' ),
. uri_escape( encode_base64( 'http://test2.example.com/', '' ) ),
'Redirection points to http://test2.example.com/'
)
or explain(
\%h,
'http://auth.example.com//upgradesession?url='
. encode_base64( 'http://test2.example.com/', '' )
. uri_escape( encode_base64( 'http://test2.example.com/', '' ) )
);
count(3);
@ -223,8 +225,9 @@ ok( $res->[0] == 302, ' Code is 302' ) or explain( $res, 302 );
count(2);
ok(
$res =
$client->_get( '/', undef, 'abfoo.a.example.org', "lemonldap=$sessionId" ),
$res = $client->_get(
'/', undef, 'abfoo.a.example.org', "lemonldap=$sessionId"
),
'Accept "abfoo.a.example.org/"'
);
ok( $res->[0] == 200, ' Code is 200' ) or explain( $res, 200 );

@ -1,6 +1,7 @@
use Test::More;
use JSON;
use MIME::Base64;
use URI::Escape;
require 't/test-psgi-lib.pm';
@ -16,13 +17,13 @@ ok( $res->[0] == 302, 'Code is 302' ) or explain( $res->[0], 302 );
my %h = @{ $res->[1] };
ok(
$h{Location} eq 'http://auth.example.com/?url='
. encode_base64( 'http://test1.example.com/', '' ),
. uri_escape( encode_base64( 'http://test1.example.com/', '' ) ),
'Redirection points to portal'
)
or explain(
\%h,
'Location => http://auth.example.com/?url='
. encode_base64( 'http://test1.example.com/', '' )
. uri_escape( encode_base64( 'http://test1.example.com/', '' ) )
);
count(4);
@ -113,13 +114,14 @@ ok( $res->[0] == 302, 'Code is 302' ) or explain( $res, 302 );
%h = @{ $res->[1] };
ok(
$h{Location} eq 'http://auth.example.com//upgradesession?url='
. encode_base64( 'http://test1.example.com/AuthStrong', '' ),
. uri_escape(
encode_base64( 'http://test1.example.com/AuthStrong', '' ) ),
'Redirection points to http://test1.example.com/AuthStrong'
)
or explain(
\%h,
'http://auth.example.com//upgradesession?url='
. encode_base64( 'http://test1.example.com/AuthStrong', '' )
. uri_escape( encode_base64( 'http://test1.example.com/AuthStrong', '' ) )
);
count(3);
@ -159,13 +161,13 @@ ok( $res->[0] == 302, 'Code is 302' ) or explain( $res, 302 );
%h = @{ $res->[1] };
ok(
$h{Location} eq 'http://auth.example.com//upgradesession?url='
. encode_base64( 'http://test2.example.com/', '' ),
. uri_escape( encode_base64( 'http://test2.example.com/', '' ) ),
'Redirection points to http://test2.example.com/'
)
or explain(
\%h,
'http://auth.example.com//upgradesession?url='
. encode_base64( 'http://test2.example.com/', '' )
. uri_escape( encode_base64( 'http://test2.example.com/', '' ) )
);
count(3);

@ -2,6 +2,7 @@ use Test::More;
use JSON;
use MIME::Base64;
use Data::Dumper;
use URI::Escape;
require 't/test-psgi-lib.pm';
@ -16,13 +17,13 @@ ok( $res->[0] == 401, 'Code is 401' ) or explain( $res->[0], 401 );
my %h = @{ $res->[1] };
ok(
$h{Location} eq 'http://auth.example.com/?url='
. encode_base64( 'http://test1.example.com/', '' ),
. uri_escape( encode_base64( 'http://test1.example.com/', '' ) ),
'Redirection points to portal'
)
or explain(
\%h,
'Location => http://auth.example.com/?url='
. encode_base64( 'http://test1.example.com/', '' )
. uri_escape( encode_base64( 'http://test1.example.com/', '' ) )
);
count(4);
@ -104,13 +105,14 @@ ok( $res->[0] == 401, 'Code is 401' ) or explain( $res, 401 );
%h = @{ $res->[1] };
ok(
$h{Location} eq 'http://auth.example.com//upgradesession?url='
. encode_base64( 'http://test1.example.com/AuthStrong', '' ),
. uri_escape(
encode_base64( 'http://test1.example.com/AuthStrong', '' ) ),
'Redirection points to http://test1.example.com/AuthStrong'
)
or explain(
\%h,
'http://auth.example.com//upgradesession?url='
. encode_base64( 'http://test1.example.com/AuthStrong', '' )
. uri_escape( encode_base64( 'http://test1.example.com/AuthStrong', '' ) )
);
count(3);
@ -150,13 +152,13 @@ ok( $res->[0] == 401, 'Code is 401' ) or explain( $res, 401 );
%h = @{ $res->[1] };
ok(
$h{Location} eq 'http://auth.example.com//upgradesession?url='
. encode_base64( 'http://test2.example.com/', '' ),
. uri_escape( encode_base64( 'http://test2.example.com/', '' ) ),
'Redirection points to http://test2.example.com/'
)
or explain(
\%h,
'http://auth.example.com//upgradesession?url='
. encode_base64( 'http://test2.example.com/', '' )
. uri_escape( encode_base64( 'http://test2.example.com/', '' ) )
);
count(3);

@ -2,6 +2,7 @@ use Test::More;
use JSON;
use MIME::Base64;
use Data::Dumper;
use URI::Escape;
require 't/test-psgi-lib.pm';
@ -30,13 +31,13 @@ ok( $res->[0] == 302, 'Code is 302' ) or explain( $res->[0], 302 );
my %h = @{ $res->[1] };
ok(
$h{Location} eq 'http://auth.example.com/?url='
. encode_base64( 'https://test1.example.com/', '' ),
. uri_escape( encode_base64( 'https://test1.example.com/', '' ) ),
'Redirection points to portal and site is https'
)
or explain(
\%h,
'Location => http://auth.example.com/?url='
. encode_base64( 'https://test1.example.com/', '' )
. uri_escape( encode_base64( 'https://test1.example.com/', '' ) )
);
count(4);

Loading…
Cancel
Save