diff options
Diffstat (limited to 'test/plugins')
-rw-r--r-- | test/plugins/Makefile.am | 74 | ||||
-rw-r--r-- | test/plugins/Makefile.in | 820 | ||||
-rw-r--r-- | test/plugins/digestplugintest.c | 322 | ||||
-rw-r--r-- | test/plugins/passwordplugintest.c | 287 | ||||
-rw-r--r-- | test/plugins/pluginproxytest.c | 664 | ||||
-rw-r--r-- | test/plugins/pluginremotetest.c | 589 |
6 files changed, 2756 insertions, 0 deletions
diff --git a/test/plugins/Makefile.am b/test/plugins/Makefile.am new file mode 100644 index 0000000..90b02ea --- /dev/null +++ b/test/plugins/Makefile.am @@ -0,0 +1,74 @@ +TESTS = digestplugintest passwordplugintest pluginproxytest pluginremotetest + +TESTS_ENVIRONMENT= SSO_PLUGINS_DIR=$(top_builddir)/src/plugins/.libs \ + SSO_BIN_DIR=$(top_builddir)/src/daemon/.libs \ + SSO_STORAGE_PATH=/tmp/gsignond \ + SSO_SECRET_PATH=/tmp/gsignond \ + LD_LIBRARY_PATH="$(top_builddir)/src/daemon/plugins/plugind/.libs:$(top_builddir)/src/common/.libs:$(top_builddir)/src/common/db/.libs:$(top_builddir)/src/daemon/.libs:$(top_builddir)/src/daemon/db/.libs:$(top_builddir)/src/daemon/dbus/.libs:$(top_builddir)/src/daemon/plugins/.libs" + +VALGRIND_TESTS_DISABLE = + +check_PROGRAMS = digestplugintest passwordplugintest pluginproxytest pluginremotetest +include $(top_srcdir)/test/valgrind_common.mk + +digestplugintest_SOURCES = digestplugintest.c +digestplugintest_CFLAGS = \ + $(GSIGNOND_CFLAGS) \ + $(CHECK_CFLAGS) \ + -I$(top_builddir) \ + -I$(top_srcdir)/src \ + -I$(top_srcdir)/src/plugins/digest \ + -I$(top_srcdir)/include + +digestplugintest_LDADD = \ + $(top_builddir)/src/common/libgsignond-common.la \ + $(top_builddir)/src/plugins/digest/libdigest.la \ + $(GSIGNOND_LIBS) \ + $(CHECK_LIBS) + +passwordplugintest_SOURCES = passwordplugintest.c +passwordplugintest_CFLAGS = \ + $(GSIGNOND_CFLAGS) \ + $(CHECK_CFLAGS) \ + -I$(top_builddir) \ + -I$(top_srcdir)/src \ + -I$(top_srcdir)/src/plugins/password \ + -I$(top_srcdir)/include/ + +passwordplugintest_LDADD = \ + $(top_builddir)/src/common/libgsignond-common.la \ + $(top_builddir)/src/plugins/password/libpassword.la \ + $(GSIGNOND_LIBS) \ + $(CHECK_LIBS) + +pluginproxytest_SOURCES = pluginproxytest.c +pluginproxytest_CFLAGS = \ + $(GSIGNOND_CFLAGS) \ + $(CHECK_CFLAGS) \ + -I$(top_builddir) \ + -I$(top_srcdir)/src \ + -I$(top_srcdir)/src/daemon/plugins \ + -I$(top_srcdir)/include + +pluginproxytest_LDADD = \ + $(top_builddir)/src/common/libgsignond-common.la \ + $(top_builddir)/src/daemon/plugins/libgsignond-plugins.la \ + $(GSIGNOND_LIBS) \ + $(CHECK_LIBS) + +pluginremotetest_SOURCES = pluginremotetest.c +pluginremotetest_CFLAGS = \ + $(GSIGNOND_CFLAGS) \ + $(CHECK_CFLAGS) \ + -I$(top_builddir) \ + -I$(top_srcdir)/src \ + -I$(top_srcdir)/src/daemon/plugins \ + -I$(top_srcdir)/src/daemon/plugins/plugind \ + -I$(top_srcdir)/include + +pluginremotetest_LDADD = \ + $(top_builddir)/src/common/libgsignond-common.la \ + $(top_builddir)/src/daemon/plugins/libgsignond-plugins.la \ + $(top_builddir)/src/daemon/plugins/plugind/libgsignond-plugind-daemon.la \ + $(GSIGNOND_LIBS) \ + $(CHECK_LIBS) diff --git a/test/plugins/Makefile.in b/test/plugins/Makefile.in new file mode 100644 index 0000000..e8a3604 --- /dev/null +++ b/test/plugins/Makefile.in @@ -0,0 +1,820 @@ +# Makefile.in generated by automake 1.11.3 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software +# Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +TESTS = digestplugintest$(EXEEXT) passwordplugintest$(EXEEXT) \ + pluginproxytest$(EXEEXT) pluginremotetest$(EXEEXT) +check_PROGRAMS = digestplugintest$(EXEEXT) passwordplugintest$(EXEEXT) \ + pluginproxytest$(EXEEXT) pluginremotetest$(EXEEXT) +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ + $(top_srcdir)/test/valgrind_common.mk +subdir = test/plugins +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_gnu_make.m4 \ + $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ + $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ + $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +am_digestplugintest_OBJECTS = \ + digestplugintest-digestplugintest.$(OBJEXT) +digestplugintest_OBJECTS = $(am_digestplugintest_OBJECTS) +am__DEPENDENCIES_1 = +digestplugintest_DEPENDENCIES = \ + $(top_builddir)/src/common/libgsignond-common.la \ + $(top_builddir)/src/plugins/digest/libdigest.la \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) +AM_V_lt = $(am__v_lt_@AM_V@) +am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) +am__v_lt_0 = --silent +digestplugintest_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ + $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ + $(digestplugintest_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ + -o $@ +am_passwordplugintest_OBJECTS = \ + passwordplugintest-passwordplugintest.$(OBJEXT) +passwordplugintest_OBJECTS = $(am_passwordplugintest_OBJECTS) +passwordplugintest_DEPENDENCIES = \ + $(top_builddir)/src/common/libgsignond-common.la \ + $(top_builddir)/src/plugins/password/libpassword.la \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) +passwordplugintest_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ + $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ + $(passwordplugintest_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +am_pluginproxytest_OBJECTS = \ + pluginproxytest-pluginproxytest.$(OBJEXT) +pluginproxytest_OBJECTS = $(am_pluginproxytest_OBJECTS) +pluginproxytest_DEPENDENCIES = \ + $(top_builddir)/src/common/libgsignond-common.la \ + $(top_builddir)/src/daemon/plugins/libgsignond-plugins.la \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) +pluginproxytest_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ + $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ + $(pluginproxytest_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ + -o $@ +am_pluginremotetest_OBJECTS = \ + pluginremotetest-pluginremotetest.$(OBJEXT) +pluginremotetest_OBJECTS = $(am_pluginremotetest_OBJECTS) +pluginremotetest_DEPENDENCIES = \ + $(top_builddir)/src/common/libgsignond-common.la \ + $(top_builddir)/src/daemon/plugins/libgsignond-plugins.la \ + $(top_builddir)/src/daemon/plugins/plugind/libgsignond-plugind-daemon.la \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) +pluginremotetest_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ + $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ + $(pluginremotetest_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ + -o $@ +DEFAULT_INCLUDES = +depcomp = $(SHELL) $(top_srcdir)/build-aux/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +AM_V_CC = $(am__v_CC_@AM_V@) +am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) +am__v_CC_0 = @echo " CC " $@; +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +CCLD = $(CC) +LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CCLD = $(am__v_CCLD_@AM_V@) +am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) +am__v_CCLD_0 = @echo " CCLD " $@; +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +SOURCES = $(digestplugintest_SOURCES) $(passwordplugintest_SOURCES) \ + $(pluginproxytest_SOURCES) $(pluginremotetest_SOURCES) +DIST_SOURCES = $(digestplugintest_SOURCES) \ + $(passwordplugintest_SOURCES) $(pluginproxytest_SOURCES) \ + $(pluginremotetest_SOURCES) +ETAGS = etags +CTAGS = ctags +am__tty_colors = \ +red=; grn=; lgn=; blu=; std= +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CHECK_CFLAGS = @CHECK_CFLAGS@ +CHECK_LIBS = @CHECK_LIBS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DBUS_INTERFACES_DIR = @DBUS_INTERFACES_DIR@ +DBUS_SERVICES_DIR = @DBUS_SERVICES_DIR@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GLIB_MKENUMS = @GLIB_MKENUMS@ +GREP = @GREP@ +GSIGNOND_CFLAGS = @GSIGNOND_CFLAGS@ +GSIGNOND_LIBS = @GSIGNOND_LIBS@ +GTKDOC_CHECK = @GTKDOC_CHECK@ +GTKDOC_DEPS_CFLAGS = @GTKDOC_DEPS_CFLAGS@ +GTKDOC_DEPS_LIBS = @GTKDOC_DEPS_LIBS@ +GTKDOC_MKPDF = @GTKDOC_MKPDF@ +GTKDOC_REBASE = @GTKDOC_REBASE@ +GTestDBus_CFLAGS = @GTestDBus_CFLAGS@ +GTestDBus_LIBS = @GTestDBus_LIBS@ +HTML_DIR = @HTML_DIR@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBECRYPTFS_CFLAGS = @LIBECRYPTFS_CFLAGS@ +LIBECRYPTFS_LIBS = @LIBECRYPTFS_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBSMACK_CFLAGS = @LIBSMACK_CFLAGS@ +LIBSMACK_LIBS = @LIBSMACK_LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MESSAGE_BUS_TYPE = @MESSAGE_BUS_TYPE@ +MKDIR_P = @MKDIR_P@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +ifGNUmake = @ifGNUmake@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +TESTS_ENVIRONMENT = SSO_PLUGINS_DIR=$(top_builddir)/src/plugins/.libs \ + SSO_BIN_DIR=$(top_builddir)/src/daemon/.libs \ + SSO_STORAGE_PATH=/tmp/gsignond \ + SSO_SECRET_PATH=/tmp/gsignond \ + LD_LIBRARY_PATH="$(top_builddir)/src/daemon/plugins/plugind/.libs:$(top_builddir)/src/common/.libs:$(top_builddir)/src/common/db/.libs:$(top_builddir)/src/daemon/.libs:$(top_builddir)/src/daemon/db/.libs:$(top_builddir)/src/daemon/dbus/.libs:$(top_builddir)/src/daemon/plugins/.libs" + +VALGRIND_TESTS_DISABLE = +SUPPRESSIONS = $(top_srcdir)/test/valgrind.supp +digestplugintest_SOURCES = digestplugintest.c +digestplugintest_CFLAGS = \ + $(GSIGNOND_CFLAGS) \ + $(CHECK_CFLAGS) \ + -I$(top_builddir) \ + -I$(top_srcdir)/src \ + -I$(top_srcdir)/src/plugins/digest \ + -I$(top_srcdir)/include + +digestplugintest_LDADD = \ + $(top_builddir)/src/common/libgsignond-common.la \ + $(top_builddir)/src/plugins/digest/libdigest.la \ + $(GSIGNOND_LIBS) \ + $(CHECK_LIBS) + +passwordplugintest_SOURCES = passwordplugintest.c +passwordplugintest_CFLAGS = \ + $(GSIGNOND_CFLAGS) \ + $(CHECK_CFLAGS) \ + -I$(top_builddir) \ + -I$(top_srcdir)/src \ + -I$(top_srcdir)/src/plugins/password \ + -I$(top_srcdir)/include/ + +passwordplugintest_LDADD = \ + $(top_builddir)/src/common/libgsignond-common.la \ + $(top_builddir)/src/plugins/password/libpassword.la \ + $(GSIGNOND_LIBS) \ + $(CHECK_LIBS) + +pluginproxytest_SOURCES = pluginproxytest.c +pluginproxytest_CFLAGS = \ + $(GSIGNOND_CFLAGS) \ + $(CHECK_CFLAGS) \ + -I$(top_builddir) \ + -I$(top_srcdir)/src \ + -I$(top_srcdir)/src/daemon/plugins \ + -I$(top_srcdir)/include + +pluginproxytest_LDADD = \ + $(top_builddir)/src/common/libgsignond-common.la \ + $(top_builddir)/src/daemon/plugins/libgsignond-plugins.la \ + $(GSIGNOND_LIBS) \ + $(CHECK_LIBS) + +pluginremotetest_SOURCES = pluginremotetest.c +pluginremotetest_CFLAGS = \ + $(GSIGNOND_CFLAGS) \ + $(CHECK_CFLAGS) \ + -I$(top_builddir) \ + -I$(top_srcdir)/src \ + -I$(top_srcdir)/src/daemon/plugins \ + -I$(top_srcdir)/src/daemon/plugins/plugind \ + -I$(top_srcdir)/include + +pluginremotetest_LDADD = \ + $(top_builddir)/src/common/libgsignond-common.la \ + $(top_builddir)/src/daemon/plugins/libgsignond-plugins.la \ + $(top_builddir)/src/daemon/plugins/plugind/libgsignond-plugind-daemon.la \ + $(GSIGNOND_LIBS) \ + $(CHECK_LIBS) + +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/test/valgrind_common.mk $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu test/plugins/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu test/plugins/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; +$(top_srcdir)/test/valgrind_common.mk: + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +clean-checkPROGRAMS: + @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \ + echo " rm -f" $$list; \ + rm -f $$list || exit $$?; \ + test -n "$(EXEEXT)" || exit 0; \ + list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f" $$list; \ + rm -f $$list +digestplugintest$(EXEEXT): $(digestplugintest_OBJECTS) $(digestplugintest_DEPENDENCIES) $(EXTRA_digestplugintest_DEPENDENCIES) + @rm -f digestplugintest$(EXEEXT) + $(AM_V_CCLD)$(digestplugintest_LINK) $(digestplugintest_OBJECTS) $(digestplugintest_LDADD) $(LIBS) +passwordplugintest$(EXEEXT): $(passwordplugintest_OBJECTS) $(passwordplugintest_DEPENDENCIES) $(EXTRA_passwordplugintest_DEPENDENCIES) + @rm -f passwordplugintest$(EXEEXT) + $(AM_V_CCLD)$(passwordplugintest_LINK) $(passwordplugintest_OBJECTS) $(passwordplugintest_LDADD) $(LIBS) +pluginproxytest$(EXEEXT): $(pluginproxytest_OBJECTS) $(pluginproxytest_DEPENDENCIES) $(EXTRA_pluginproxytest_DEPENDENCIES) + @rm -f pluginproxytest$(EXEEXT) + $(AM_V_CCLD)$(pluginproxytest_LINK) $(pluginproxytest_OBJECTS) $(pluginproxytest_LDADD) $(LIBS) +pluginremotetest$(EXEEXT): $(pluginremotetest_OBJECTS) $(pluginremotetest_DEPENDENCIES) $(EXTRA_pluginremotetest_DEPENDENCIES) + @rm -f pluginremotetest$(EXEEXT) + $(AM_V_CCLD)$(pluginremotetest_LINK) $(pluginremotetest_OBJECTS) $(pluginremotetest_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/digestplugintest-digestplugintest.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/passwordplugintest-passwordplugintest.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pluginproxytest-pluginproxytest.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pluginremotetest-pluginremotetest.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\ +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< + +.c.obj: +@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\ +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\ +@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\ +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\ +@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< + +digestplugintest-digestplugintest.o: digestplugintest.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(digestplugintest_CFLAGS) $(CFLAGS) -MT digestplugintest-digestplugintest.o -MD -MP -MF $(DEPDIR)/digestplugintest-digestplugintest.Tpo -c -o digestplugintest-digestplugintest.o `test -f 'digestplugintest.c' || echo '$(srcdir)/'`digestplugintest.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/digestplugintest-digestplugintest.Tpo $(DEPDIR)/digestplugintest-digestplugintest.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='digestplugintest.c' object='digestplugintest-digestplugintest.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(digestplugintest_CFLAGS) $(CFLAGS) -c -o digestplugintest-digestplugintest.o `test -f 'digestplugintest.c' || echo '$(srcdir)/'`digestplugintest.c + +digestplugintest-digestplugintest.obj: digestplugintest.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(digestplugintest_CFLAGS) $(CFLAGS) -MT digestplugintest-digestplugintest.obj -MD -MP -MF $(DEPDIR)/digestplugintest-digestplugintest.Tpo -c -o digestplugintest-digestplugintest.obj `if test -f 'digestplugintest.c'; then $(CYGPATH_W) 'digestplugintest.c'; else $(CYGPATH_W) '$(srcdir)/digestplugintest.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/digestplugintest-digestplugintest.Tpo $(DEPDIR)/digestplugintest-digestplugintest.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='digestplugintest.c' object='digestplugintest-digestplugintest.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(digestplugintest_CFLAGS) $(CFLAGS) -c -o digestplugintest-digestplugintest.obj `if test -f 'digestplugintest.c'; then $(CYGPATH_W) 'digestplugintest.c'; else $(CYGPATH_W) '$(srcdir)/digestplugintest.c'; fi` + +passwordplugintest-passwordplugintest.o: passwordplugintest.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(passwordplugintest_CFLAGS) $(CFLAGS) -MT passwordplugintest-passwordplugintest.o -MD -MP -MF $(DEPDIR)/passwordplugintest-passwordplugintest.Tpo -c -o passwordplugintest-passwordplugintest.o `test -f 'passwordplugintest.c' || echo '$(srcdir)/'`passwordplugintest.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/passwordplugintest-passwordplugintest.Tpo $(DEPDIR)/passwordplugintest-passwordplugintest.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='passwordplugintest.c' object='passwordplugintest-passwordplugintest.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(passwordplugintest_CFLAGS) $(CFLAGS) -c -o passwordplugintest-passwordplugintest.o `test -f 'passwordplugintest.c' || echo '$(srcdir)/'`passwordplugintest.c + +passwordplugintest-passwordplugintest.obj: passwordplugintest.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(passwordplugintest_CFLAGS) $(CFLAGS) -MT passwordplugintest-passwordplugintest.obj -MD -MP -MF $(DEPDIR)/passwordplugintest-passwordplugintest.Tpo -c -o passwordplugintest-passwordplugintest.obj `if test -f 'passwordplugintest.c'; then $(CYGPATH_W) 'passwordplugintest.c'; else $(CYGPATH_W) '$(srcdir)/passwordplugintest.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/passwordplugintest-passwordplugintest.Tpo $(DEPDIR)/passwordplugintest-passwordplugintest.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='passwordplugintest.c' object='passwordplugintest-passwordplugintest.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(passwordplugintest_CFLAGS) $(CFLAGS) -c -o passwordplugintest-passwordplugintest.obj `if test -f 'passwordplugintest.c'; then $(CYGPATH_W) 'passwordplugintest.c'; else $(CYGPATH_W) '$(srcdir)/passwordplugintest.c'; fi` + +pluginproxytest-pluginproxytest.o: pluginproxytest.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pluginproxytest_CFLAGS) $(CFLAGS) -MT pluginproxytest-pluginproxytest.o -MD -MP -MF $(DEPDIR)/pluginproxytest-pluginproxytest.Tpo -c -o pluginproxytest-pluginproxytest.o `test -f 'pluginproxytest.c' || echo '$(srcdir)/'`pluginproxytest.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/pluginproxytest-pluginproxytest.Tpo $(DEPDIR)/pluginproxytest-pluginproxytest.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pluginproxytest.c' object='pluginproxytest-pluginproxytest.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pluginproxytest_CFLAGS) $(CFLAGS) -c -o pluginproxytest-pluginproxytest.o `test -f 'pluginproxytest.c' || echo '$(srcdir)/'`pluginproxytest.c + +pluginproxytest-pluginproxytest.obj: pluginproxytest.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pluginproxytest_CFLAGS) $(CFLAGS) -MT pluginproxytest-pluginproxytest.obj -MD -MP -MF $(DEPDIR)/pluginproxytest-pluginproxytest.Tpo -c -o pluginproxytest-pluginproxytest.obj `if test -f 'pluginproxytest.c'; then $(CYGPATH_W) 'pluginproxytest.c'; else $(CYGPATH_W) '$(srcdir)/pluginproxytest.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/pluginproxytest-pluginproxytest.Tpo $(DEPDIR)/pluginproxytest-pluginproxytest.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pluginproxytest.c' object='pluginproxytest-pluginproxytest.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pluginproxytest_CFLAGS) $(CFLAGS) -c -o pluginproxytest-pluginproxytest.obj `if test -f 'pluginproxytest.c'; then $(CYGPATH_W) 'pluginproxytest.c'; else $(CYGPATH_W) '$(srcdir)/pluginproxytest.c'; fi` + +pluginremotetest-pluginremotetest.o: pluginremotetest.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pluginremotetest_CFLAGS) $(CFLAGS) -MT pluginremotetest-pluginremotetest.o -MD -MP -MF $(DEPDIR)/pluginremotetest-pluginremotetest.Tpo -c -o pluginremotetest-pluginremotetest.o `test -f 'pluginremotetest.c' || echo '$(srcdir)/'`pluginremotetest.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/pluginremotetest-pluginremotetest.Tpo $(DEPDIR)/pluginremotetest-pluginremotetest.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pluginremotetest.c' object='pluginremotetest-pluginremotetest.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pluginremotetest_CFLAGS) $(CFLAGS) -c -o pluginremotetest-pluginremotetest.o `test -f 'pluginremotetest.c' || echo '$(srcdir)/'`pluginremotetest.c + +pluginremotetest-pluginremotetest.obj: pluginremotetest.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pluginremotetest_CFLAGS) $(CFLAGS) -MT pluginremotetest-pluginremotetest.obj -MD -MP -MF $(DEPDIR)/pluginremotetest-pluginremotetest.Tpo -c -o pluginremotetest-pluginremotetest.obj `if test -f 'pluginremotetest.c'; then $(CYGPATH_W) 'pluginremotetest.c'; else $(CYGPATH_W) '$(srcdir)/pluginremotetest.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/pluginremotetest-pluginremotetest.Tpo $(DEPDIR)/pluginremotetest-pluginremotetest.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='pluginremotetest.c' object='pluginremotetest-pluginremotetest.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(pluginremotetest_CFLAGS) $(CFLAGS) -c -o pluginremotetest-pluginremotetest.obj `if test -f 'pluginremotetest.c'; then $(CYGPATH_W) 'pluginremotetest.c'; else $(CYGPATH_W) '$(srcdir)/pluginremotetest.c'; fi` + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +check-TESTS: $(TESTS) + @failed=0; all=0; xfail=0; xpass=0; skip=0; \ + srcdir=$(srcdir); export srcdir; \ + list=' $(TESTS) '; \ + $(am__tty_colors); \ + if test -n "$$list"; then \ + for tst in $$list; do \ + if test -f ./$$tst; then dir=./; \ + elif test -f $$tst; then dir=; \ + else dir="$(srcdir)/"; fi; \ + if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *[\ \ ]$$tst[\ \ ]*) \ + xpass=`expr $$xpass + 1`; \ + failed=`expr $$failed + 1`; \ + col=$$red; res=XPASS; \ + ;; \ + *) \ + col=$$grn; res=PASS; \ + ;; \ + esac; \ + elif test $$? -ne 77; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *[\ \ ]$$tst[\ \ ]*) \ + xfail=`expr $$xfail + 1`; \ + col=$$lgn; res=XFAIL; \ + ;; \ + *) \ + failed=`expr $$failed + 1`; \ + col=$$red; res=FAIL; \ + ;; \ + esac; \ + else \ + skip=`expr $$skip + 1`; \ + col=$$blu; res=SKIP; \ + fi; \ + echo "$${col}$$res$${std}: $$tst"; \ + done; \ + if test "$$all" -eq 1; then \ + tests="test"; \ + All=""; \ + else \ + tests="tests"; \ + All="All "; \ + fi; \ + if test "$$failed" -eq 0; then \ + if test "$$xfail" -eq 0; then \ + banner="$$All$$all $$tests passed"; \ + else \ + if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \ + banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \ + fi; \ + else \ + if test "$$xpass" -eq 0; then \ + banner="$$failed of $$all $$tests failed"; \ + else \ + if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \ + banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \ + fi; \ + fi; \ + dashes="$$banner"; \ + skipped=""; \ + if test "$$skip" -ne 0; then \ + if test "$$skip" -eq 1; then \ + skipped="($$skip test was not run)"; \ + else \ + skipped="($$skip tests were not run)"; \ + fi; \ + test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$skipped"; \ + fi; \ + report=""; \ + if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \ + report="Please report to $(PACKAGE_BUGREPORT)"; \ + test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$report"; \ + fi; \ + dashes=`echo "$$dashes" | sed s/./=/g`; \ + if test "$$failed" -eq 0; then \ + col="$$grn"; \ + else \ + col="$$red"; \ + fi; \ + echo "$${col}$$dashes$${std}"; \ + echo "$${col}$$banner$${std}"; \ + test -z "$$skipped" || echo "$${col}$$skipped$${std}"; \ + test -z "$$report" || echo "$${col}$$report$${std}"; \ + echo "$${col}$$dashes$${std}"; \ + test "$$failed" -eq 0; \ + else :; fi + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) + $(MAKE) $(AM_MAKEFLAGS) check-TESTS +check: check-am +all-am: Makefile +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-checkPROGRAMS clean-generic clean-libtool \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: check-am install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \ + clean-checkPROGRAMS clean-generic clean-libtool ctags \ + distclean distclean-compile distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags uninstall uninstall-am + + +%.valgrind: % + @$(TESTS_ENVIRONMENT) \ + CK_FORK=no \ + CK_DEFAULT_TIMEOUT=120 \ + G_SLICE=always-malloc \ + $(LIBTOOL) --mode=execute \ + valgrind -q \ + $(foreach s,$(SUPPRESSIONS),--suppressions=$(s)) \ + --tool=memcheck --leak-check=full --trace-children=yes \ + --leak-resolution=high --num-callers=20 \ + --error-exitcode=1 \ + ./$* + +valgrind: $(check_PROGRAMS) + for t in $(filter-out $(VALGRIND_TESTS_DISABLE),$(check_PROGRAMS)); do \ + $(MAKE) $$t.valgrind; \ + done; + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/test/plugins/digestplugintest.c b/test/plugins/digestplugintest.c new file mode 100644 index 0000000..953eefd --- /dev/null +++ b/test/plugins/digestplugintest.c @@ -0,0 +1,322 @@ +/* vi: set et sw=4 ts=4 cino=t0,(0: */ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of gsignond + * + * Copyright (C) 2012-2013 Intel Corporation. + * + * Contact: Imran Zaman <imran.zaman@intel.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + +#include <check.h> +#include <stdlib.h> +#include "gsignond-digest-plugin.h" +#include "gsignond/gsignond-session-data.h" +#include "gsignond/gsignond-plugin-interface.h" +#include "gsignond/gsignond-error.h" +#include "gsignond/gsignond-log.h" +#include "gsignond/gsignond-config.h" +#include "common/gsignond-plugin-loader.h" + +static void check_plugin(GSignondPlugin* plugin) +{ + gchar* type; + gchar** mechanisms; + + fail_if(plugin == NULL); + + g_object_get(plugin, "type", &type, "mechanisms", &mechanisms, NULL); + + fail_unless(g_strcmp0(type, "digest") == 0); + fail_unless(g_strcmp0(mechanisms[0], "digest") == 0); + fail_unless(mechanisms[1] == NULL); + + g_free(type); + g_strfreev(mechanisms); +} + +START_TEST (test_digestplugin_create) +{ + gpointer plugin; + + plugin = g_object_new(GSIGNOND_TYPE_DIGEST_PLUGIN, NULL); + check_plugin(plugin); + g_object_unref(plugin); +} +END_TEST + +static void +response_callback( + GSignondPlugin* plugin, + GSignondSessionData* result, + gpointer user_data) +{ + GSignondSessionData** user_data_p = user_data; + *user_data_p = gsignond_dictionary_copy(result); +} + +static void +user_action_required_callback( + GSignondPlugin* plugin, + GSignondSignonuiData* ui_request, + gpointer user_data) +{ + GSignondSignonuiData** user_data_p = user_data; + *user_data_p = gsignond_dictionary_copy(ui_request); + gsignond_signonui_data_set_username(*user_data_p, "user1"); + gsignond_signonui_data_set_password(*user_data_p, "password1"); +} + +static void +error_callback( + GSignondPlugin* plugin, + GError* error, + gpointer user_data) +{ + GError** user_data_p = user_data; + *user_data_p = g_error_copy(error); +} + + +START_TEST (test_digestplugin_request) +{ + gpointer plugin; + gboolean query_res; + + plugin = g_object_new(GSIGNOND_TYPE_DIGEST_PLUGIN, NULL); + fail_if(plugin == NULL); + + GSignondSessionData* result = NULL; + GSignondSignonuiData* ui_action = NULL; + GError* error = NULL; + + g_signal_connect(plugin, "response-final", G_CALLBACK(response_callback), + &result); + g_signal_connect(plugin, "user-action-required", + G_CALLBACK(user_action_required_callback), &ui_action); + g_signal_connect(plugin, "error", G_CALLBACK(error_callback), &error); + + GSignondSessionData* data = gsignond_dictionary_new(); + + // set only username and password + gsignond_session_data_set_username(data, "user1"); + gsignond_session_data_set_secret(data, "password1"); + + gsignond_plugin_request_initial(plugin, data, "digest"); + fail_if(result != NULL); + fail_if(ui_action != NULL); + fail_if(error == NULL); + fail_unless(g_error_matches(error, GSIGNOND_ERROR, + GSIGNOND_ERROR_MISSING_DATA)); + g_error_free(error); + error = NULL; + + // set all the required stuff so that no ui-action is required + gsignond_session_data_set_realm(data, "realm1"); + gsignond_dictionary_set_string(data, "Algo", "md5-sess"); + gsignond_dictionary_set_string(data, "Nonce", + "abg10b1234ee1f0e8b11d0f600bfb0c093"); + gsignond_dictionary_set_string(data, "Method", "GET"); + gsignond_dictionary_set_string(data, "DigestUri", "/test/index.html"); + + gsignond_plugin_request_initial(plugin, data, "digest"); + fail_if(result == NULL); + fail_if(ui_action != NULL); + fail_if(error != NULL); + fail_if(g_strcmp0(gsignond_session_data_get_username(result), + "user1") != 0); + fail_if(gsignond_dictionary_get_string(result, "Response") == NULL); + fail_if(gsignond_dictionary_get_string(result, "CNonce") == NULL); + gsignond_dictionary_unref(result); + result = NULL; + + //remove secret so that ui action is required + gsignond_dictionary_remove (data, "Secret"); + gsignond_plugin_request_initial(plugin, data, "digest"); + fail_if(result != NULL); + fail_if(ui_action == NULL); + fail_if(error != NULL); + fail_if(g_strcmp0(gsignond_signonui_data_get_username(ui_action), + "user1") != 0); + fail_if(g_strcmp0(gsignond_signonui_data_get_password(ui_action), + "password1") != 0); + fail_if(gsignond_dictionary_get_string(ui_action, "Realm") == NULL); + fail_if(gsignond_dictionary_get_string(ui_action, "DigestUri") == NULL); + gsignond_signonui_data_get_query_username(ui_action, &query_res); + fail_if(query_res == FALSE); + gsignond_signonui_data_get_query_password(ui_action, &query_res); + fail_if(query_res == FALSE); + gsignond_dictionary_unref(ui_action); + ui_action = NULL; + + gsignond_dictionary_unref(data); + g_object_unref(plugin); +} +END_TEST + +START_TEST (test_digestplugin_user_action_finished) +{ + gpointer plugin; + + plugin = g_object_new(GSIGNOND_TYPE_DIGEST_PLUGIN, NULL); + fail_if(plugin == NULL); + + GSignondSessionData *result = NULL, *data = NULL; + GSignondSignonuiData *ui_action = NULL, *ui_data = NULL; + GError* error = NULL; + + g_signal_connect(plugin, "response-final", G_CALLBACK(response_callback), + &result); + g_signal_connect(plugin, "user-action-required", + G_CALLBACK(user_action_required_callback), &ui_action); + g_signal_connect(plugin, "error", G_CALLBACK(error_callback), &error); + + ui_data = gsignond_signonui_data_new(); + gsignond_signonui_data_set_query_error(ui_data, SIGNONUI_ERROR_NONE); + + //empty data + gsignond_plugin_user_action_finished(plugin, ui_data); + fail_if(result != NULL); + fail_if(ui_action != NULL); + fail_if(error == NULL); + fail_unless(g_error_matches(error, GSIGNOND_ERROR, + GSIGNOND_ERROR_USER_INTERACTION)); + g_error_free(error); + error = NULL; + + // user cancelled + gsignond_signonui_data_set_query_error(ui_data, SIGNONUI_ERROR_CANCELED); + gsignond_plugin_user_action_finished(plugin, ui_data); + fail_if(result != NULL); + fail_if(ui_action != NULL); + fail_if(error == NULL); + fail_unless(g_error_matches(error, GSIGNOND_ERROR, + GSIGNOND_ERROR_SESSION_CANCELED)); + g_error_free(error); + error = NULL; + + // error in ui request + gsignond_signonui_data_set_query_error(ui_data, SIGNONUI_ERROR_GENERAL); + gsignond_plugin_user_action_finished(plugin, ui_data); + fail_if(result != NULL); + fail_if(ui_action != NULL); + fail_if(error == NULL); + fail_unless(g_error_matches(error, GSIGNOND_ERROR, + GSIGNOND_ERROR_USER_INTERACTION)); + g_error_free(error); + error = NULL; + + // correct values but no session data + gsignond_signonui_data_set_username (ui_data, "user1"); + gsignond_signonui_data_set_password (ui_data, "password1"); + gsignond_signonui_data_set_query_error (ui_data, SIGNONUI_ERROR_NONE); + gsignond_plugin_user_action_finished (plugin, ui_data); + fail_if(result != NULL); + fail_if(ui_action != NULL); + fail_if(error == NULL); + fail_unless(g_error_matches(error, GSIGNOND_ERROR, + GSIGNOND_ERROR_USER_INTERACTION)); + g_error_free(error); + error = NULL; + + //correct values + data = gsignond_dictionary_new (); + gsignond_session_data_set_username (data, "user1"); + gsignond_session_data_set_realm (data, "realm1"); + gsignond_dictionary_set_string (data, "Algo", "md5-sess"); + gsignond_dictionary_set_string (data, "Nonce", + "abg10b1234ee1f0e8b11d0f600bfb0c093"); + gsignond_dictionary_set_string (data, "Method", "GET"); + gsignond_dictionary_set_string (data, "DigestUri", "/test/index.html"); + gsignond_plugin_request_initial (plugin, data, "digest"); + gsignond_dictionary_unref (data); data = NULL; + + gsignond_plugin_user_action_finished (plugin, ui_data); + fail_if (result == NULL); + fail_if (error != NULL); + fail_if(ui_action == NULL); + fail_if(g_strcmp0(gsignond_session_data_get_username(result), + "user1") != 0); + fail_if(gsignond_dictionary_get_string(result, "Response") == NULL); + fail_if(gsignond_dictionary_get_string(result, "CNonce") == NULL); + gsignond_dictionary_unref(result); + result = NULL; + gsignond_dictionary_unref(ui_action); + ui_action = NULL; + + gsignond_dictionary_unref (ui_data); + g_object_unref (plugin); +} +END_TEST + +START_TEST (test_digestplugin_refresh) +{ + gpointer plugin; + + plugin = g_object_new(GSIGNOND_TYPE_DIGEST_PLUGIN, NULL); + fail_if(plugin == NULL); + + GSignondSessionData* result = NULL; + GError* error = NULL; + + g_signal_connect(plugin, "refreshed", G_CALLBACK(response_callback), + &result); + g_signal_connect(plugin, "error", G_CALLBACK(error_callback), &error); + + GSignondSessionData* data = gsignond_dictionary_new(); + gsignond_plugin_refresh(plugin, data); + fail_if(result == NULL); + fail_if(error != NULL); + gsignond_dictionary_unref(result); + result = NULL; + + gsignond_dictionary_unref(data); + g_object_unref(plugin); +} +END_TEST + +Suite* digestplugin_suite (void) +{ + Suite *s = suite_create ("Digest plugin"); + + /* Core test case */ + TCase *tc_core = tcase_create ("Tests"); + tcase_add_test (tc_core, test_digestplugin_create); + tcase_add_test (tc_core, test_digestplugin_request); + tcase_add_test (tc_core, test_digestplugin_user_action_finished); + tcase_add_test (tc_core, test_digestplugin_refresh); + suite_add_tcase (s, tc_core); + return s; +} + +int main (void) +{ + int number_failed; + +#if !GLIB_CHECK_VERSION (2, 36, 0) + g_type_init (); +#endif + + Suite *s = digestplugin_suite(); + SRunner *sr = srunner_create(s); + srunner_run_all(sr, CK_NORMAL); + number_failed = srunner_ntests_failed(sr); + srunner_free(sr); + return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; +} + diff --git a/test/plugins/passwordplugintest.c b/test/plugins/passwordplugintest.c new file mode 100644 index 0000000..b7b3eab --- /dev/null +++ b/test/plugins/passwordplugintest.c @@ -0,0 +1,287 @@ +/* vi: set et sw=4 ts=4 cino=t0,(0: */ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of gsignond + * + * Copyright (C) 2012 Intel Corporation. + * + * Contact: Alexander Kanavin <alex.kanavin@gmail.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + +#include <check.h> +#include <stdlib.h> +#include "gsignond-password-plugin.h" +#include "gsignond/gsignond-session-data.h" +#include "gsignond/gsignond-signonui-data.h" +#include "gsignond/gsignond-plugin-interface.h" +#include "gsignond/gsignond-error.h" +#include "gsignond/gsignond-config.h" +#include "common/gsignond-plugin-loader.h" + + +static void check_plugin(GSignondPlugin* plugin) +{ + gchar* type; + gchar** mechanisms; + + fail_if(plugin == NULL); + + g_object_get(plugin, "type", &type, "mechanisms", &mechanisms, NULL); + + fail_unless(g_strcmp0(type, "password") == 0); + fail_unless(g_strcmp0(mechanisms[0], "password") == 0); + fail_unless(mechanisms[1] == NULL); + + g_free(type); + g_strfreev(mechanisms); +} + +START_TEST (test_passwordplugin_create) +{ + gpointer plugin; + + plugin = g_object_new(GSIGNOND_TYPE_PASSWORD_PLUGIN, NULL); + check_plugin(plugin); + g_object_unref(plugin); +} +END_TEST + +static void response_callback(GSignondPlugin* plugin, GSignondSessionData* result, + gpointer user_data) +{ + GSignondSessionData** user_data_p = user_data; + *user_data_p = gsignond_dictionary_copy(result); +} + +static void user_action_required_callback(GSignondPlugin* plugin, + GSignondSignonuiData* ui_request, + gpointer user_data) +{ + GSignondSignonuiData** user_data_p = user_data; + *user_data_p = gsignond_dictionary_copy(ui_request); +} + +static void error_callback(GSignondPlugin* plugin, GError* error, + gpointer user_data) +{ + GError** user_data_p = user_data; + *user_data_p = g_error_copy(error); +} + + +START_TEST (test_passwordplugin_request) +{ + gpointer plugin; + + plugin = g_object_new(GSIGNOND_TYPE_PASSWORD_PLUGIN, NULL); + fail_if(plugin == NULL); + + GSignondSessionData* result = NULL; + GSignondSignonuiData* ui_action = NULL; + GError* error = NULL; + gboolean bool_res; + + g_signal_connect(plugin, "response-final", G_CALLBACK(response_callback), &result); + g_signal_connect(plugin, "user-action-required", + G_CALLBACK(user_action_required_callback), &ui_action); + g_signal_connect(plugin, "error", G_CALLBACK(error_callback), &error); + + GSignondSessionData* data = gsignond_dictionary_new(); + + // username empty, password not empty + gsignond_session_data_set_secret(data, "megapassword"); + gsignond_plugin_request_initial(plugin, data, "password"); + fail_if(result == NULL); + fail_if(ui_action != NULL); + fail_if(error != NULL); + fail_if(gsignond_session_data_get_username(result) != NULL); + fail_if(g_strcmp0( + gsignond_session_data_get_secret(result), "megapassword") != 0); + gsignond_dictionary_unref(result); + result = NULL; + + // username and password not empty + gsignond_session_data_set_username(data, "megauser"); + gsignond_plugin_request_initial(plugin, data, "password"); + fail_if(result == NULL); + fail_if(ui_action != NULL); + fail_if(error != NULL); + fail_if(g_strcmp0( + gsignond_session_data_get_username(result), "megauser") != 0); + fail_if(g_strcmp0( + gsignond_session_data_get_secret(result), "megapassword") != 0); + gsignond_dictionary_unref(result); + result = NULL; + + //username and password empty + gsignond_dictionary_unref(data); + data = gsignond_dictionary_new(); + gsignond_plugin_request_initial(plugin, data, "password"); + fail_if(result != NULL); + fail_if(ui_action == NULL); + fail_if(error != NULL); + fail_if(gsignond_signonui_data_get_query_username(ui_action, &bool_res) == FALSE); + fail_if(bool_res == FALSE); + fail_if(gsignond_signonui_data_get_query_password(ui_action, &bool_res) == FALSE); + fail_if(bool_res == FALSE); + gsignond_dictionary_unref(ui_action); + ui_action = NULL; + + //username not empty, password empty + gsignond_session_data_set_username(data, "megauser"); + gsignond_plugin_request_initial(plugin, data, "password"); + fail_if(result != NULL); + fail_if(ui_action == NULL); + fail_if(error != NULL); + fail_if(gsignond_signonui_data_get_query_username(ui_action, &bool_res) == FALSE); + fail_if(bool_res == TRUE); + fail_if(gsignond_signonui_data_get_query_password(ui_action, &bool_res) == FALSE); + fail_if(bool_res == FALSE); + gsignond_dictionary_unref(ui_action); + ui_action = NULL; + + gsignond_dictionary_unref(data); + g_object_unref(plugin); +} +END_TEST + +START_TEST (test_passwordplugin_user_action_finished) +{ + gpointer plugin; + + plugin = g_object_new(GSIGNOND_TYPE_PASSWORD_PLUGIN, NULL); + fail_if(plugin == NULL); + + GSignondSessionData* result = NULL; + GSignondSignonuiData* ui_action = NULL; + GError* error = NULL; + + g_signal_connect(plugin, "response-final", G_CALLBACK(response_callback), &result); + g_signal_connect(plugin, "user-action-required", + G_CALLBACK(user_action_required_callback), &ui_action); + g_signal_connect(plugin, "error", G_CALLBACK(error_callback), &error); + + GSignondSignonuiData* data = gsignond_dictionary_new(); + + //empty data + gsignond_plugin_user_action_finished(plugin, data); + fail_if(result != NULL); + fail_if(ui_action != NULL); + fail_if(error == NULL); + fail_unless(g_error_matches(error, GSIGNOND_ERROR, + GSIGNOND_ERROR_USER_INTERACTION)); + g_error_free(error); + error = NULL; + + // correct values + gsignond_signonui_data_set_username(data, "megauser"); + gsignond_signonui_data_set_password(data, "megapassword"); + gsignond_signonui_data_set_query_error(data, SIGNONUI_ERROR_NONE); + gsignond_plugin_user_action_finished(plugin, data); + fail_if(result == NULL); + fail_if(ui_action != NULL); + fail_if(error != NULL); + fail_if(g_strcmp0( + gsignond_session_data_get_username(result), "megauser") != 0); + fail_if(g_strcmp0( + gsignond_session_data_get_secret(result), "megapassword") != 0); + gsignond_dictionary_unref(result); + result = NULL; + + // user canceled + gsignond_signonui_data_set_query_error(data, SIGNONUI_ERROR_CANCELED); + gsignond_plugin_user_action_finished(plugin, data); + fail_if(result != NULL); + fail_if(ui_action != NULL); + fail_if(error == NULL); + fail_unless(g_error_matches(error, GSIGNOND_ERROR, + GSIGNOND_ERROR_SESSION_CANCELED)); + g_error_free(error); + error = NULL; + + // error in ui request + gsignond_signonui_data_set_query_error(data, SIGNONUI_ERROR_GENERAL); + gsignond_plugin_user_action_finished(plugin, data); + fail_if(result != NULL); + fail_if(ui_action != NULL); + fail_if(error == NULL); + fail_unless(g_error_matches(error, GSIGNOND_ERROR, + GSIGNOND_ERROR_USER_INTERACTION)); + g_error_free(error); + error = NULL; + + gsignond_dictionary_unref(data); + g_object_unref(plugin); +} +END_TEST + +START_TEST (test_passwordplugin_refresh) +{ + gpointer plugin; + + plugin = g_object_new(GSIGNOND_TYPE_PASSWORD_PLUGIN, NULL); + fail_if(plugin == NULL); + + GSignondSessionData* result = NULL; + GError* error = NULL; + + g_signal_connect(plugin, "refreshed", G_CALLBACK(response_callback), &result); + g_signal_connect(plugin, "error", G_CALLBACK(error_callback), &error); + + GSignondSessionData* data = gsignond_dictionary_new(); + gsignond_plugin_refresh(plugin, data); + fail_if(result == NULL); + fail_if(error != NULL); + gsignond_dictionary_unref(result); + result = NULL; + + gsignond_dictionary_unref(data); + g_object_unref(plugin); +} +END_TEST + +Suite* passwordplugin_suite (void) +{ + Suite *s = suite_create ("Password plugin"); + + /* Core test case */ + TCase *tc_core = tcase_create ("Tests"); + tcase_add_test (tc_core, test_passwordplugin_create); + tcase_add_test (tc_core, test_passwordplugin_request); + tcase_add_test (tc_core, test_passwordplugin_user_action_finished); + tcase_add_test (tc_core, test_passwordplugin_refresh); + suite_add_tcase (s, tc_core); + return s; +} + +int main (void) +{ + int number_failed; + +#if !GLIB_CHECK_VERSION (2, 36, 0) + g_type_init (); +#endif + + Suite *s = passwordplugin_suite(); + SRunner *sr = srunner_create(s); + srunner_run_all(sr, CK_NORMAL); + number_failed = srunner_ntests_failed(sr); + srunner_free(sr); + return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; +} + diff --git a/test/plugins/pluginproxytest.c b/test/plugins/pluginproxytest.c new file mode 100644 index 0000000..998abfe --- /dev/null +++ b/test/plugins/pluginproxytest.c @@ -0,0 +1,664 @@ +/* vi: set et sw=4 ts=4 cino=t0,(0: */ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of gsignond + * + * Copyright (C) 2012 Intel Corporation. + * + * Contact: Alexander Kanavin <alex.kanavin@gmail.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + +#include <check.h> +#include <stdlib.h> +#include <glib-object.h> +#include <string.h> + +#include "gsignond-plugin-proxy.h" +#include "gsignond-plugin-proxy-factory.h" +#include "gsignond-plugin-remote.h" +#include "gsignond/gsignond-error.h" +#include "gsignond/gsignond-log.h" +#include "common/gsignond-plugin-loader.h" + +static GMainLoop *main_loop = NULL; + +static void +_stop_mainloop () +{ + if (main_loop) { + g_main_loop_quit (main_loop); + } +} + +static void +_run_mainloop () +{ + g_main_loop_run (main_loop); +} + + +static void +_setup () +{ +#if !GLIB_CHECK_VERSION (2, 36, 0) + g_type_init (); +#endif + if (main_loop == NULL) { + main_loop = g_main_loop_new (NULL, FALSE); + } +} + +static void +_teardown () +{ + if (main_loop) { + _stop_mainloop (); + g_main_loop_unref (main_loop); + main_loop = NULL; + } +} + +struct _GSignondAuthSession +{ + GObject parent; + +}; + +struct _GSignondAuthSessionClass +{ + GObjectClass parent_class; +}; + +G_DEFINE_TYPE (GSignondAuthSession, gsignond_auth_session, G_TYPE_OBJECT); + +static void +gsignond_auth_session_init ( + GSignondAuthSession *self) +{ +} + +static void +gsignond_auth_session_class_init ( + GSignondAuthSessionClass *klass) +{ +// GObjectClass *object_class = G_OBJECT_CLASS (klass); +} + +gboolean testing_proxy_process = FALSE; +gboolean testing_proxy_process_cancel = FALSE; +gboolean testing_proxy_process_queue = FALSE; +gint proxy_process_queue_results = 0; +gboolean testing_proxy_process_queue_cancel = FALSE; +gint proxy_process_queue_cancel_results = 0; +gboolean testing_proxy_process_cancel_triggered = FALSE; + +void +gsignond_auth_session_notify_process_result ( + GSignondAuthSession *iface, + GSignondSessionData *result, + gpointer user_data) +{ + int i; + + DBG (""); + + if (testing_proxy_process) { + testing_proxy_process = FALSE; + fail_if(g_strcmp0( + gsignond_session_data_get_username(result), "megauser") != 0); + fail_if(g_strcmp0( + gsignond_session_data_get_secret(result), "megapassword") != 0); + _stop_mainloop (); + + } else if (testing_proxy_process_queue) { + proxy_process_queue_results++; + if (proxy_process_queue_results == 1) { + GSignondPluginProxy* proxy = GSIGNOND_PLUGIN_PROXY(user_data); + GSignondSessionData* data = gsignond_dictionary_new(); + fail_if(data == NULL); + gsignond_session_data_set_username(data, "megauser"); + gsignond_session_data_set_secret(data, "megapassword"); + + gsignond_plugin_proxy_process(proxy, iface, data, "password", + proxy); + + gsignond_plugin_proxy_process(proxy, iface, data, "password", + proxy); + + gsignond_dictionary_unref(data); + } + if (proxy_process_queue_results == 3) { + testing_proxy_process_queue = FALSE; + _stop_mainloop (); + } + } else if (testing_proxy_process_queue_cancel) { + proxy_process_queue_cancel_results++; + if (proxy_process_queue_cancel_results == 1) { + GSignondPluginProxy* proxy = GSIGNOND_PLUGIN_PROXY(user_data); + GSignondSessionData* data = gsignond_dictionary_new(); + fail_if(data == NULL); + + for (i = 0; i < 9; i++) { + gsignond_plugin_proxy_process(proxy, iface, data, "mech1", + proxy); + } + gsignond_dictionary_unref(data); + } + if (proxy_process_queue_cancel_results == 10) { + testing_proxy_process_queue_cancel = FALSE; + _stop_mainloop (); + } + } else + fail_if(TRUE); +} + +void +gsignond_auth_session_notify_process_error ( + GSignondAuthSession *iface, + const GError *error, + gpointer user_data) +{ + DBG (""); + + if (testing_proxy_process_cancel) { + fail_if(error->code != GSIGNOND_ERROR_SESSION_CANCELED); + testing_proxy_process_cancel = FALSE; + _stop_mainloop (); + } else if (testing_proxy_process_queue_cancel) { + fail_if(error->code != GSIGNOND_ERROR_SESSION_CANCELED); + proxy_process_queue_cancel_results++; + } + +} + +void +gsignond_auth_session_notify_store ( + GSignondAuthSession *self, + GSignondSessionData *session_data) +{ + DBG (""); + fail_if(TRUE); +} + +void +gsignond_auth_session_notify_user_action_required ( + GSignondAuthSession *self, + GSignondSignonuiData *session_data) +{ + DBG (""); + fail_if(TRUE); +} + +void +gsignond_auth_session_notify_refreshed ( + GSignondAuthSession *self, + GSignondSignonuiData *session_data) +{ + DBG (""); + fail_if(TRUE); +} + +void +gsignond_auth_session_notify_state_changed ( + GSignondAuthSession *self, + gint state, + const gchar *message, + gpointer user_data) +{ + if (testing_proxy_process_cancel && + !testing_proxy_process_cancel_triggered && + state == GSIGNOND_PLUGIN_STATE_WAITING) { + GSignondPluginProxy* proxy = GSIGNOND_PLUGIN_PROXY(user_data); + gsignond_plugin_proxy_cancel(proxy, self); + testing_proxy_process_cancel_triggered = TRUE; + } else if (testing_proxy_process_queue_cancel && + state == GSIGNOND_PLUGIN_STATE_WAITING && + proxy_process_queue_cancel_results == 5) { + GSignondPluginProxy* proxy = GSIGNOND_PLUGIN_PROXY(user_data); + gsignond_plugin_proxy_cancel(proxy, self); + } +} + +static void +check_plugin_proxy( + GSignondPluginProxy* proxy, + gchar *type, + gchar **mechanisms) +{ + gchar* ptype = NULL; + gchar** pmechanisms = NULL; + gint i = 0; + + fail_if(proxy == NULL); + + g_object_get(proxy, "type", &ptype, "mechanisms", &pmechanisms, NULL); + fail_unless(g_strcmp0(ptype, type) == 0); + g_free(ptype); + + guint len = g_strv_length (pmechanisms); + fail_unless (len == g_strv_length (mechanisms)); + + for (i=0; i<len; i++) { + fail_unless(g_strcmp0(pmechanisms[i], mechanisms[i]) == 0); + } + if (pmechanisms) { + g_strfreev(pmechanisms); + } +} + +START_TEST (test_pluginproxy_create) +{ + DBG("test_pluginproxy_create\n"); + + gchar *pass_mechs[] = {"password", NULL}; + + GSignondConfig* config = gsignond_config_new(); + fail_if(config == NULL); + + GSignondPluginProxy* proxy2 = gsignond_plugin_proxy_new(config, + "absentplugin"); + fail_if (proxy2 != NULL); + + GSignondPluginProxy* proxy = gsignond_plugin_proxy_new(config, "password"); + fail_if (proxy == NULL); + check_plugin_proxy(proxy, "password", pass_mechs); + + g_object_unref(proxy); + g_object_unref(config); +} +END_TEST + +START_TEST (test_pluginproxy_process) +{ + DBG("test_pluginproxy_process\n"); + + GSignondConfig* config = gsignond_config_new(); + fail_if(config == NULL); + + GSignondPluginProxy* proxy = gsignond_plugin_proxy_new(config, "password"); + fail_if (proxy == NULL); + + GSignondSessionData* data = gsignond_dictionary_new(); + fail_if(data == NULL); + gsignond_session_data_set_username(data, "megauser"); + gsignond_session_data_set_secret(data, "megapassword"); + + GSignondAuthSession* test_auth_session = + g_object_new(gsignond_auth_session_get_type(), NULL); + + testing_proxy_process = TRUE; + + gsignond_plugin_proxy_process(proxy, test_auth_session, data, "password", + proxy); + + _run_mainloop (); + + fail_if(testing_proxy_process); + + gsignond_dictionary_unref(data); + g_object_unref(test_auth_session); + g_object_unref(proxy); + g_object_unref(config); +} +END_TEST + +START_TEST (test_pluginproxy_process_cancel) +{ + DBG("test_pluginproxy_process_cancel\n"); + + GSignondConfig* config = gsignond_config_new(); + fail_if(config == NULL); + + GSignondPluginProxy* proxy = gsignond_plugin_proxy_new(config, "ssotest"); + fail_if (proxy == NULL); + + GSignondSessionData* data = gsignond_dictionary_new(); + fail_if(data == NULL); + + GSignondAuthSession* test_auth_session = g_object_new( + gsignond_auth_session_get_type(), NULL); + + testing_proxy_process_cancel = TRUE; + + gsignond_plugin_proxy_process(proxy, test_auth_session, data, "mech1", + proxy); + + _run_mainloop (); + + fail_if(testing_proxy_process_cancel); + + gsignond_dictionary_unref(data); + g_object_unref(test_auth_session); + g_object_unref(proxy); + g_object_unref(config); +} +END_TEST + +START_TEST (test_pluginproxy_process_queue) +{ + DBG("test_pluginproxy_process_queue\n"); + + GSignondConfig* config = gsignond_config_new(); + fail_if(config == NULL); + + GSignondPluginProxy* proxy = gsignond_plugin_proxy_new(config, "password"); + fail_if (proxy == NULL); + + GSignondSessionData* data = gsignond_dictionary_new(); + fail_if(data == NULL); + gsignond_session_data_set_username(data, "megauser"); + gsignond_session_data_set_secret(data, "megapassword"); + + GSignondAuthSession* test_auth_session = g_object_new( + gsignond_auth_session_get_type(), NULL); + + testing_proxy_process_queue = TRUE; + + gsignond_plugin_proxy_process(proxy, test_auth_session, data, "password", + proxy); + _run_mainloop (); + + fail_if(testing_proxy_process_queue); + fail_if(proxy_process_queue_results < 3); + + gsignond_dictionary_unref(data); + g_object_unref(test_auth_session); + g_object_unref(proxy); + g_object_unref(config); +} +END_TEST + +START_TEST (test_pluginproxy_process_queue_cancel) +{ + GSignondConfig* config = gsignond_config_new(); + fail_if(config == NULL); + + GSignondPluginProxy* proxy = gsignond_plugin_proxy_new(config, "ssotest"); + fail_if (proxy == NULL); + + GSignondSessionData* data = gsignond_dictionary_new(); + fail_if(data == NULL); + + GSignondAuthSession* test_auth_session = g_object_new( + gsignond_auth_session_get_type(), NULL); + + testing_proxy_process_queue_cancel = TRUE; + + gsignond_plugin_proxy_process(proxy, test_auth_session, data, "mech1", + proxy); + + _run_mainloop (); + + fail_if(testing_proxy_process_queue_cancel); + fail_if(proxy_process_queue_cancel_results != 10); + + gsignond_dictionary_unref(data); + g_object_unref(test_auth_session); + g_object_unref(proxy); + g_object_unref(config); +} +END_TEST + +START_TEST (test_pluginproxyfactory_methods_and_mechanisms) +{ + DBG(""); + GSignondConfig* config = gsignond_config_new(); + fail_if(config == NULL); + + GSignondPluginProxyFactory* factory = gsignond_plugin_proxy_factory_new( + config); + fail_if(factory == NULL); + const gchar *pass_method = NULL; + const gchar** pmethods = NULL; + + const gchar** methods = gsignond_plugin_proxy_factory_get_plugin_types( + factory); + fail_if(methods == NULL); + pmethods = methods; + while (pmethods[0] != NULL) { + DBG ("Method %s", pmethods[0]); + if (g_strcmp0 (pmethods[0], "password") == 0) { + pass_method = pmethods[0]; + } + pmethods++; + } + const gchar** mechanisms = + gsignond_plugin_proxy_factory_get_plugin_mechanisms(factory, + pass_method); + fail_if(mechanisms == NULL); + fail_if(strcmp(mechanisms[0], "password") != 0); + fail_if(mechanisms[1] != NULL); + + g_object_unref(factory); + g_object_unref(config); +} +END_TEST + +START_TEST (test_pluginproxyfactory_get) +{ + DBG(""); + gchar *pass_mechs[] = {"password", NULL}; + GSignondConfig* config = gsignond_config_new(); + fail_if(config == NULL); + + GSignondPluginProxyFactory* factory = gsignond_plugin_proxy_factory_new( + config); + fail_if(factory == NULL); + + fail_if(gsignond_plugin_proxy_factory_get_plugin(factory, "absentplugin") + != NULL); + + GSignondPluginProxy* proxy1 = gsignond_plugin_proxy_factory_get_plugin( + factory, "password"); + GSignondPluginProxy* proxy2 = gsignond_plugin_proxy_factory_get_plugin( + factory, "password"); + GSignondPluginProxy* proxy3 = gsignond_plugin_proxy_factory_get_plugin( + factory, "password"); + fail_if(proxy1 == NULL || proxy2 == NULL || proxy3 == NULL); + fail_if(proxy1 != proxy3 || proxy1 != proxy2); + check_plugin_proxy(proxy1, "password", pass_mechs); + + g_object_unref(proxy1); + g_object_unref(proxy2); + g_object_unref(proxy3); + + g_object_unref(factory); + g_object_unref(config); +} +END_TEST + +START_TEST (test_pluginproxyfactory_add) +{ + DBG(""); + GSignondConfig* config = gsignond_config_new(); + fail_if(config == NULL); + + GSignondPluginProxyFactory* factory = gsignond_plugin_proxy_factory_new( + config); + fail_if(factory == NULL); + + GSignondPluginProxy* proxy = gsignond_plugin_proxy_new(config, "password"); + fail_if (proxy == NULL); + fail_if(gsignond_plugin_proxy_factory_add_plugin(factory, proxy) == FALSE); + fail_if(gsignond_plugin_proxy_factory_add_plugin(factory, proxy) == TRUE); + fail_if(gsignond_plugin_proxy_factory_get_plugin(factory, "password") + != proxy); + + g_object_unref(proxy); + g_object_unref(factory); + g_object_unref(config); +} +END_TEST + +typedef struct { + GSignondPluginProxyFactory *factory; + GSignondPluginProxy *proxy; +} ProxyTimeoutData; + +static gboolean +_validate_new_proxy(gpointer userdata) +{ + ProxyTimeoutData *data = (ProxyTimeoutData *)userdata; + fail_if (data == NULL); + + GSignondPluginProxy *proxy = gsignond_plugin_proxy_factory_get_plugin (data->factory, "ssotest"); + fail_if (proxy == NULL); + + fail_if (proxy == data->proxy, "expected new proxy object, but got cached object"); + g_object_unref(proxy); + + g_free (userdata); + + _stop_mainloop(); + + return FALSE; +} + +static gboolean +_validate_cached_proxy (gpointer userdata) +{ + ProxyTimeoutData *data = (ProxyTimeoutData *)userdata; + fail_if (data == NULL); + + GSignondPluginProxy *proxy = gsignond_plugin_proxy_factory_get_plugin (data->factory, "ssotest"); + fail_if (proxy == NULL); + + fail_unless (proxy == data->proxy, "expected cached proxy object, but got new object"); + + g_object_unref (proxy); + + g_timeout_add (2200, _validate_new_proxy, userdata); + + return FALSE; +} + +START_TEST (test_pluginproxyfactory_proxy_timeout) +{ + DBG("test_pluginproxyfactory_proxy_timeout\n"); + GSignondPluginProxyFactory *factory = NULL; + GSignondPluginProxy *proxy1 = NULL, *proxy2 = NULL; + GSignondConfig *config = NULL; + + /* CASE 1: proxy timeout disabled */ + g_setenv ("SSO_PLUGIN_TIMEOUT", "0", TRUE); + + config = gsignond_config_new(); + fail_if(config == NULL); + + factory = gsignond_plugin_proxy_factory_new ( config); + fail_if (factory == NULL); + + proxy1 = gsignond_plugin_proxy_factory_get_plugin (factory, "ssotest"); + fail_if (proxy1 == NULL); + g_object_unref (proxy1); + + proxy2 = gsignond_plugin_proxy_factory_get_plugin (factory, "ssotest"); + fail_if (proxy2 == NULL); + + fail_unless (proxy1 == proxy2, "got new plugin proxy object, " + "where expected cached object(%p,%p)", + proxy1, proxy2); + g_object_unref (proxy2); + + g_object_unref (config); + g_object_unref (factory); + + /* CASE 2: proxy timeout enbled */ + g_setenv ("SSO_PLUGIN_TIMEOUT", "1", TRUE); + + config = gsignond_config_new(); + fail_if(config == NULL); + + factory = gsignond_plugin_proxy_factory_new (config); + fail_if (factory == NULL); + + proxy1 = gsignond_plugin_proxy_factory_get_plugin (factory, "ssotest"); + fail_if (proxy1 == NULL); + g_object_unref (proxy1); + + ProxyTimeoutData *data = g_new0(ProxyTimeoutData, 1); + data->factory = factory; + data->proxy = proxy1; + g_timeout_add_seconds (2, _validate_new_proxy, (gpointer)data); + + _run_mainloop (); + + g_object_unref(config); + g_object_unref(factory); + + /* CASE 3: proxy timeout enable - request recently closed plugin */ + g_setenv ("SSO_PLUGIN_TIMEOUT", "2", TRUE); + config = gsignond_config_new (); + fail_if (config == NULL); + + factory = gsignond_plugin_proxy_factory_new(config); + fail_if (factory == NULL); + + proxy1 = gsignond_plugin_proxy_factory_get_plugin(factory, "ssotest"); + fail_if (proxy1 == NULL); + g_object_unref (proxy1); + + ProxyTimeoutData *data1 = g_new0(ProxyTimeoutData, 1); + data1->factory = factory; + data1->proxy = proxy1; + + g_timeout_add_seconds (1, _validate_cached_proxy, (gpointer)data1); + + _run_mainloop(); + + g_object_unref(config); + g_object_unref(factory); +} +END_TEST + +Suite* pluginproxy_suite (void) +{ + Suite *s = suite_create ("Plugin proxy"); + + /* Core test case */ + TCase *tc_core = tcase_create ("Tests"); + tcase_add_checked_fixture (tc_core, _setup, _teardown); + + tcase_set_timeout (tc_core, 10); + tcase_add_test (tc_core, test_pluginproxy_create); + tcase_add_test (tc_core, test_pluginproxy_process); + tcase_add_test (tc_core, test_pluginproxy_process_cancel); + tcase_add_test (tc_core, test_pluginproxy_process_queue); + tcase_add_test (tc_core, test_pluginproxy_process_queue_cancel); + tcase_add_test (tc_core, test_pluginproxyfactory_methods_and_mechanisms); + tcase_add_test (tc_core, test_pluginproxyfactory_get); + tcase_add_test (tc_core, test_pluginproxyfactory_add); + tcase_add_test (tc_core, test_pluginproxyfactory_proxy_timeout); + + suite_add_tcase (s, tc_core); + return s; +} + +int main (void) +{ + int number_failed; + + Suite *s = pluginproxy_suite(); + SRunner *sr = srunner_create(s); + srunner_run_all(sr, CK_NORMAL); + number_failed = srunner_ntests_failed(sr); + srunner_free(sr); + return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; +} + + diff --git a/test/plugins/pluginremotetest.c b/test/plugins/pluginremotetest.c new file mode 100644 index 0000000..32fc2cb --- /dev/null +++ b/test/plugins/pluginremotetest.c @@ -0,0 +1,589 @@ +/* vi: set et sw=4 ts=4 cino=t0,(0: */ +/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of gsignond + * + * Copyright (C) 2012 Intel Corporation. + * + * Contact: Alexander Kanavin <alex.kanavin@gmail.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + +#include <check.h> +#include <stdlib.h> +#include <errno.h> + +#include "daemon/gsignond-types.h" +#include "gsignond-plugin-remote-private.h" +#include "gsignond-plugin-remote.h" +#include "plugind/gsignond-plugin-daemon.h" +#include <gsignond/gsignond-plugin-interface.h> +#include <gsignond/gsignond-error.h> +#include <gsignond/gsignond-config.h> +#include <gsignond/gsignond-log.h> + +static GMainLoop *main_loop = NULL; +guint child_watch_id = 0; + +struct _GSignondAuthSession +{ + GObject parent; +}; + +struct _GSignondAuthSessionClass +{ + GObjectClass parent_class; +}; + +G_DEFINE_TYPE (GSignondAuthSession, gsignond_auth_session, G_TYPE_OBJECT); + +static void +_stop_mainloop () +{ + if (main_loop) { + g_main_loop_quit (main_loop); + } +} + +static void +_run_mainloop () +{ + g_main_loop_run (main_loop); +} + +static void +_setup () +{ +#if !GLIB_CHECK_VERSION (2, 36, 0) + g_type_init (); +#endif + + if (main_loop == NULL) { + main_loop = g_main_loop_new (NULL, FALSE); + } +} + +static void +_teardown () +{ + if (main_loop) { + _stop_mainloop (); + g_main_loop_unref (main_loop); + main_loop = NULL; + } +} + +static gboolean +_timeout_quit_loop (gpointer data) +{ + _stop_mainloop (); + return FALSE; +} + +static void +_run_loop_with_timeout (guint timeout) +{ + g_timeout_add_seconds (timeout, _timeout_quit_loop, NULL); + _run_mainloop (); +} + +static void +gsignond_auth_session_init ( + GSignondAuthSession *self) +{ +} + +static void +gsignond_auth_session_class_init ( + GSignondAuthSessionClass *klass) +{ +} + +void +gsignond_auth_session_notify_process_result ( + GSignondAuthSession *iface, + GSignondSessionData *result, + gpointer user_data) +{ +} + +void +gsignond_auth_session_notify_process_error ( + GSignondAuthSession *iface, + const GError *error, + gpointer user_data) +{ +} + +void +gsignond_auth_session_notify_store ( + GSignondAuthSession *self, + GSignondSessionData *session_data) +{ +} + +void +gsignond_auth_session_notify_user_action_required ( + GSignondAuthSession *self, + GSignondSignonuiData *session_data) +{ +} + +void +gsignond_auth_session_notify_refreshed ( + GSignondAuthSession *self, + GSignondSignonuiData *session_data) +{ +} + +void +gsignond_auth_session_notify_state_changed ( + GSignondAuthSession *self, + gint state, + const gchar *message, + gpointer user_data) +{ +} + +static void +check_plugin( + GSignondPlugin* plugin) +{ + gchar* type; + gchar** mechanisms; + + fail_if(plugin == NULL); + + g_object_get(plugin, "type", &type, "mechanisms", &mechanisms, NULL); + + fail_unless(g_strcmp0(type, "password") == 0); + fail_unless(g_strcmp0(mechanisms[0], "password") == 0); + fail_unless(mechanisms[1] == NULL); + + g_free(type); + g_strfreev(mechanisms); +} + +static void +response_callback( + GSignondPlugin* plugin, + GSignondSessionData* result, + gpointer user_data) +{ + DBG (""); + GSignondSessionData** user_data_p = user_data; + *user_data_p = gsignond_dictionary_copy(result); + _stop_mainloop (); +} + +static void +user_action_required_callback( + GSignondPlugin* plugin, + GSignondSignonuiData* ui_request, + gpointer user_data) +{ + DBG (""); + GSignondSignonuiData** user_data_p = user_data; + *user_data_p = gsignond_dictionary_copy(ui_request); + _stop_mainloop (); +} + +static void +error_callback( + GSignondPlugin* plugin, + GError* error, + gpointer user_data) +{ + DBG (""); + GError** user_data_p = user_data; + *user_data_p = g_error_copy(error); + _stop_mainloop (); +} + +START_TEST (test_pluginremote_create) +{ + DBG (""); + GSignondPlugin *plugin = NULL; + const gchar *plugin_type = "password"; + + GSignondConfig* config = gsignond_config_new (); + fail_if (config == NULL); + + plugin = GSIGNOND_PLUGIN (gsignond_plugin_remote_new(config, plugin_type)); + g_object_unref (config); + + check_plugin (plugin); + g_object_unref (plugin); +} +END_TEST + +START_TEST (test_pluginremote_plugind_create) +{ + DBG (""); + GSignondPlugin *plugin = NULL; + const gchar *plugin_type = "password"; + GSignondPluginRemotePrivate* priv = NULL; + + GSignondConfig* config = gsignond_config_new (); + fail_if (config == NULL); + + plugin = GSIGNOND_PLUGIN (gsignond_plugin_remote_new(config, plugin_type)); + g_object_unref (config); + + fail_if (plugin == NULL); + priv = (GSignondPluginRemotePrivate *)GSIGNOND_PLUGIN_REMOTE (plugin)->priv; + + fail_unless (priv->cpid > 0); + fail_unless (kill (priv->cpid, 0) == 0); + + check_plugin (plugin); + + g_object_unref (plugin); +} +END_TEST + +START_TEST (test_pluginremote_plugind_unref) +{ + DBG (""); + GSignondPlugin *plugin = NULL; + const gchar *plugin_type = "password"; + GSignondPluginRemotePrivate* priv = NULL; + gint cpid = 0; + + GSignondConfig* config = gsignond_config_new (); + fail_if (config == NULL); + + plugin = GSIGNOND_PLUGIN (gsignond_plugin_remote_new(config, plugin_type)); + fail_if (plugin == NULL); + priv = (GSignondPluginRemotePrivate *)GSIGNOND_PLUGIN_REMOTE (plugin)->priv; + + fail_unless (priv->cpid > 0); + fail_unless (kill (priv->cpid, 0) == 0); + cpid = priv->cpid; + + g_object_unref (plugin); + g_object_unref (config); + + fail_unless (kill (cpid, 0) != 0); +} +END_TEST + +START_TEST (test_pluginremote_plugind_kill) +{ + DBG (""); + GSignondPlugin *plugin = NULL; + const gchar *plugin_type = "password"; + GSignondPluginRemotePrivate* priv = NULL; + gint cpid = 0; + + GSignondConfig* config = gsignond_config_new (); + fail_if (config == NULL); + + plugin = GSIGNOND_PLUGIN (gsignond_plugin_remote_new(config, plugin_type)); + fail_if (plugin == NULL); + priv = (GSignondPluginRemotePrivate *)GSIGNOND_PLUGIN_REMOTE (plugin)->priv; + + fail_unless (priv->cpid > 0); + fail_unless (kill (priv->cpid, 0) == 0); + cpid = priv->cpid; + check_plugin (plugin); + + kill (priv->cpid, SIGTERM); + + _run_loop_with_timeout (1); + + fail_unless (kill (cpid, 0) != 0); + + g_object_unref (plugin); + g_object_unref (config); +} +END_TEST + +START_TEST (test_pluginremote_request) +{ + DBG (""); + GSignondPlugin *plugin = NULL; + const gchar *plugin_type = "password"; + + GSignondConfig* config = gsignond_config_new (); + fail_if(config == NULL); + + plugin = GSIGNOND_PLUGIN (gsignond_plugin_remote_new(config, plugin_type)); + fail_if(plugin == NULL); + + GSignondSessionData* result = NULL; + GSignondSignonuiData* ui_action = NULL; + GError* error = NULL; + gboolean bool_res; + + g_signal_connect(plugin, "response-final", G_CALLBACK(response_callback), + &result); + g_signal_connect(plugin, "user-action-required", + G_CALLBACK(user_action_required_callback), &ui_action); + g_signal_connect(plugin, "error", G_CALLBACK(error_callback), &error); + + GSignondSessionData* data = gsignond_dictionary_new (); + + // username empty, password not empty + gsignond_session_data_set_secret(data, "megapassword"); + gsignond_plugin_request_initial(plugin, data, "password"); + _run_mainloop (); + + fail_if(result == NULL); + fail_if(ui_action != NULL); + fail_if(error != NULL); + fail_if(gsignond_session_data_get_username(result) != NULL); + fail_if(g_strcmp0( + gsignond_session_data_get_secret(result), "megapassword") != 0); + gsignond_dictionary_unref(result); + result = NULL; + + // username and password not empty + gsignond_session_data_set_username(data, "megauser"); + gsignond_plugin_request_initial(plugin, data, "password"); + _run_mainloop (); + + fail_if(result == NULL); + fail_if(ui_action != NULL); + fail_if(error != NULL); + fail_if(g_strcmp0( + gsignond_session_data_get_username(result), "megauser") != 0); + fail_if(g_strcmp0( + gsignond_session_data_get_secret(result), "megapassword") != 0); + gsignond_dictionary_unref(result); + result = NULL; + + //username and password empty + gsignond_dictionary_unref(data); + data = gsignond_dictionary_new(); + gsignond_plugin_request_initial(plugin, data, "password"); + _run_mainloop (); + + fail_if(result != NULL); + fail_if(ui_action == NULL); + fail_if(error != NULL); + fail_if(gsignond_signonui_data_get_query_username(ui_action, &bool_res) + == FALSE); + fail_if(bool_res == FALSE); + fail_if(gsignond_signonui_data_get_query_password(ui_action, &bool_res) + == FALSE); + fail_if(bool_res == FALSE); + gsignond_dictionary_unref(ui_action); + ui_action = NULL; + + //username not empty, password empty + gsignond_session_data_set_username(data, "megauser"); + gsignond_plugin_request_initial(plugin, data, "password"); + _run_mainloop (); + + fail_if(result != NULL); + fail_if(ui_action == NULL); + fail_if(error != NULL); + fail_if(gsignond_signonui_data_get_query_username(ui_action, &bool_res) + == FALSE); + fail_if(bool_res == TRUE); + fail_if(gsignond_signonui_data_get_query_password(ui_action, &bool_res) + == FALSE); + fail_if(bool_res == FALSE); + gsignond_dictionary_unref(ui_action); + ui_action = NULL; + + gsignond_dictionary_unref(data); + + g_object_unref(config); + g_object_unref(plugin); +} +END_TEST + +START_TEST (test_pluginremote_user_action_finished) +{ + DBG (""); + GSignondPlugin *plugin = NULL; + const gchar *plugin_type = "password"; + + GSignondConfig* config = gsignond_config_new (); + fail_if(config == NULL); + + plugin = GSIGNOND_PLUGIN (gsignond_plugin_remote_new(config, plugin_type)); + fail_if(plugin == NULL); + + GSignondSessionData* result = NULL; + GSignondSignonuiData* ui_action = NULL; + GError* error = NULL; + + g_signal_connect(plugin, "response-final", G_CALLBACK(response_callback), + &result); + g_signal_connect(plugin, "user-action-required", + G_CALLBACK(user_action_required_callback), &ui_action); + g_signal_connect(plugin, "error", G_CALLBACK(error_callback), &error); + + GSignondSignonuiData* data = gsignond_dictionary_new(); + + //empty data + gsignond_plugin_user_action_finished(plugin, data); + _run_mainloop (); + + fail_if(result != NULL); + fail_if(ui_action != NULL); + fail_if(error == NULL); + fail_unless (error->code == GSIGNOND_ERROR_USER_INTERACTION); + g_error_free(error); + error = NULL; + + // correct values + gsignond_signonui_data_set_username(data, "megauser"); + gsignond_signonui_data_set_password(data, "megapassword"); + gsignond_signonui_data_set_query_error(data, SIGNONUI_ERROR_NONE); + gsignond_plugin_user_action_finished(plugin, data); + _run_mainloop (); + + fail_if(result == NULL); + fail_if(ui_action != NULL); + fail_if(error != NULL); + fail_if(g_strcmp0( + gsignond_session_data_get_username(result), "megauser") != 0); + fail_if(g_strcmp0( + gsignond_session_data_get_secret(result), "megapassword") != 0); + gsignond_dictionary_unref(result); + result = NULL; + + // user canceled + gsignond_signonui_data_set_query_error(data, SIGNONUI_ERROR_CANCELED); + gsignond_plugin_user_action_finished(plugin, data); + _run_mainloop (); + + fail_if(result != NULL); + fail_if(ui_action != NULL); + fail_if(error == NULL); + fail_unless (error->code == GSIGNOND_ERROR_SESSION_CANCELED); + g_error_free(error); + error = NULL; + + // error in ui request + gsignond_signonui_data_set_query_error(data, SIGNONUI_ERROR_GENERAL); + gsignond_plugin_user_action_finished(plugin, data); + _run_mainloop (); + + fail_if(result != NULL); + fail_if(ui_action != NULL); + fail_if(error == NULL); + fail_unless (error->code == GSIGNOND_ERROR_USER_INTERACTION); + g_error_free(error); + error = NULL; + + gsignond_dictionary_unref(data); + + g_object_unref(config); + g_object_unref(plugin); +} +END_TEST + +START_TEST (test_pluginremote_refresh) +{ + DBG (""); + GSignondPlugin *plugin = NULL; + const gchar *plugin_type = "password"; + + GSignondConfig* config = gsignond_config_new (); + fail_if(config == NULL); + + plugin = GSIGNOND_PLUGIN (gsignond_plugin_remote_new(config, plugin_type)); + fail_if(plugin == NULL); + + GSignondSessionData* result = NULL; + GError* error = NULL; + + g_signal_connect(plugin, "refreshed", G_CALLBACK(response_callback), + &result); + g_signal_connect(plugin, "error", G_CALLBACK(error_callback), &error); + + GSignondSessionData* data = gsignond_dictionary_new(); + gsignond_plugin_refresh(plugin, data); + _run_mainloop (); + + fail_if(result == NULL); + fail_if(error != NULL); + gsignond_dictionary_unref(result); + result = NULL; + + gsignond_dictionary_unref(data); + + g_object_unref(config); + g_object_unref(plugin); +} +END_TEST + +START_TEST (test_plugind_daemon) +{ + DBG (""); + GSignondPluginDaemon *daemon = NULL; + const gchar *plugin_type = "password"; + + GSignondConfig* config = gsignond_config_new (); + fail_if(config == NULL); + + gchar *plugin_path = g_module_build_path (gsignond_config_get_string ( + config, GSIGNOND_CONFIG_GENERAL_PLUGINS_DIR), "nonexisting"); + fail_if (plugin_path == NULL); + daemon = gsignond_plugin_daemon_new (plugin_path, "nonexisting", 0, 1); + g_free (plugin_path); + fail_if (daemon != NULL); + + plugin_path = g_module_build_path (gsignond_config_get_string ( + config, GSIGNOND_CONFIG_GENERAL_PLUGINS_DIR), plugin_type); + fail_if (plugin_path == NULL); + daemon = gsignond_plugin_daemon_new (plugin_path, plugin_type, 0, 1); + g_free (plugin_path); + fail_if (daemon == NULL); + g_object_unref (daemon); + daemon = NULL; + g_object_unref(config); +} +END_TEST + +Suite* pluginremote_suite (void) +{ + Suite *s = suite_create ("Plugin remote"); + + /* Core test case */ + TCase *tc_core = tcase_create ("RemoteTests"); + tcase_add_checked_fixture (tc_core, _setup, _teardown); + tcase_add_test (tc_core, test_pluginremote_create); + tcase_add_test (tc_core, test_pluginremote_plugind_create); + tcase_add_test (tc_core, test_pluginremote_plugind_unref); + tcase_add_test (tc_core, test_pluginremote_plugind_kill); + tcase_add_test (tc_core, test_pluginremote_request); + tcase_add_test (tc_core, test_pluginremote_user_action_finished); + tcase_add_test (tc_core, test_pluginremote_refresh); + tcase_add_test (tc_core, test_plugind_daemon); + + suite_add_tcase (s, tc_core); + return s; +} + +int main (void) +{ + int number_failed; + + Suite *s = pluginremote_suite(); + SRunner *sr = srunner_create(s); + srunner_run_all(sr, CK_NORMAL); + number_failed = srunner_ntests_failed(sr); + srunner_free(sr); + return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; +} + |