Annotation of palm/Palm-Keyring/t/keyring5-samples.t, Revision 1.5
1.3 andrew 1: #!/usr/bin/perl -T
1.5 ! andrew 2: # $RedRiver: keyring5-samples.t,v 1.4 2007/02/27 17:08:05 andrew Exp $
1.1 andrew 3: use strict;
4: use warnings;
5:
6: use Test::More tests => 30;
7:
8: BEGIN { use_ok( 'Palm::PDB' ); }
9: BEGIN { use_ok( 'Palm::Keyring' ); }
10:
11: my $password = 'abc';
12: my $orig_recs = [
1.5 ! andrew 13: {
! 14: 0 => {
! 15: 'label_id' => 0,
! 16: 'data' => '',
! 17: 'label' => 'name',
! 18: 'font' => 0,
! 19: },
! 20: 2 => {
1.1 andrew 21: 'label_id' => 2,
22: 'data' => 'only password is set',
23: 'label' => 'password',
24: 'font' => 0
25: },
1.5 ! andrew 26: 3 => {
1.1 andrew 27: 'label_id' => 3,
28: 'data' => {
29: 'month' => 1,
30: 'day' => 1,
31: 'year' => 107
32: },
33: 'label' => 'lastchange',
34: 'font' => 0
35: }
1.5 ! andrew 36: },
! 37: {
! 38: 0 => {
! 39: 'label_id' => 0,
! 40: 'data' => 'hoenicke',
! 41: 'label' => 'name',
! 42: 'font' => 0,
! 43: },
! 44: 1 => {
1.1 andrew 45: 'label_id' => 1,
46: 'data' => 'test',
47: 'label' => 'account',
48: 'font' => 0
49: },
1.5 ! andrew 50: 2 => {
1.1 andrew 51: 'label_id' => 2,
52: 'data' => 'abcd1234',
53: 'label' => 'password',
54: 'font' => 0
55: },
1.5 ! andrew 56: 3 => {
1.1 andrew 57: 'label_id' => 3,
58: 'data' => {
59: 'month' => 1,
60: 'day' => 11,
61: 'year' => 107
62: },
63: 'label' => 'lastchange',
64: 'font' => 0
65: },
1.5 ! andrew 66: 255 => {
1.1 andrew 67: 'label_id' => 255,
68: 'data' => 'This is a short note.',
69: 'label' => 'notes',
70: 'font' => 0
71: }
1.5 ! andrew 72: },
! 73: {
! 74: 0 => {
! 75: 'label_id' => 0,
! 76: 'data' => 'name',
! 77: 'label' => 'name',
! 78: 'font' => 0,
! 79: },
! 80: 2 => {
1.1 andrew 81: 'label_id' => 2,
82: 'data' => 'password (date is 2/2/07)',
83: 'label' => 'password',
84: 'font' => 0
85: },
1.5 ! andrew 86: 3 => {
1.1 andrew 87: 'label_id' => 3,
88: 'data' => {
89: 'month' => 1,
90: 'day' => 2,
91: 'year' => 107
92: },
93: 'label' => 'lastchange',
94: 'font' => 0
95: }
1.5 ! andrew 96: }
1.1 andrew 97: ];
98:
99: foreach my $file ('Keys-None.pdb', 'Keys-3DES.pdb', 'Keys-AES.pdb', 'Keys-AES256.pdb') {
100: my $pdb;
101: ok( $pdb = new Palm::PDB, 'new Palm::PDB' );
102: ok( $pdb->Load('t/' . $file), "Loading '$file'" );
1.2 andrew 103: SKIP: {
104: skip 'Digest::HMAC_SHA1 not installed', 5 unless
105: eval " require Digest::HMAC_SHA1 ";
106:
107: if ($pdb->{appinfo}->{cipher} > 0) {
108: my $crypt = Palm::Keyring::crypts($pdb->{appinfo}->{cipher});
109: skip 'Crypt::CBC not installed', 5 unless
110: eval "require Crypt::CBC";
111: skip 'Crypt::' . $crypt->{name} . ' not installed', 5 unless
112: eval "require Crypt::$crypt->{name}";
113: }
114:
115: $password = 'abc';
116: ok( $pdb->Password($password), 'Passing Password' );
117: my @recs = ();
118: foreach my $rec (@{ $pdb->{records}}) {
119: my $acct;
120: ok( $acct = $pdb->Decrypt( $rec ), 'Decrypting record ' . scalar @recs );
121: push @recs, $acct;
122: }
123: is_deeply(\@recs, $orig_recs, "Matching records in '$file'" );
1.1 andrew 124: }
125: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>