SAML2/Protocol/LogoutRequest.pm

filter: Statementstmt 100% 54 / 54 Branchbran 75.0% 15 / 20 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 10 / 10 Podpod 100% 2 / 2 totaltotal 92.3% 84 / 91 CC 12 SCAR 14.7
CC
12
Cov
92%
as_xml
8.3
new_from_xml
3.0
__ANON__
3.0
CRAP 4.3
« SAML2/Protocol/AuthnRequest.pm ↑ Summary SAML2/Protocol/Artifact.pm »
1 package Net::SAML2::Protocol::LogoutRequest;
2 32 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 32 our $VERSION = '0.89'; # VERSION
5  
6 32 ▶use MooseX::Types::Common::String qw/ NonEmptySimpleStr /;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 32 ▶use MooseX::Types::URI qw/ Uri /;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 32 ▶use Net::SAML2::XML::Util qw/ no_comments /;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 32 ▶use XML::Generator;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 32 ▶use URN::OASIS::SAML2 qw(:urn NAMEID_PERSISTENT);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 32 ▶use XML::LibXML::XPathContext;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 32 with 'Net::SAML2::Role::ProtocolMessage';
14  
15 # ABSTRACT: SAML2 LogoutRequest Protocol object
16  
17  
18 32 has 'session' => (isa => NonEmptySimpleStr, is => 'ro', required => 1);
19 32 has 'nameid' => (isa => NonEmptySimpleStr, is => 'ro', required => 1);
20 32 has 'nameid_format' => (
21 isa => NonEmptySimpleStr,
22 is => 'ro',
23 required => 0,
24 predicate => 'has_nameid_format'
25 );
26 32 has 'destination' => (
27 isa => NonEmptySimpleStr,
28 is => 'ro',
29 required => 0,
30 predicate => 'has_destination'
31 );
32  
33 32 has sp_provided_id => (
34 isa => NonEmptySimpleStr,
35 is => 'ro',
36 required => 0,
37 predicate => 'has_sp_provided_id'
38 );
39  
40 32 has affiliation_group_id => (
41 isa => NonEmptySimpleStr,
42 is => 'ro',
43 required => 0,
44 predicate => 'has_affiliation_group_id'
45 );
46  
47 32 has name_qualifier => (
48 isa => NonEmptySimpleStr,
49 is => 'ro',
50 required => 0,
51 predicate => 'has_name_qualifier'
52 );
53 32 has include_name_qualifier =>
54 (isa => 'Bool', is => 'ro', required => 0, default => 0);
55  
56 8 ▶around BUILDARGS => sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
57 8 my $orig = shift;
58 8 my $self = shift;
59 8 my %args = @_;
60  
61 8 ▶ if ($args{nameid_format} && $args{nameid_format} eq NAMEID_PERSISTENT()) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"nameid_format"} and $args{"nameid_format"} eq "urn:oasis:names:tc:SAML:2.0:nameid-format:persistent") 7 1 8
Condition66%2/3
$args{"nameid_format"} and $args{"nameid_format"} eq "urn:oasis:names:tc:SAML:2.0:nameid-format:persistent"
!ll&&!rl&&r
017
MC/DC50%1/2
$args{"nameid_format"} and $args{"nameid_format"} eq "urn:oasis:names:tc:SAML:2.0:nameid-format:persistent"
$args{"nameid_format"} $args{"nameid_format"} eq "urn:oasis:names:tc:SAML:2.0:nameid-format:persistent"
Truth table66%2/3
A and B
A= $args{"nameid_format"}B= $args{"nameid_format"} eq "urn:oasis:names:tc:SAML:2.0:nameid-format:persistent"
ABresult
0X0
100
111
62 7 $args{include_name_qualifier} = 1;
63 }
64  
65 8 return $self->$orig(%args);
66 32 };
67  
68  
69  
70 1 ▶sub new_from_xml {
Subroutine new_from_xml: called CC=3 SCAR=11.1
Pod documented
71 1 my ($class, %args) = @_;
72  
73 1 my $dom = no_comments($args{xml});
74  
75 1 my $xpath = XML::LibXML::XPathContext->new($dom);
76 1 $xpath->registerNs('saml', URN_ASSERTION);
77 1 $xpath->registerNs('samlp', URN_PROTOCOL);
78  
79 1 my %params = (
80 id => $xpath->findvalue('/samlp:LogoutRequest/@ID'),
81 session => $xpath->findvalue('/samlp:LogoutRequest/samlp:SessionIndex'),
82 issuer => $xpath->findvalue('/samlp:LogoutRequest/saml:Issuer'),
83 nameid => $xpath->findvalue('/samlp:LogoutRequest/saml:NameID'),
84 destination => $xpath->findvalue('/samlp:LogoutRequest/@Destination'),
85 );
86  
87 1 my $nameid_format
88 = $xpath->findvalue('/samlp:LogoutRequest/saml:NameID/@Format');
89  
90 1 ▶ $params{nameid_format} = $nameid_format
Branch: 1 branch
BranchTrueFalseTotal
if NonEmptySimpleStr()->check($nameid_format) 1 0 1
91 if NonEmptySimpleStr->check($nameid_format);
92  
93 $params{include_name_qualifier} = $args{include_name_qualifier}
94 1 ▶ if $args{include_name_qualifier};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"include_name_qualifier"} 0 1 1
95  
96 1 return $class->new(%params);
97 }
98  
99  
100 7 ▶sub as_xml {
Subroutine as_xml: called CC=8 SCAR=21.1
Pod documented
101 7 my $self = shift;
102  
103 7 my $x = XML::Generator->new(':pretty=0');
104 7 my $saml = ['saml' => URN_ASSERTION];
105 7 my $samlp = ['samlp' => URN_PROTOCOL];
106  
107  
108 7 ▶ $x->xml(
Branch: 7 branches
BranchTrueFalseTotal
$self->has_destination ? : 7 0 7
$self->has_nameid_format ? : 7 0 7
$self->has_sp_provided_id ? : 1 6 7
$self->include_name_qualifier ? : 6 1 7
$self->has_name_qualifier ? : 1 5 6
$self->has_destination ? : 5 0 5
$self->has_affiliation_group_id ? : 1 5 6
109 $x->LogoutRequest(
110 $samlp,
111 {
112 ID => $self->id,
113 IssueInstant => $self->issue_instant,
114 $self->has_destination
115 ? (Destination => $self->destination)
116 : (),
117 Version => '2.0'
118 },
119 $x->Issuer($saml, $self->issuer),
120 $x->NameID(
121 $saml,
122 {
123 $self->has_nameid_format
124 ? (Format => $self->nameid_format)
125 : (),
126 $self->has_sp_provided_id ? (
127 SPProvidedID => $self->sp_provided_id
128 ) : (),
129 $self->include_name_qualifier
130 ? (
131 $self->has_name_qualifier
132 ? (NameQualifier => $self->name_qualifier)
133 : ($self->has_destination ? (NameQualifier => $self->destination) : ()),
134 SPNameQualifier =>
135 $self->has_affiliation_group_id ? $self->affiliation_group_id : $self->issuer
136 )
137 : (),
138 },
139 $self->nameid
140 ),
141 $x->SessionIndex($samlp, $self->session),
142 )
143 );
144 }
145  
146 32 __PACKAGE__->meta->make_immutable;
147  
148 __END__
« SAML2/Protocol/AuthnRequest.pm ↑ Summary SAML2/Protocol/Artifact.pm »