ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilSamlIdpXmlMetadataParserTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
23 class 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  $this->parser->parse('phpunit');
39 
40  $this->assertTrue($this->parser->result()->isError());
41  $this->assertFalse($this->parser->result()->isOK());
42 
43  $this->assertNotEmpty($this->parser->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>
96 EOT;
97 
98  $this->parser->parse($xml);
99 
100  $this->assertFalse($this->parser->result()->isError(), $this->parser->result()->isError() ? $this->parser->result()->error() : '');
101  $this->assertTrue($this->parser->result()->isOK());
102 
103  $this->assertSame('https://sso.example.org/idp', $this->parser->result()->value());
104  }
105 
111  {
112  $xml = <<<EOT
113 <md:EntityDescriptor xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata"
114  xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"
115  xmlns:mdrpi="urn:oasis:names:tc:SAML:metadata:rpi"
116  xmlns:mdattr="urn:oasis:names:tc:SAML:metadata:attribute"
117  xmlns:mdui="urn:oasis:names:tc:SAML:metadata:ui"
118  xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
119  <md:Extensions>
120  <mdrpi:RegistrationInfo registrationAuthority="https://registrar.example.net"/>
121  <mdrpi:PublicationInfo creationInstant="2017-08-16T19:10:29Z" publisher="https://registrar.example.net"/>
122  <mdattr:EntityAttributes>
123  <saml:Attribute Name="http://registrar.example.net/entity-category"
124  NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">
125  <saml:AttributeValue>https://registrar.example.net/category/self-certified</saml:AttributeValue>
126  </saml:Attribute>
127  </mdattr:EntityAttributes>
128  </md:Extensions>
129  <md:IDPSSODescriptor protocolSupportEnumeration="urn:oasis:names:tc:SAML:2.0:protocol">
130  <md:Extensions>
131  <mdui:UIInfo>
132  <mdui:DisplayName xml:lang="en">Example.org</mdui:DisplayName>
133  <mdui:Description xml:lang="en">The identity provider at Example.org</mdui:Description>
134  <mdui:Logo height="32" width="32" xml:lang="en">https://idp.example.org/myicon.png</mdui:Logo>
135  </mdui:UIInfo>
136  </md:Extensions>
137  <md:KeyDescriptor use="signing">
138  <ds:KeyInfo>...</ds:KeyInfo>
139  </md:KeyDescriptor>
140  <md:SingleSignOnService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect"
141  Location="https://idp.example.org/SAML2/SSO/Redirect"/>
142  <md:SingleSignOnService Binding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"
143  Location="https://idp.example.org/SAML2/SSO/POST"/>
144  </md:IDPSSODescriptor>
145  <md:Organization>
146  <md:OrganizationName xml:lang="en">Example.org Non-Profit Org</md:OrganizationName>
147  <md:OrganizationDisplayName xml:lang="en">Example.org</md:OrganizationDisplayName>
148  <md:OrganizationURL xml:lang="en">https://www.example.org/</md:OrganizationURL>
149  </md:Organization>
150  <md:ContactPerson contactType="technical">
151  <md:SurName>SAML Technical Support</md:SurName>
152  <md:EmailAddress>mailto:technical-support@example.org</md:EmailAddress>
153  </md:ContactPerson>
154 </md:EntityDescriptor>
155 EOT;
156 
157  $this->parser->parse($xml);
158 
159  $this->assertTrue($this->parser->result()->isError());
160  $this->assertFalse($this->parser->result()->isOK());
161 
162  $this->assertNotEmpty($this->parser->result()->error());
163  }
164 }
Class ChatMainBarProvider .
$xml
Definition: metadata.php:351