File: [local] / palm / Palm-Keyring / t / keyring.t (download)
Revision 1.3, Tue Jan 30 04:59:55 2007 UTC (17 years, 5 months ago) by andrew
Branch: MAIN
Changes since 1.2: +84 -26 lines
Switch to decrypting one record at a time when requested. That leads to more tests so that's kewl :-)
|
# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl test.pl'
######################### We start with some black magic to print on failure.
# Change 1..1 below to 1..last_test_to_print .
# (It may become useful if the test is moved to ./t subdirectory.)
my $test = 1;
BEGIN { $| = 1; print "1..12\n"; }
END {print "not ok $test\n" unless $loaded;}
use Palm::PDB;
use Palm::Keyring;
$loaded = 1;
print "ok $test\n";
$test++;
######################### End of black magic.
# Insert your test code below (better if it prints "ok 13"
# (correspondingly "not ok 13") depending on the success of chunk 13
# of the test code):
my $file = 'Keys-GTKR-test.pdb';
my $password = '12345';
my $new_password = '54321';
my $acct = {
name => 'test3',
account => 'atestaccount',
password => $password,
notes => 'now that really roxorZ!',
};
my $pdb;
my $record;
eval { $pdb = new Palm::Keyring($password) };
unless( $@ ) {
print "ok $test\n";
} else {
print "not ok $test\n";
}
$test++;
eval { $record = $pdb->append_Record() };
unless( $@ ) {
print "ok $test\n";
} else {
print "not ok $test\n";
}
$test++;
eval { $pdb->Encrypt($record, $acct, $password) || die };
unless( $@ ) {
print "ok $test\n";
} else {
print "not ok $test\n";
}
$test++;
eval { $pdb->Write($file) };
unless( $@ ) {
print "ok $test\n";
} else {
print "not ok $test\n";
}
$test++;
$pdb = new Palm::PDB;
$acct = {};
eval { $pdb->Load($file) };
unless( $@ ) {
print "ok $test\n";
} else {
print "not ok $test\n";
}
$test++;
eval { $pdb->Password($password) || die };
unless( $@ ) {
print "ok $test\n";
} else {
print "not ok $test\n";
}
$test++;
eval { $acct = $pdb->Decrypt($pdb->{'records'}->[1]) || die };
unless( $@ ) {
print "ok $test\n";
} else {
print "not ok $test\n";
}
$test++;
if ($acct->{'password'} eq $password) {
print "ok $test\n";
} else {
print "not ok $test\n";
}
$test++;
eval { $pdb->Password($password, $new_password) || die };
unless( $@ ) {
print "ok $test\n";
} else {
print "not ok $test\n";
}
$test++;
$acct = {};
eval { $acct = $pdb->Decrypt($pdb->{'records'}->[1]) || die };
unless( $@ ) {
print "ok $test\n";
} else {
print "not ok $test\n";
}
$test++;
if ($acct->{'password'} eq $password) {
print "ok $test\n";
} else {
print "not ok $test\n";
}
$test++;
unlink($file);
1;