Permalink
Browse files

Simplified test suite code by creating a set of default arguments for

the gpgdir command line as each test is executed


git-svn-id: file:///home/mbr/svn/gpgdir_repos/gpgdir/trunk@323 958e171a-1414-0410-8e2f-9d295d3c0db0
  • Loading branch information...
mrash committed Oct 3, 2008
1 parent 989ad8f commit ee0a831f469fd0ad9bef64acb7c5f220260c8dcc
Showing with 33 additions and 34 deletions.
  1. +4 −0 ChangeLog
  2. +12 −9 gpgdir
  3. +17 −25 test/gpgdir_test.pl
View
@@ -1,3 +1,7 @@
+gpgdir-1.9.3 (08/31/2008):
+ - Simplified test suite code by creating a set of default arguments for
+ the gpgdir command line as each test is executed.
+
gpgdir-1.9.2 (08/31/2008):
- Added new modes '--sign <dir>' and '--verify <dir>' to allow all files
in the specified directory to be signed or verified instead of encrypted
View
21 gpgdir
@@ -464,6 +464,15 @@ sub encrypt_or_sign_file() {
close $pw_fh;
my @errors = <$error_fh>;
+ close $error_fh;
+
+ my @status = <$status_fh>;
+ close $status_fh;
+
+ close $input_fh;
+ close $output_fh;
+
+ waitpid $pid, 0;
if ($verbose) {
print for @errors;
@@ -473,13 +482,6 @@ sub encrypt_or_sign_file() {
}
}
- close $input_fh;
- close $output_fh;
- close $error_fh;
- close $status_fh;
-
- waitpid $pid, 0;
-
if (-s $out_file == 0) {
&delete_file($out_file);
&delete_file($in_file) if $del_flag == $DEL_SOURCE_FILE;
@@ -572,12 +574,13 @@ sub decrypt_or_verify_file() {
}
my @errors = <$error_fh>;
+ close $error_fh;
+
my @status = <$status_fh>;
+ close $status_fh;
close $input_fh;
close $output_fh;
- close $error_fh;
- close $status_fh;
waitpid $pid, 0;
View
@@ -64,6 +64,9 @@
my @data_dir_files = ();
my %md5sums = ();
+my $default_args = "--gnupg-dir $gpg_dir " .
+ "--Key-id $key_id --pw-file $pw_file";
+
die "[*] Use --help" unless GetOptions(
'Prepare-results' => \$prepare_results,
'help' => \$help
@@ -86,7 +89,7 @@
&test_driver('(Encrypt dir) gpgdir directory encryption', \&encrypt);
&test_driver('(Encrypt dir) Files recursively encrypted',
\&recursively_encrypted);
-&test_driver('(Encrypt dir) Excluded hidden files/dirs',
+&test_driver('(Encrypt dir) Exclude hidden files/dirs',
\&skipped_hidden_files_dirs);
&test_driver('(Decrypt dir) gpgdir directory decryption', \&decrypt);
&test_driver('(Decrypt dir) Files recursively decrypted',
@@ -99,7 +102,7 @@
\&ascii_encrypt);
&test_driver('(Ascii-armor dir) Files recursively encrypted',
\&ascii_recursively_encrypted);
-&test_driver('(Ascii-armor dir) Excluded hidden files/dirs',
+&test_driver('(Ascii-armor dir) Exclude hidden files/dirs',
\&skipped_hidden_files_dirs);
&test_driver('(Decrypt dir) gpgdir directory decryption', \&decrypt);
&test_driver('(Decrypt dir) Files recursively decrypted',
@@ -112,7 +115,7 @@
\&obf_encrypt);
&test_driver('(Obfuscate filenames) Files recursively encrypted',
\&obf_recursively_encrypted);
-&test_driver('(Obfuscate filenames) Excluded hidden files/dirs',
+&test_driver('(Obfuscate filenames) Exclude hidden files/dirs',
\&obf_skipped_hidden_files_dirs);
&test_driver('(Decrypt dir) gpgdir directory decryption',
\&obf_decrypt);
@@ -125,7 +128,7 @@
&test_driver('(Sign/verify dir) gpgdir directory signing', \&sign);
&test_driver('(Sign/verify dir) Files recursively signed',
\&recursively_signed);
-&test_driver('(Sign/verify dir) Excluded hidden files/dirs',
+&test_driver('(Sign/verify dir) Exclude hidden files/dirs',
\&skipped_hidden_files_dirs);
&test_driver('(Sign/verify dir) Broken signature detection',
\&broken_sig_detection);
@@ -134,7 +137,7 @@
\&recursively_verified);
### bad password detection
-&test_driver('(Bad passphrase) detected broken passphrase',
+&test_driver('(Bad passphrase) detect broken passphrase',
\&broken_passphrase);
&logr("\n");
@@ -194,62 +197,54 @@ ()
}
sub encrypt() {
- if (&run_cmd("$gpgdirCmd --gnupg-dir $gpg_dir " .
- " --pw-file $pw_file --Key-id $key_id -e $data_dir",
- $NO_APPEND)) {
+ if (&run_cmd("$gpgdirCmd $default_args -e $data_dir", $NO_APPEND)) {
return 1;
}
return &print_errors("[-] Directory encryption");
}
sub ascii_encrypt() {
- if (&run_cmd("$gpgdirCmd --Plain-ascii --gnupg-dir $gpg_dir " .
- " --pw-file $pw_file --Key-id $key_id -e $data_dir",
+ if (&run_cmd("$gpgdirCmd $default_args --Plain-ascii -e $data_dir",
$NO_APPEND)) {
return 1;
}
return &print_errors("[-] Directory encryption");
}
sub obf_encrypt() {
- if (&run_cmd("$gpgdirCmd -O --gnupg-dir $gpg_dir " .
- " --pw-file $pw_file --Key-id $key_id -e $data_dir",
+ if (&run_cmd("$gpgdirCmd $default_args -O -e $data_dir",
$NO_APPEND)) {
return 1;
}
return &print_errors("[-] Directory encryption");
}
sub sign() {
- if (&run_cmd("$gpgdirCmd --gnupg-dir $gpg_dir " .
- " --pw-file $pw_file --Key-id $key_id --sign $data_dir",
+ if (&run_cmd("$gpgdirCmd $default_args --sign $data_dir",
$NO_APPEND)) {
return 1;
}
return &print_errors("[-] Directory signing");
}
sub decrypt() {
- if (&run_cmd("$gpgdirCmd --gnupg-dir $gpg_dir " .
- " --pw-file $pw_file --Key-id $key_id -d $data_dir",
+ if (&run_cmd("$gpgdirCmd $default_args -d $data_dir",
$NO_APPEND)) {
return 1;
}
return &print_errors("[-] Directory decryption");
}
sub obf_decrypt() {
- if (&run_cmd("$gpgdirCmd -O --gnupg-dir $gpg_dir " .
- " --pw-file $pw_file --Key-id $key_id -d $data_dir",
+ if (&run_cmd("$gpgdirCmd $default_args -O -d $data_dir",
$NO_APPEND)) {
return 1;
}
return &print_errors("[-] Directory decryption");
}
sub verify() {
- if (&run_cmd("$gpgdirCmd --gnupg-dir $gpg_dir " .
- " --pw-file $pw_file --Key-id $key_id --verify $data_dir",
+ if (&run_cmd("$gpgdirCmd $default_args --verify $data_dir",
$NO_APPEND)) {
return 1;
}
@@ -304,8 +299,7 @@ ()
print F "bogus data\n";
close F;
- &run_cmd("$gpgdirCmd --gnupg-dir $gpg_dir " .
- " --pw-file $pw_file --Key-id $key_id --verify $data_dir",
+ &run_cmd("$gpgdirCmd $default_args --verify $data_dir",
$NO_APPEND);
my $found_bad_sig = 0;
@@ -473,9 +467,7 @@ ()
}
sub test_mode() {
- if (&run_cmd("$gpgdirCmd --test --gnupg-dir $gpg_dir " .
- " --pw-file $pw_file --Key-id $key_id",
- $NO_APPEND)) {
+ if (&run_cmd("$gpgdirCmd $default_args --test", $NO_APPEND)) {
my $found = 0;
open F, "< $current_test_file"
or die "[*] Could not open $current_test_file: $!";

0 comments on commit ee0a831

Please sign in to comment.