From e2c6b92f3f7dec057700f07836c54f180bf1bada Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Fri, 16 Dec 2011 11:20:24 +0100 Subject: [PATCH] [tests] fix tests to comply with new implementation of parsing The test around parsing of EncryptedAssertion was wrong since it was missing the XMLEnc namespace declaration. --- bindings/python/tests/profiles_tests.py | 8 ++--- tests/basic_tests.c | 46 ++++++++++++++++++------- 2 files changed, 37 insertions(+), 17 deletions(-) diff --git a/bindings/python/tests/profiles_tests.py b/bindings/python/tests/profiles_tests.py index 45478f02..f5fd4637 100755 --- a/bindings/python/tests/profiles_tests.py +++ b/bindings/python/tests/profiles_tests.py @@ -452,8 +452,8 @@ class AttributeAuthorityTestCase(unittest.TestCase): class LogoutTestCase(unittest.TestCase): def test01(self): '''Test parsing of a logout request with more than one session index''' - content = ''' - me + content = ''' + me id1 id2 id3 @@ -461,8 +461,8 @@ class LogoutTestCase(unittest.TestCase): node = lasso.Samlp2LogoutRequest.newFromXmlNode(content) assert isinstance(node, lasso.Samlp2LogoutRequest) - assert node.sessionIndex == 'id3' - assert node.sessionIndexes == ('id1', 'id2', 'id3') + assert node.sessionIndex == 'id1' + assert node.sessionIndexes == ('id2', 'id3', 'id1') serverSuite = unittest.makeSuite(ServerTestCase, 'test') loginSuite = unittest.makeSuite(LoginTestCase, 'test') diff --git a/tests/basic_tests.c b/tests/basic_tests.c index 406e93b4..a73cc882 100644 --- a/tests/basic_tests.c +++ b/tests/basic_tests.c @@ -62,7 +62,7 @@ END_TEST START_TEST(test03_server_load_dump_random_xml) { LassoServer *serverContext; - begin_check_do_log(G_LOG_LEVEL_CRITICAL, "(xml.c/:2307) Unable to build a LassoNode from a xmlNode", TRUE); + begin_check_do_log(G_LOG_LEVEL_CRITICAL, " Unable to build a LassoNode from a xmlNode", TRUE); serverContext = lasso_server_new_from_dump(""); end_check_do_log(); fail_unless(serverContext == NULL, @@ -1856,21 +1856,21 @@ START_TEST(test10_test_alldumps) #endif /* test deserialization of saml2:EncryptedAssertion" */ const char *encrypted_element_xml[] = { - "\n\ - \ - \ + "\n\ + \ + \ ", - "\n\ - \ - \ + "\n\ + \ + \ ", - "\n\ - \ - \ + "\n\ + \ + \ ", - "\n\ - \ - \ + "\n\ + \ + \ ", NULL }; const char **iter = encrypted_element_xml; while (*iter) { @@ -2027,6 +2027,8 @@ START_TEST(test15_ds_key_info) LassoDsKeyValue *ds_key_value = lasso_ds_key_value_new(); LassoDsX509Data *x509_data = lasso_ds_x509_data_new(); char *dump; + GList list; + LassoNode *node; lasso_ds_x509_data_set_certificate(x509_data, "coucou"); lasso_ds_key_value_set_x509_data(ds_key_value, x509_data); @@ -2036,6 +2038,7 @@ START_TEST(test15_ds_key_info) lasso_release_gobject(ds_key_value); lasso_release_gobject(x509_data); ds_key_info = (LassoDsKeyInfo*)lasso_node_new_from_dump(dump); + lasso_release_string(dump); check_not_null(ds_key_info); check_true(LASSO_IS_DS_KEY_INFO(ds_key_info)); check_not_null(ds_key_info->KeyValue); @@ -2044,7 +2047,24 @@ START_TEST(test15_ds_key_info) check_not_null(x509_data); check_true(LASSO_IS_DS_X509_DATA(x509_data)); check_str_equals(lasso_ds_x509_data_get_certificate(x509_data), "coucou"); + /* LassoSaml2SubjectConfirmation */ + LassoSaml2SubjectConfirmation *sc = (LassoSaml2SubjectConfirmation*) \ + lasso_saml2_subject_confirmation_new(); + LassoSaml2KeyInfoConfirmationDataType *kicdt = (LassoSaml2KeyInfoConfirmationDataType*) \ + lasso_saml2_key_info_confirmation_data_type_new(); + lasso_assign_string(sc->Method, LASSO_SAML2_CONFIRMATION_METHOD_HOLDER_OF_KEY); + lasso_assign_new_gobject(sc->SubjectConfirmationData, &kicdt->parent); + list = (GList){ .data = ds_key_info, .next = NULL, .prev = NULL }; + lasso_saml2_key_info_confirmation_data_type_set_key_info(kicdt, &list); + dump = lasso_node_debug((LassoNode*)sc, 10); + printf("1 %s\n", dump); + lasso_release_gobject(sc); lasso_release_gobject(ds_key_info); + node = lasso_node_new_from_dump(dump); + lasso_release_string(dump); + dump = lasso_node_debug(node, 10); + printf("2 %s\n", dump); + lasso_release_string(dump); } END_TEST