@@ -217,8 +217,6 @@ def test_assertion_consumer_service(self):
217
217
metadata_file = 'remote_metadata_one_idp.xml' ,
218
218
)
219
219
220
- self .init_cookies ()
221
-
222
220
# session_id should start with a letter since it is a NCName
223
221
session_id = "a0123456789abcdef0123456789abcdef"
224
222
came_from = '/another-view/'
@@ -259,6 +257,37 @@ def test_assertion_consumer_service(self):
259
257
self .assertEqual (url .path , settings .LOGIN_REDIRECT_URL )
260
258
self .assertEqual (force_text (new_user .id ), self .client .session [SESSION_KEY ])
261
259
260
+ def test_assertion_consumer_service_no_session (self ):
261
+ settings .SAML_CONFIG = conf .create_conf (
262
+ sp_host = 'sp.example.com' ,
263
+ idp_hosts = ['idp.example.com' ],
264
+ metadata_file = 'remote_metadata_one_idp.xml' ,
265
+ )
266
+
267
+ # session_id should start with a letter since it is a NCName
268
+ session_id = "a0123456789abcdef0123456789abcdef"
269
+ came_from = '/another-view/'
270
+ self .add_outstanding_query (session_id , came_from )
271
+
272
+ # Authentication is confirmed.
273
+ saml_response = auth_response (session_id , 'student' )
274
+ response = self .client .post (reverse ('saml2_acs' ), {
275
+ 'SAMLResponse' : self .b64_for_post (saml_response ),
276
+ 'RelayState' : came_from ,
277
+ })
278
+ self .assertEqual (response .status_code , 302 )
279
+ location = response ['Location' ]
280
+ url = urlparse (location )
281
+ self .assertEqual (url .path , came_from )
282
+
283
+ # Session should no longer be in outstanding queries.
284
+ saml_response = auth_response (session_id , 'student' )
285
+ response = self .client .post (reverse ('saml2_acs' ), {
286
+ 'SAMLResponse' : self .b64_for_post (saml_response ),
287
+ 'RelayState' : came_from ,
288
+ })
289
+ self .assertEqual (response .status_code , 403 )
290
+
262
291
def test_missing_param_to_assertion_consumer_service_request (self ):
263
292
# Send request without SAML2Response parameter
264
293
response = self .client .post (reverse ('saml2_acs' ))
0 commit comments