From 92d12b995459c01ccba48d8b99bd69b09f00f5b1 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Wed, 22 Apr 2020 04:45:52 +0200 Subject: [PATCH] Keep order of SessionIndexes --- bindings/python/tests/binding_tests.py | 9 +++++++++ lasso/xml/saml-2.0/samlp2_logout_request.c | 12 +++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/bindings/python/tests/binding_tests.py b/bindings/python/tests/binding_tests.py index 90df3adf..936e8b3b 100755 --- a/bindings/python/tests/binding_tests.py +++ b/bindings/python/tests/binding_tests.py @@ -322,6 +322,15 @@ class BindingTestCase(unittest.TestCase): # on reparse non namespaces attributes are ignore, they should not exist assert node.attributes == {} + def test13(self): + node = lasso.Samlp2LogoutRequest() + node.sessionIndexes = ('1', '2') + assert node.sessionIndexes == ('1', '2'), node.sessionIndexes + node.sessionIndexes = () + assert node.sessionIndexes == (), node.sessionIndexes + + + bindingSuite = unittest.makeSuite(BindingTestCase, 'test') diff --git a/lasso/xml/saml-2.0/samlp2_logout_request.c b/lasso/xml/saml-2.0/samlp2_logout_request.c index e1f20d40..bb0c9d6e 100644 --- a/lasso/xml/saml-2.0/samlp2_logout_request.c +++ b/lasso/xml/saml-2.0/samlp2_logout_request.c @@ -268,14 +268,12 @@ lasso_samlp2_logout_request_set_session_indexes(LassoSamlp2LogoutRequest *logout /* assign rest of the list to the new private field */ pv = GET_PRIVATE(logout_request); - lasso_assign_list_of_strings(pv->SessionIndex, session_index); - /* extract last element and assign it to old field */ - if (pv->SessionIndex && pv->SessionIndex->next) { - GList *last = g_list_last(pv->SessionIndex); - lasso_assign_new_string(logout_request->SessionIndex, (char*) last->data); - pv->SessionIndex = g_list_delete_link(pv->SessionIndex, last); - } else { + if (! session_index) { lasso_release_string(logout_request->SessionIndex); + lasso_release_list_of_strings(pv->SessionIndex); + } else { + lasso_assign_string(logout_request->SessionIndex, (char*) session_index->data); + lasso_assign_list_of_strings(pv->SessionIndex, session_index->next); } }