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