Keep order of SessionIndexes

This commit is contained in:
Benjamin Dauvergne 2020-04-22 04:45:52 +02:00
parent 55feba5762
commit 92d12b9954
2 changed files with 14 additions and 7 deletions

View File

@ -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')

View File

@ -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);
}
}