File: 11_encryption.t

package info (click to toggle)
libspreadsheet-parseexcel-perl 0.6500-1.1%2Bdeb11u1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,852 kB
  • sloc: perl: 9,442; makefile: 12
file content (92 lines) | stat: -rwxr-xr-x 2,463 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/perl -w

###############################################################################
#
# A test for Spreadsheet::ParseExcel.
#
# Tests for encrypted file handling.
#
# reverse(''), April 2011, John McNamara, jmcnamara@cpan.org
#

use strict;

use Spreadsheet::ParseExcel;
use Test::More tests => 4;


###############################################################################
#
# Tests setup.
#
my $file;
my $parser;
my $workbook;
my $got;
my $caption;
my $error_code;
my $error_string;
my $expected_code;


###############################################################################
#
# Tests 1. Normal file, not encrypted.
#
$caption       = " \tUnencrypted file.";
$file          = 't/excel_files/chart1.xls';
$parser        = Spreadsheet::ParseExcel->new();
$workbook      = $parser->Parse( $file );
$error_string  = $parser->error();
$error_code    = $parser->error_code();
$expected_code = 0;

is( $error_code, $expected_code, $caption );


###############################################################################
#
# Tests 2. Encrypted file with default password.
#
$caption       = " \tEncrypted file. Defualt password.";
$file          = 't/excel_files/pers-protected.xls';
$parser        = Spreadsheet::ParseExcel->new();
$workbook      = $parser->Parse( $file );
$error_string  = $parser->error();
$error_code    = $parser->error_code();
$expected_code = 0;

is( $error_code, $expected_code, $caption );


###############################################################################
#
# Tests 3. Encrypted file with password.
#
$caption       = " \tEncrypted file with password.";
$file          = 't/excel_files/pers-encrypted-def-pass-QwErTyUiOp.xls';
$parser        = Spreadsheet::ParseExcel->new( Password => 'QwErTyUiOp' );
$workbook      = $parser->Parse( $file );
$error_string  = $parser->error();
$error_code    = $parser->error_code();
$expected_code = 0;

is( $error_code, $expected_code, $caption );


###############################################################################
#
# Tests 4. Encrypted file with password.
#
$caption       = " \tEncrypted file with password.";
$file          = 't/excel_files/pers-encrypted-RC4-pass-11.xls';
$parser        = Spreadsheet::ParseExcel->new( Password => '11' );
$workbook      = $parser->Parse( $file );
$error_string  = $parser->error();
$error_code    = $parser->error_code();
$expected_code = 3;

is( $error_code, $expected_code, $caption );


__END__