using check <http://check.sourceforge.net/> for the test suite

(--enable-tests=no if you don't want them)
This commit is contained in:
Frédéric Péters 2004-07-24 18:00:16 +00:00
parent eda0f459be
commit 1893900d09
4 changed files with 92 additions and 36 deletions

View File

@ -1,4 +1,4 @@
SUBDIRS = lasso docs python win32
SUBDIRS = lasso docs python win32 tests
ABS_BUILDDIR = $(shell pwd)

View File

@ -194,6 +194,25 @@ fi
AM_CONDITIONAL(ENABLE_GTK_DOC, test x$enable_gtk_doc = xyes)
dnl ==========================================================================
dnl Test suite (requires check)
dnl ==========================================================================
AC_ARG_ENABLE(tests,
[ --enable-tests build the test suite (default)],
[case "${enableval}" in
yes) tests_val=true;;
no) tests_val=false;;
esac], tests_val=true)
if $tests_val ; then
AM_PATH_CHECK
fi
AM_CONDITIONAL(WITH_TESTS, $tests_val)
dnl ==========================================================================
dnl Where do we want to install docs
dnl ==========================================================================
@ -312,6 +331,7 @@ python/protocols/Makefile
python/protocols/elements/Makefile
python/tests/Makefile
python/xml/Makefile
tests/Makefile
win32/Makefile
win32/nsis/Makefile
]
@ -330,4 +350,4 @@ Configuration:
Build Python binding: ${enable_python}
Build C API reference: ${enable_gtk_doc}
"
"

22
tests/Makefile.am Normal file
View File

@ -0,0 +1,22 @@
if WITH_TESTS
TESTS = login_tests
noinst_PROGRAMS = login_tests
INCLUDES = \
-DPACKAGE=\"@PACKAGE@\" \
-I$(top_srcdir) \
-I$(top_srcdir)/lasso \
$(LASSO_DEFINES) \
$(LASSO_CFLAGS) \
$(CHECK_CFLAGS)
login_tests_SOURCES = login_tests.c
login_tests_LDADD = \
$(top_builddir)/lasso/liblasso.la \
$(LASSO_LIBS) \
$(CHECK_LIBS)
endif
EXTRA_DIST = login_tests.c

View File

@ -21,48 +21,62 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
gcc -g -O2 -I./.. `pkg-config gobject-2.0 --cflags` `pkg-config libxml-2.0 --cflags` -L../lasso/.libs -llasso `pkg-config gobject-2.0 --libs` `pkg-config libxml-2.0 --libs` -DXMLSEC_CRYPTO=\"openssl\" -DXMLSEC_LIBXML_260=1 -D__XMLSEC_FUNCTION__=__FUNCTION__ -DXMLSEC_NO_XKMS=1 -DXMLSEC_NO_CRYPTO_DYNAMIC_LOADING=1 -DXMLSEC_CRYPTO_OPENSSL=1 -I/usr/include/xmlsec1 -I/usr/include/libxml2 -L/usr/lib -L/usr/local/lib -lxmlsec1-openssl -lxmlsec1 -lxslt -lxml2 -lz -lpthread -lm -lssl -lcrypto -ldl login_tests.c -o login_tests
*/
#include <stdlib.h>
#include <check.h>
#include <lasso/lasso.h>
char *generateIdentityProviderContextDump() {
LassoServer *serverContext = lasso_server_new(
"../examples/data/idp-metadata.xml",
"../examples/data/idp-public-key.pem",
"../examples/data/idp-private-key.pem",
"../examples/data/idp-crt.pem",
lassoSignatureMethodRsaSha1);
lasso_server_add_provider(
serverContext,
"../examples/data/sp-metadata.xml",
"../examples/data/sp-public-key.pem",
"../examples/data/ca-crt.pem");
char *serverContextDump = lasso_server_dump(serverContext);
return serverContextDump;
LassoServer *serverContext = lasso_server_new(
"../examples/data/idp-metadata.xml",
"../examples/data/idp-public-key.pem",
"../examples/data/idp-private-key.pem",
"../examples/data/idp-crt.pem",
lassoSignatureMethodRsaSha1);
lasso_server_add_provider(
serverContext,
"../examples/data/sp-metadata.xml",
"../examples/data/sp-public-key.pem",
"../examples/data/ca-crt.pem");
char *serverContextDump = lasso_server_dump(serverContext);
return serverContextDump;
}
void test01_generateServersContextDumps() {
char *identityProviderContextDump = generateIdentityProviderContextDump();
printf("SUCCESS = %s\n", identityProviderContextDump);
/* char *serviceProviderContextDump = generateServiceProviderContextDump(); */
/* assertNotNull(serviceProviderContextDump); */
START_TEST(test01_generateServersContextDumps)
{
char *identityProviderContextDump = generateIdentityProviderContextDump();
fail_unless(identityProviderContextDump != NULL,
"generateIdentityProviderContextDump should not return NULL");
}
END_TEST
Suite* login_suite()
{
Suite *s = suite_create("Login");
TCase *tc_generate = tcase_create("Generate Server Contexts");
suite_add_tcase(s, tc_generate);
tcase_add_test(tc_generate, test01_generateServersContextDumps);
return s;
}
int main(int argc, char *argv[])
{
int rc;
Suite *s;
SRunner *sr;
void test02_serviceProviderLogin() {
lasso_init();
s = login_suite();
sr = srunner_create(s);
srunner_run_all (sr, CK_VERBOSE);
rc = srunner_ntests_failed(sr);
srunner_free(sr);
suite_free(s);
/*lasso_destroy();*/
return (rc == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
}
int main() {
lasso_init();
test01_generateServersContextDumps();
test02_serviceProviderLogin();
lasso_shutdown();
}