mirror of
https://github.com/vgough/encfs.git
synced 2024-11-25 01:13:12 +01:00
tests: Add reverse mode tests
This commit is contained in:
parent
b696f87ace
commit
7e03b6d2c5
@ -1,5 +1,7 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
# Test EncFS normal and paranoid mode
|
||||
|
||||
use Test::More qw( no_plan );
|
||||
use File::Path;
|
||||
use File::Copy;
|
||||
|
66
tests/reverse.pl
Executable file
66
tests/reverse.pl
Executable file
@ -0,0 +1,66 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
# Test EncFS --reverse mode
|
||||
|
||||
use Test::More qw( no_plan );
|
||||
use File::Path;
|
||||
use File::Temp;
|
||||
|
||||
my $tempDir = $ENV{'TMPDIR'} || "/tmp";
|
||||
|
||||
# Helper function
|
||||
# Create a new empty working directory
|
||||
sub newWorkingDir
|
||||
{
|
||||
our $workingDir = mkdtemp("$tempDir/encfs-reverse-tests-XXXX")
|
||||
|| BAIL_OUT("Could not create temporary directory");
|
||||
|
||||
our $plain = "$workingDir/plain";
|
||||
mkdir($plain);
|
||||
our $ciphertext = "$workingDir/ciphertext";
|
||||
mkdir($ciphertext);
|
||||
our $decrypted = "$workingDir/decrypted";
|
||||
mkdir($decrypted);
|
||||
}
|
||||
|
||||
# Helper function
|
||||
# Unmount and delete mountpoint
|
||||
sub cleanup
|
||||
{
|
||||
system("fusermount -u $decrypted");
|
||||
system("fusermount -u $ciphertext");
|
||||
|
||||
rmtree($workingDir);
|
||||
ok( ! -d $workingDir, "working dir removed");
|
||||
}
|
||||
|
||||
# Helper function
|
||||
# Mount encryption-decryption chain
|
||||
#
|
||||
# Directory structure: plain -[encrypt]-> ciphertext -[decrypt]-> decrypted
|
||||
sub mount
|
||||
{
|
||||
my $r=system("encfs --extpass=\"echo test\" --standard $plain $ciphertext --reverse > /dev/null");
|
||||
ok($r == 0, "mounted ciphertext file system");
|
||||
|
||||
$r=system("ENCFS6_CONFIG=$plain/.encfs6.xml encfs --extpass=\"echo test\" $ciphertext $decrypted");
|
||||
ok($r == 0, "mounted decrypting file system");
|
||||
}
|
||||
|
||||
# Copy a directory tree and verify that the decrypted data is identical
|
||||
sub copy_test
|
||||
{
|
||||
ok(system("cp -a encfs $plain")==0, "copying files to plain");
|
||||
ok(system("diff -r -q $plain $decrypted")==0, "decrypted files are identical");
|
||||
|
||||
ok(-f "$plain/encfs/encfs.cpp", "file exists");
|
||||
unlink("$plain/encfs/encfs.cpp");
|
||||
ok(! -f "$decrypted/encfs.cpp", "file deleted");
|
||||
}
|
||||
|
||||
newWorkingDir();
|
||||
mount();
|
||||
|
||||
copy_test();
|
||||
|
||||
cleanup();
|
Loading…
Reference in New Issue
Block a user