summaryrefslogtreecommitdiffstats
path: root/tests/login_tests_saml2.c
diff options
context:
space:
mode:
authorBenjamin Dauvergne <bdauvergne@entrouvert.com>2009-12-01 02:06:07 (GMT)
committerBenjamin Dauvergne <bdauvergne@entrouvert.com>2009-12-01 02:06:07 (GMT)
commit4f973512b9ddc16348973a0b466b2103063d147a (patch)
tree74dfd4cf0fc5f7338506bb59d0b87786f340bd34 /tests/login_tests_saml2.c
parent896d9abd3fb070bda17c78a1d2b84c9348253ef0 (diff)
downloadlasso-4f973512b9ddc16348973a0b466b2103063d147a.zip
lasso-4f973512b9ddc16348973a0b466b2103063d147a.tar.gz
lasso-4f973512b9ddc16348973a0b466b2103063d147a.tar.bz2
Add SP initiated logout test to SAML 2.0 regression tests
* tests/login_tests_saml2.c: add logout to first SAML 2.0 login regression test. * tests/tests.h: add macros to simplify checking of return value with check macros (encapsulate fail_unless macro to check for NULL/non-NULL values and good rc value (0) or expected bad value).
Diffstat (limited to 'tests/login_tests_saml2.c')
-rw-r--r--tests/login_tests_saml2.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/login_tests_saml2.c b/tests/login_tests_saml2.c
index 87a812e..2d1c2c7 100644
--- a/tests/login_tests_saml2.c
+++ b/tests/login_tests_saml2.c
@@ -32,6 +32,7 @@
#include "../lasso/utils.h"
#include "../lasso/backward_comp.h"
+#include "./tests.h"
static char*
generateIdentityProviderContextDump()
@@ -135,10 +136,13 @@ START_TEST(test02_saml2_serviceProviderLogin)
char *serviceProviderContextDump = NULL, *identityProviderContextDump = NULL;
LassoServer *spContext = NULL, *idpContext = NULL;
LassoLogin *spLoginContext = NULL, *idpLoginContext = NULL;
+ LassoLogout *spLogoutContext = NULL, *idpLogoutContext = NULL;
LassoSamlp2AuthnRequest *request = NULL;
int rc;
char *relayState = NULL;
char *authnRequestUrl = NULL, *authnRequestQuery = NULL;
+ char *logoutRequestUrl = NULL, *logoutRequestQuery = NULL;
+ char *logoutResponseUrl = NULL, *logoutResponseQuery = NULL;
char *responseUrl = NULL, *responseQuery = NULL;
char *idpIdentityContextDump = NULL, *idpSessionContextDump = NULL;
char *serviceProviderId = NULL, *soapRequestMsg = NULL, *soapResponseMsg = NULL;
@@ -288,6 +292,43 @@ START_TEST(test02_saml2_serviceProviderLogin)
rc = lasso_login_accept_sso(spLoginContext);
fail_unless(rc != 0, "lasso_login_accept_sso must fail");
+ /* logout test */
+ /* generate a logout request */
+ check_not_null(idpLogoutContext = lasso_logout_new(idpContext));
+ check_good_rc(lasso_profile_set_session_from_dump(&idpLogoutContext->parent, idpSessionContextDump));
+ check_good_rc(lasso_logout_init_request(idpLogoutContext, NULL, LASSO_HTTP_METHOD_REDIRECT));
+ check_good_rc(lasso_logout_build_request_msg(idpLogoutContext));
+ check_not_null(idpLogoutContext->parent.msg_url);
+ check_null(idpLogoutContext->parent.msg_body);
+ check_null(idpLogoutContext->parent.msg_relayState);
+ lasso_assign_string(logoutRequestUrl, idpLogoutContext->parent.msg_url);
+ lasso_release_gobject(idpLogoutContext);
+ logoutRequestQuery = strchr(logoutRequestUrl, '?');
+ logoutRequestQuery += 1; /* keep only the query */
+ check_not_null(logoutRequestQuery);
+
+ /* process the logout request */
+ check_not_null(spLogoutContext = lasso_logout_new(spContext));
+ check_good_rc(rc = lasso_profile_set_session_from_dump(&spLogoutContext->parent, spSessionDump));
+ check_good_rc(rc = lasso_logout_process_request_msg(spLogoutContext, logoutRequestQuery));
+ check_good_rc(rc = lasso_logout_validate_request(spLogoutContext));
+ check_good_rc(rc = lasso_logout_build_response_msg(spLogoutContext));
+ check_not_null(spLogoutContext->parent.msg_url);
+ check_null(spLogoutContext->parent.msg_body);
+ check_null(spLogoutContext->parent.msg_relayState);
+ lasso_assign_string(logoutResponseUrl, spLogoutContext->parent.msg_url);
+ check_not_null(logoutResponseQuery = strchr(logoutResponseUrl, '?'));
+ logoutResponseQuery += 1; /* keep only the query */
+ lasso_release_gobject(spLogoutContext);
+
+ /* process the response */
+ check_not_null(idpLogoutContext = lasso_logout_new(idpContext));
+ check_good_rc(lasso_profile_set_session_from_dump(&idpLogoutContext->parent, idpSessionContextDump));
+ check_good_rc(lasso_logout_process_response_msg(idpLogoutContext, logoutResponseQuery));
+ lasso_release_gobject(idpLogoutContext);
+ lasso_release_string(logoutRequestUrl);
+ lasso_release_string(logoutResponseUrl);
+
g_free(idpLoginDump);
g_free(serviceProviderId);
g_free(serviceProviderContextDump);