@@ -42,17 +42,8 @@ def get_ava(assertion):
4242
4343
4444class TestSignedResponse ():
45-
4645 def setup_class (self ):
4746 self .server = Server ("idp_conf" )
48- sign_alg = Mock ()
49- sign_alg .return_value = ds .SIG_RSA_SHA512
50- digest_alg = Mock ()
51- digest_alg .return_value = ds .DIGEST_SHA512
52- self .restet_default = ds .DefaultSignature
53- ds .DefaultSignature = MagicMock ()
54- ds .DefaultSignature ().get_sign_alg = sign_alg
55- ds .DefaultSignature ().get_digest_alg = digest_alg
5647 conf = config .SPConfig ()
5748 conf .load_file ("server_conf" )
5849 self .client = client .Saml2Client (conf )
@@ -62,7 +53,6 @@ def setup_class(self):
6253 "mail" : ["derek@nyy.mlb.com" ], "title" : "The man" }
6354
6455 def teardown_class (self ):
65- ds .DefaultSignature = self .restet_default
6656 self .server .close ()
6757
6858 def verify_assertion (self , assertion ):
@@ -76,7 +66,6 @@ def verify_assertion(self, assertion):
7666 'surName' : ['Jeter' ], 'title' : ['The man' ]}
7767
7868 def test_signed_response (self ):
79-
8069 print (ds .DefaultSignature ().get_digest_alg ())
8170 name_id = self .server .ident .transient_nameid (
8271 "urn:mace:example.com:saml:roland:sp" , "id12" )
@@ -96,11 +85,10 @@ def test_signed_response(self):
9685 assert signed_resp
9786
9887 sresponse = response_from_string (signed_resp )
99- assert ds .SIG_RSA_SHA512 in str (sresponse ), "Not correctly signed!"
100- assert ds .DIGEST_SHA512 in str (sresponse ), "Not correctly signed!"
88+ assert ds .SIG_RSA_SHA1 in str (sresponse ), "Not correctly signed!"
89+ assert ds .DIGEST_SHA1 in str (sresponse ), "Not correctly signed!"
10190
10291 def test_signed_response_1 (self ):
103-
10492 signed_resp = self .server .create_authn_response (
10593 self .ava ,
10694 "id12" , # in_response_to
@@ -112,15 +100,15 @@ def test_signed_response_1(self):
112100 )
113101
114102 sresponse = response_from_string (signed_resp )
115- assert ds .SIG_RSA_SHA512 in str (sresponse ), "Not correctly signed!"
116- assert ds .DIGEST_SHA512 in str (sresponse ), "Not correctly signed!"
103+ assert ds .SIG_RSA_SHA1 in str (sresponse ), "Not correctly signed!"
104+ assert ds .DIGEST_SHA1 in str (sresponse ), "Not correctly signed!"
117105 valid = self .server .sec .verify_signature (signed_resp ,
118106 self .server .config .cert_file ,
119107 node_name = 'urn:oasis:names:tc:SAML:2.0:protocol:Response' ,
120108 node_id = sresponse .id )
121109 assert valid
122- assert ds .SIG_RSA_SHA512 in str (sresponse .assertion [0 ]), "Not correctly signed!"
123- assert ds .DIGEST_SHA512 in str (sresponse .assertion [0 ]), "Not correctly signed!"
110+ assert ds .SIG_RSA_SHA1 in str (sresponse .assertion [0 ]), "Not correctly signed!"
111+ assert ds .DIGEST_SHA1 in str (sresponse .assertion [0 ]), "Not correctly signed!"
124112 valid = self .server .sec .verify_signature (signed_resp ,
125113 self .server .config .cert_file ,
126114 node_name = 'urn:oasis:names:tc:SAML:2.0:assertion:Assertion' ,
@@ -130,7 +118,6 @@ def test_signed_response_1(self):
130118 self .verify_assertion (sresponse .assertion )
131119
132120 def test_signed_response_2 (self ):
133-
134121 signed_resp = self .server .create_authn_response (
135122 self .ava ,
136123 "id12" , # in_response_to
@@ -161,6 +148,7 @@ def test_signed_response_2(self):
161148
162149 self .verify_assertion (sresponse .assertion )
163150
151+
164152if __name__ == "__main__" :
165153 ts = TestSignedResponse ()
166154 ts .setup_class ()
0 commit comments