Annotation of palm/Palm-Keyring/t/keyring5-samples.t, Revision 1.1
1.1 ! andrew 1: #!/usr/bin/perl
! 2: # $RedRiver: keyring4.t,v 1.1 2007/02/17 23:36:07 andrew Exp $
! 3: use strict;
! 4: use warnings;
! 5:
! 6: use Test::More tests => 30;
! 7: use Data::Dumper;
! 8:
! 9: BEGIN { use_ok( 'Palm::PDB' ); }
! 10: BEGIN { use_ok( 'Palm::Keyring' ); }
! 11:
! 12: my $password = 'abc';
! 13: my $orig_recs = [
! 14: [
! 15: {
! 16: 'label_id' => 2,
! 17: 'data' => 'only password is set',
! 18: 'label' => 'password',
! 19: 'font' => 0
! 20: },
! 21: {
! 22: 'label_id' => 3,
! 23: 'data' => {
! 24: 'month' => 1,
! 25: 'day' => 1,
! 26: 'year' => 107
! 27: },
! 28: 'label' => 'lastchange',
! 29: 'font' => 0
! 30: }
! 31: ],
! 32: [
! 33: {
! 34: 'label_id' => 1,
! 35: 'data' => 'test',
! 36: 'label' => 'account',
! 37: 'font' => 0
! 38: },
! 39: {
! 40: 'label_id' => 2,
! 41: 'data' => 'abcd1234',
! 42: 'label' => 'password',
! 43: 'font' => 0
! 44: },
! 45: {
! 46: 'label_id' => 3,
! 47: 'data' => {
! 48: 'month' => 1,
! 49: 'day' => 11,
! 50: 'year' => 107
! 51: },
! 52: 'label' => 'lastchange',
! 53: 'font' => 0
! 54: },
! 55: {
! 56: 'label_id' => 255,
! 57: 'data' => 'This is a short note.',
! 58: 'label' => 'notes',
! 59: 'font' => 0
! 60: }
! 61: ],
! 62: [
! 63: {
! 64: 'label_id' => 2,
! 65: 'data' => 'password (date is 2/2/07)',
! 66: 'label' => 'password',
! 67: 'font' => 0
! 68: },
! 69: {
! 70: 'label_id' => 3,
! 71: 'data' => {
! 72: 'month' => 1,
! 73: 'day' => 2,
! 74: 'year' => 107
! 75: },
! 76: 'label' => 'lastchange',
! 77: 'font' => 0
! 78: }
! 79: ]
! 80: ];
! 81:
! 82: foreach my $file ('Keys-None.pdb', 'Keys-3DES.pdb', 'Keys-AES.pdb', 'Keys-AES256.pdb') {
! 83: my $pdb;
! 84: ok( $pdb = new Palm::PDB, 'new Palm::PDB' );
! 85: ok( $pdb->Load('t/' . $file), "Loading '$file'" );
! 86: ok( $pdb->Password($password), 'Passing Password' );
! 87: my @recs = ();
! 88: foreach my $rec (@{ $pdb->{records}}) {
! 89: my $acct;
! 90: ok( $acct = $pdb->Decrypt( $rec ), 'Decrypting record ' . scalar @recs );
! 91: push @recs, $acct;
! 92: }
! 93: is_deeply( $orig_recs, \@recs, "Matching records in '$file'" );
! 94: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>