[BACK]Return to keyring5-samples.t CVS log [TXT][DIR] Up to [local] / palm / Palm-Keyring / t

File: [local] / palm / Palm-Keyring / t / keyring5-samples.t (download)

Revision 1.1, Sun Feb 18 05:50:25 2007 UTC (17 years, 4 months ago) by andrew
Branch: MAIN

support Loading and Decrypting v5 databases.

Need to support Encrypting and Writing.  And write docs for it.

#!/usr/bin/perl
# $RedRiver: keyring4.t,v 1.1 2007/02/17 23:36:07 andrew Exp $
use strict;
use warnings;

use Test::More tests => 30;
use Data::Dumper;

BEGIN { use_ok( 'Palm::PDB' ); }
BEGIN { use_ok( 'Palm::Keyring' ); }

my $password = 'abc';
my $orig_recs = [
    [
        {
            'label_id' => 2,
            'data' => 'only password is set',
            'label' => 'password',
            'font' => 0
        },
        {
            'label_id' => 3,
            'data' => {
                'month' => 1,
                'day' => 1,
                'year' => 107
            },
            'label' => 'lastchange',
            'font' => 0
        }
    ],
    [
        {
            'label_id' => 1,
            'data' => 'test',
            'label' => 'account',
            'font' => 0
        },
        {
            'label_id' => 2,
            'data' => 'abcd1234',
            'label' => 'password',
            'font' => 0
        },
        {
            'label_id' => 3,
            'data' => {
                'month' => 1,
                'day' => 11,
                'year' => 107
            },
            'label' => 'lastchange',
            'font' => 0
        },
        {
            'label_id' => 255,
            'data' => 'This is a short note.',
            'label' => 'notes',
            'font' => 0
        }
    ],
    [
        {
            'label_id' => 2,
            'data' => 'password (date is 2/2/07)',
            'label' => 'password',
            'font' => 0
        },
        {
            'label_id' => 3,
            'data' => {
                'month' => 1,
                'day' => 2,
                'year' => 107
            },
            'label' => 'lastchange',
            'font' => 0
        }
    ]
];

foreach my $file ('Keys-None.pdb', 'Keys-3DES.pdb', 'Keys-AES.pdb', 'Keys-AES256.pdb') {
    my $pdb;
    ok( $pdb = new Palm::PDB, 'new Palm::PDB' );
    ok( $pdb->Load('t/' . $file), "Loading '$file'" );
    ok( $pdb->Password($password), 'Passing Password' );
    my @recs = ();
    foreach my $rec (@{ $pdb->{records}}) {
        my $acct;
        ok( $acct = $pdb->Decrypt( $rec ), 'Decrypting record ' . scalar @recs );
        push @recs, $acct;
    }
    is_deeply( $orig_recs, \@recs, "Matching records in '$file'" );
}