Append ZimbraPreAuth handler test (#1954)
parent
892516d55e
commit
32a0d0944a
@ -0,0 +1,60 @@ |
||||
use Test::More; |
||||
|
||||
BEGIN { |
||||
require 't/test-psgi-lib.pm'; |
||||
} |
||||
|
||||
my $maintests = 4; |
||||
|
||||
SKIP: { |
||||
eval { require Digest::HMAC_SHA1; }; |
||||
if ($@) { |
||||
skip 'Digest::HMAC_SHA1 not found', $maintests; |
||||
} |
||||
init( |
||||
'Lemonldap::NG::Handler::Server', |
||||
{ |
||||
logLevel => 'error', |
||||
zimbraPreAuthKey => '1234567890', |
||||
vhostOptions => { |
||||
'test1.example.com' => { |
||||
vhostHttps => 0, |
||||
vhostPort => 80, |
||||
vhostMaintenance => 0, |
||||
vhostServiceTokenTTL => -1, |
||||
}, |
||||
}, |
||||
exportedHeaders => { |
||||
'test1.example.com' => { |
||||
'Auth-User' => '$uid', |
||||
}, |
||||
} |
||||
} |
||||
); |
||||
my $timestamp = time() * 1000; |
||||
my $value = |
||||
Digest::HMAC_SHA1::hmac_sha1_hex( "dwho|id|0|$timestamp", '1234567890' ); |
||||
ok( |
||||
$res = $client->_get( |
||||
'/zimbrasso', undef, |
||||
'test1.example.com', "lemonldap=$sessionId", |
||||
VHOSTTYPE => 'ZimbraPreAuth', |
||||
), |
||||
'Query' |
||||
); |
||||
ok( $res->[0] == 302, 'Code is 302' ) or explain( $res->[0], 302 ); |
||||
|
||||
# Check headers |
||||
%h = @{ $res->[1] }; |
||||
ok( |
||||
$h{'Location'} =~ |
||||
m%^/service/preauth\?account=dwho&by=id×tamp=$timestamp&expires=0&preauth=$value$%, |
||||
'Header Location is set to Zimbra URL' |
||||
) or explain( \%h, 'Location => "Zimbra URL' ); |
||||
ok( $h{'Auth-User'} eq 'dwho', 'Header Auth-User is set to "dwho"' ) |
||||
or explain( \%h, 'Auth-User => "dwho"' ); |
||||
count(4); |
||||
} |
||||
|
||||
done_testing( count() ); |
||||
clean(); |
Loading…
Reference in new issue