@@ -177,6 +177,44 @@ void nonDefaultZoneSamlMetadataXMLValidationZoneSamlEntityIDNotSet() throws Exce
177177 }
178178 }
179179
180+ @ Nested
181+ @ DefaultTestContext
182+ @ TestPropertySource (properties = {
183+ "login.entityID = http://some.saml.provider/url/entityId"
184+ })
185+ class SamlMetadataWhenEntityIDIsAUrlMockMvcTests {
186+ @ Autowired
187+ private MockMvc mockMvc ;
188+
189+ @ Test
190+ void samlMetadataXMLValidation () throws Exception {
191+
192+ mockMvc .perform (get (new URI ("/saml/metadata" )))
193+ .andDo (print ())
194+ .andExpectAll (
195+ status ().isOk (),
196+ header ().string (HttpHeaders .CONTENT_DISPOSITION , containsString ("filename=\" saml-sp.xml\" ;" )),
197+ xpath ("/EntityDescriptor/SPSSODescriptor/AssertionConsumerService/@Location" ).string (containsString ("/saml/SSO/alias/some.saml.provider" )),
198+ xpath ("/EntityDescriptor/@entityID" ).string ("http://some.saml.provider/url/entityId" )
199+ );
200+ }
201+
202+ @ Test
203+ void samlMetadataXMLValidationInZone () throws Exception {
204+ IdentityZone alternativeSpZone = setupIdentityZone (false );
205+ String zoneSubdomain = alternativeSpZone .getSubdomain ();
206+ mockMvc .perform (get (new URI ("/saml/metadata" ))
207+ .header (HOST , zoneSubdomain + ".localhost:8080" ))
208+ .andDo (print ())
209+ .andExpectAll (
210+ status ().isOk (),
211+ header ().string (HttpHeaders .CONTENT_DISPOSITION , containsString ("filename=\" saml-%s-sp.xml\" ;" .formatted (zoneSubdomain ))),
212+ xpath ("/EntityDescriptor/SPSSODescriptor/AssertionConsumerService/@Location" ).string (containsString ("/saml/SSO/alias/%s.some.saml.provider" .formatted (zoneSubdomain ))),
213+ xpath ("/EntityDescriptor/@entityID" ).string ("http://%s.some.saml.provider/url/entityId" .formatted (zoneSubdomain ))
214+ );
215+ }
216+ }
217+
180218 private IdentityZone setupIdentityZone (boolean hasEntityId ) throws Exception {
181219 UaaClientDetails adminClient = new UaaClientDetails ("admin" , "" , "" , "client_credentials" , "uaa.admin" );
182220 adminClient .setClientSecret ("adminsecret" );
0 commit comments