From: <svn...@op...> - 2009-04-01 21:59:16
|
Author: scriptor Date: Wed Apr 1 23:59:13 2009 New Revision: 5514 URL: http://www.opensync.org/changeset/5514 Log: Further tests. Added: plugins/ldap-sync/tests/check_osynctool_add_modify_delete_file_and_sync (contents, props changed) Added: plugins/ldap-sync/tests/check_osynctool_add_modify_delete_file_and_sync ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/ldap-sync/tests/check_osynctool_add_modify_delete_file_and_sync Wed Apr 1 23:59:13 2009 (r5514) @@ -0,0 +1,190 @@ +#!/bin/bash + +set -x + +FILE=$0 +OSYNCTOOL=$(which osynctool 2>/dev/null) +if test ! -f "$OSYNCTOOL"; then + echo "$FILE:$LINENO: ERROR: osynctool could not be found. Exiting." + exit 1 +fi + +if test ! -x "$OSYNCTOOL"; then + echo "$FILE:$LINENO: ERROR: osynctool could be found, but it is not executable. Exiting." + exit 1 +fi + + + +PLUGINNAME="ldap-sync" +PLUGINPATH="$1/src" +CFG="$2/src/$PLUGINNAME" +OBJECTTYPE="$3" +XMLFILE="$4" +MODIFIED_FILE="$5" + + + +SOURCE_DIR=`dirname $FILE` +if test ! -d "$SOURCE_DIR"; then + echo "$FILE:$LINENO: ERROR: \"$SOURCE_DIR\" is not a directory. Exiting." + exit 1 +fi + +if test ! -r "$SOURCE_DIR/test.conf"; then + echo "$FILE:$LINENO: ERROR: \"$SOURCE_DIR/test.conf\" could not be read. Exiting." + exit 1 +fi + +if test ! -r "$SOURCE_DIR/check_osynctool_common.inc"; then + echo "$FILE:$LINENO: ERROR: \"$SOURCE_DIR/test.conf\" could not be read. Exiting." + exit 1 +fi + +source "$SOURCE_DIR/test.conf" +source "$SOURCE_DIR/check_osynctool_common.inc" + +echo "PLUGINPATH = \"$PLUGINPATH\"" +echo "CFG = \"$CFG\"" + + +if test -n "$TRACE_FILES"; then + echo "$FILE:$LINENO: Enabling OSYNC_TRACE." + if test ! -d "$TRACE_FILES"; then + mkdir -p "$TRACE_FILES" + fi + export OSYNC_TRACE="$TRACE_FILES" +fi + + +if test -z "$XMLFILE"; then + echo "$FILE:$LINENO: ERROR: \$XMLFILE is empty. Exiting." + exit 1 +fi + +if test ! -f "$XMLFILE"; then + echo "$FILE:$LINENO: ERROR: \"$XMLFILE\" could not be found. Exiting." + exit 1 +fi + +if test ! -r "$XMLFILE"; then + echo "$FILE:$LINENO: ERROR: \"$XMLFILE\" could be found, but it is not readable. Exiting." + exit 1 +fi + + +if test -z "$MODIFIED_FILE"; then + echo "$FILE:$LINENO: ERROR: \$MODIFIED_FILE is empty. Exiting." + exit 1 +fi + +if test ! -f "$MODIFIED_FILE"; then + echo "$FILE:$LINENO: ERROR: \"$MODIFIED_FILE\" could not be found. Exiting." + exit 1 +fi + +if test ! -r "$MODIFIED_FILE"; then + echo "$FILE:$LINENO: ERROR: \"$MODIFIED_FILE\" could be found, but it is not readable. Exiting." + exit 1 +fi + + + + + +TMPDIR=`mktemp -d /tmp/ldap_sync_test.XXXXXX` || exit 1 +echo "TMPDIR = \"$TMPDIR\"" + + + + +# Set up test group +prologue; + + +# Empty LDAP DIT +$SOURCE_DIR/remove_test_ldifs + + +# Remove entry from directory used by file-sync +remove_file_by_objtype "$OBJECTTYPE" + + +# Add XML file +echo -e "\n\n\nAdd XML file\n\n\n" +add_file "$OBJECTTYPE" "$XMLFILE" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: add_file() has failed." + exit 1; +fi + + +# osynctool should synchronize only one particular object type: +echo -e "\n\n\nEnable just $OBJECTTYPE\n\n\n" +enable_only "$OBJECTTYPE" + + +# Trigger synchronization +echo -e "\n\n\nSynchronize after an XML file has been added\n\n\n" +fast_sync "$OBJECTTYPE" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: fast_sync() has failed (1)." + exit 1; +fi + + +# Modify the XML File +echo -e "\n\n\nModify XML file\n\n\n" +modify_file "$OBJECTTYPE" "$XMLFILE" "$MODIFIED_FILE" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: modify_file() has failed." + exit 1; +fi + +echo -e "\n\n\n" +diff "$XMLFILE" "$MODIFIED_FILE" +echo -e "\n\n\n" + + +# Trigger synchronization +echo -e "\n\n\nSynchronize after the XML file has been modified\n\n\n" +fast_sync "$OBJECTTYPE" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: fast_sync() has failed (1)." + exit 1; +fi + + +# Delete the XML File +echo -e "\n\n\nDelete XML file\n\n\n" +delete_file "$OBJECTTYPE" "$XMLFILE" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: delete_file() has failed." + exit 1; +fi + + +# Trigger synchronization +echo -e "\n\n\nSynchronize after the XML file has been deleted\n\n\n" +fast_sync "$OBJECTTYPE" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: fast_sync() has failed (1)." + exit 1; +fi +echo -e "\n\n\n" + + + +# Shut down test group +epilogue + + +exit $rv + +#vim:ts=2:sw=2 |