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

Annotation of palm/Palm-Keyring/t/keyring.t, Revision 1.3

1.1       andrew      1: # Before `make install' is performed this script should be runnable with
                      2: # `make test'. After `make install' it should work as `perl test.pl'
                      3:
                      4: ######################### We start with some black magic to print on failure.
                      5:
                      6: # Change 1..1 below to 1..last_test_to_print .
                      7: # (It may become useful if the test is moved to ./t subdirectory.)
                      8:
1.3     ! andrew      9: my $test = 1;
        !            10: BEGIN { $| = 1; print "1..12\n"; }
        !            11: END {print "not ok $test\n" unless $loaded;}
        !            12: use Palm::PDB;
1.1       andrew     13: use Palm::Keyring;
                     14: $loaded = 1;
1.3     ! andrew     15: print "ok $test\n";
        !            16: $test++;
1.1       andrew     17:
                     18: ######################### End of black magic.
                     19:
                     20: # Insert your test code below (better if it prints "ok 13"
                     21: # (correspondingly "not ok 13") depending on the success of chunk 13
                     22: # of the test code):
                     23:
1.3     ! andrew     24: my $file = 'Keys-GTKR-test.pdb';
1.1       andrew     25: my $password = '12345';
1.3     ! andrew     26: my $new_password = '54321';
        !            27: my $acct = {
        !            28:     name        => 'test3',
        !            29:        account     => 'atestaccount',
        !            30:        password    => $password,
        !            31:        notes       => 'now that really roxorZ!',
        !            32: };
        !            33:
1.1       andrew     34: my $pdb;
1.3     ! andrew     35: my $record;
1.1       andrew     36:
                     37: eval { $pdb = new Palm::Keyring($password) };
                     38: unless( $@ ) {
1.3     ! andrew     39:        print "ok $test\n";
        !            40: } else {
        !            41:        print "not ok $test\n";
        !            42: }
        !            43: $test++;
        !            44:
        !            45: eval { $record = $pdb->append_Record() };
        !            46: unless( $@ ) {
        !            47:        print "ok $test\n";
        !            48: } else {
        !            49:        print "not ok $test\n";
        !            50: }
        !            51: $test++;
        !            52:
        !            53: eval { $pdb->Encrypt($record, $acct, $password) || die };
        !            54: unless( $@ ) {
        !            55:        print "ok $test\n";
        !            56: } else {
        !            57:        print "not ok $test\n";
        !            58: }
        !            59: $test++;
        !            60:
        !            61: eval { $pdb->Write($file) };
        !            62: unless( $@ ) {
        !            63:        print "ok $test\n";
1.1       andrew     64: } else {
1.3     ! andrew     65:        print "not ok $test\n";
1.1       andrew     66: }
1.3     ! andrew     67: $test++;
1.1       andrew     68:
1.3     ! andrew     69: $pdb = new Palm::PDB;
        !            70: $acct = {};
1.1       andrew     71:
1.3     ! andrew     72: eval { $pdb->Load($file) };
1.1       andrew     73: unless( $@ ) {
1.3     ! andrew     74:        print "ok $test\n";
1.1       andrew     75: } else {
1.3     ! andrew     76:        print "not ok $test\n";
1.1       andrew     77: }
1.3     ! andrew     78: $test++;
1.1       andrew     79:
1.3     ! andrew     80: eval { $pdb->Password($password) || die };
        !            81: unless( $@ ) {
        !            82:        print "ok $test\n";
        !            83: } else {
        !            84:        print "not ok $test\n";
        !            85: }
        !            86: $test++;
1.1       andrew     87:
1.3     ! andrew     88: eval { $acct = $pdb->Decrypt($pdb->{'records'}->[1]) || die };
        !            89: unless( $@ ) {
        !            90:        print "ok $test\n";
        !            91: } else {
        !            92:        print "not ok $test\n";
        !            93: }
        !            94: $test++;
1.1       andrew     95:
1.3     ! andrew     96: if ($acct->{'password'} eq $password) {
        !            97:        print "ok $test\n";
1.1       andrew     98: } else {
1.3     ! andrew     99:        print "not ok $test\n";
1.1       andrew    100: }
1.3     ! andrew    101: $test++;
1.1       andrew    102:
1.3     ! andrew    103: eval { $pdb->Password($password, $new_password) || die };
        !           104: unless( $@ ) {
        !           105:        print "ok $test\n";
1.1       andrew    106: } else {
1.3     ! andrew    107:        print "not ok $test\n";
1.1       andrew    108: }
1.3     ! andrew    109: $test++;
1.1       andrew    110:
1.3     ! andrew    111: $acct = {};
        !           112: eval { $acct = $pdb->Decrypt($pdb->{'records'}->[1]) || die };
        !           113: unless( $@ ) {
        !           114:        print "ok $test\n";
1.1       andrew    115: } else {
1.3     ! andrew    116:        print "not ok $test\n";
1.1       andrew    117: }
1.3     ! andrew    118: $test++;
1.1       andrew    119:
1.3     ! andrew    120: if ($acct->{'password'} eq $password) {
        !           121:        print "ok $test\n";
        !           122: } else {
        !           123:        print "not ok $test\n";
        !           124: }
        !           125: $test++;
1.1       andrew    126: unlink($file);
                    127:
                    128: 1;
                    129:

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>