@@ -112,6 +112,20 @@ def test_example_multi(self):
112
112
expect_references = 2 ,
113
113
)
114
114
115
+ def test_example_multi_unspecified_reference_count (self ):
116
+ cert , _ = self .load_example_keys ()
117
+ with open (os .path .join (os .path .dirname (__file__ ), "example.pem" )) as fh :
118
+ cert = fh .read ()
119
+ example_file = os .path .join (os .path .dirname (__file__ ), "example-125.xml" )
120
+ res = XMLVerifier ().verify (
121
+ data = etree .parse (example_file ),
122
+ x509_cert = cert ,
123
+ expect_references = True ,
124
+ )
125
+
126
+ self .assertIsInstance (res , list )
127
+ self .assertEqual (2 , len (res ))
128
+
115
129
116
130
class TestSignXML (unittest .TestCase , LoadExampleKeys ):
117
131
def setUp (self ):
@@ -490,6 +504,16 @@ def test_elementtree_compat(self):
490
504
</samlp:Response>""" ,
491
505
]
492
506
507
+ def test_verify_results_with_nonspecific_reference_count (self ):
508
+ crt , key = self .load_example_keys ()
509
+ data = etree .fromstring (self .saml_test_vectors [0 ])
510
+ reference_uri = "assertionId"
511
+ signed_root = XMLSigner ().sign (data , reference_uri = reference_uri , key = key , cert = crt )
512
+ res = XMLVerifier ().verify (etree .tostring (signed_root ), x509_cert = crt , expect_references = True )
513
+
514
+ self .assertIsInstance (res , list )
515
+ self .assertEqual (1 , len (res ))
516
+
493
517
def test_reference_uris_and_custom_key_info (self ):
494
518
crt , key = self .load_example_keys ()
495
519
@@ -499,7 +523,7 @@ def test_reference_uris_and_custom_key_info(self):
499
523
reference_uri = ["assertionId" , "assertion2" ] if "assertion2" in d else "assertionId"
500
524
signed_root = XMLSigner ().sign (data , reference_uri = reference_uri , key = key , cert = crt )
501
525
res = XMLVerifier ().verify (etree .tostring (signed_root ), x509_cert = crt , expect_references = True )
502
- signed_data_root = res .signed_xml
526
+ signed_data_root = res [ 0 ] .signed_xml
503
527
ref = signed_root .xpath (
504
528
"/samlp:Response/saml:Assertion/ds:Signature/ds:SignedInfo/ds:Reference" ,
505
529
namespaces = {
0 commit comments