@decorators.needs_root
def zap(self, args):
device = args.device
+ if disk.is_mapper_device(device):
+ terminal.error("Refusing to zap the mapper device: {}".format(device))
+ raise SystemExit(1)
lv = api.get_lv_from_argument(device)
if lv:
# we are zapping a logical volume
lvm.zap.Zap(argv=['--help']).main()
stdout, stderr = capsys.readouterr()
assert 'optional arguments' in stdout
- assert 'positional arguments' in stdout
+
+ @pytest.mark.parametrize('device_name', [
+ '/dev/mapper/foo',
+ '/dev/dm-0',
+ ])
+ def test_can_not_zap_mapper_device(self, capsys, is_root, device_name):
+ with pytest.raises(SystemExit):
+ lvm.zap.Zap(argv=[device_name]).main()
+ stdout, stderr = capsys.readouterr()
+ assert 'Refusing to zap' in stdout