Mojo/SAML/Document/SPSSODescriptor.pm untested

filter: Statementstmt 0.0% 0 / 14 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 2 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 19 CC 2 SCAR 15.4
CC
2
Cov
0%
before_render
6.0
BEGIN
2.0
CRAP 4.7
1 package Mojo::SAML::Document::SPSSODescriptor;
2  
3 use Mojo::Base 'Mojo::SAML::Document';
4  
5 has template => sub { shift->build_template(<<'XML') };
6 <%
7 my @attrs = (
8 xmlns => 'urn:oasis:names:tc:SAML:2.0:metadata',
9 protocolSupportEnumeration => 'urn:oasis:names:tc:SAML:2.0:protocol',
10 AuthnRequestsSigned => $self->authn_requests_signed ? 'true' : 'false',
11 WantAssertionsSigned => $self->want_assertions_signed ? 'true' : 'false',
12 );
13 %>
14 %= tag SPSSODescriptor => @attrs => begin
15 % for my $desc (@{ $self->key_descriptors }) {
16 <%= $desc %>
17 % }
18 % for my $format (@{ $self->nameid_format }) {
19 <NameIDFormat><%= nameid_format($format) %></NameIDFormat>
20 % }
21 % for my $service (@{ $self->assertion_consumer_services }) {
22 <%= $service %>
23 % }
24 % for my $service (@{ $self->attribute_consuming_services }) {
25 <%= $service %>
26 % }
27 % end
28 XML
29  
30 has [qw/authn_requests_signed want_assertions_signed/] => 0;
31 has [qw/key_descriptors assertion_consumer_services attribute_consuming_services nameid_format/] => sub { [] };
32  
33 sub before_render {
34 my $self = shift;
35 for my $method (qw/assertion_consumer_services/) {
36 Carp::croak "$method cannot be empty" unless @{$self->$method};
37 }
38 }
39  
40 1;
41  
42 =head1 NAME
43  
44 Mojo::SAML::Document::SPSSODescriptor
45  
46 =head1 DESCRIPTION
47  
48 Represents an SPSSODescriptor SAML metadata tag
49  
50 =head1 ATTRIBUTES
51  
52 L<Mojo::SAML::Document::SPSSODescriptor> inherits all attributes from L<Mojo::SAML::Document> and implements the following new ones.
53  
54 =head2 authn_requests_signed
55  
56 Optional.
57 A boolean specifying whether this service signs authn requests.
58 Defaults to false.
59  
60 =head2 want_assertions_signed
61  
62 Optional.
63 A boolean specifying whether this service requires assertions to be signed.
64 Defaults to false.
65  
66 =head2 key_descriptors
67  
68 An array reference of L<Mojo::SAML::Document::KeyDescriptor> objects containing descriptors of keys used by this service.
69  
70 =head2 assertion_consumer_services
71  
72 An array reference of L<Mojo::SAML::Document::AssertionConsumerService> elements.
73 Must not be empty at render time.
74  
75 =head2 attribute_consuming_services
76  
77 An array reference of L<Mojo::SAML::Document::AttributeConsumingService> elements.
78  
79 =head2 nameid_format
80  
81 An array reference of nameid formats that this service understands.
82  
83 =head2 template
84  
85 A template specific to the document type.
86  
87 =head1 METHODS
88  
89 L<Mojo::SAML::Document::SPSSODescriptor> inherits all methods from L<Mojo::SAML::Document> and implements the following new ones.
90  
91 =head2 before_render
92  
93 Enforces that L</assertion_consumer_services> is not empty at render time.
94