2 # This script is uses ShUnit to test packaging/common/*. Currently
3 # it only tests the functions as they perform for rpm and deb building.
4 # As support is added for other styles of package, these tests should be
7 #######################
8 # If EXECUTING WITH ROOT ACCESS SCRIPT DELETES AND CREATES USERS.
9 # EXECUTE WITH CAUTION.
10 #######################
14 # Note on conflicting variable names:
15 # SHUNIT_* and SHU_* are shunit2 variables
16 # test_* should only be used by test functions.
17 # All other variables will probably be used by pre/post/common functions.
19 # shunit2 assumes _inc is, but we might run from a separate builddir. So try to
20 # use srcdir, as defined by automake, or otherwise `pwd`.
21 SHUNIT_INC="${srcdir=`pwd`}/packaging/common"; export SHUNIT_INC
23 TMPDIR=`pwd`/shunit-test; export TMPDIR
24 amanda_user=test_amandabackup; export amanda_user
25 amanda_group=test_disk; export amanda_group
26 sup_group="test_tape"; export sup_group
27 AMANDAHOMEDIR=$TMPDIR/amanda; export AMANDAHOMEDIR
28 AMANDATES=$AMANDAHOMEDIR/amandates; export AMANDATES
30 wanted_shell='/bin/false'; export wanted_shell
31 dist=Fedora; export dist
32 SYSCONFDIR=$TMPDIR/etc; export SYSCONFDIR
33 SBINDIR=$TMPDIR/sbin; export SBINDIR
34 # Don't potentially conflict with a real value...
35 deb_uid=63000; export deb_uid
38 # Append stuff to this when you make temp files if they are outside TMPDIR
39 test_cleanup_files="$TMPDIR"; export test_cleanup_files
41 # This can't be part of one-time setup, because TMPDIR must exist before
43 mkdir -p ${TMPDIR} || exit 1
46 (umask 077 && mktemp "$TMPDIR/test-log.XXXX") 2> /dev/null
50 LOGFILE=$TMPDIR/test-log.$$.$RANDOM
51 (umask 077 && touch "$LOGFILE")
53 echo "Unable to create log file!"
59 msg_prefix="oneTimeSetUp: "
60 if [ "$IAmRoot" ]; then
61 # Delete an existing user.
62 echo "$msg_prefix attempting to delete an existing user."
63 userdel -f -r ${amanda_user}
64 # If the user exists, our tests will act wrong, so exit
65 grep "${amanda_user}" ${SYSCONFDIR}/passwd &> /dev/null || { \
66 echo "$msg_prefix ${amanda_user} still exists, or no ${SYSCONFDIR}/passwd.";
68 groupdel ${amanda_group} || exit 1
69 groupdel ${sup_group} || exit 1
71 echo "Not root, cleanup skipped"
73 # Make all directories which might be needed.
74 mkdir -p ${AMANDAHOMEDIR}/example
75 if [ ! "$IAmRoot" ]; then
76 mkdir -p ${SYSCONFDIR}/xinetd.d
77 mkdir -p ${SYSCONFDIR}/init.d
82 if [ ${__shunit_assertsFailed} -eq 0 ]; then
83 rm -rf $test_cleanup_files
85 echo "Check ${test_cleanup_files} for logs and error info."
89 test_cleanup_files="$LOGFILE ${test_cleanup_files}"
91 # shows syntax errors before the tests are run.
92 . ${SHUNIT_INC}/common_functions.sh
93 . ${SHUNIT_INC}/pre_inst_functions.sh
94 . ${SHUNIT_INC}/post_inst_functions.sh
95 . ${SHUNIT_INC}/post_rm_functions.sh
97 # Use this to skip root requiring tests.
98 # id -u is not portable to solaris.
99 tester_id=`id | sed 's/gid=\([0-9]*\).*/\1/'`
100 if [ "$tester_id" = "0" ]; then
101 # Same as SHUNIT_TRUE, but we can't use that yet...
107 # CAUTION: using real values if we are root.
108 if [ "$IAmRoot" ]; then
109 amanda_group=disk; export amanda_group
110 SYSCONFDIR=/etc; export SYSCONFDIR
111 SBINDDIR=/sbin; export SBINDDIR
114 # Source our mock utils.
115 . ${SHUNIT_INC}/mock_utils.sh
117 ######################################
120 # shUnit reorders tests alphabetically. We need the logger and cleanup tests
123 # Write a line to the log, test that it got there.
124 TEST_MSG="test___logger message"
125 LOG_LINE="`date +'%b %e %Y %T'`: ${TEST_MSG}"
126 # It's important for the log messages to be quoted, or funny stuff happens.
128 assertEquals "logger() return code" 0 $?
129 LOG_TAIL=`tail -1 ${LOGFILE}`
130 assertEquals "logger() did not write <${LOG_LINE}> " \
131 "${LOG_LINE}" "${LOG_TAIL}"
132 # Leave this outside the unit test framework. if the logger is
133 # broken we must exit.
134 if [ ! `grep -c "${LOG_LINE}" ${LOGFILE}` = "1" ]; then
135 echo "error: logger(): Incorrect content in ${LOGFILE}: " `cat ${LOGFILE}`
140 test__log_output_of() {
141 # Use log_output_of to append to the log
142 TEST_MSG="test__log_output_of message"
143 log_output_of echo "${TEST_MSG}"
144 assertEquals "log_output_of()" 0 $?
145 COUNT=`grep -c "${TEST_MSG}" ${LOGFILE}`
146 assertEquals "log_output_of(): incorrect content in log" \
148 # Leave this outside the unit test framework. if the logger is
149 # broken we must exit.
150 if [ ! ${COUNT} = '1' ]; then
151 echo "error: log_output_of(): Incorrect content in ${LOGFILE}: " `cat ${LOGFILE}`
157 # NOTE: check_xinetd and check_inetd tests end up simply duplicating the
158 # code of the function itself
161 logger "test_check_smf"
162 [ "$os" = "SunOS" ] || { startSkipping; echo "test_check_smf: skipped"; }
163 # Test existing service
164 touch ${MOCKDIR}/prexisting_service
166 assertEquals "check_smf preexisting services" 0 $?
167 rm ${MOCKDIR}/prexisting_service
169 assertEquals "check_smf no amanda service" 1 $?
172 test_check_superserver_running() {
173 logger "test_check_superserver_running"
174 [ "$IAmRoot" ] && { startSkipping; echo "test_check_superserver_running: skipped"; }
175 # Test the positive cases
176 # running changes the output of mocked ps
177 touch ${MOCKDIR}/running
178 check_superserver_running inetd
179 assertEquals "check_superserver_running inetd" 0 $?
180 assertSame "ps args: -e" "`cat $mock_ps_flags`"
181 if [ `uname` = 'Darwin' ]; then
182 [ "$IAmRoot" ] && startSkipping
183 check_superserver_running launchd
184 assertEquals "check_superserver_running launchd" 0 $?
185 assertSame "ps args: aux" "`cat $mock_ps_flags`"
189 check_superserver_running launchd
192 # Test the negative case, skip if root
193 [ "$IAmRoot" ] && startSkipping
194 rm ${MOCKDIR}/running
195 check_superserver_running inetd
196 assertEquals "check_superserver_running inetd returned 0 when inetd was not running" 1 $?
197 assertSame "ps args: -e" "`cat $mock_ps_flags`"
198 check_superserver_running xinetd
199 assertNotEquals "check_superserver_running xinetd incorrectly returned 0" \
201 assertSame "ps args: -e" "`cat $mock_ps_flags`"
204 test_backup_xinetd() {
205 logger "test_backup_xinetd"
206 touch ${SYSCONFDIR}/xinetd.d/amandaserver
207 backup_xinetd "amandaserver"
208 assertEquals "backup_xinetd returns 0" 0 $?
209 assertTrue "[ -f ${AMANDAHOMEDIR}/example/*.amandaserver.orig ]"
212 test_backup_inetd() {
213 logger "test_backup_inetd"
215 SunOS) inetd_dir=${SYSCONFDIR}/inet ;;
216 *) inetd_dir=${SYSCONFDIR} ;;
218 [ -d "${inetd_dir}" ] || mkdir -p ${inetd_dir}
219 touch ${inetd_dir}/inetd.conf
220 echo "amanda foo/bar/baz amandad" >> ${inetd_dir}/inetd.conf
222 assertEquals "backup_inetd returns 0" 0 $?
223 assertTrue "[ -f ${AMANDAHOMEDIR}/example/inetd.orig ]"
227 logger "test_backup_smf"
229 # TODO: how to mock this?
232 test_install_xinetd() {
233 logger "test_install_xinetd"
234 if [ "$os" = "SunOS" ] ; then
235 # Solaris has install_xinetd_sol
237 echo "test_install_xinetd: skipped"
241 touch ${MOCKDIR}/success
242 touch ${AMANDAHOMEDIR}/example/xinetd.amandaserver
243 install_xinetd "amandaserver"
244 assertEquals "install_xinetd returns 0" 0 $?
245 # Test "install" failure
246 rm ${MOCKDIR}/success
247 install_xinetd "amandaserver"
248 assertEquals "install_xinetd returns 1" 1 $?
251 test_install_inetd() {
252 logger "test_install_inetd"
254 SunOS) inetd_dir=${BASEDIR}/${SYSCONFDIR}/inet ;;
255 *) inetd_dir=${SYSCONFDIR} ;;
257 [ -f ${inetd_dir}/inetd.conf ] || touch ${inetd_dir}/inetd.conf
258 test_inetd_entry='amanda foo/bar/baz amandad'
259 if [ ! -f ${AMANDAHOMEDIR}/example/inetd.conf ]; then
260 echo "${test_inetd_entry}" > ${AMANDAHOMEDIR}/example/inetd.conf.amandaserver
262 install_inetd amandaserver
263 assertEquals "install_inetd returns 0" 0 $?
264 assertSame "${test_inetd_entry}" "`tail -1 ${inetd_dir}/inetd.conf`"
267 # TODO: test_install_smf() {
268 # Needs mocks for: inetconv, inetadm, svcadm.
270 test_reload_xinetd() {
271 logger "test_reload_xinetd"
272 # Might need init script.
273 if [ "$IAmRoot" ]; then
275 echo "test_install_smf: skipped"
277 elif [ ! -f "${SYSCONFDIR}/init.d/xinetd" ]; then
278 mv ${MOCKDIR}/xinetd ${SYSCONFDIR}/init.d
282 assertEquals "reload_xinetd should reject argument 'foo'" 1 $?
284 touch ${MOCKDIR}/success
285 reload_xinetd "reload"
286 assertEquals "reload_xinetd" 0 $?
288 rm ${MOCKDIR}/success
289 reload_xinetd "reload"
290 assertEquals "reload_xinetd" 1 $?
291 tail -4 ${LOGFILE}|grep "\<xinetd.*Attempting restart" >/dev/null
292 assertEquals "reload_xinetd should try to restart." 0 $?
293 reload_xinetd "restart"
294 assertEquals "restart should fail." 1 $?
295 tail -3 ${LOGFILE}|grep "Restarting xinetd" >/dev/null
296 assertEquals "Should log attempt to restart" 0 $?
299 test_reload_inetd() {
300 logger "test_reload_inetd"
302 # Might need init script.
303 if [ ! "$IAmRoot" ]; then
304 if [ ! -f "${SYSCONFDIR}/init.d/inetd" ]; then
305 mv ${MOCKDIR}/inetd ${SYSCONFDIR}/init.d
310 assertEquals "reload_inetd should reject argument 'foo' (return 1):" 1 $?
312 touch ${MOCKDIR}/success
314 assertEquals "reload_inetd" 0 $?
316 rm ${MOCKDIR}/success
317 reload_inetd "reload"
318 assertEquals "reload_inetd" 1 $?
319 tail -4 ${LOGFILE}|grep "\<inetd.*Attempting restart" >/dev/null
320 assertEquals "reload_inetd should try to restart." 0 $?
321 reload_inetd "restart"
322 assertEquals "restart should fail." 1 $?
323 tail -3 ${LOGFILE}|grep "Restarting inetd" >/dev/null
324 assertEquals "Should log attempt to restart" 0 $?
328 ######################################
329 # pre_install_functions
331 test_check_user_group_missing() {
332 logger "test_check_user_group_missing no param"
334 assertNotEquals "'check_user_group' should fail" 0 $?
335 logger "test_check_user_group_missing missing group"
336 [ ! "$IAmRoot" ] && rm -f ${SYSCONFDIR}/group
337 touch ${SYSCONFDIR}/group
338 for os in linux osx solaris; do
339 echo $os > ${MOCKDIR}/id_os
340 check_user_group "abracadabra"
341 assertNotEquals "'check_user group abracadabra' should not be found:" 0 $?
342 LOG_TAIL=`tail -1 ${LOGFILE}|cut -d " " -f 5-`
343 assertEquals "check_user_group should write" \
344 "User's primary group 'abracadabra' does not exist" \
349 good_group_entry="${amanda_group}:x:100:"
350 export good_group_entry
351 test_check_user_group_exists() {
352 logger "test_check_user_group user and group exist"
353 touch ${MOCKDIR}/id_exists
354 touch ${SYSCONFDIR}/group
355 # Non-root adds and entry to the mock group file
356 [ ! "$IAmRoot" ] && echo $good_group_entry > ${SYSCONFDIR}/group
357 for os in linux osx solaris; do
358 echo $os > ${MOCKDIR}/id_os
360 # Case 1: Amanda_user is correct.
361 echo ${amanda_group} > ${MOCKDIR}/id_group
362 check_user_group "${amanda_group}"
363 assertEquals "'check_user_group ${amanda_group}': id returns correct groupname" \
366 # Case 2: Amanda_user is not a member of the the correct primary group.
367 rm ${MOCKDIR}/id_group
368 check_user_group "${amanda_group}"
369 assertEquals "'check_user_group ${amanda_group}' when not a member" 1 $?
373 test_check_user_supplemental_group_missing() {
374 logger "test_check_user_supplemental_group missing"
375 [ ! "$IAmRoot" ] && echo $good_group_entry > ${SYSCONFDIR}/group
376 for os in linux osx solaris; do
377 echo $os > ${MOCKDIR}/id_os
378 check_user_supplemental_group ${sup_group}
379 assertEquals "'check_user supplemental-group ${sup_group}' when group missing" \
384 missing_group_member="${sup_group}:x:105:nobody"
385 export missing_group_member
386 good_sup_group_entry="${missing_group_member},${amanda_user}"
387 export good_sup_group_entry
389 test_check_user_supplemental_group_exists() {
390 logger "test_check_user_supplemental_group exists"
391 [ ! "$IAmRoot" ] && echo $missing_group_member > ${SYSCONFDIR}/group
392 check_user_supplemental_group ${sup_group}
393 assertEquals "'check_user_supplemental_group ${sup_group}' when amanda_user is not a member" \
396 [ ! "$IAmRoot" ] && echo ${good_sup_group_entry} > ${SYSCONFDIR}/group
397 check_user_supplemental_group ${sup_group}
398 assertEquals "'check_user_supplemental_group ${sup_group}' with correct membership" \
401 test_check_user_shell() {
402 logger "test_check_user_shell"
403 if [ ! "$IAmRoot" ]; then
404 echo "${good_passwd_entry}" > ${SYSCONFDIR}/passwd
406 # Case 1: Provide a matching shell
407 check_user_shell "/bin/bash"
408 assertEquals "check_user_shell /bin/bash (matching)" 0 $?
409 # Case 2: Provide a non-matching shell.
410 check_user_shell "/bin/ksh"
411 assertEquals "check_user_shell /bin/ksh (not matching)" 1 $?
414 test_check_user_homedir() {
415 logger 'test_check_user_homedir'
416 if [ ! "$IAmRoot" ]; then
417 echo "${good_passwd_entry}" > ${SYSCONFDIR}/passwd
419 # Case 1: Assume amanda_user is correct.
420 check_user_homedir "${AMANDAHOMEDIR}"
421 assertEquals "check_user_homedir ${AMANDAHOMEDIR}" 0 $?
422 # Case 2: Provide an incorrect homedir
423 check_user_homedir "/tmp"
424 assertEquals "check_user_homedir /tmp" 1 $?
427 test_check_user_uid() {
428 echo "${amanda_group}" > ${MOCKDIR}/id_group
429 touch ${MOCKDIR}/id_exists
430 logger 'test_check_user_uid'
431 for os in linux osx solaris; do
432 echo $os > ${MOCKDIR}/id_os
434 assertEquals "check_user_uid without a uid" 1 $?
435 logger 'test_check_user_uid wrong id'
437 assertEquals "check_user_uid uids don't match" 1 $?
438 logger 'test_check_user_uid correct id'
439 check_user_uid ${deb_uid}
443 test_check_homedir_dir_missing() {
444 logger "test_check_homedir_dir_missing"
445 # First make sure the dir is missing
446 rm -rf ${AMANDAHOMEDIR}
448 assertNotEquals "check_homedir returned 0, but homedir did not exist" 0 $?
451 # passwd file entry for Linux systems, maybe others. UID is correct
452 # for Debian as well.
453 good_passwd_entry="${amanda_user}:x:${mock_deb_uid}:6::${AMANDAHOMEDIR}:/bin/bash"
454 export good_passwd_entry
456 logger "test_create_user"
457 if [ ! "$IAmRoot" ]; then
459 echo "test_create_user: Creating mock passwd file."
460 echo "$good_passwd_entry" > ${SYSCONFDIR}/passwd
461 echo "test_create_user: tests skipped."
465 # Case 1: create_user should succeed.
467 assertEquals "create_user()" 0 $?
470 test_add_group_check_parameters_logs() {
471 rm -f ${MOCKDIR}/groupadd_rc ${MOCKDIR}/num_groups
472 # Return codes are integers.
473 printf '%i' 0 > ${MOCKDIR}/groupadd_rc
474 # Test that first parameter is required.
476 assertEquals "add_group without a group should fail." 1 $?
477 LOG_TAIL=`tail -1 ${LOGFILE}|cut -d " " -f 5-`
478 assertEquals "add_group should write" \
479 "Error: first argument was not a group to add." \
483 test_add_group_group_ok() {
484 # groupadd created group
485 printf '%i' 0 > ${MOCKDIR}/groupadd_rc
486 echo '${amanda_user} : prev_grp1' > ${MOCKDIR}/groups_output
488 assertEquals "add_group group ok" 0 $?
489 flags=`cat ${mock_usermod_flags}`
490 assertEquals "usermod_flags" \
491 "usermod args: -G prev_grp1,twinkle ${amanda_user}" \
494 # Make sure supplemental groups are preserved when adding groups to an
496 echo '${amanda_user} : prev_grp1 prev_grp2' > ${MOCKDIR}/groups_output
497 printf '%i' 1 > ${MOCKDIR}/num_groups
499 assertEquals "add_group group ok" 0 $?
500 flags=`cat ${mock_usermod_flags}`
501 assertEquals "usermod_flags should contain:" \
502 "usermod args: -G prev_grp1,prev_grp2,twinkle ${amanda_user}" \
506 test_create_homedir() {
507 logger "test_create_homedir"
508 rm -rf ${AMANDAHOMEDIR}
510 assertEquals "create_homedir returns 0" 0 $?
511 assertTrue "${AMANDAHOMEDIR} did not get created" "[ -d ${AMANDAHOMEDIR} ]"
512 if [ "$IAmRoot" ]; then
514 real_owner=`ls -ld $AMANDAHOMEDIR | awk '{ print $3":"$4; }'`
515 assertSame "${amanda_user}:${amanda_group}" "$real_owner"
518 "chown args: -R ${amanda_user}:${amanda_group} ${AMANDAHOMEDIR}" \
519 "`cat $mock_chown_flags`"
521 # A second run should succeed too.
523 assertEquals "When homedir exists, create_homedir returns 0:" 0 $?
524 # Later tests use ${AMANDAHOMEDIR}, so leave the dir there.
527 test_check_homedir_dir_existing() {
528 logger "test_check_homedir_dir_existing"
529 # Create the dir (example needed for other tests), then check again.
530 mkdir -p ${AMANDAHOMEDIR}/example
532 assertEquals "Homedir exists; check_homedir" 0 $?
535 test_create_logdir() {
536 logger "test_create_logdir"
537 # The logdir variable for the shell libs, not shunit2.
538 LOGDIR=$TMPDIR/amanda_log; export LOGDIR
540 rm -rf ${LOGDIR}.save
542 assertEquals "create_logdir clean system" 0 $?
543 if [ -n "$IAmRoot" ]; then
544 real_owner=`ls -ld $LOGDIR | awk '{ print $3":"$4; }'`
545 assertSame "${amanda_user}:${amanda_group}" "$real_owner"
548 "chown args: -R ${amanda_user}:${amanda_group} ${LOGDIR}"\
549 "`cat $mock_chown_flags`"
551 assertTrue "${LOGDIR} exists" "[ -d ${LOGDIR} ]"
552 # What happens if logdir is a file?
556 assertEquals "create_logdir" 0 $?
557 assertTrue "${LOGDIR} exists" "[ -d ${LOGDIR} ]"
558 assertTrue "${LOGDIR}/amanda_log.save backup exists" \
559 "[ -f ${LOGDIR}/amanda_log.save ]"
562 test_create_amandates() {
563 logger "test_create_amandates"
566 assertEquals "create_amandates" 0 $?
567 assertTrue "[ -f ${AMANDATES} ]"
570 test_check_amandates() {
571 logger "test_check_amandates"
572 touch $mock_chown_flags
573 touch $mock_chmod_flags
575 assertEquals "check_amandates" 0 $?
576 [ "$IAmRoot" ] && { startSkipping; echo "test_check_amandates: skipped"; }
578 "chown args: ${amanda_user}:${amanda_group} ${AMANDATES}" \
579 "`cat $mock_chown_flags`"
581 "chmod args: 0640 ${AMANDATES}" \
582 "`cat $mock_chmod_flags`"
585 test_create_gnupg() {
586 logger "test_create_gnupg"
588 assertEquals "create_gnupg" 0 $?
589 assertTrue "[ -d ${AMANDAHOMEDIR}/.gnupg ]"
593 logger "test_check_gnupg"
595 assertEquals "check_gnupg" 0 $?
596 [ "$IAmRoot" ] && { startSkipping; echo "test_check_gnupg: skipped"; }
598 "chown args: ${amanda_user}:${amanda_group} ${AMANDAHOMEDIR}/.gnupg" \
599 "`cat $mock_chown_flags`"
601 "chmod args: 700 ${AMANDAHOMEDIR}/.gnupg" \
602 "`cat $mock_chmod_flags`"
605 test_create_amandahosts() {
606 logger "test_create_amandahosts"
608 assertEquals "create_amandahosts:" 0 $?
609 assertEquals "${AMANDAHOMEDIR}/.amandahosts exists:" 0 $?
610 assertEquals "create_amandahosts" 0 $?
611 assertTrue "[ -f ${AMANDAHOMEDIR}/.amandahosts ]"
614 test_check_amandahosts_entry() {
615 logger "test_check_amandahosts_entry"
616 if [ -f ${AMANDAHOMEDIR}/.amandahosts ]; then
617 check_amandahosts_entry root amindexd amidxtaped
618 assertEquals "check_amandahosts_entry root amindexd amidxtaped" \
621 echo "test_check_amandahosts_entry: ${AMANDAHOMEDIR}/.amandahosts missing. test skipped"
626 test_check_amandahosts_perm() {
627 logger "test_check_amandahosts_perm"
628 check_amandahosts_perms
629 assertEquals "check_amandahosts_perms" 0 $?
630 [ "$IAmRoot" ] && { startSkipping; echo "test_check_amandahosts_perm: skipped"; }
632 "chown args: ${amanda_user}:${amanda_group} ${AMANDAHOMEDIR}/.amandahosts" \
633 "`cat $mock_chown_flags`"
635 "chmod args: 0600 ${AMANDAHOMEDIR}/.amandahosts" \
636 "`cat $mock_chmod_flags`"
639 test_create_ssh_key() {
640 logger "test_create_ssh_key"
641 keydir=${AMANDAHOMEDIR}/.ssh
643 create_ssh_key server
644 assertEquals "create_ssh_key" 0 $?
645 assertTrue "[ -f ${keydir}/id_rsa_amdump ]"
646 [ "$IAmRoot" ] && { startSkipping; echo "test_create_ssh_key: skipped"; }
648 "chown args: ${amanda_user}:${amanda_group} ${keydir} ${keydir}/id_rsa_amdump ${keydir}/id_rsa_amdump.pub" \
649 "`cat $mock_chown_flags`"
650 # Chmod is called twice, but we only get the 2nd invocation.
652 "chmod args: 0600 ${keydir}/id_rsa_amdump ${keydir}/id_rsa_amdump.pub" \
653 "`cat $mock_chmod_flags`"
657 # What happens if .ssh is a file?
658 touch ${AMANDAHOMEDIR}/.ssh
659 create_ssh_key client
660 assertEquals "create_ssh_key" 0 $?
661 assertTrue "[ -f ${keydir}.save ]"
662 assertTrue "[ -f ${keydir}/id_rsa_amrecover ]"
665 test_create_profile() {
666 logger "test_create_profile"
667 rm -f ${AMANDAHOMEDIR}/.profile
669 assertEquals "create_profile" 0 $?
670 assertTrue "[ -f ${AMANDAHOMEDIR}/.profile ]"
673 test_check_profile() {
674 logger "test_check_profile"
675 [ -f "${AMANDAHOMEDIR}/.profile" ] || touch ${AMANDAHOMEDIR}/.profile
677 assertEquals "check_profile" 0 $?
678 assertTrue "[ -s ${AMANDAHOMEDIR}/.profile ]"
679 [ "$IAmRoot" ] && { startSkipping; echo "test_check_profile: skipped"; }
681 "chown args: ${amanda_user}:${amanda_group} ${AMANDAHOMEDIR}/.profile" \
682 "`cat $mock_chown_flags`"
684 "chmod args: 0640 ${AMANDAHOMEDIR}/.profile" \
685 "`cat $mock_chmod_flags`"
688 test_install_client_conf() {
689 logger "test_install_client_conf"
691 touch ${MOCKDIR}/success
693 assertEquals "install_client_conf" 0 $?
694 prefix="install args:"
695 inst_files="${AMANDAHOMEDIR}/example/amanda-client.conf ${SYSCONFDIR}/amanda/"
698 "`cat $mock_install_flags`" \
699 "${prefix} -m 0600 -u ${amanda_user} -g ${amanda_group} ${inst_files}"
702 "`cat $mock_install_flags`" \
703 "${prefix} -m 0600 -o ${amanda_user} -g ${amanda_group} ${inst_files}"
707 #TODO: create_ampassphrase, create_amtmp
709 ######################################
710 #TODO: post_rm_functions
712 # Run a single test, or let shunit run all tests
713 if [ $# -gt 0 ]; then
717 suite_addTest test___logger
718 suite_addTest test__log_output_of
719 for t in $SPECIFIC_TESTS; do
725 # Importing shunit2 triggers test enumeration, so must happen after
726 # all tests are defined.
727 . ${SHUNIT_INC}/shunit2
729 echo "shunit2 log is: ${LOGFILE}"
730 echo "mockdir is: ${MOCKDIR}"