version 1.2, 2007/02/19 01:37:10 |
version 1.3, 2007/02/19 02:55:35 |
|
|
#!/usr/bin/perl |
#!/usr/bin/perl |
# $RedRiver: keyring5.t,v 1.1 2007/02/19 00:28:28 andrew Exp $ |
# $RedRiver: keyring5.t,v 1.2 2007/02/19 01:37:10 andrew Exp $ |
use strict; |
use strict; |
use warnings; |
use warnings; |
|
|
use Test::More tests => 118; |
use Test::More tests => 126; |
use YAML; |
use YAML; |
|
|
BEGIN { |
BEGIN { |
|
|
cipher => $cipher, |
cipher => $cipher, |
}; |
}; |
|
|
|
my $rec1_name = 'test'; |
|
|
my $original_accts = [ |
my $original_accts = [ |
[ |
[ |
{ |
{ |
'label_id' => 2, |
'label_id' => 2, |
'data' => 'only password is set', |
'data' => 'only password is set', |
'label' => 'password', |
'label' => 'password', |
'font' => 0 |
'font' => 0, |
}, |
}, |
{ |
{ |
'label_id' => 3, |
'label_id' => 3, |
|
|
'year' => 107 |
'year' => 107 |
}, |
}, |
'label' => 'lastchange', |
'label' => 'lastchange', |
'font' => 0 |
'font' => 0, |
} |
} |
], |
], |
[ |
[ |
{ |
{ |
'label_id' => 1, |
|
'data' => 'test', |
|
'label' => 'account', |
|
'font' => 0 |
|
}, |
|
{ |
|
'label_id' => 2, |
'label_id' => 2, |
'data' => 'abcd1234', |
'data' => 'abcd1234', |
'label' => 'password', |
'label' => 'password', |
'font' => 0 |
'font' => 0, |
}, |
}, |
{ |
{ |
'label_id' => 3, |
'label_id' => 3, |
|
|
'year' => 107 |
'year' => 107 |
}, |
}, |
'label' => 'lastchange', |
'label' => 'lastchange', |
'font' => 0 |
'font' => 0, |
}, |
}, |
{ |
{ |
'label_id' => 255, |
'label_id' => 255, |
'data' => 'This is a short note.', |
'data' => 'This is a short note.', |
'label' => 'notes', |
'label' => 'notes', |
'font' => 0 |
'font' => 0, |
} |
} |
], |
], |
[ |
[ |
|
|
'label_id' => 2, |
'label_id' => 2, |
'data' => 'password (date is 2/2/07)', |
'data' => 'password (date is 2/2/07)', |
'label' => 'password', |
'label' => 'password', |
'font' => 0 |
'font' => 0, |
}, |
}, |
{ |
{ |
'label_id' => 3, |
'label_id' => 3, |
|
|
'year' => 107 |
'year' => 107 |
}, |
}, |
'label' => 'lastchange', |
'label' => 'lastchange', |
'font' => 0 |
'font' => 0, |
} |
} |
] |
] |
]; |
]; |
|
|
. $options->{cipher} |
. $options->{cipher} |
); |
); |
|
|
|
my $rec_id = 0; |
foreach my $acct (@{ $original_accts} ) { |
foreach my $acct (@{ $original_accts} ) { |
ok( $record = $pdb->append_Record(), 'Append Record' ); |
ok( $record = $pdb->append_Record(), 'Append Record' ); |
|
if ($rec_id == 1) { |
|
ok( $record->{name} = $rec1_name, 'Setting record name' ); |
|
} |
ok( $pdb->Encrypt($record, $acct, $password), 'Encrypt account into record' ); |
ok( $pdb->Encrypt($record, $acct, $password), 'Encrypt account into record' ); |
|
$rec_id++; |
} |
} |
|
|
ok( $pdb->Write($file), 'Write file' ); |
ok( $pdb->Write($file), 'Write file' ); |
|
|
|
|
ok( $pdb->Password($password), 'Verify Password' ); |
ok( $pdb->Password($password), 'Verify Password' ); |
|
|
|
$rec_id = 0; |
foreach my $rec (@{ $pdb->{records} }) { |
foreach my $rec (@{ $pdb->{records} }) { |
ok( $decrypted = $pdb->Decrypt($rec), 'Decrypt record' ); |
ok( $decrypted = $pdb->Decrypt($rec), 'Decrypt record' ); |
|
if ($rec_id == 1) { |
|
is( $rec->{name}, $rec1_name, 'Checking record name' ); |
|
} |
push @recs, $decrypted; |
push @recs, $decrypted; |
|
$rec_id++; |
} |
} |
|
|
is_deeply( $original_accts, \@recs, 'Account Matches' ); |
is_deeply( \@recs, $original_accts, 'Account Matches' ); |
|
|
@recs = (); |
@recs = (); |
my $rec_num = 1; |
my $rec_num = 1; |
|
|
push @recs, $decrypted; |
push @recs, $decrypted; |
} |
} |
|
|
is_deeply( $original_accts, \@recs, 'Account Matches' ); |
is_deeply( \@recs, $original_accts, 'Account Matches' ); |
|
|
my $acct; |
my $acct; |
ok( $acct = $pdb->Decrypt( $pdb->{records}->[$rec_num]), 'decrypt record ' . $rec_num); |
ok( $acct = $pdb->Decrypt( $pdb->{records}->[$rec_num]), 'decrypt record ' . $rec_num); |