From: <svn...@op...> - 2009-04-04 00:36:50
|
Author: scriptor Date: Sat Apr 4 02:36:45 2009 New Revision: 5529 URL: http://www.opensync.org/changeset/5529 Log: Added some tests. Added pseudo test "clean_up". Running this between certain blocks of tests brings about a defined state both of the LDAP DIT and the directories for the file-sync plugin, even when crashs happen, e.g. because of #define CALL_ABORT in ldap_plugin.h. Enabled a style sheet test that was disabled before. Should run successfully, now. Added: plugins/ldap-sync/tests/check_osynctool_add_modify_delete_four_files_and_sync (contents, props changed) plugins/ldap-sync/tests/check_osynctool_add_modify_delete_four_ldifs_and_sync (contents, props changed) plugins/ldap-sync/tests/check_osynctool_add_modify_delete_ldif_and_sync (contents, props changed) plugins/ldap-sync/tests/clean_up (contents, props changed) Modified: plugins/ldap-sync/tests/CMakeLists.txt plugins/ldap-sync/tests/check_osynctool_add_modify_delete_file_and_sync Modified: plugins/ldap-sync/tests/CMakeLists.txt ============================================================================== --- plugins/ldap-sync/tests/CMakeLists.txt Sat Apr 4 02:36:28 2009 (r5528) +++ plugins/ldap-sync/tests/CMakeLists.txt Sat Apr 4 02:36:45 2009 (r5529) @@ -210,7 +210,7 @@ ADD_TEST( stylesheet5.4 ${TESTDIR}/check_stylesheet5 ${XMLDIR}/contact2.xml ${XSLDIR}/xmlformat_contact2ldap_inetorgperson.xsl ${XSLDIR}/ldap_inetorgperson2xmlformat_contact.xsl ) - # ADD_TEST( stylesheet5.5 ${TESTDIR}/check_stylesheet5 ${XMLDIR}/ldap_evolutionperson1.xml ${XSLDIR}/ldap_evolutionperson2xmlformat_contact.xsl ${XSLDIR}/xmlformat_contact2ldap_evolutionperson.xsl ) + ADD_TEST( stylesheet5.5 ${TESTDIR}/check_stylesheet5 ${XMLDIR}/ldap_evolutionperson1.xml ${XSLDIR}/ldap_evolutionperson2xmlformat_contact.xsl ${XSLDIR}/xmlformat_contact2ldap_evolutionperson.xsl ) # ADD_TEST( stylesheet5.6 ${TESTDIR}/check_stylesheet5 ${XMLDIR}/ldap_evolutionperson2.xml ${XSLDIR}/ldap_evolutionperson2xmlformat_contact.xsl ${XSLDIR}/xmlformat_contact2ldap_evolutionperson.xsl ) @@ -222,15 +222,15 @@ ADD_TEST( stylesheet5.10 ${TESTDIR}/check_stylesheet5 ${XMLDIR}/ldap_event1.xml ${XSLDIR}/ldap_event2xmlformat_event.xsl ${XSLDIR}/xmlformat_event2ldap_event.xsl ) - # ADD_TEST( stylesheet5.11 ${TESTDIR}/check_stylesheet5 ${XMLDIR}/todo1.xml ${XSLDIR}/xmlformat_todo2ldap_todo.xsl ${XSLDIR}/ldap_todo2xmlformat_todo.xsl ) + ADD_TEST( stylesheet5.11 ${TESTDIR}/check_stylesheet5 ${XMLDIR}/todo1.xml ${XSLDIR}/xmlformat_todo2ldap_todo.xsl ${XSLDIR}/ldap_todo2xmlformat_todo.xsl ) - # ADD_TEST( stylesheet5.12 ${TESTDIR}/check_stylesheet5 ${XMLDIR}/ldap_todo1.xml ${XSLDIR}/ldap_todo2xmlformat_todo.xsl ${XSLDIR}/xmlformat_todo2ldap_todo.xsl ) + #ADD_TEST( stylesheet5.12 ${TESTDIR}/check_stylesheet5 ${XMLDIR}/ldap_todo1.xml ${XSLDIR}/ldap_todo2xmlformat_todo.xsl ${XSLDIR}/xmlformat_todo2ldap_todo.xsl ) ADD_TEST( stylesheet5.13 ${TESTDIR}/check_stylesheet5 ${XMLDIR}/note1.xml ${XSLDIR}/xmlformat_note2ldap_note.xsl ${XSLDIR}/ldap_note2xmlformat_note.xsl ) ADD_TEST( stylesheet5.14 ${TESTDIR}/check_stylesheet5 ${XMLDIR}/note2.xml ${XSLDIR}/xmlformat_note2ldap_note.xsl ${XSLDIR}/ldap_note2xmlformat_note.xsl ) - # ADD_TEST( stylesheet5.15 ${TESTDIR}/check_stylesheet5 ${XMLDIR}/ldap_note1.xml ${XSLDIR}/ldap_note2xmlformat_note.xsl ${XSLDIR}/xmlformat_note2ldap_note.xsl ) + #ADD_TEST( stylesheet5.15 ${TESTDIR}/check_stylesheet5 ${XMLDIR}/ldap_note1.xml ${XSLDIR}/ldap_note2xmlformat_note.xsl ${XSLDIR}/xmlformat_note2ldap_note.xsl ) ENDIF (XSLTPROC_EXECUTABLE) ENDIF (XMLLINT_EXECUTABLE) @@ -271,7 +271,7 @@ # present, the script removes them. # Otherwise the first test trying to add an already exising DN will fail # just because of "Already exists (68)" error. -ADD_TEST( remove_test_ldifs1 ${TESTDIR}/remove_test_ldifs ) +ADD_TEST( clean_up1 ${TESTDIR}/clean_up ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} ) IF (LDAPADD_EXECUTABLE) @@ -462,6 +462,9 @@ ADD_TEST( osynctool_add_note_ldif ${TESTDIR}/check_osynctool_add_ldif_and_slowsync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "note" "${TESTDIR}/note1.ldif" ) + ADD_TEST( clean_up2 ${TESTDIR}/clean_up ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} ) + + ADD_TEST( osynctool_add_contact1_xmlfile ${TESTDIR}/check_osynctool_add_file_and_slowsync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "contact" "${TESTDIR}/contact1.xml" ) ADD_TEST( osynctool_add_contact2_xmlfile ${TESTDIR}/check_osynctool_add_file_and_slowsync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "contact" "${TESTDIR}/contact2.xml" ) @@ -475,9 +478,7 @@ ADD_TEST( osynctool_add_note2_xmlfile ${TESTDIR}/check_osynctool_add_file_and_slowsync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "note" "${TESTDIR}/note2.xml" ) - - ADD_TEST( remove_test_ldifs2 ${TESTDIR}/remove_test_ldifs ) - + ADD_TEST( clean_up3 ${TESTDIR}/clean_up ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} ) ADD_TEST( osynctool_add_modify_delete_contact1_xmlfile ${TESTDIR}/check_osynctool_add_modify_delete_file_and_sync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "contact" "${TESTDIR}/contact1.xml" "${TESTDIR}/contact1.xml_modified" ) @@ -492,6 +493,26 @@ ADD_TEST( osynctool_add_modify_delete_note2_xmlfile ${TESTDIR}/check_osynctool_add_modify_delete_file_and_sync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "note" "${TESTDIR}/note2.xml" "${TESTDIR}/note2.xml_modified" ) + ADD_TEST( osynctool_add_modify_delete_all_four_xmlfiles ${TESTDIR}/check_osynctool_add_modify_delete_four_files_and_sync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "${TESTDIR}/contact1.xml" "${TESTDIR}/event1.xml" "${TESTDIR}/todo1.xml" "${TESTDIR}/note1.xml" "${TESTDIR}/contact1.xml_modified" "${TESTDIR}/event1.xml_modified" "${TESTDIR}/todo1.xml_modified" "${TESTDIR}/note1.xml_modified" ) + + + ADD_TEST( clean_up4 ${TESTDIR}/clean_up ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} ) + + + ADD_TEST( osynctool_add_modify_delete_contact1_ldif_and_sync ${TESTDIR}/check_osynctool_add_modify_delete_ldif_and_sync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "contact" ${TESTDIR}/contact1.ldif ${TESTDIR}/contact1_entrymods ) + + ADD_TEST( osynctool_add_modify_delete_contact2_ldif_and_sync ${TESTDIR}/check_osynctool_add_modify_delete_ldif_and_sync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "contact" ${TESTDIR}/contact2.ldif ${TESTDIR}/contact2_entrymods ) + + ADD_TEST( osynctool_add_modify_delete_event_ldif_and_sync ${TESTDIR}/check_osynctool_add_modify_delete_ldif_and_sync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "event" ${TESTDIR}/event1.ldif ${TESTDIR}/event1_entrymods ) + + ADD_TEST( osynctool_add_modify_delete_todo_ldif_and_sync ${TESTDIR}/check_osynctool_add_modify_delete_ldif_and_sync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "todo" ${TESTDIR}/todo1.ldif ${TESTDIR}/todo1_entrymods ) + + ADD_TEST( osynctool_add_modify_delete_note_ldif_and_sync ${TESTDIR}/check_osynctool_add_modify_delete_ldif_and_sync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} "note" ${TESTDIR}/note1.ldif ${TESTDIR}/note1_entrymods ) + + ADD_TEST( osynctool_add_modify_delete_all_four_ldifs_and_sync ${TESTDIR}/check_osynctool_add_modify_delete_four_ldifs_and_sync ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} ${TESTDIR}/contact1.ldif ${TESTDIR}/event1.ldif ${TESTDIR}/todo1.ldif ${TESTDIR}/note1.ldif ${TESTDIR}/contact1_entrymods ${TESTDIR}/event1_entrymods ${TESTDIR}/todo1_entrymods ${TESTDIR}/note1_entrymods ) + + + ENDIF (LDAPDELETE_EXECUTABLE) ENDIF (LDAPMODIFY_EXECUTABLE) @@ -539,7 +560,7 @@ ENDIF (LDAPADD_EXECUTABLE) - +ADD_TEST( final_clean_up ${TESTDIR}/clean_up ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} ) # vim:tw=0:nowrap Modified: plugins/ldap-sync/tests/check_osynctool_add_modify_delete_file_and_sync ============================================================================== --- plugins/ldap-sync/tests/check_osynctool_add_modify_delete_file_and_sync Sat Apr 4 02:36:28 2009 (r5528) +++ plugins/ldap-sync/tests/check_osynctool_add_modify_delete_file_and_sync Sat Apr 4 02:36:45 2009 (r5529) @@ -127,7 +127,7 @@ # Trigger synchronization echo -e "\n\n\nSynchronize after an XML file has been added\n\n\n" -fast_sync "$OBJECTTYPE" +fast_sync rv=$? if test $rv -ne 0; then echo "$FILE:$LINENO: ERROR: fast_sync() has failed (1)." @@ -151,10 +151,10 @@ # Trigger synchronization echo -e "\n\n\nSynchronize after the XML file has been modified\n\n\n" -fast_sync "$OBJECTTYPE" +fast_sync rv=$? if test $rv -ne 0; then - echo "$FILE:$LINENO: ERROR: fast_sync() has failed (1)." + echo "$FILE:$LINENO: ERROR: fast_sync() has failed (2)." exit 1; fi @@ -171,10 +171,10 @@ # Trigger synchronization echo -e "\n\n\nSynchronize after the XML file has been deleted\n\n\n" -fast_sync "$OBJECTTYPE" +fast_sync rv=$? if test $rv -ne 0; then - echo "$FILE:$LINENO: ERROR: fast_sync() has failed (1)." + echo "$FILE:$LINENO: ERROR: fast_sync() has failed (3)." exit 1; fi echo -e "\n\n\n" Added: plugins/ldap-sync/tests/check_osynctool_add_modify_delete_four_files_and_sync ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/ldap-sync/tests/check_osynctool_add_modify_delete_four_files_and_sync Sat Apr 4 02:36:45 2009 (r5529) @@ -0,0 +1,386 @@ +#!/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" +XMLFILE_CONTACT="$3" +XMLFILE_EVENT="$4" +XMLFILE_TODO="$5" +XMLFILE_NOTE="$6" +MODIFIED_FILE_CONTACT="$7" +MODIFIED_FILE_EVENT="$8" +MODIFIED_FILE_TODO="$9" +MODIFIED_FILE_NOTE="${10}" + + +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_CONTACT"; then + echo "$FILE:$LINENO: ERROR: \$XMLFILE_CONTACT is empty. Exiting." + exit 1 +fi + +if test ! -f "$XMLFILE_CONTACT"; then + echo "$FILE:$LINENO: ERROR: \"$XMLFILE_CONTACT\" could not be found. Exiting." + exit 1 +fi + +if test ! -r "$XMLFILE_CONTACT"; then + echo "$FILE:$LINENO: ERROR: \"$XMLFILE_CONTACT\" could be found, but it is not readable. Exiting." + exit 1 +fi + + + +if test -z "$XMLFILE_EVENT"; then + echo "$FILE:$LINENO: ERROR: \$XMLFILE_EVENT is empty. Exiting." + exit 1 +fi + +if test ! -f "$XMLFILE_EVENT"; then + echo "$FILE:$LINENO: ERROR: \"$XMLFILE_EVENT\" could not be found. Exiting." + exit 1 +fi + +if test ! -r "$XMLFILE_EVENT"; then + echo "$FILE:$LINENO: ERROR: \"$XMLFILE_EVENT\" could be found, but it is not readable. Exiting." + exit 1 +fi + + + +if test -z "$XMLFILE_TODO"; then + echo "$FILE:$LINENO: ERROR: \$XMLFILE_TODO is empty. Exiting." + exit 1 +fi + +if test ! -f "$XMLFILE_TODO"; then + echo "$FILE:$LINENO: ERROR: \"$XMLFILE_TODO\" could not be found. Exiting." + exit 1 +fi + +if test ! -r "$XMLFILE_TODO"; then + echo "$FILE:$LINENO: ERROR: \"$XMLFILE_TODO\" could be found, but it is not readable. Exiting." + exit 1 +fi + + + + +if test -z "$XMLFILE_NOTE"; then + echo "$FILE:$LINENO: ERROR: \$XMLFILE_NOTE is empty. Exiting." + exit 1 +fi + +if test ! -f "$XMLFILE_NOTE"; then + echo "$FILE:$LINENO: ERROR: \"$XMLFILE_NOTE\" could not be found. Exiting." + exit 1 +fi + +if test ! -r "$XMLFILE_NOTE"; then + echo "$FILE:$LINENO: ERROR: \"$XMLFILE_NOTE\" could be found, but it is not readable. Exiting." + exit 1 +fi + + + + + + + + +if test -z "$MODIFIED_FILE_CONTACT"; then + echo "$FILE:$LINENO: ERROR: \$MODIFIED_FILE_CONTACT is empty. Exiting." + exit 1 +fi + +if test ! -f "$MODIFIED_FILE_CONTACT"; then + echo "$FILE:$LINENO: ERROR: \"$MODIFIED_FILE_CONTACT\" could not be found. Exiting." + exit 1 +fi + +if test ! -r "$MODIFIED_FILE_CONTACT"; then + echo "$FILE:$LINENO: ERROR: \"$MODIFIED_FILE_CONTACT\" could be found, but it is not readable. Exiting." + exit 1 +fi + + + +if test -z "$MODIFIED_FILE_EVENT"; then + echo "$FILE:$LINENO: ERROR: \$MODIFIED_FILE_EVENT is empty. Exiting." + exit 1 +fi + +if test ! -f "$MODIFIED_FILE_EVENT"; then + echo "$FILE:$LINENO: ERROR: \"$MODIFIED_FILE_EVENT\" could not be found. Exiting." + exit 1 +fi + +if test ! -r "$MODIFIED_FILE_EVENT"; then + echo "$FILE:$LINENO: ERROR: \"$MODIFIED_FILE_EVENT\" could be found, but it is not readable. Exiting." + exit 1 +fi + + + +if test -z "$MODIFIED_FILE_TODO"; then + echo "$FILE:$LINENO: ERROR: \$MODIFIED_FILE_TODO is empty. Exiting." + exit 1 +fi + +if test ! -f "$MODIFIED_FILE_TODO"; then + echo "$FILE:$LINENO: ERROR: \"$MODIFIED_FILE_TODO\" could not be found. Exiting." + exit 1 +fi + +if test ! -r "$MODIFIED_FILE_TODO"; then + echo "$FILE:$LINENO: ERROR: \"$MODIFIED_FILE_TODO\" could be found, but it is not readable. Exiting." + exit 1 +fi + + + + +if test -z "$MODIFIED_FILE_NOTE"; then + echo "$FILE:$LINENO: ERROR: \$MODIFIED_FILE_NOTE is empty. Exiting." + exit 1 +fi + +if test ! -f "$MODIFIED_FILE_NOTE"; then + echo "$FILE:$LINENO: ERROR: \"$MODIFIED_FILE_NOTE\" could not be found. Exiting." + exit 1 +fi + +if test ! -r "$MODIFIED_FILE_NOTE"; then + echo "$FILE:$LINENO: ERROR: \"$MODIFIED_FILE_NOTE\" 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_files + + +# Add XML files +echo -e "\n\n\nAdd XML files\n\n\n" +add_file "contact" "$XMLFILE_CONTACT" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: add_file() has failed." + exit 1; +fi + +add_file "event" "$XMLFILE_EVENT" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: add_file() has failed." + exit 1; +fi + +add_file "todo" "$XMLFILE_TODO" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: add_file() has failed." + exit 1; +fi + +add_file "note" "$XMLFILE_NOTE" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: add_file() has failed." + exit 1; +fi + + + + + +# Trigger synchronization after ADD +echo -e "\n\n\nSynchronize after 4 XML files have been added\n\n\n" +fast_sync +rv=$? +if test "$rv" -ne 0; then + echo "$FILE:$LINENO: ERROR: fast_sync has failed after 4 XML files have been added." + exit $rv +fi + + + + +# Modify all of the 4 XML files +echo -e "\n\n\nModify 4 XML files\n\n\n" +modify_file "contact" "$XMLFILE_CONTACT" "$MODIFIED_FILE_CONTACT" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: modify_file() has failed." + exit 1; +fi + + +modify_file "event" "$XMLFILE_EVENT" "$MODIFIED_FILE_EVENT" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: modify_file() has failed." + exit 1; +fi + + +modify_file "todo" "$XMLFILE_TODO" "$MODIFIED_FILE_TODO" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: modify_file() has failed." + exit 1; +fi + + +modify_file "note" "$XMLFILE_NOTE" "$MODIFIED_FILE_NOTE" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: modify_file() has failed." + exit 1; +fi + + + + + + +# Trigger synchronization after MODIFY +echo -e "\n\n\nSynchronize after 4 XML files have been modified\n\n\n" +fast_sync +rv=$? +if test "$rv" -ne 0; then + echo "$FILE:$LINENO: ERROR: fast_sync has failed after 4 XML files have been modified." + exit $rv +fi + + + + + + + +# Delete all of the 4 XML Files +echo -e "\n\n\nDelete 4 XML files\n\n\n" +delete_file "contact" "$XMLFILE_CONTACT" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: delete_file() has failed." + exit 1; +fi + +delete_file "event" "$XMLFILE_EVENT" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: delete_file() has failed." + exit 1; +fi + +delete_file "todo" "$XMLFILE_TODO" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: delete_file() has failed." + exit 1; +fi + +delete_file "note" "$XMLFILE_NOTE" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: delete_file() has failed." + exit 1; +fi + + + + + + + + +# Trigger synchronization after DELETE +echo -e "\n\n\nSynchronize after 4 XML files have been deleted\n\n\n" +fast_sync +rv=$? +if test "$rv" -ne 0; then + echo "$FILE:$LINENO: ERROR: fast_sync has failed after 4 XML files have been deleted." + exit $rv +fi + + + + + +# Shut down test group +epilogue + + +if test -d "$TMPDIR"; then + rm -rf "$TMPDIR" +fi + + +exit $rv Added: plugins/ldap-sync/tests/check_osynctool_add_modify_delete_four_ldifs_and_sync ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/ldap-sync/tests/check_osynctool_add_modify_delete_four_ldifs_and_sync Sat Apr 4 02:36:45 2009 (r5529) @@ -0,0 +1,382 @@ +#!/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" +LDIF_CONTACT="$3" +LDIF_EVENT="$4" +LDIF_TODO="$5" +LDIF_NOTE="$6" +ENTRYMODS_CONTACT="$7" +ENTRYMODS_EVENT="$8" +ENTRYMODS_TODO="$9" +ENTRYMODS_NOTE="${10}" + + + +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 "$LDIF_CONTACT"; then + echo "$FILE:$LINENO: ERROR: \$LDIF_CONTACT is empty. Exiting." + exit 1 +fi + +if test ! -f "$LDIF_CONTACT"; then + echo "$FILE:$LINENO: ERROR: \"$LDIF_CONTACT\" could not be found. Exiting." + exit 1 +fi + +if test ! -r "$LDIF_CONTACT"; then + echo "$FILE:$LINENO: ERROR: \"$LDIF_CONTACT\" could be found, but it is not readable. Exiting." + exit 1 +fi + + + + +if test -z "$LDIF_EVENT"; then + echo "$FILE:$LINENO: ERROR: \$LDIF_EVENT is empty. Exiting." + exit 1 +fi + +if test ! -f "$LDIF_EVENT"; then + echo "$FILE:$LINENO: ERROR: \"$LDIF_EVENT\" could not be found. Exiting." + exit 1 +fi + +if test ! -r "$LDIF_EVENT"; then + echo "$FILE:$LINENO: ERROR: \"$LDIF_EVENT\" could be found, but it is not readable. Exiting." + exit 1 +fi + + + +if test -z "$LDIF_TODO"; then + echo "$FILE:$LINENO: ERROR: \$LDIF_TODO is empty. Exiting." + exit 1 +fi + +if test ! -f "$LDIF_TODO"; then + echo "$FILE:$LINENO: ERROR: \"$LDIF_TODO\" could not be found. Exiting." + exit 1 +fi + +if test ! -r "$LDIF_TODO"; then + echo "$FILE:$LINENO: ERROR: \"$LDIF_TODO\" could be found, but it is not readable. Exiting." + exit 1 +fi + + + + +if test -z "$LDIF_NOTE"; then + echo "$FILE:$LINENO: ERROR: \$LDIF_NOTE is empty. Exiting." + exit 1 +fi + +if test ! -f "$LDIF_NOTE"; then + echo "$FILE:$LINENO: ERROR: \"$LDIF_NOTE\" could not be found. Exiting." + exit 1 +fi + +if test ! -r "$LDIF_NOTE"; then + echo "$FILE:$LINENO: ERROR: \"$LDIF_NOTE\" could be found, but it is not readable. Exiting." + exit 1 +fi + + + + + + + + +if test -z "$ENTRYMODS_CONTACT"; then + echo "$FILE:$LINENO: ERROR: \$ENTRYMODS_CONTACT is empty. Exiting." + exit 1 +fi + +if test ! -f "$ENTRYMODS_CONTACT"; then + echo "$FILE:$LINENO: ERROR: \"$ENTRYMODS_CONTACT\" could not be found. Exiting." + exit 1 +fi + +if test ! -r "$ENTRYMODS_CONTACT"; then + echo "$FILE:$LINENO: ERROR: \"$ENTRYMODS_CONTACT\" could be found, but it is not readable. Exiting." + exit 1 +fi + + +if test -z "$ENTRYMODS_EVENT"; then + echo "$FILE:$LINENO: ERROR: \$ENTRYMODS_EVENT is empty. Exiting." + exit 1 +fi + +if test ! -f "$ENTRYMODS_EVENT"; then + echo "$FILE:$LINENO: ERROR: \"$ENTRYMODS_EVENT\" could not be found. Exiting." + exit 1 +fi + +if test ! -r "$ENTRYMODS_EVENT"; then + echo "$FILE:$LINENO: ERROR: \"$ENTRYMODS_EVENT\" could be found, but it is not readable. Exiting." + exit 1 +fi + + + +if test -z "$ENTRYMODS_TODO"; then + echo "$FILE:$LINENO: ERROR: \$ENTRYMODS_TODO is empty. Exiting." + exit 1 +fi + +if test ! -f "$ENTRYMODS_TODO"; then + echo "$FILE:$LINENO: ERROR: \"$ENTRYMODS_TODO\" could not be found. Exiting." + exit 1 +fi + +if test ! -r "$ENTRYMODS_TODO"; then + echo "$FILE:$LINENO: ERROR: \"$ENTRYMODS_TODO\" could be found, but it is not readable. Exiting." + exit 1 +fi + + + + +if test -z "$ENTRYMODS_NOTE"; then + echo "$FILE:$LINENO: ERROR: \$ENTRYMODS_NOTE is empty. Exiting." + exit 1 +fi + +if test ! -f "$ENTRYMODS_NOTE"; then + echo "$FILE:$LINENO: ERROR: \"$ENTRYMODS_NOTE\" could not be found. Exiting." + exit 1 +fi + +if test ! -r "$ENTRYMODS_NOTE"; then + echo "$FILE:$LINENO: ERROR: \"$ENTRYMODS_NOTE\" 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_files + + +# Add 4 LDIFs +echo -e "\n\n\nAdd 4 LDIFs\n\n\n" +run_ldapadd "$LDIF_CONTACT" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: run_ldapadd has failed." + exit 1; +fi + +run_ldapadd "$LDIF_EVENT" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: run_ldapadd has failed." + exit 1; +fi + +run_ldapadd "$LDIF_TODO" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: run_ldapadd has failed." + exit 1; +fi + +run_ldapadd "$LDIF_NOTE" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: run_ldapadd has failed." + exit 1; +fi + + + + + + +# Trigger synchronization +echo -e "\n\n\nSynchronize after 4 LDIFs have been added\n\n\n" +fast_sync +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: fast_sync() has failed (1)." + exit 1; +fi + + +# Modify all of the 4 LDIFs +echo -e "\n\n\nModify 4 LDIFs\n\n\n" +run_ldapmodify "$ENTRYMODS_CONTACT" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: run_ldapmodify() has failed." + exit 1; +fi + +run_ldapmodify "$ENTRYMODS_EVENT" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: run_ldapmodify() has failed." + exit 1; +fi + +run_ldapmodify "$ENTRYMODS_TODO" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: run_ldapmodify() has failed." + exit 1; +fi + +run_ldapmodify "$ENTRYMODS_NOTE" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: run_ldapmodify() has failed." + exit 1; +fi + + + + +# Trigger synchronization +echo -e "\n\n\nSynchronize after all of the 4 LDIFs have been modified\n\n\n" +fast_sync +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: fast_sync() has failed (2)." + exit 1; +fi + + +# Delete all of the 4 LDIFs +echo -e "\n\n\nDelete all of the 4 LDIFs\n\n\n" +run_ldapdelete "$LDIF_CONTACT" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: run_ldapdelete has failed." + exit 1; +fi + +run_ldapdelete "$LDIF_EVENT" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: run_ldapdelete has failed." + exit 1; +fi + +run_ldapdelete "$LDIF_TODO" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: run_ldapdelete has failed." + exit 1; +fi + +run_ldapdelete "$LDIF_NOTE" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: run_ldapdelete has failed." + exit 1; +fi + + + + + + + +# Trigger synchronization +echo -e "\n\n\nSynchronize after the LDIFs have been deleted\n\n\n" +fast_sync +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: fast_sync() has failed (3)." + exit 1; +fi +echo -e "\n\n\n" + + + +# Shut down test group +epilogue + + +if test -d "$TMPDIR"; then + rm -rf "$TMPDIR" +fi + + +exit $rv + +#vim:ts=2:sw=2 Added: plugins/ldap-sync/tests/check_osynctool_add_modify_delete_ldif_and_sync ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/ldap-sync/tests/check_osynctool_add_modify_delete_ldif_and_sync Sat Apr 4 02:36:45 2009 (r5529) @@ -0,0 +1,192 @@ +#!/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" +LDIF="$4" +ENTRYMODS="$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 "$LDIF"; then + echo "$FILE:$LINENO: ERROR: \$LDIF is empty. Exiting." + exit 1 +fi + +if test ! -f "$LDIF"; then + echo "$FILE:$LINENO: ERROR: \"$LDIF\" could not be found. Exiting." + exit 1 +fi + +if test ! -r "$LDIF"; then + echo "$FILE:$LINENO: ERROR: \"$LDIF\" could be found, but it is not readable. Exiting." + exit 1 +fi + + +if test -z "$ENTRYMODS"; then + echo "$FILE:$LINENO: ERROR: \$ENTRYMODS is empty. Exiting." + exit 1 +fi + +if test ! -f "$ENTRYMODS"; then + echo "$FILE:$LINENO: ERROR: \"$ENTRYMODS\" could not be found. Exiting." + exit 1 +fi + +if test ! -r "$ENTRYMODS"; then + echo "$FILE:$LINENO: ERROR: \"$ENTRYMODS\" 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 LDIF +echo -e "\n\n\nAdd LDIF\n\n\n" +run_ldapadd "$LDIF" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: run_ldapadd 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 LDIF has been added\n\n\n" +fast_sync +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: fast_sync() has failed (1)." + exit 1; +fi + + +# Modify the LDIF +echo -e "\n\n\nModify LDIF\n\n\n" +run_ldapmodify "$ENTRYMODS" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: run_ldapmodify() has failed." + exit 1; +fi + + + +# Trigger synchronization +echo -e "\n\n\nSynchronize after the LDIF has been modified\n\n\n" +fast_sync +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: fast_sync() has failed (1)." + exit 1; +fi + + +# Delete the LDIF +echo -e "\n\n\nDelete LDIF\n\n\n" +run_ldapdelete "$LDIF" +rv=$? +if test $rv -ne 0; then + echo "$FILE:$LINENO: ERROR: run_ldapdelete has failed." + exit 1; +fi + + +# Trigger synchronization +echo -e "\n\n\nSynchronize after the LDIF has been deleted\n\n\n" +fast_sync +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 + + +if test -d "$TMPDIR"; then + rm -rf "$TMPDIR" +fi + + +exit $rv + +#vim:ts=2:sw=2 Added: plugins/ldap-sync/tests/clean_up ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ plugins/ldap-sync/tests/clean_up Sat Apr 4 02:36:45 2009 (r5529) @@ -0,0 +1,35 @@ +#!/bin/bash + +set -x + +FILE=$0 +PLUGINNAME="ldap-sync" +PLUGINPATH="$1/src" +CFG="$2/src/$PLUGINNAME" +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" + + +###### Clean up LDAP server +$SOURCE_DIR/remove_test_ldifs + +###### Clean up directories in /tmp +remove_files + + |