@@ -207,6 +207,26 @@ def testQueryAssertions(self):
207207 response_7 = OneLogin_Saml2_Response (settings , xml_7 )
208208 self .assertEqual (['http://idp.example.com/' ], response_7 .get_issuers ())
209209
210+ def testQueryAssertionsWithEmptyRefenceURI (self ):
211+ """
212+ Tests the __query_assertion if //Signature/Reference/@URI is empty.
213+ """
214+ settings = OneLogin_Saml2_Settings (self .loadSettingsJSON ())
215+
216+ # test with signed assertion still work
217+ xml = self .file_contents (join (self .data_path , 'responses' , 'valid_response.xml.base64' ))
218+ response = OneLogin_Saml2_Response (settings , xml )
219+ self .assertEqual ('492882615acf31c8096b627245d76ae53036c090' , response .get_nameid ())
220+
221+ # test with unsigned assertion still work
222+ xml = self .file_contents (join (self .data_path , 'responses' , 'valid_response_with_unsigned_assertion.xml.base64' ))
223+ response = OneLogin_Saml2_Response (settings , xml )
224+ self .assertEqual ('492882615acf31c8096b627245d76ae53036c090' , response .get_nameid ())
225+
226+ xml = self .file_contents (join (self .data_path , 'responses' , 'response_without_reference_uri.xml.base64' ))
227+ response = OneLogin_Saml2_Response (settings , xml )
228+ self .assertEqual ('saml@user.com' , response .get_nameid ())
229+
210230 def testGetIssuers (self ):
211231 """
212232 Tests the get_issuers method of the OneLogin_Saml2_Response
@@ -1198,6 +1218,12 @@ def testIsValidSignWithEmptyReferenceURI(self):
11981218 response = OneLogin_Saml2_Response (settings , xml )
11991219 self .assertTrue (response .is_valid (self .get_request_data ()))
12001220
1221+ def testIsValidSignWithEmptyReferenceURIAndIdPCert (self ):
1222+ settings = OneLogin_Saml2_Settings (self .loadSettingsJSON ())
1223+ xml = self .file_contents (join (self .data_path , 'responses' , 'valid_response_with_unsigned_assertion.xml.base64' ))
1224+ response = OneLogin_Saml2_Response (settings , xml )
1225+ self .assertTrue (response .is_valid (self .get_request_data ()))
1226+
12011227 def testIsValidWithoutInResponseTo (self ):
12021228 """
12031229 If assertion contains InResponseTo but not the Response tag, we should
0 commit comments