Unit test for samlBuildAuthnResponse

This commit is contained in:
Maxime Besson 2022-09-02 15:51:27 +02:00
parent 6f4ae3552c
commit dfcb11f203
2 changed files with 17 additions and 1 deletions

View File

@ -11,7 +11,7 @@ BEGIN {
require 't/saml-lib.pm';
}
my $maintests = 25;
my $maintests = 27;
my $debug = 'error';
my ( $issuer, $sp, $res );
@ -144,6 +144,13 @@ SKIP: {
expectAutoPost( $res, 'auth.sp.com', '/saml/proxySingleSignOnPost',
'SAMLResponse' );
my $resp = expectSamlResponse($s);
like(
$resp,
qr/AuthnInstant="2000-01-01T00:00:01Z"/,
"Found AuthnInstant modified by hook"
);
$pdata_hash = expectPdata($res);
is( $pdata_hash->{gotRequestHookCalled},
1, 'samlGotRequestHookCalled called' );

View File

@ -7,8 +7,17 @@ use constant hook => {
samlGotAuthnRequest => 'gotRequest',
samlGenerateAuthnRequest => 'genRequest',
samlGotAuthnResponse => 'gotResponse',
samlBuildAuthnResponse => 'genResponse',
};
sub genResponse {
my ( $self, $req, $login ) = @_;
use Test::More;
$login->response->Assertion->AuthnStatement->AuthnInstant(
"2000-01-01T00:00:01Z");
return 0;
}
sub gotRequest {
my ( $self, $req, $login ) = @_;