ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilSamlIdpXmlMetadataParserTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use PHPUnit\Framework\TestCase;
22
23class ilSamlIdpXmlMetadataParserTest extends TestCase
24{
26
27 protected function setUp(): void
28 {
29 parent::setUp();
30 $this->parser = new ilSamlIdpXmlMetadataParser(
31 new ILIAS\Data\Factory(),
33 );
34 }
35
37 {
38 $result = $this->parser->parse('phpunit');
39
40 $this->assertTrue($result->isError());
41 $this->assertFalse($result->isOK());
42
43 $this->assertNotEmpty($result->error());
44 }
45
51 {
52 $xml = <<<EOT
53<md:EntityDescriptor entityID="https://sso.example.org/idp" validUntil="2017-08-30T19:10:29Z"
54 xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata"
55 xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"
56 xmlns:mdrpi="urn:oasis:names:tc:SAML:metadata:rpi"
57 xmlns:mdattr="urn:oasis:names:tc:SAML:metadata:attribute"
58 xmlns:mdui="urn:oasis:names:tc:SAML:metadata:ui"
59 xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
60 <md:Extensions>
61 <mdrpi:RegistrationInfo registrationAuthority="https://registrar.example.net"/>
62 <mdrpi:PublicationInfo creationInstant="2017-08-16T19:10:29Z" publisher="https://registrar.example.net"/>
63 <mdattr:EntityAttributes>
64 <saml:Attribute Name="http://registrar.example.net/entity-category"
65 NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">
66 <saml:AttributeValue>https://registrar.example.net/category/self-certified</saml:AttributeValue>
67 </saml:Attribute>
68 </mdattr:EntityAttributes>
69 </md:Extensions>
70 <md:IDPSSODescriptor protocolSupportEnumeration="urn:oasis:names:tc:SAML:2.0:protocol">
71 <md:Extensions>
72 <mdui:UIInfo>
73 <mdui:DisplayName xml:lang="en">Example.org</mdui:DisplayName>
74 <mdui:Description xml:lang="en">The identity provider at Example.org</mdui:Description>
75 <mdui:Logo height="32" width="32" xml:lang="en">https://idp.example.org/myicon.png</mdui:Logo>
76 </mdui:UIInfo>
77 </md:Extensions>
78 <md:KeyDescriptor use="signing">
79 <ds:KeyInfo>...</ds:KeyInfo>
80 </md:KeyDescriptor>
81 <md:SingleSignOnService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect"
82 Location="https://idp.example.org/SAML2/SSO/Redirect"/>
83 <md:SingleSignOnService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"
84 Location="https://idp.example.org/SAML2/SSO/POST"/>
85 </md:IDPSSODescriptor>
86 <md:Organization>
87 <md:OrganizationName xml:lang="en">Example.org Non-Profit Org</md:OrganizationName>
88 <md:OrganizationDisplayName xml:lang="en">Example.org</md:OrganizationDisplayName>
89 <md:OrganizationURL xml:lang="en">https://www.example.org/</md:OrganizationURL>
90 </md:Organization>
91 <md:ContactPerson contactType="technical">
92 <md:SurName>SAML Technical Support</md:SurName>
93 <md:EmailAddress>mailto:technical-support@example.org</md:EmailAddress>
94 </md:ContactPerson>
95</md:EntityDescriptor>
96EOT;
97
98 $result = $this->parser->parse($xml);
99
100 $this->assertTrue($result->isOK());
101
102 $this->assertSame('https://sso.example.org/idp', $result->value());
103 }
104
110 {
111 $xml = <<<EOT
112<md:EntityDescriptor xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata"
113 xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"
114 xmlns:mdrpi="urn:oasis:names:tc:SAML:metadata:rpi"
115 xmlns:mdattr="urn:oasis:names:tc:SAML:metadata:attribute"
116 xmlns:mdui="urn:oasis:names:tc:SAML:metadata:ui"
117 xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
118 <md:Extensions>
119 <mdrpi:RegistrationInfo registrationAuthority="https://registrar.example.net"/>
120 <mdrpi:PublicationInfo creationInstant="2017-08-16T19:10:29Z" publisher="https://registrar.example.net"/>
121 <mdattr:EntityAttributes>
122 <saml:Attribute Name="http://registrar.example.net/entity-category"
123 NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">
124 <saml:AttributeValue>https://registrar.example.net/category/self-certified</saml:AttributeValue>
125 </saml:Attribute>
126 </mdattr:EntityAttributes>
127 </md:Extensions>
128 <md:IDPSSODescriptor protocolSupportEnumeration="urn:oasis:names:tc:SAML:2.0:protocol">
129 <md:Extensions>
130 <mdui:UIInfo>
131 <mdui:DisplayName xml:lang="en">Example.org</mdui:DisplayName>
132 <mdui:Description xml:lang="en">The identity provider at Example.org</mdui:Description>
133 <mdui:Logo height="32" width="32" xml:lang="en">https://idp.example.org/myicon.png</mdui:Logo>
134 </mdui:UIInfo>
135 </md:Extensions>
136 <md:KeyDescriptor use="signing">
137 <ds:KeyInfo>...</ds:KeyInfo>
138 </md:KeyDescriptor>
139 <md:SingleSignOnService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect"
140 Location="https://idp.example.org/SAML2/SSO/Redirect"/>
141 <md:SingleSignOnService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"
142 Location="https://idp.example.org/SAML2/SSO/POST"/>
143 </md:IDPSSODescriptor>
144 <md:Organization>
145 <md:OrganizationName xml:lang="en">Example.org Non-Profit Org</md:OrganizationName>
146 <md:OrganizationDisplayName xml:lang="en">Example.org</md:OrganizationDisplayName>
147 <md:OrganizationURL xml:lang="en">https://www.example.org/</md:OrganizationURL>
148 </md:Organization>
149 <md:ContactPerson contactType="technical">
150 <md:SurName>SAML Technical Support</md:SurName>
151 <md:EmailAddress>mailto:technical-support@example.org</md:EmailAddress>
152 </md:ContactPerson>
153</md:EntityDescriptor>
154EOT;
155
156 $result = $this->parser->parse($xml);
157
158 $this->assertTrue($result->isError());
159 $this->assertFalse($result->isOK());
160
161 $this->assertNotEmpty($result->error());
162 }
163}
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.