version 1.1, 2007/01/27 23:59:29 |
version 1.4, 2007/02/01 01:56:11 |
|
|
# Change 1..1 below to 1..last_test_to_print . |
# Change 1..1 below to 1..last_test_to_print . |
# (It may become useful if the test is moved to ./t subdirectory.) |
# (It may become useful if the test is moved to ./t subdirectory.) |
|
|
BEGIN { $| = 1; print "1..6\n"; } |
my $test = 1; |
END {print "not ok 1\n" unless $loaded;} |
BEGIN { $| = 1; print "1..17\n"; } |
use lib '../lib'; |
END {print "not ok $test\n" unless $loaded;} |
|
use Palm::PDB; |
use Palm::Keyring; |
use Palm::Keyring; |
$loaded = 1; |
$loaded = 1; |
print "ok 1\n"; |
print "ok $test\n"; |
|
$test++; |
|
|
|
|
######################### End of black magic. |
######################### End of black magic. |
|
|
# Insert your test code below (better if it prints "ok 13" |
# Insert your test code below (better if it prints "ok 13" |
# (correspondingly "not ok 13") depending on the success of chunk 13 |
# (correspondingly "not ok 13") depending on the success of chunk 13 |
# of the test code): |
# of the test code): |
|
|
|
my $file = 'Keys-GTKR-test.pdb'; |
my $password = '12345'; |
my $password = '12345'; |
|
my $new_password = '54321'; |
|
my $acct = { |
|
name => 'test3', |
|
account => 'atestaccount', |
|
password => $password, |
|
notes => 'now that really roxorZ!', |
|
lastchange => { |
|
day => 2, |
|
month => 2, |
|
year => 99, |
|
}, |
|
}; |
|
|
my $pdb; |
my $pdb; |
|
my $record; |
|
|
eval { $pdb = new Palm::Keyring($password) }; |
eval { $pdb = new Palm::Keyring($password) }; |
unless( $@ ) { |
unless( $@ ) { |
print "ok 2\n"; |
print "ok $test\n"; |
} else { |
} else { |
print "not ok 2\n"; |
print "not ok $test\n"; |
} |
} |
|
$test++; |
|
|
my $record; |
|
|
|
eval { $record = $pdb->append_Record() }; |
eval { $record = $pdb->append_Record() }; |
unless( $@ ) { |
unless( $@ ) { |
print "ok 3\n"; |
print "ok $test\n"; |
} else { |
} else { |
print "not ok 3\n"; |
print "not ok $test\n"; |
} |
} |
|
$test++; |
|
|
$record->{plaintext} = { |
eval { $pdb->Encrypt($record, $acct, $password) || die }; |
name => 'Test3', |
unless( $@ ) { |
account => 'atestaccount', |
print "ok $test\n"; |
password => $password, |
} else { |
description => 'now that really roxorZ!', |
print "not ok $test\n"; |
}; |
} |
|
$test++; |
|
|
my $file = 'Keys-GTKR-test.pdb'; |
eval { $pdb->Write($file) }; |
|
unless( $@ ) { |
|
print "ok $test\n"; |
|
} else { |
|
print "not ok $test\n"; |
|
} |
|
$test++; |
|
|
if ( $pdb->Write($file) ) { |
$pdb = new Palm::PDB; |
print "ok 4\n"; |
$acct = {}; |
|
|
|
eval { $pdb->Load($file) }; |
|
unless( $@ ) { |
|
print "ok $test\n"; |
} else { |
} else { |
print "not ok 4\n"; |
print "not ok $test\n"; |
} |
} |
|
$test++; |
|
|
if ( $pdb->Load($file, $password) ) { |
eval { $pdb->Password($password) || die }; |
print "ok 5\n"; |
unless( $@ ) { |
|
print "ok $test\n"; |
} else { |
} else { |
print "not ok 5\n"; |
print "not ok $test\n"; |
} |
} |
|
$test++; |
|
|
if ($pdb->{'records'}->[1]->{'plaintext'}->{'password'} eq $password) { |
eval { $acct = $pdb->Decrypt($pdb->{'records'}->[1]) || die }; |
print "ok 6\n"; |
unless( $@ ) { |
|
print "ok $test\n"; |
} else { |
} else { |
print "not ok 6\n"; |
print "not ok $test\n"; |
} |
} |
|
$test++; |
|
|
|
if ($acct->{'password'} eq $password) { |
|
print "ok $test\n"; |
|
} else { |
|
print "not ok $test\n"; |
|
} |
|
$test++; |
|
|
|
my $old_date = $acct->{'lastchange'}; |
|
|
|
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++; |
|
|
|
my $new_date = $acct->{'lastchange'}; |
|
|
|
if ( |
|
$old_date->{'day'} == $new_date->{'day'} && |
|
$old_date->{'month'} == $new_date->{'month'} && |
|
$old_date->{'year'} == $new_date->{'year'} |
|
) { |
|
print "ok $test\n"; |
|
} else { |
|
print "not ok $test\n"; |
|
} |
|
$test++; |
|
|
|
$acct->{'password'} = $new_password; |
|
|
|
eval { $acct = $pdb->Encrypt($pdb->{'records'}->[1], $acct) || die }; |
|
unless( $@ ) { |
|
print "ok $test\n"; |
|
} else { |
|
print "not ok $test\n"; |
|
} |
|
$test++; |
|
|
|
$old_date = $new_date; |
|
$new_date = $acct->{'lastchange'}; |
|
|
|
eval { $acct = $pdb->Decrypt($pdb->{'records'}->[1]) || die }; |
|
unless( $@ ) { |
|
print "ok $test\n"; |
|
} else { |
|
print "not ok $test\n"; |
|
} |
|
$test++; |
|
|
|
if ( |
|
$old_date->{'day'} != $new_date->{'day'} || |
|
$old_date->{'month'} != $new_date->{'month'} || |
|
$old_date->{'year'} != $new_date->{'year'} |
|
) { |
|
print "ok $test\n"; |
|
} else { |
|
print "not ok $test\n"; |
|
} |
|
$test++; |
|
|
|
if ($acct->{'password'} eq $new_password) { |
|
print "ok $test\n"; |
|
} else { |
|
print "not ok $test\n"; |
|
} |
|
$test++; |
|
|
|
|
unlink($file); |
unlink($file); |
|
|