diff --git a/Vagrantfile b/Vagrantfile index 20dd85d..65da6e1 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -4,7 +4,8 @@ ENV["LC_ALL"] = "en_US.UTF-8" empty_disk = '.vagrant/tmp/empty.vdi' lvm_disk = '.vagrant/tmp/lvm.vdi' -luks_disk = '.vagrant/tmp/luks.vdi' +lukspart_disk = '.vagrant/tmp/lukspart.vdi' +luksdev_disk = '.vagrant/tmp/luksdev.vdi' Vagrant.configure("2") do |config| config.vm.box = "debian/buster64" @@ -30,12 +31,16 @@ Vagrant.configure("2") do |config| unless File.exist?(empty_disk) vb.customize ['createhd', '--filename', lvm_disk, '--size', 100 ] end - unless File.exist?(luks_disk) - vb.customize ['createhd', '--filename', luks_disk, '--size', 100 ] + unless File.exist?(lukspart_disk) + vb.customize ['createhd', '--filename', lukspart_disk, '--size', 100 ] + end + unless File.exist?(luksdev_disk) + vb.customize ['createhd', '--filename', luksdev_disk, '--size', 100 ] end vb.customize ['storageattach', :id, '--storagectl', 'SATA Controller', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', empty_disk] vb.customize ['storageattach', :id, '--storagectl', 'SATA Controller', '--port', 2, '--device', 0, '--type', 'hdd', '--medium', lvm_disk] - vb.customize ['storageattach', :id, '--storagectl', 'SATA Controller', '--port', 3, '--device', 0, '--type', 'hdd', '--medium', luks_disk] + vb.customize ['storageattach', :id, '--storagectl', 'SATA Controller', '--port', 3, '--device', 0, '--type', 'hdd', '--medium', lukspart_disk] + vb.customize ['storageattach', :id, '--storagectl', 'SATA Controller', '--port', 4, '--device', 0, '--type', 'hdd', '--medium', luksdev_disk] end end diff --git a/test/sys.bats b/test/sys.bats index 100949c..5fa3589 100644 --- a/test/sys.bats +++ b/test/sys.bats @@ -25,6 +25,7 @@ EOF parted -s /dev/sdd mklabel msdos mkpart p 1MiB 50% mkpart p 50% 100% cryptsetup -q --type luks1 luksFormat /dev/sdd1 <<< 123test cryptsetup -q --type luks2 luksFormat /dev/sdd2 <<< 123test + cryptsetup -q --type luks2 luksFormat /dev/sde <<< 123test # Do backup run backupninja -f "${BATS_TMPDIR}/backupninja.conf" --now --run "${BATS_TMPDIR}/backup.d/test.sys" @@ -36,6 +37,7 @@ finish_sys() { pvremove /dev/sdc dd if=/dev/zero of=/dev/sdc bs=512 count=1 conv=notrunc dd if=/dev/zero of=/dev/sdd bs=512 count=1 conv=notrunc + dd if=/dev/zero of=/dev/sde bs=512 count=1 conv=notrunc } @test "action runs without errors" { @@ -71,10 +73,14 @@ finish_sys() { grep -q 'contents = "Text Format Volume Group"' "/var/backups/lvm/vgtest" } -@test "luksheaders v1 backup is made" { +@test "luksheaders v1 partition backup is made" { file /var/backups/luksheader.sdd1.bin | grep -q "LUKS encrypted file" } -@test "luksheaders v2 backup is made" { +@test "luksheaders v2 partition backup is made" { file /var/backups/luksheader.sdd2.bin | grep -q "LUKS encrypted file" } + +@test "luksheaders v2 device backup is made" { + file /var/backups/luksheader.sde.bin | grep -q "LUKS encrypted file" +}