[BACK]Return to keyring.t CVS log [TXT][DIR] Up to [local] / palm / Palm-Keyring / t

Diff for /palm/Palm-Keyring/t/keyring.t between version 1.21 and 1.23

version 1.21, 2008/09/19 03:08:01 version 1.23, 2008/09/19 06:39:58
Line 1 
Line 1 
 #!/usr/bin/perl -T  #!/usr/bin/perl -T
 # $RedRiver: keyring.t,v 1.20 2008/09/18 06:06:11 andrew Exp $  # $RedRiver: keyring.t,v 1.22 2008/09/19 02:51:44 andrew Exp $
 use strict;  use strict;
 use warnings;  use warnings;
   
 use Test::More tests => 194;  use Test::More tests => 202;
 use Data::Dumper;  use Data::Dumper;
   
 BEGIN {  BEGIN {
Line 62 
Line 62 
     },      },
 };  };
   
   my %unchanging_date = %{ $acct->{3}->{data} };
   
 my $bad_cipher      = 999;  my $bad_cipher      = 999;
 my %crypt_1_details = (  my %crypt_1_details = (
     'default_iter'   => 1000,      'default_iter'   => 1000,
Line 110 
Line 112 
 );  );
   
   
   
 my $pdb;  my $pdb;
   
 eval { $pdb = new Palm::Keyring( -file => 't/Keys-invalid_version.pdb' ) };  eval { $pdb = new Palm::Keyring( -file => 't/Keys-invalid_version.pdb' ) };
Line 127 
Line 128 
     'Couldn\'t load pdb with Unknown Cipher'      'Couldn\'t load pdb with Unknown Cipher'
 );  );
   
   eval { $pdb = new Palm::Keyring( -file => 't/Keys-invalid_appinfo.pdb' ) };
   like(
       $@,
       qr/^Corrupt \s appinfo\? \s no \s {other}/xms,
       'Couldn\'t load pdb with invalid appinfo'
   );
   
   ok( $pdb = new Palm::Keyring( -file => 't/Keys-no_data.pdb', -password =>
           $new_password ),
       'Loaded Palm::Keyring file with no data' );
 ok( $pdb = new Palm::Keyring( -file => 't/Keys-no_data.pdb' ),  ok( $pdb = new Palm::Keyring( -file => 't/Keys-no_data.pdb' ),
     'Loaded Palm::Keyring file with no data' );      'Loaded Palm::Keyring file with no data' );
   
 ok( $pdb->Password($password), 'Entering Password' );  
   
 my $record;  my $record;
 ok( $record = $pdb->append_Record(), 'Append Record' );  ok( $record = $pdb->append_Record(), 'Append Record' );
 ok( $pdb->Encrypt( $record, $password, $acct ),  eval{ $pdb->Encrypt() };
     'Encrypt account into record' );  like(
       $@,
       qr/^Needed \s parameter \s \[record\] \s not \s passed!/xms,
       'Encrypt account into record without record'
   );
   eval{ $pdb->Encrypt( $record ) };
   like(
       $@,
       qr/^password \s not \s set!/xms,
       'Encrypt account into record without password'
   );
   eval{ $pdb->Encrypt( $record, $password ) };
   like(
       $@,
       qr/^Needed \s parameter \s \[plaintext\] \s not \s passed!/xms,
       'Encrypt account into record without account'
   );
   eval{ $pdb->Encrypt( $record, $new_password, $acct ) };
   like(
       $@,
       qr/^Incorrect \s Password!/xms,
       'Encrypt account into record with wrong password'
   );
   
   my $ivec = pack("C*", 1..8);
   ok( $pdb->Encrypt( $record, $password, $acct, $ivec),
       'Encrypt account into record (with custom ivec)' );
   ok( $pdb->Encrypt( $record, $password, $acct),
       'Encrypt account into record (with no changes)');
   
   delete $record->{plaintext};
   
 ok( $pdb->PackRecord($record), 'Pack Proper Record');  ok( $pdb->PackRecord($record), 'Pack Proper Record');
 ok( $record = $pdb->ParseRecord(%{ $record }), 'Parse Proper Packed');  ok( $record = $pdb->ParseRecord(%{ $record }), 'Parse Proper Packed');
   
 my $record2;  my $record2;
 ok( $record2 = $pdb->append_Record(), 'Append Record' );  ok( $record2 = $pdb->append_Record(), 'Append Record' );
 ok( $pdb->PackRecord($record2), 'Pack Empty Record');  eval{ $pdb->PackRecord($record2) };
 ok( $record = $pdb->ParseRecord(%{ $record2 }), 'Parse Empty Packed');  like(
       $@,
       qr/^No \s encrypted \s data \s in \s record/xms,
       'Pack Empty Record'
   );
   
   $record2->{encrypted} = q{};
   eval{ $pdb->PackRecord($record2) };
   like(
       $@,
       qr/^No \s ivec/xms,
       'Pack Empty Record with encrypted, but no ivec'
   );
   
 $pdb->{version} = 999;  $pdb->{version} = 4;
   delete $record->{encrypted};
   delete $record->{data};
 eval{ $pdb->PackRecord($record) };  eval{ $pdb->PackRecord($record) };
 like( $@,  like( $@,
     qr/^Unsupported \s Version \s 999/xms,      qr/^No \s data \s in \s record \s to \s pack/xms,
     'Couldn\'t PackRecord with Invalid Version'      'Couldn\'t PackRecord without data'
 );  );
   
 eval{ $pdb->ParseRecord(%{ $record2 }) };  $pdb->{version} = 999;
 like( $@,  eval{ $pdb->Encrypt( $record, $password, $acct ) };
     qr/^Unsupported \s Version \s 999/xms,  like(
     'Couldn\'t ParseRecord with Invalid Version'      $@,
       qr/^Unsupported \s version \s 999/xms,
       'Couldn\'t Encrypt with unsupported version'
 );  );
   
 eval { $pdb->Write($file) };  eval { $pdb->Write($file) };
Line 165 
Line 220 
     'Couldn\'t Write file with unsupported version'      'Couldn\'t Write file with unsupported version'
 );  );
   
   eval{ $pdb->PackRecord($record) };
   like( $@,
       qr/^Unsupported \s Version \s 999/xms,
       'Couldn\'t PackRecord with Invalid Version'
   );
   
 $pdb = undef;  $record2->{data} = q{nothing};
   eval{ $pdb->ParseRecord(%{ $record2 }) };
   like( $@,
       qr/^Unsupported \s Version \s 999/xms,
       'Couldn\'t ParseRecord with Invalid Version'
   );
   
   
   $pdb     = undef;
   $record  = undef;
   $record2 = undef;
   %{ $acct->{3}->{data} } = %unchanging_date;
   
 unlink $file;  unlink $file;
   
 foreach my $options (@o) {  foreach my $options (@o) {
Line 227 
Line 298 
             );              );
   
             ok( $pdb->Write($file), 'Write "empty" file' );              ok( $pdb->Write($file), 'Write "empty" file' );
               #exit if $pdb->{version} == 5;
   
             ok( $record = $pdb->append_Record(), 'Append Record' );              ok( $record = $pdb->append_Record(), 'Append Record' );
   

Legend:
Removed from v.1.21  
changed lines
  Added in v.1.23

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>