Annotation of palm/Palm-Keyring/t/keyring5-samples.t, Revision 1.2
1.1 andrew 1: #!/usr/bin/perl
1.2 ! andrew 2: # $RedRiver: keyring5-samples.t,v 1.1 2007/02/18 05:50:25 andrew Exp $
1.1 andrew 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'" );
1.2 ! andrew 86: SKIP: {
! 87: skip 'Digest::HMAC_SHA1 not installed', 5 unless
! 88: eval " require Digest::HMAC_SHA1 ";
! 89:
! 90: if ($pdb->{appinfo}->{cipher} > 0) {
! 91: my $crypt = Palm::Keyring::crypts($pdb->{appinfo}->{cipher});
! 92: skip 'Crypt::CBC not installed', 5 unless
! 93: eval "require Crypt::CBC";
! 94: skip 'Crypt::' . $crypt->{name} . ' not installed', 5 unless
! 95: eval "require Crypt::$crypt->{name}";
! 96: }
! 97:
! 98: $password = 'abc';
! 99: ok( $pdb->Password($password), 'Passing Password' );
! 100: my @recs = ();
! 101: foreach my $rec (@{ $pdb->{records}}) {
! 102: my $acct;
! 103: ok( $acct = $pdb->Decrypt( $rec ), 'Decrypting record ' . scalar @recs );
! 104: push @recs, $acct;
! 105: }
! 106: is_deeply(\@recs, $orig_recs, "Matching records in '$file'" );
1.1 andrew 107: }
108: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>