]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
regress: Add test to check the volume encryption key errors
authorEric Bollengier <eric@baculasystems.com>
Tue, 15 Nov 2022 08:23:45 +0000 (09:23 +0100)
committerEric Bollengier <eric@baculasystems.com>
Thu, 14 Sep 2023 11:57:00 +0000 (13:57 +0200)
regress/tests/encrypt-vol-error-key-test [new file with mode: 0755]

diff --git a/regress/tests/encrypt-vol-error-key-test b/regress/tests/encrypt-vol-error-key-test
new file mode 100755 (executable)
index 0000000..66f1ca1
--- /dev/null
@@ -0,0 +1,86 @@
+#!/usr/bin/env bash
+#
+# Copyright (C) 2000-2021 Kern Sibbald
+# Copyright (C) 2021-2022 Bacula Systems SA
+# License: BSD 2-Clause; see file LICENSE-FOSS
+#
+# Run a simple backup of the Bacula build directory
+#   then restore it.
+#
+TestName="encrypt-vol-error-key-test"
+JobName=backup
+export FORCE_ENC=yes
+. scripts/functions
+
+scripts/cleanup
+scripts/copy-confs
+
+#
+# Zap out any schedule in default conf file so that
+#  it doesn't start during our test
+#
+outf="$tmp/sed_tmp"
+echo "s%  Schedule =%# Schedule =%g" >${outf}
+cp $scripts/bacula-dir.conf $tmp/1
+sed -f ${outf} $tmp/1 >$scripts/bacula-dir.conf
+
+change_jobname BackupClient1 $JobName
+start_test
+
+cat <<END_OF_DATA >$tmp/bconcmds
+@output /dev/null
+messages
+@$out $tmp/log1.out
+setdebug level=4 storage=File1
+label volume=TestVolume001 storage=File1 pool=File slot=1 drive=0
+run job=$JobName yes
+wait
+messages
+@# 
+@# now do a restore
+@#
+@$out $tmp/log2.out  
+setdebug level=4 storage=File1
+restore where=$tmp/bacula-restores1 select all done
+yes
+wait
+messages
+quit
+END_OF_DATA
+
+run_bacula
+check_for_zombie_jobs storage=File1
+stop_bacula
+
+sed 's/cipher_key: ..../cipher_key: aaaa/' $conf/keydir/TestVolume001 > $tmp/1
+mv $conf/keydir/TestVolume001 $conf/keydir/TestVolume001.org
+mv $tmp/1 $conf/keydir/TestVolume001
+
+diff $conf/keydir/TestVolume001 $conf/keydir/TestVolume001.org > /dev/null
+if [ $? != 1 ]; then
+    print_error "ERROR: Need a different key"
+    estat=1
+fi
+
+cat <<END_OF_DATA >$tmp/bconcmds
+@$out /dev/null
+messages
+@# 
+@# now do a restore
+@#
+@$out $tmp/log2.out  
+setdebug level=4 storage=File1
+restore where=$tmp/bacula-restores select all done
+yes
+wait
+messages
+quit
+END_OF_DATA
+
+run_bacula
+check_for_zombie_jobs storage=File1
+stop_bacula
+
+check_two_logs
+check_restore_diff
+end_test