1818from saml2 .samlp import response_from_string
1919from saml2 .s_utils import factory , do_attribute_statement
2020
21- #from pyasn1.codec.der import decoder
22-
21+ import pytest
2322from py .test import raises
2423
2524from pathutils import full_path
@@ -69,6 +68,10 @@ def _eq(l1, l2):
6968wKe3ACFXBvqGQN0IbcH49hu0FKhYFM/GPDJcIHFBsiyMBXChpye9vBaTNEBCtU3K
7069jjyG0hRT2mAQ9h+bkPmOvlEo/aH0xR68Z9hw4PF13w=="""
7170
71+ try :
72+ from pyasn1 .codec .der import decoder
73+ except ImportError :
74+ decoder = None
7275
7376
7477def test_cert_from_instance_1 ():
@@ -81,16 +84,18 @@ def test_cert_from_instance_1():
8184 assert certs [0 ] == CERT1
8285
8386
84- # def test_cert_from_instance_ssp():
85- # xml_response = open(SIMPLE_SAML_PHP_RESPONSE).read()
86- # response = samlp.response_from_string(xml_response)
87- # assertion = response.assertion[0]
88- # certs = sigver.cert_from_instance(assertion)
89- # assert len(certs) == 1
90- # assert certs[0] == CERT_SSP
91- # der = base64.b64decode(certs[0])
92- # print(str(decoder.decode(der)).replace('.', "\n."))
93- # assert decoder.decode(der)
87+ @pytest .mark .skipif (not decoder ,
88+ reason = "pyasn1 is not installed" )
89+ def test_cert_from_instance_ssp ():
90+ xml_response = open (SIMPLE_SAML_PHP_RESPONSE ).read ()
91+ response = samlp .response_from_string (xml_response )
92+ assertion = response .assertion [0 ]
93+ certs = sigver .cert_from_instance (assertion )
94+ assert len (certs ) == 1
95+ assert certs [0 ] == CERT_SSP
96+ der = base64 .b64decode (certs [0 ])
97+ print (str (decoder .decode (der )).replace ('.' , "\n ." ))
98+ assert decoder .decode (der )
9499
95100
96101class FakeConfig ():
0 commit comments