diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile.am | 73 | ||||
-rw-r--r-- | tests/Makefile.in | 757 | ||||
-rw-r--r-- | tests/dbus-interface.c | 578 | ||||
-rw-r--r-- | tests/null-config.conf | 2 | ||||
-rw-r--r-- | tests/server-test.c | 280 | ||||
-rwxr-xr-x | tests/slmock | 235 | ||||
-rw-r--r-- | tests/slmock-config.conf.in | 9 | ||||
-rw-r--r-- | tests/uccs-config.conf | 9 |
8 files changed, 1943 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am new file mode 100644 index 0000000..bc52633 --- /dev/null +++ b/tests/Makefile.am @@ -0,0 +1,73 @@ + +CLEANFILES = +DISTCLEANFILES = +EXTRA_DIST = +check_PROGRAMS = + +TESTS = \ + server-tester \ + dbus-interface-tester + +##################################### +# Server Test +##################################### + +SERVER_XML_REPORT = server-test.xml +server-tester: server-test Makefile.am + @echo "#!/bin/bash" > $@ + @echo gtester --verbose -k -o $(SERVER_XML_REPORT) $(abs_builddir)/server-test >> $@ + @chmod +x $@ + +CLEANFILES += \ + $(SERVER_XML_REPORT) \ + server-tester + +server_test_SOURCES = \ + server-test.c +server_test_CFLAGS = \ + -I$(top_srcdir)/src \ + -I$(top_builddir)/src \ + $(SERVICE_CFLAGS) +server_test_LDADD = \ + $(top_builddir)/src/libservers.la \ + $(SERVICE_LIBS) + +check_PROGRAMS += server-test + +##################################### +# DBus Interface +##################################### + +DBUS_XML_REPORT = dbus-interface.xml +dbus-interface-tester: dbus-interface uccs-config.conf slmock-config.conf Makefile.am + @echo "#!/bin/bash" > $@ + @echo gtester --verbose -k -o $(DBUS_XML_REPORT) $(abs_builddir)/dbus-interface >> $@ + @chmod +x $@ + +CLEANFILES += \ + $(DBUS_XML_REPORT) \ + dbus-interface-tester \ + slmock-config.conf + +EXTRA_DIST += \ + null-config.conf \ + uccs-config.conf \ + slmock \ + slmock-config.conf.in + +slmock-config.conf: slmock-config.conf.in + sed -e "s|\@slmock\@|$(abs_srcdir)/slmock|" $< > $@ +dbus_interface_SOURCES = \ + dbus-interface.c +dbus_interface_CFLAGS = \ + -DREMOTE_LOGIN_SERVICE="\"$(abs_top_builddir)/src/remote-login-service\"" \ + -DUCCS_CONFIG_FILE="\"$(abs_srcdir)/uccs-config.conf\"" \ + -DSLMOCK_CONFIG_FILE="\"$(abs_builddir)/slmock-config.conf\"" \ + -DNULL_CONFIG_FILE="\"$(abs_srcdir)/null-config.conf\"" \ + $(SERVICE_CFLAGS) \ + $(TEST_CFLAGS) +dbus_interface_LDADD = \ + $(SERVICE_LIBS) \ + $(TEST_LIBS) + +check_PROGRAMS += dbus-interface diff --git a/tests/Makefile.in b/tests/Makefile.in new file mode 100644 index 0000000..f739f1a --- /dev/null +++ b/tests/Makefile.in @@ -0,0 +1,757 @@ +# Makefile.in generated by automake 1.11.5 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@ +am__make_dryrun = \ + { \ + am__dry=no; \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \ + | grep '^AM OK$$' >/dev/null || am__dry=yes;; \ + *) \ + for am__flg in $$MAKEFLAGS; do \ + case $$am__flg in \ + *=*|--*) ;; \ + *n*) am__dry=yes; break;; \ + esac; \ + done;; \ + esac; \ + test $$am__dry = yes; \ + } +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@ +check_PROGRAMS = server-test$(EXEEXT) dbus-interface$(EXEEXT) +subdir = tests +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4/gcov.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +am_dbus_interface_OBJECTS = dbus_interface-dbus-interface.$(OBJEXT) +dbus_interface_OBJECTS = $(am_dbus_interface_OBJECTS) +am__DEPENDENCIES_1 = +dbus_interface_DEPENDENCIES = $(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 +dbus_interface_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ + $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ + $(dbus_interface_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o \ + $@ +am_server_test_OBJECTS = server_test-server-test.$(OBJEXT) +server_test_OBJECTS = $(am_server_test_OBJECTS) +server_test_DEPENDENCIES = $(top_builddir)/src/libservers.la \ + $(am__DEPENDENCIES_1) +server_test_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(server_test_CFLAGS) \ + $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/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 = $(dbus_interface_SOURCES) $(server_test_SOURCES) +DIST_SOURCES = $(dbus_interface_SOURCES) $(server_test_SOURCES) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +ETAGS = etags +CTAGS = ctags +am__tty_colors = \ +red=; grn=; lgn=; blu=; std= +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ALL_LINGUAS = @ALL_LINGUAS@ +AMTAR = @AMTAR@ +AM_CFLAGS = @AM_CFLAGS@ +AM_CPPFLAGS = @AM_CPPFLAGS@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CATALOGS = @CATALOGS@ +CATOBJEXT = @CATOBJEXT@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +COVERAGE_CFLAGS = @COVERAGE_CFLAGS@ +COVERAGE_LDFLAGS = @COVERAGE_LDFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATADIRNAME = @DATADIRNAME@ +DBUSSERVICEDIR = @DBUSSERVICEDIR@ +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@ +GCOVR = @GCOVR@ +GCRYPT_LIBS = @GCRYPT_LIBS@ +GENHTML = @GENHTML@ +GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ +GMOFILES = @GMOFILES@ +GMSGFMT = @GMSGFMT@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INSTOBJEXT = @INSTOBJEXT@ +INTLLIBS = @INTLLIBS@ +INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ +INTLTOOL_MERGE = @INTLTOOL_MERGE@ +INTLTOOL_PERL = @INTLTOOL_PERL@ +INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ +INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@ +INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@ +INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@ +INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@ +LCOV = @LCOV@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LOCALEDIR = @LOCALEDIR@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MKDIR_P = @MKDIR_P@ +MKINSTALLDIRS = @MKINSTALLDIRS@ +MSGFMT = @MSGFMT@ +MSGFMT_OPTS = @MSGFMT_OPTS@ +MSGMERGE = @MSGMERGE@ +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@ +POFILES = @POFILES@ +POSUB = @POSUB@ +PO_IN_DATADIR_FALSE = @PO_IN_DATADIR_FALSE@ +PO_IN_DATADIR_TRUE = @PO_IN_DATADIR_TRUE@ +RANLIB = @RANLIB@ +SED = @SED@ +SERVICE_CFLAGS = @SERVICE_CFLAGS@ +SERVICE_LIBS = @SERVICE_LIBS@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SHTOOL = @SHTOOL@ +STRIP = @STRIP@ +TEST_CFLAGS = @TEST_CFLAGS@ +TEST_LIBS = @TEST_LIBS@ +USE_NLS = @USE_NLS@ +VERSION = @VERSION@ +XGETTEXT = @XGETTEXT@ +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@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +intltool__v_merge_options_ = @intltool__v_merge_options_@ +intltool__v_merge_options_0 = @intltool__v_merge_options_0@ +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@ +CLEANFILES = $(SERVER_XML_REPORT) server-tester $(DBUS_XML_REPORT) \ + dbus-interface-tester slmock-config.conf +DISTCLEANFILES = +EXTRA_DIST = null-config.conf uccs-config.conf slmock \ + slmock-config.conf.in +TESTS = \ + server-tester \ + dbus-interface-tester + + +##################################### +# Server Test +##################################### +SERVER_XML_REPORT = server-test.xml +server_test_SOURCES = \ + server-test.c + +server_test_CFLAGS = \ + -I$(top_srcdir)/src \ + -I$(top_builddir)/src \ + $(SERVICE_CFLAGS) + +server_test_LDADD = \ + $(top_builddir)/src/libservers.la \ + $(SERVICE_LIBS) + + +##################################### +# DBus Interface +##################################### +DBUS_XML_REPORT = dbus-interface.xml +dbus_interface_SOURCES = \ + dbus-interface.c + +dbus_interface_CFLAGS = \ + -DREMOTE_LOGIN_SERVICE="\"$(abs_top_builddir)/src/remote-login-service\"" \ + -DUCCS_CONFIG_FILE="\"$(abs_srcdir)/uccs-config.conf\"" \ + -DSLMOCK_CONFIG_FILE="\"$(abs_builddir)/slmock-config.conf\"" \ + -DNULL_CONFIG_FILE="\"$(abs_srcdir)/null-config.conf\"" \ + $(SERVICE_CFLAGS) \ + $(TEST_CFLAGS) + +dbus_interface_LDADD = \ + $(SERVICE_LIBS) \ + $(TEST_LIBS) + +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(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 tests/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu tests/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_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 +dbus-interface$(EXEEXT): $(dbus_interface_OBJECTS) $(dbus_interface_DEPENDENCIES) $(EXTRA_dbus_interface_DEPENDENCIES) + @rm -f dbus-interface$(EXEEXT) + $(AM_V_CCLD)$(dbus_interface_LINK) $(dbus_interface_OBJECTS) $(dbus_interface_LDADD) $(LIBS) +server-test$(EXEEXT): $(server_test_OBJECTS) $(server_test_DEPENDENCIES) $(EXTRA_server_test_DEPENDENCIES) + @rm -f server-test$(EXEEXT) + $(AM_V_CCLD)$(server_test_LINK) $(server_test_OBJECTS) $(server_test_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dbus_interface-dbus-interface.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/server_test-server-test.Po@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.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 $< + +.c.obj: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.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 `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.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 $@ $< + +dbus_interface-dbus-interface.o: dbus-interface.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(dbus_interface_CFLAGS) $(CFLAGS) -MT dbus_interface-dbus-interface.o -MD -MP -MF $(DEPDIR)/dbus_interface-dbus-interface.Tpo -c -o dbus_interface-dbus-interface.o `test -f 'dbus-interface.c' || echo '$(srcdir)/'`dbus-interface.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/dbus_interface-dbus-interface.Tpo $(DEPDIR)/dbus_interface-dbus-interface.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dbus-interface.c' object='dbus_interface-dbus-interface.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) $(dbus_interface_CFLAGS) $(CFLAGS) -c -o dbus_interface-dbus-interface.o `test -f 'dbus-interface.c' || echo '$(srcdir)/'`dbus-interface.c + +dbus_interface-dbus-interface.obj: dbus-interface.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(dbus_interface_CFLAGS) $(CFLAGS) -MT dbus_interface-dbus-interface.obj -MD -MP -MF $(DEPDIR)/dbus_interface-dbus-interface.Tpo -c -o dbus_interface-dbus-interface.obj `if test -f 'dbus-interface.c'; then $(CYGPATH_W) 'dbus-interface.c'; else $(CYGPATH_W) '$(srcdir)/dbus-interface.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/dbus_interface-dbus-interface.Tpo $(DEPDIR)/dbus_interface-dbus-interface.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dbus-interface.c' object='dbus_interface-dbus-interface.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) $(dbus_interface_CFLAGS) $(CFLAGS) -c -o dbus_interface-dbus-interface.obj `if test -f 'dbus-interface.c'; then $(CYGPATH_W) 'dbus-interface.c'; else $(CYGPATH_W) '$(srcdir)/dbus-interface.c'; fi` + +server_test-server-test.o: server-test.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(server_test_CFLAGS) $(CFLAGS) -MT server_test-server-test.o -MD -MP -MF $(DEPDIR)/server_test-server-test.Tpo -c -o server_test-server-test.o `test -f 'server-test.c' || echo '$(srcdir)/'`server-test.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/server_test-server-test.Tpo $(DEPDIR)/server_test-server-test.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='server-test.c' object='server_test-server-test.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) $(server_test_CFLAGS) $(CFLAGS) -c -o server_test-server-test.o `test -f 'server-test.c' || echo '$(srcdir)/'`server-test.c + +server_test-server-test.obj: server-test.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(server_test_CFLAGS) $(CFLAGS) -MT server_test-server-test.obj -MD -MP -MF $(DEPDIR)/server_test-server-test.Tpo -c -o server_test-server-test.obj `if test -f 'server-test.c'; then $(CYGPATH_W) 'server-test.c'; else $(CYGPATH_W) '$(srcdir)/server-test.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/server_test-server-test.Tpo $(DEPDIR)/server_test-server-test.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='server-test.c' object='server_test-server-test.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) $(server_test_CFLAGS) $(CFLAGS) -c -o server_test-server-test.obj `if test -f 'server-test.c'; then $(CYGPATH_W) 'server-test.c'; else $(CYGPATH_W) '$(srcdir)/server-test.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: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +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) + -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) + +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 + +server-tester: server-test Makefile.am + @echo "#!/bin/bash" > $@ + @echo gtester --verbose -k -o $(SERVER_XML_REPORT) $(abs_builddir)/server-test >> $@ + @chmod +x $@ +dbus-interface-tester: dbus-interface uccs-config.conf slmock-config.conf Makefile.am + @echo "#!/bin/bash" > $@ + @echo gtester --verbose -k -o $(DBUS_XML_REPORT) $(abs_builddir)/dbus-interface >> $@ + @chmod +x $@ + +slmock-config.conf: slmock-config.conf.in + sed -e "s|\@slmock\@|$(abs_srcdir)/slmock|" $< > $@ + +# 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/tests/dbus-interface.c b/tests/dbus-interface.c new file mode 100644 index 0000000..28ce314 --- /dev/null +++ b/tests/dbus-interface.c @@ -0,0 +1,578 @@ + +#include <glib.h> +#include <gio/gio.h> +#include <libdbustest/dbus-test.h> + +typedef struct _slmock_table_t slmock_table_t; +typedef struct _slmock_server_t slmock_server_t; + +struct _slmock_table_t { + const gchar * username; + const gchar * password; + slmock_server_t * servers; +}; + +struct _slmock_server_t { + const gchar * name; + const gchar * uri; + const gchar * type; + gboolean last_used; + const gchar * username; + const gchar * password; + const gchar * domain; +}; + +slmock_server_t citrix_server_table[] = { + {"Citrix USA", "107.21.17.35", "ica", FALSE, "useradmin1", "", "IP-0A00001E"}, + {"Citrix 2", "107.21.17.35", "ica", FALSE, "useradmin2", "", "IP-0A00001E"}, + {"Citrix 3", "107.21.17.35", "ica", FALSE, "useradmin3", "", "IP-0A00001E"}, + {"Citrix 4", "107.21.17.35", "ica", FALSE, "useradmin4", "userpass", "IP-0A00001E"}, + {NULL, NULL, NULL} +}; + +slmock_server_t freerdp_server_table[] = { + {"FreeRDP US", "23.21.151.133", "freerdp", TRUE, "Administrator", "", ""}, + {"FreeRDP Asia", "46.137.222.181", "freerdp", FALSE, "Administrator", "", ""}, + {"FreeRDP UK", "46.137.189.194", "freerdp", FALSE, "Administrator", "", ""}, + {NULL, NULL, NULL} +}; + +slmock_server_t freerdp_server_table_after_set_last_used[] = { + {"FreeRDP US", "23.21.151.133", "freerdp", FALSE, "Administrator", "", ""}, + {"FreeRDP Asia", "46.137.222.181", "freerdp", TRUE, "Administrator", "", ""}, + {"FreeRDP UK", "46.137.189.194", "freerdp", FALSE, "Administrator", "", ""}, + {NULL, NULL, NULL} +}; + +slmock_server_t big_server_table[] = { + {"XenServer", "107.21.17.35", "ica", FALSE, "", "", "ASIA"}, + {"Citrix2", "http://1.2.3.4", "ica", FALSE, "fakeuser", "fakepassword", "DOMAIN1"}, + {"Accenture", "10.21.17.35", "freerdp", FALSE, "fakeuser", "", "EUROPE"}, + {"Accenture 2", "https://4.5.6.7", "freerdp", TRUE, "", "", "domain2"}, + {NULL, NULL, NULL} +}; + +slmock_table_t slmock_table[] = { + {"c", "c", citrix_server_table}, + {"f", "f", freerdp_server_table}, + {"b", "b", big_server_table}, + {"f", "f", freerdp_server_table_after_set_last_used} +}; + +static gboolean +find_server (GVariant * varray, slmock_server_t * server) +{ + int ichild; + for (ichild = 0; ichild < g_variant_n_children(varray); ichild++) { + GVariant * child = g_variant_get_child_value(varray, ichild); + gboolean test = FALSE; + + GVariant * type = g_variant_get_child_value(child, 0); + test = g_strcmp0(g_variant_get_string(type, NULL), server->type) == 0; + g_variant_unref(type); + if (!test) { + g_variant_unref(child); + continue; + } + + GVariant * name = g_variant_get_child_value(child, 1); + test = g_strcmp0(g_variant_get_string(name, NULL), server->name) == 0; + g_variant_unref(name); + if (!test) { + g_variant_unref(child); + continue; + } + + GVariant * uri = g_variant_get_child_value(child, 2); + test = g_strcmp0(g_variant_get_string(uri, NULL), server->uri) == 0; + g_variant_unref(uri); + if (!test) { + g_variant_unref(child); + continue; + } + + GVariant * last_used = g_variant_get_child_value(child, 3); + test = g_variant_get_boolean(last_used) == server->last_used; + g_variant_unref(last_used); + if (!test) { + g_variant_unref(child); + continue; + } + + gboolean match_username = FALSE; + gboolean match_password = FALSE; + gboolean match_domain = FALSE; + + GVariant * props = g_variant_get_child_value(child, 4); + int iprop; + for (iprop = 0; iprop < g_variant_n_children(props); iprop++) { + GVariant * prop = g_variant_get_child_value(props, iprop); + + GVariant * prop_type = g_variant_get_child_value(prop, 0); + GVariant * prop_value_wrap = g_variant_get_child_value(prop, 2); + GVariant * prop_value = g_variant_get_variant(prop_value_wrap); + + if (g_strcmp0(g_variant_get_string(prop_type, NULL), "username") == 0) { + if (g_strcmp0(g_variant_get_string(prop_value, NULL), server->username) == 0) { + match_username = TRUE; + } + } else if (g_strcmp0(g_variant_get_string(prop_type, NULL), "password") == 0) { + if (g_strcmp0(g_variant_get_string(prop_value, NULL), server->password) == 0) { + match_password = TRUE; + } + } else if (g_strcmp0(g_variant_get_string(prop_type, NULL), "domain") == 0) { + if (g_strcmp0(g_variant_get_string(prop_value, NULL), server->domain) == 0) { + match_domain = TRUE; + } + } + + g_variant_unref(prop_value); + g_variant_unref(prop_value_wrap); + g_variant_unref(prop_type); + g_variant_unref(prop); + } + g_variant_unref(props); + + g_variant_unref(child); + + if (match_username && match_password && match_domain) { + return TRUE; + } else { + continue; + } + } + + return FALSE; +} + +static gboolean +slmock_check_login(GDBusConnection * session, slmock_table_t * slmockdata, gboolean clear_cache) +{ + if (clear_cache) { + gchar *username_sha = g_compute_checksum_for_string (G_CHECKSUM_SHA256, slmockdata->username, -1); + gchar *file_path = g_build_path ("/", g_get_user_cache_dir(), "remote-login-service", "cache", username_sha, NULL); + unlink (file_path); + g_free (username_sha); + g_free (file_path); + } + GVariant * retval = g_dbus_connection_call_sync(session, + "com.canonical.RemoteLogin", + "/com/canonical/RemoteLogin", + "com.canonical.RemoteLogin", + "GetServersForLogin", + g_variant_new("(sssb)", + "https://slmock.com/", + slmockdata->username, + slmockdata->password, + TRUE), /* params */ + G_VARIANT_TYPE("(bsa(sssba(sbva{sv})a(si)))"), /* ret type */ + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, + NULL); + + g_assert(retval != NULL); + g_assert(g_variant_n_children(retval) == 3); + + GVariant * loggedin = g_variant_get_child_value(retval, 0); + g_assert(g_variant_get_boolean(loggedin)); + g_variant_unref(loggedin); loggedin = NULL; + + GVariant * data = g_variant_get_child_value(retval, 1); + g_assert(g_strcmp0(g_variant_get_string(data, NULL), "network") == 0); + g_variant_unref(data); data = NULL; + + GVariant * array = g_variant_get_child_value(retval, 2); + int i; + for (i = 0; slmockdata->servers[i].name != NULL; i++) { + g_assert(find_server(array, &slmockdata->servers[i])); + } + g_variant_unref(array); + + g_variant_unref(retval); + + return TRUE; +} + +static void +test_getservers_slmock (gconstpointer data) +{ + DbusTestService * service = dbus_test_service_new(NULL); + + /* RLS */ + DbusTestProcess * rls = dbus_test_process_new(REMOTE_LOGIN_SERVICE); + dbus_test_process_append_param(rls, "--config-file=" SLMOCK_CONFIG_FILE); + dbus_test_service_add_task(service, DBUS_TEST_TASK(rls)); + + /* Dummy */ + DbusTestTask * dummy = dbus_test_task_new(); + dbus_test_task_set_wait_for(dummy, "com.canonical.RemoteLogin"); + dbus_test_service_add_task(service, dummy); + + /* Get RLS up and running and us on that bus */ + dbus_test_service_start_tasks(service); + + GDBusConnection * session = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, NULL); + g_dbus_connection_set_exit_on_close(session, FALSE); + + g_assert(slmock_check_login(session, (slmock_table_t *)data, TRUE)); + + g_object_unref(session); + g_object_unref(rls); + g_object_unref(service); + + return; +} + +static void +test_getservers_slmock_none (void) +{ + DbusTestService * service = dbus_test_service_new(NULL); + + /* RLS */ + DbusTestProcess * rls = dbus_test_process_new(REMOTE_LOGIN_SERVICE); + dbus_test_process_append_param(rls, "--config-file=" SLMOCK_CONFIG_FILE); + dbus_test_service_add_task(service, DBUS_TEST_TASK(rls)); + + /* Dummy */ + DbusTestTask * dummy = dbus_test_task_new(); + dbus_test_task_set_wait_for(dummy, "com.canonical.RemoteLogin"); + dbus_test_service_add_task(service, dummy); + + /* Get RLS up and running and us on that bus */ + dbus_test_service_start_tasks(service); + + GDBusConnection * session = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, NULL); + g_dbus_connection_set_exit_on_close(session, FALSE); + + GVariant * retval = g_dbus_connection_call_sync(session, + "com.canonical.RemoteLogin", + "/com/canonical/RemoteLogin", + "com.canonical.RemoteLogin", + "GetServersForLogin", + g_variant_new("(sssb)", + "https://slmock.com/", + "Baduser", + "Badpass", + TRUE), /* params */ + G_VARIANT_TYPE("(bsa(sssba(sbva{sv})a(si)))"), /* ret type */ + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, + NULL); + + g_assert(retval != NULL); + g_assert(g_variant_n_children(retval) == 3); + + GVariant * loggedin = g_variant_get_child_value(retval, 0); + g_assert(!g_variant_get_boolean(loggedin)); + g_variant_unref(loggedin); loggedin = NULL; + + GVariant * array = g_variant_get_child_value(retval, 2); + g_assert(g_variant_n_children(array) == 0); + g_variant_unref(array); + g_variant_unref(retval); + + g_object_unref(session); + g_object_unref(rls); + g_object_unref(service); + + return; +} + +static void +test_getservers_slmock_two (void) +{ + DbusTestService * service = dbus_test_service_new(NULL); + + /* RLS */ + DbusTestProcess * rls = dbus_test_process_new(REMOTE_LOGIN_SERVICE); + dbus_test_process_append_param(rls, "--config-file=" SLMOCK_CONFIG_FILE); + dbus_test_service_add_task(service, DBUS_TEST_TASK(rls)); + + /* Dummy */ + DbusTestTask * dummy = dbus_test_task_new(); + dbus_test_task_set_wait_for(dummy, "com.canonical.RemoteLogin"); + dbus_test_service_add_task(service, dummy); + + /* Get RLS up and running and us on that bus */ + dbus_test_service_start_tasks(service); + + GDBusConnection * session = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, NULL); + g_dbus_connection_set_exit_on_close(session, FALSE); + + g_assert(slmock_check_login(session, &slmock_table[0], TRUE)); + g_assert(slmock_check_login(session, &slmock_table[1], TRUE)); + + g_object_unref(session); + g_object_unref(rls); + g_object_unref(service); + + return; +} + +static void +test_getservers_none (void) +{ + DbusTestService * service = dbus_test_service_new(NULL); + + /* RLS */ + DbusTestProcess * rls = dbus_test_process_new(REMOTE_LOGIN_SERVICE); + dbus_test_process_append_param(rls, "--config-file=" NULL_CONFIG_FILE); + dbus_test_service_add_task(service, DBUS_TEST_TASK(rls)); + + /* Dummy */ + DbusTestTask * dummy = dbus_test_task_new(); + dbus_test_task_set_wait_for(dummy, "com.canonical.RemoteLogin"); + dbus_test_service_add_task(service, dummy); + + /* Get RLS up and running and us on that bus */ + dbus_test_service_start_tasks(service); + + GDBusConnection * session = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, NULL); + g_dbus_connection_set_exit_on_close(session, FALSE); + + GVariant * retval = g_dbus_connection_call_sync(session, + "com.canonical.RemoteLogin", + "/com/canonical/RemoteLogin", + "com.canonical.RemoteLogin", + "GetServers", + NULL, /* params */ + G_VARIANT_TYPE("(a(sssba(sbva{sv})a(si)))"), /* ret type */ + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, + NULL); + + g_assert(retval != NULL); + g_assert(g_variant_n_children(retval) == 1); + + GVariant * array = g_variant_get_child_value(retval, 0); + g_assert(g_variant_n_children(array) == 0); + g_assert(g_variant_is_of_type(array, G_VARIANT_TYPE_ARRAY)); + + g_variant_unref(array); + g_variant_unref(retval); + + g_object_unref(session); + g_object_unref(rls); + g_object_unref(service); + + return; +} + +static void +test_getservers_uccs (void) +{ + DbusTestService * service = dbus_test_service_new(NULL); + + /* RLS */ + DbusTestProcess * rls = dbus_test_process_new(REMOTE_LOGIN_SERVICE); + dbus_test_process_append_param(rls, "--config-file=" UCCS_CONFIG_FILE); + dbus_test_service_add_task(service, DBUS_TEST_TASK(rls)); + + /* Dummy */ + DbusTestTask * dummy = dbus_test_task_new(); + dbus_test_task_set_wait_for(dummy, "com.canonical.RemoteLogin"); + dbus_test_service_add_task(service, dummy); + + /* Get RLS up and running and us on that bus */ + dbus_test_service_start_tasks(service); + + GDBusConnection * session = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, NULL); + g_dbus_connection_set_exit_on_close(session, FALSE); + + GVariant * retval = g_dbus_connection_call_sync(session, + "com.canonical.RemoteLogin", + "/com/canonical/RemoteLogin", + "com.canonical.RemoteLogin", + "GetServers", + NULL, /* params */ + G_VARIANT_TYPE("(a(sssba(sbva{sv})a(si)))"), /* ret type */ + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, + NULL); + + g_assert(retval != NULL); + g_assert(g_variant_n_children(retval) == 1); + + GVariant * array = g_variant_get_child_value(retval, 0); + g_assert(g_variant_n_children(array) == 1); + g_assert(g_variant_is_of_type(array, G_VARIANT_TYPE_ARRAY)); + + GVariant * tuple = g_variant_get_child_value(array, 0); + + if (TRUE) { /* type check */ + GVariant * type = g_variant_get_child_value(tuple, 0); + g_assert(g_variant_is_of_type(type, G_VARIANT_TYPE_STRING)); + g_assert(g_strcmp0(g_variant_get_string(type, NULL), "uccs") == 0); + g_variant_unref(type); + } + + if (TRUE) { /* name check */ + GVariant * name = g_variant_get_child_value(tuple, 1); + g_assert(g_variant_is_of_type(name, G_VARIANT_TYPE_STRING)); + g_assert(g_strcmp0(g_variant_get_string(name, NULL), "Test Server Name") == 0); + g_variant_unref(name); + } + + if (TRUE) { /* uri check */ + GVariant * uri = g_variant_get_child_value(tuple, 2); + g_assert(g_variant_is_of_type(uri, G_VARIANT_TYPE_STRING)); + g_assert(g_strcmp0(g_variant_get_string(uri, NULL), "https://uccs.test.mycompany.com/") == 0); + g_variant_unref(uri); + } + + g_variant_unref(tuple); + g_variant_unref(array); + g_variant_unref(retval); + + g_object_unref(session); + g_object_unref(rls); + g_object_unref(service); + + return; +} + +static void +test_getdomains_basic (void) +{ + DbusTestService * service = dbus_test_service_new(NULL); + + /* RLS */ + DbusTestProcess * rls = dbus_test_process_new(REMOTE_LOGIN_SERVICE); + dbus_test_process_append_param(rls, "--config-file=" SLMOCK_CONFIG_FILE); + dbus_test_service_add_task(service, DBUS_TEST_TASK(rls)); + + /* Dummy */ + DbusTestTask * dummy = dbus_test_task_new(); + dbus_test_task_set_wait_for(dummy, "com.canonical.RemoteLogin"); + dbus_test_service_add_task(service, dummy); + + /* Get RLS up and running and us on that bus */ + dbus_test_service_start_tasks(service); + + GDBusConnection * session = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, NULL); + g_dbus_connection_set_exit_on_close(session, FALSE); + + GError * error = NULL; + GVariant * retval = g_dbus_connection_call_sync(session, + "com.canonical.RemoteLogin", + "/com/canonical/RemoteLogin", + "com.canonical.RemoteLogin", + "GetCachedDomainsForServer", + g_variant_new("(s)", "https://slmock.com/"), /* params */ + G_VARIANT_TYPE("(as)"), /* ret type */ + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, + &error); + + if (error != NULL) { + g_debug("Error from GetCachedDomainsForServer: %s", error->message); + g_error_free(error); + error = NULL; + } + + g_assert(retval != NULL); + g_assert(g_variant_n_children(retval) == 1); + + GVariant * child = g_variant_get_child_value(retval, 0); + g_assert(g_variant_is_of_type(child, G_VARIANT_TYPE_ARRAY)); + g_variant_unref(child); + + g_variant_unref(retval); + + g_object_unref(session); + g_object_unref(rls); + g_object_unref(service); + + return; +} + + +static void +test_setlastused_basic (void) +{ + DbusTestService * service = dbus_test_service_new(NULL); + + /* RLS */ + DbusTestProcess * rls = dbus_test_process_new(REMOTE_LOGIN_SERVICE); + dbus_test_process_append_param(rls, "--config-file=" SLMOCK_CONFIG_FILE); + dbus_test_service_add_task(service, DBUS_TEST_TASK(rls)); + + /* Dummy */ + DbusTestTask * dummy = dbus_test_task_new(); + dbus_test_task_set_wait_for(dummy, "com.canonical.RemoteLogin"); + dbus_test_service_add_task(service, dummy); + + /* Get RLS up and running and us on that bus */ + dbus_test_service_start_tasks(service); + + GDBusConnection * session = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, NULL); + g_dbus_connection_set_exit_on_close(session, FALSE); + + g_assert(slmock_check_login(session, &slmock_table[1], TRUE)); + + GError * error = NULL; + GVariant * retval = g_dbus_connection_call_sync(session, + "com.canonical.RemoteLogin", + "/com/canonical/RemoteLogin", + "com.canonical.RemoteLogin", + "SetLastUsedServer", + g_variant_new("(ss)", "Landscape", freerdp_server_table[1].uri), /* params */ + NULL, /* ret type */ + G_DBUS_CALL_FLAGS_NONE, + -1, + NULL, + &error); + + if (error != NULL) { + g_debug("Error from SetLastUsedServer: %s", error->message); + g_error_free(error); + error = NULL; + } + + g_assert(retval != NULL); + g_assert(g_variant_n_children(retval) == 0); + g_variant_unref(retval); + + g_assert(slmock_check_login(session, &slmock_table[3], FALSE)); + + g_object_unref(session); + g_object_unref(rls); + g_object_unref(service); + + return; +} + + +/* Build the test suite */ +static void +test_dbus_suite (void) +{ + g_test_add_func ("/dbus/interface/GetServers/None", test_getservers_none); + g_test_add_func ("/dbus/interface/GetServers/UCCS", test_getservers_uccs); + g_test_add_data_func ("/dbus/interface/GetServers/SLMock/citrix", &slmock_table[0], test_getservers_slmock); + g_test_add_data_func ("/dbus/interface/GetServers/SLMock/freerdp", &slmock_table[1], test_getservers_slmock); + g_test_add_data_func ("/dbus/interface/GetServers/SLMock/big", &slmock_table[2], test_getservers_slmock); + g_test_add_func ("/dbus/interface/GetServers/SLMock/none", test_getservers_slmock_none); + g_test_add_func ("/dbus/interface/GetServers/SLMock/two", test_getservers_slmock_two); + g_test_add_func ("/dbus/interface/GetDomains/Basic", test_getdomains_basic); + g_test_add_func ("/dbus/interface/SetLastUsed/Basic", test_setlastused_basic); + + return; +} + +gint +main (gint argc, gchar * argv[]) +{ + g_type_init(); + g_test_init(&argc, &argv, NULL); + + /* Test suites */ + test_dbus_suite(); + + return g_test_run (); +} diff --git a/tests/null-config.conf b/tests/null-config.conf new file mode 100644 index 0000000..18184d0 --- /dev/null +++ b/tests/null-config.conf @@ -0,0 +1,2 @@ +[Remote Login Service] +DummyValue=This is intentionally left blank diff --git a/tests/server-test.c b/tests/server-test.c new file mode 100644 index 0000000..32299af --- /dev/null +++ b/tests/server-test.c @@ -0,0 +1,280 @@ +#include <glib.h> + +#include "defines.h" +#include "server.h" +#include "citrix-server.h" +#include "rdp-server.h" +#include "uccs-server.h" + +static gboolean +no_fatal_warnings (const gchar * log_domain, GLogLevelFlags level, const gchar * message, gpointer userdata) +{ + if (level & (G_LOG_LEVEL_WARNING | G_LOG_LEVEL_MESSAGE | G_LOG_LEVEL_INFO | G_LOG_LEVEL_DEBUG)) { + return FALSE; + } + + return TRUE; +} + +static void +state_signal (Server * server, ServerState newstate, gboolean * signaled) +{ + *signaled = TRUE; + return; +} + +static void +test_update_signal (void) +{ + g_test_log_set_fatal_handler(no_fatal_warnings, NULL); + + GKeyFile * keyfile = g_key_file_new(); + const gchar * groupname = CONFIG_SERVER_PREFIX " Server Name"; + g_key_file_set_string(keyfile, groupname, CONFIG_SERVER_NAME, "My Server"); + g_key_file_set_string(keyfile, groupname, CONFIG_SERVER_URI, "http://my.domain.com"); + g_key_file_set_string(keyfile, groupname, CONFIG_UCCS_NETWORK, CONFIG_UCCS_NETWORK_NONE); + + Server * server = NULL; + server = server_new_from_keyfile(keyfile, groupname); + g_assert(server != NULL); + g_assert(g_strcmp0(server->name, "My Server") == 0); + g_assert(g_strcmp0(server->uri, "http://my.domain.com") == 0); + + UccsServer * userver = UCCS_SERVER(server); + g_assert(userver != NULL); + + gboolean signaled = FALSE; + g_signal_connect(G_OBJECT(server), SERVER_SIGNAL_STATE_CHANGED, G_CALLBACK(state_signal), &signaled); + + if (server->state == SERVER_STATE_ALLGOOD) { + signaled = FALSE; + uccs_server_set_exec(userver, "thisshouldnotexist"); + g_assert(signaled); + g_assert(server->state == SERVER_STATE_UNAVAILABLE); + } + + signaled = FALSE; + uccs_server_set_exec(userver, "ls"); + g_assert(signaled); + g_assert(server->state == SERVER_STATE_ALLGOOD); + + return; +} + +static void +test_uccs_domains (void) +{ + g_test_log_set_fatal_handler(no_fatal_warnings, NULL); + + GKeyFile * keyfile = g_key_file_new(); + const gchar * groupname = CONFIG_SERVER_PREFIX " Server Name"; + g_key_file_set_string(keyfile, groupname, CONFIG_SERVER_NAME, "My Server"); + g_key_file_set_string(keyfile, groupname, CONFIG_SERVER_URI, "http://my.domain.com"); + + Server * server = NULL; + server = server_new_from_keyfile(keyfile, groupname); + g_assert(server != NULL); + g_assert(g_strcmp0(server->name, "My Server") == 0); + g_assert(g_strcmp0(server->uri, "http://my.domain.com") == 0); + + GVariant * domains = server_cached_domains(server); + g_assert(domains != NULL); + g_assert(g_variant_is_of_type(domains, G_VARIANT_TYPE_ARRAY)); + g_variant_ref_sink(domains); + g_variant_unref(domains); + + g_object_unref(server); + g_key_file_unref(keyfile); + + return; +} + +static void +test_uccs_exec (void) +{ + g_test_log_set_fatal_handler(no_fatal_warnings, NULL); + + GKeyFile * keyfile = g_key_file_new(); + const gchar * groupname = CONFIG_SERVER_PREFIX " Server Name"; + g_key_file_set_string(keyfile, groupname, CONFIG_SERVER_NAME, "My Server"); + g_key_file_set_string(keyfile, groupname, CONFIG_SERVER_URI, "http://my.domain.com"); + g_key_file_set_string(keyfile, groupname, CONFIG_UCCS_EXEC, "ls"); + + Server * server = NULL; + server = server_new_from_keyfile(keyfile, groupname); + g_assert(server != NULL); + g_assert(g_strcmp0(server->name, "My Server") == 0); + g_assert(g_strcmp0(server->uri, "http://my.domain.com") == 0); + g_assert(g_strcmp0(UCCS_SERVER(server)->exec, "/bin/ls") == 0); + + g_object_unref(server); + g_key_file_unref(keyfile); + + return; +} + +typedef struct _type_data_t type_data_t; +struct _type_data_t { + GType type; + const gchar * name; + const gchar * config_type; +}; + +type_data_t type_data[3] = { + {0, "ica", CONFIG_SERVER_TYPE_ICA}, + {0, "freerdp", CONFIG_SERVER_TYPE_RDP}, + {0, "uccs", CONFIG_SERVER_TYPE_UCCS} +}; + +/* +static void +type_data_dump (type_data_t * data) +{ + g_debug("Type data: %X", data); + g_debug(" type: %d", data->type); + g_debug(" name: %s", data->name); + g_debug(" c. type: %s", data->config_type); +} +*/ + +static gboolean +fatal_func (const gchar * log_domain, GLogLevelFlags level, const gchar * message, gpointer userdata) +{ + return FALSE; +} + +static void +test_object_variant (gconstpointer data) +{ + g_test_log_set_fatal_handler(fatal_func, NULL); + + type_data_t * typedata = (type_data_t *)data; + + Server * server = g_object_new(typedata->type, NULL); + + g_assert(server != NULL); + g_assert(IS_SERVER(server)); + + server->name = g_strdup("My Name"); + server->uri = g_strdup("http://mysite.loves.testing.com"); + + GVariant * variant = server_get_variant(server); + + g_assert(g_variant_n_children(variant) == 6); + + GVariant * child = g_variant_get_child_value(variant, 0); + g_assert(g_variant_is_of_type(child, G_VARIANT_TYPE_STRING)); + g_assert(g_strcmp0(g_variant_get_string(child, NULL), typedata->name) == 0); + g_variant_unref(child); + + child = g_variant_get_child_value(variant, 1); + g_assert(g_variant_is_of_type(child, G_VARIANT_TYPE_STRING)); + g_assert(g_strcmp0(g_variant_get_string(child, NULL), "My Name") == 0); + g_variant_unref(child); + + child = g_variant_get_child_value(variant, 2); + g_assert(g_variant_is_of_type(child, G_VARIANT_TYPE_STRING)); + g_assert(g_strcmp0(g_variant_get_string(child, NULL), "http://mysite.loves.testing.com") == 0); + g_variant_unref(child); + + g_variant_ref_sink(variant); + g_variant_unref(variant); + g_object_unref(G_OBJECT(server)); + + return; +} + +static void +test_object_keyfile_basics (gconstpointer data) +{ + g_test_log_set_fatal_handler(fatal_func, NULL); + + type_data_t * typedata = (type_data_t *)data; + + Server * server = NULL; + + server = server_new_from_keyfile(NULL, NULL); + g_assert(server == NULL); + + GKeyFile * keyfile = g_key_file_new(); + server = server_new_from_keyfile(keyfile, NULL); + g_assert(server == NULL); + + server = server_new_from_keyfile(keyfile, CONFIG_SERVER_PREFIX " Server Name"); + g_assert(server == NULL); + + gchar * groupname = g_strdup_printf("%s %s", CONFIG_SERVER_PREFIX, "Server Name"); + g_key_file_set_string(keyfile, groupname, CONFIG_SERVER_NAME, "My Server"); + g_key_file_set_string(keyfile, groupname, CONFIG_SERVER_URI, "http://my.domain.com"); + g_key_file_set_string(keyfile, groupname, CONFIG_SERVER_TYPE, typedata->config_type); + g_key_file_set_string(keyfile, groupname, "dumbledorf", "Bad data, don't screw up!"); + + server = server_new_from_keyfile(keyfile, CONFIG_SERVER_PREFIX " Server Name"); + g_assert(server != NULL); + g_assert(g_strcmp0(server->name, "My Server") == 0); + g_assert(g_strcmp0(server->uri, "http://my.domain.com") == 0); + g_assert(typedata->type == G_OBJECT_TYPE(server)); + + g_object_unref(server); + g_free(groupname); + g_key_file_unref(keyfile); + + return; +} + +static void +test_object_creation (gconstpointer data) +{ + g_test_log_set_fatal_handler(no_fatal_warnings, NULL); + + type_data_t * typedata = (type_data_t *)data; + + Server * server = g_object_new(typedata->type, NULL); + + g_assert(server != NULL); + g_assert(IS_SERVER(server)); + + g_object_unref(G_OBJECT(server)); + return; +} + +/* Build the test suite */ +static void +test_objects_suite (void) +{ + /* Here because they might require code to create the type so can't be + statically defined in the global */ + type_data[0].type = CITRIX_SERVER_TYPE; + type_data[1].type = RDP_SERVER_TYPE; + type_data[2].type = UCCS_SERVER_TYPE; + + g_test_add_data_func ("/server/object/creation/citrix", &type_data[0], test_object_creation); + g_test_add_data_func ("/server/object/creation/rdp", &type_data[1], test_object_creation); + g_test_add_data_func ("/server/object/creation/uccs", &type_data[2], test_object_creation); + + g_test_add_data_func ("/server/object/keyfile/citrix", &(type_data[0]), test_object_keyfile_basics); + g_test_add_data_func ("/server/object/keyfile/rdp", &(type_data[1]), test_object_keyfile_basics); + g_test_add_data_func ("/server/object/keyfile/uccs", &(type_data[2]), test_object_keyfile_basics); + + g_test_add_data_func ("/server/object/variant/citrix", &(type_data[0]), test_object_variant); + g_test_add_data_func ("/server/object/variant/rdp", &(type_data[1]), test_object_variant); + g_test_add_data_func ("/server/object/variant/uccs", &(type_data[2]), test_object_variant); + + g_test_add_func ("/server/uccs/exec", test_uccs_exec); + g_test_add_func ("/server/uccs/domains", test_uccs_domains); + g_test_add_func ("/server/uccs/signal", test_update_signal); + + return; +} + +gint +main (gint argc, gchar * argv[]) +{ + g_type_init(); + g_test_init(&argc, &argv, NULL); + + /* Test suites */ + test_objects_suite(); + + return g_test_run (); +} diff --git a/tests/slmock b/tests/slmock new file mode 100755 index 0000000..59c5174 --- /dev/null +++ b/tests/slmock @@ -0,0 +1,235 @@ +#!/usr/bin/python3 +# +# Copyright (C) 2012 Canonical, Ltd. +# Author: Matthew Fischer <matthew.fischer@canonical.com> + +import sys +import json +import random +import argparse +import string + +class ManagementServer(): + def __init__(self, url, name): + self.RemoteDesktopServers = [] + self.AdditionalManagementServers = [] + self.URL = url + self.Name = name + + def set_default(self, tsName): + if isinstance(tsName, str): + self.DefaultServer = tsName + else: + raise TypeError("set_default expects a string argument") + + def add_terminal_server(self, server): + self.RemoteDesktopServers.append(server) + + def add_additional_management_server(self, amserver): + if isinstance(amserver, AdditionalManagementServer): + self.AdditionalManagementServers.append(amserver) + else: + raise TypeError("add_additional_management_server expects a "\ + "AdditionalManagementServer argument") + + def toJson(self): + return json.dumps(self, default=convert_to_builtin_type) + +class AdditionalManagementServer(): + def __init__(self, url, name): + self.URL = url + self.Name = name + +class TerminalServer(): + def __init__(self, url, name, protocol, domainRequired = True, + username = None, password = None): + self.URL = url + self.Name = name + self.Protocol = protocol + self.DomainRequired = domainRequired + self.Username = username + self.Password = password + + def add_domain(self, domainName): + if isinstance(domainName, str): + self.WindowsDomain = domainName + else: + raise TypeError("add_domain expects a string argument") + + def toJson(self): + return json.dumps(self, default=convert_to_builtin_type) + +def convert_to_builtin_type(obj): + d = { } + d.update(obj.__dict__) + return d + +def freerdp(email): + ms = ManagementServer("http://tc.canonical.com", "Landscape") + ts1 = TerminalServer("23.21.151.133", "FreeRDP US", "freerdp", False, + "Administrator") + ts2 = TerminalServer("46.137.222.181", "FreeRDP Asia", "freerdp", False, + "Administrator") + ts3 = TerminalServer("46.137.189.194", "FreeRDP UK", "freerdp", False, + "Administrator") + ms.add_terminal_server(ts1) + ms.add_terminal_server(ts2) + ms.add_terminal_server(ts3) + ms.set_default(ts1.Name) + print(ms.toJson()) + +def print_error(text): + print("{ \"Error\": \"%s\" }" % text) + +def error(email): + print_error("Server did not respond") + +def citrix(email): + ms = ManagementServer("http://tc.canonical.com", "Landscape") + ts1 = TerminalServer("107.21.17.35", "Citrix USA", "ICA", True, + "useradmin1") + ts2 = TerminalServer("107.21.17.35", "Citrix 2", "ICA", True, + "useradmin2") + ts3 = TerminalServer("107.21.17.35", "Citrix 3", "ICA", True, + "useradmin3") + ts4 = TerminalServer("107.21.17.35", "Citrix 4", "ICA", True, + "useradmin4", "userpass") + ts1.add_domain("IP-0A00001E") + ts2.add_domain("IP-0A00001E") + ts3.add_domain("IP-0A00001E") + ts4.add_domain("IP-0A00001E") + ms.add_terminal_server(ts1) + ms.add_terminal_server(ts2) + ms.add_terminal_server(ts3) + ms.add_terminal_server(ts4) + print(ms.toJson()) + +def vmware(email): + ms = ManagementServer("http://tc.canonical.com", "Landscape") + ts = TerminalServer("https://10.193.37.140", "VMWare-View Lexington", + "vmware", True, "Administrator") + ts.add_domain("VMWARE") + ms.add_terminal_server(ts) + print(ms.toJson()) + +def defaults(email): + ms = ManagementServer("http://tc.canonical.com", "Landscape") + ts1 = TerminalServer("https://10.10.10.10", "AAA", "vmware") + ts2 = TerminalServer("https://10.10.10.10", "ZZZ", "vmware") + ts3 = TerminalServer("https://10.10.10.10", "MMM-Default", "vmware", True) + ts1.add_domain("VMWARE") + ts2.add_domain("VMWARE") + ts3.add_domain("VMWARE") + ms.set_default(ts3.Name) + ms.add_terminal_server(ts1) + ms.add_terminal_server(ts2) + ms.add_terminal_server(ts3) + print(ms.toJson()) + +# a choice of random problems in the json that the parser should catch +def missing_fields(email): + val = random.randint(1,4) + ms = ManagementServer("http://tc.canonical.com", "Landscape") + ts3 = TerminalServer("https://10.10.10.10", "TS1-Default", "vmware", True) + ts3.add_domain("VMWARE") + ms.set_default(ts3.Name) + + # no ts's + if val == 1: + print(ms.toJson()) + return + + # no protocol in TS + elif val == 2: + ts3.Protocol = None + + # no url in TS + elif val == 3: + ts3.URL = None + + # no name in TS + elif val == 4: + ts3.Name = None + + ms.add_terminal_server(ts3) + print(ms.toJson()) + +def big(email): + ms = ManagementServer("http://tc.canonical.com", "Landscape") + + ts1 = TerminalServer("107.21.17.35", "XenServer", "ICA") + ts2 = TerminalServer("http://1.2.3.4", "Citrix2", "ICA", True, + "fakeuser", "fakepassword") + ts3 = TerminalServer("10.21.17.35", "Accenture", "freerdp", True, + "fakeuser") + ts4 = TerminalServer("https://4.5.6.7", "Accenture 2", "freerdp", False) + ts5 = TerminalServer("5.21.17.35", "VmWare Cloud", "vmware", False, + "fakeuser", "fakepassword") + ts6 = TerminalServer("http://8.9.10.11", "Canonicloud", "vmware", True) + + ts1.add_domain("ASIA") + ts2.add_domain("DOMAIN1") + ts3.add_domain("EUROPE") + ts4.add_domain("domain2") + + ms.add_terminal_server(ts1) + ms.add_terminal_server(ts2) + ms.add_terminal_server(ts3) + ms.add_terminal_server(ts4) + ms.add_terminal_server(ts5) + ms.add_terminal_server(ts6) + ms.set_default(ts4.Name) + + ams1 = AdditionalManagementServer("http://1.2.3.4", "AMS1") + ams2 = AdditionalManagementServer("http://5.6.7.8", "Landscape - Accenture") + ams3 = AdditionalManagementServer("http://10.10.10.10", "AMS3") + ms.add_additional_management_server(ams1) + ms.add_additional_management_server(ams2) + ms.add_additional_management_server(ams3) + + print(ms.toJson()) + +def garbage(email): + print("{, garbage''''''''}}}}}}}}{{{},garbage\n\r\n\n\n\n") + +def random_string(email): + numchars = random.randint(0,4096) + print(''.join(random.choice(string.printable) for x in range(numchars))) + +emailaddrs = {"b" : big, #lots of domains/servers + "c" : citrix, + "d" : defaults, #for easy testing of default ts + "e" : error, + "f" : freerdp, + "g" : garbage, + "m" : missing_fields, #json missing some fields + "r" : random_string, + "v" : vmware, +} + +def help(): + helpstr = "Email address to retrieve server info for. Currently "\ + "the options are: " + emaillist = "" + for key in emailaddrs: + emaillist += key + ", " + helpstr += emaillist[:-2] + return helpstr + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument('email', help=help()) + + args = parser.parse_args() + + password = sys.stdin.read() + + if args.email in emailaddrs: + if password != args.email: + print_error("Invalid password") + sys.exit(-1); + else: + emailaddrs[args.email](args.email) + else: + print_error("Invalid username") + sys.exit(-1); diff --git a/tests/slmock-config.conf.in b/tests/slmock-config.conf.in new file mode 100644 index 0000000..ca285a9 --- /dev/null +++ b/tests/slmock-config.conf.in @@ -0,0 +1,9 @@ +[Remote Login Service] +Servers=SLMock Server + +[Server SLMock Server] +Name=SLMock +Type=UCCS +URI=https://slmock.com/ +Exec=@slmock@ +NetworkRequired=None diff --git a/tests/uccs-config.conf b/tests/uccs-config.conf new file mode 100644 index 0000000..ea1a82c --- /dev/null +++ b/tests/uccs-config.conf @@ -0,0 +1,9 @@ +[Remote Login Service] +Servers=Test Server + +[Server Test Server] +Name=Test Server Name +Type=UCCS +URI=https://uccs.test.mycompany.com/ +Exec=ls +NetworkRequired=None |