@@ -1011,6 +1011,10 @@ public function testIsInValidWrongXML()
10111011 */
10121012 public function testIsInValidDestination ()
10131013 {
1014+ $ _SERVER ['HTTP_HOST ' ] = 'stuff.com ' ;
1015+ $ _SERVER ['HTTPS ' ] = 'https ' ;
1016+ $ _SERVER ['REQUEST_URI ' ] = '/endpoints/endpoints/acs.php ' ;
1017+
10141018 $ xml = file_get_contents (TEST_ROOT . '/data/responses/unsigned_response.xml.base64 ' );
10151019
10161020 $ response = new OneLogin_Saml2_Response ($ this ->_settings , $ xml );
@@ -1031,10 +1035,28 @@ public function testIsInValidDestination()
10311035 $ this ->assertEquals ('The response has an empty Destination value ' , $ response3 ->getError ());
10321036
10331037 include TEST_ROOT .'/settings/settings1.php ' ;
1038+ $ settingsInfo ['strict ' ] = true ;
10341039 $ settingsInfo ['security ' ]['relaxDestinationValidation ' ] = true ;
10351040 $ settings = new OneLogin_Saml2_Settings ($ settingsInfo );
10361041 $ response4 = new OneLogin_Saml2_Response ($ settings , $ xml2 );
10371042 $ this ->assertTrue ($ response4 ->isValid ());
1043+
1044+ // Destination strict match
1045+ $ xml3 = file_get_contents (TEST_ROOT . '/data/responses/invalids/invalid_strict_destination.xml.base64 ' );
1046+ $ response5 = new OneLogin_Saml2_Response ($ settings , $ xml3 );
1047+ $ this ->assertTrue ($ response5 ->isValid ());
1048+
1049+ $ settingsInfo ['security ' ]['destinationStrictlyMatches ' ] = true ;
1050+ $ settings2 = new OneLogin_Saml2_Settings ($ settingsInfo );
1051+ $ response6 = new OneLogin_Saml2_Response ($ settings2 , $ xml3 );
1052+ $ this ->assertFalse ($ response6 ->isValid ());
1053+ $ this ->assertContains ('The response was received at ' , $ response6 ->getError ());
1054+
1055+ unset($ settingsInfo ['strict ' ]);
1056+ unset($ settingsInfo ['security ' ]['destinationStrictlyMatches ' ]);
1057+ unset($ _SERVER ['HTTP_HOST ' ]);
1058+ unset($ _SERVER ['HTTPS ' ]);
1059+ unset($ _SERVER ['REQUEST_URI ' ]);
10381060 }
10391061
10401062 /**
0 commit comments