tests: Seperate LUKS test for partition vs device

This commit is contained in:
Jerome Charaoui 2020-12-30 15:46:38 -05:00
parent e4054ea85a
commit 340853d96a
2 changed files with 17 additions and 6 deletions

13
Vagrantfile vendored
View File

@ -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

View File

@ -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"
}