Annotation of palm/Palm-Keyring/t/keyring5-samples.t, Revision 1.6
1.3 andrew 1: #!/usr/bin/perl -T
1.6 ! andrew 2: # $RedRiver: keyring5-samples.t,v 1.5 2007/08/10 04:13:31 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.6 ! andrew 103: my $Num_Tests_Left = 5;
1.2 andrew 104: SKIP: {
1.6 ! andrew 105: skip 'Digest::HMAC_SHA1 not installed', $Num_Tests_Left
! 106: unless eval "require Digest::HMAC_SHA1";
1.2 andrew 107:
108: if ($pdb->{appinfo}->{cipher} > 0) {
109: my $crypt = Palm::Keyring::crypts($pdb->{appinfo}->{cipher});
1.6 ! andrew 110: skip 'Crypt::CBC not installed', $Num_Tests_Left
! 111: unless eval "require Crypt::CBC";
! 112: skip 'Crypt::' . $crypt->{name} . ' not installed', $Num_Tests_Left
! 113: unless eval "require Crypt::$crypt->{name}";
1.2 andrew 114: }
115:
116: $password = 'abc';
117: ok( $pdb->Password($password), 'Passing Password' );
118: my @recs = ();
119: foreach my $rec (@{ $pdb->{records}}) {
120: my $acct;
121: ok( $acct = $pdb->Decrypt( $rec ), 'Decrypting record ' . scalar @recs );
122: push @recs, $acct;
123: }
124: is_deeply(\@recs, $orig_recs, "Matching records in '$file'" );
1.1 andrew 125: }
126: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>