Safety Valve

- Added safety valve processing.  Whenever a write-command omits a
  filter, the command will affect every task.  This is dangerous.
  If rc.confirmation is disabled, the command is terminated.
This commit is contained in:
Paul Beckingham
2011-09-04 08:44:22 -04:00
parent f74c33dc02
commit fa973f734b
4 changed files with 66 additions and 25 deletions

View File

@@ -28,43 +28,36 @@
use strict;
use warnings;
use Test::More tests => 9;
use Test::More tests => 5;
# Create the rc file.
if (open my $fh, '>', 'bug_annotate.rc')
if (open my $fh, '>', 'bug.rc')
{
print $fh "data.location=.\n";
close $fh;
ok (-r 'bug_annotate.rc', 'Created bug_annotate.rc');
ok (-r 'bug.rc', 'Created bug.rc');
}
# Attempt a blank annotation.
qx{../src/task rc:bug_annotate.rc add foo};
my $output = qx{../src/task rc:bug_annotate.rc 1 annotate};
qx{../src/task rc:bug.rc add foo};
my $output = qx{../src/task rc:bug.rc 1 annotate};
like ($output, qr/Additional text must be provided/, 'failed on blank annotation');
# Attempt an annotation without ID
$output = qx{../src/task rc:bug_annotate.rc annotate bar};
like ($output, qr/ID needed to apply an annotation./, 'failed on annotation without ID');
$output = qx{echo "-- n" | ../src/task rc:bug.rc annotate bar};
like ($output, qr/Command prevented from running/, 'Filter-less write command inhibited');
$output = qx{echo "-- y" | ../src/task rc:bug.rc annotate bar};
unlike ($output, qr/Command prevented from running/, 'Filter-less write command permitted');
# Cleanup.
unlink 'pending.data';
ok (!-r 'pending.data', 'Removed pending.data');
unlink 'completed.data';
ok (!-r 'completed.data', 'Removed completed.data');
unlink 'undo.data';
ok (!-r 'undo.data', 'Removed undo.data');
unlink 'backlog.data';
ok (!-r 'backlog.data', 'Removed backlog.data');
unlink 'synch.key';
ok (!-r 'synch.key', 'Removed synch.key');
unlink 'bug_annotate.rc';
ok (!-r 'bug_annotate.rc', 'Removed bug_annotate.rc');
unlink qw(pending.data completed.data undo.data backlog.data synch.key bug.rc);
ok (! -r 'pending.data' &&
! -r 'completed.data' &&
! -r 'undo.data' &&
! -r 'backlog.data' &&
! -r 'synch_key.data' &&
! -r 'bug.rc', 'Cleanup');
exit 0;