block the same set of extensions in http, scalar and file uploads in Storage.

This commit is contained in:
Colin Kuskie 2010-08-11 14:50:19 -07:00
parent 1f99da3315
commit 9f724a7193
3 changed files with 109 additions and 20 deletions

View file

@ -29,10 +29,14 @@ my $session = WebGUI::Test->session;
my $cwd = Cwd::cwd();
my ($extensionTests, $fileIconTests) = setupDataDrivenTests($session);
my ($extensionTests, $fileIconTests, $block_extension_tests) = setupDataDrivenTests($session);
my $numTests = 140; # increment this value for each test you create
plan tests => $numTests + scalar @{ $extensionTests } + scalar @{ $fileIconTests };
plan tests => 140
+ scalar @{ $extensionTests }
+ scalar @{ $fileIconTests }
+ scalar @{ $block_extension_tests }
;
my $uploadDir = $session->config->get('uploadsPath');
ok ($uploadDir, "uploadDir defined in config");
@ -375,6 +379,17 @@ ok (-e $tempStor->getPath(), '... directory was created');
ok($tempStor->getHexId, '... getHexId returns something');
is($tempStor->getHexId, $session->id->toHex($tempStor->getId), '... returns the hexadecimal value of the GUID');
####################################################
#
# block_extensions
#
####################################################
##Run a set of extensions through and watch how the files get changed.
foreach my $extTest (@{ $block_extension_tests }) {
is( $storage1->block_extensions($extTest->{filename}), $extTest->{blockname}, $extTest->{comment} );
}
####################################################
#
# tar
@ -472,17 +487,17 @@ is($formStore->addFileFromFormPost('files'), undef, 'addFileFromFormPost returns
$session->request->uploadFiles(
'oneFile',
[ WebGUI::Test->getTestCollateralPath('WebGUI.pm') ],
[ WebGUI::Test->getTestCollateralPath('littleTextFile') ],
);
is($formStore->addFileFromFormPost('oneFile'), 'WebGUI.pm', '... returns the name of the uploaded file');
cmp_bag($formStore->getFiles, [ qw/WebGUI.pm/ ], '... adds the file to the storage location');
is($formStore->addFileFromFormPost('oneFile'), 'littleTextFile', '... returns the name of the uploaded file');
cmp_bag($formStore->getFiles, [ qw/littleTextFile/ ], '... adds the file to the storage location');
$session->request->uploadFiles(
'thumbFile',
[ WebGUI::Test->getTestCollateralPath('thumb-thumb.gif') ],
);
is($formStore->addFileFromFormPost('thumbFile'), 'thumb.gif', '... strips thumb- prefix from files');
cmp_bag($formStore->getFiles, [ qw/WebGUI.pm thumb.gif/ ], '... adds the file to the storage location');
cmp_bag($formStore->getFiles, [ qw/littleTextFile thumb.gif/ ], '... adds the file to the storage location');
####################################################
#
@ -748,6 +763,63 @@ sub setupDataDrivenTests {
},
];
my $block_extension_tests = [
{
filename => 'filename',
blockname => 'filename',
comment => 'no extension',
},
{
filename => 'filename.pl',
blockname => 'filename_pl.txt',
comment => 'pl file',
},
{
filename => 'filename.perl',
blockname => 'filename_perl.txt',
comment => 'perl file',
},
{
filename => 'filename.cgi',
blockname => 'filename_cgi.txt',
comment => 'cgi file',
},
{
filename => 'filename.php',
blockname => 'filename_php.txt',
comment => 'php file',
},
{
filename => 'filename.asp',
blockname => 'filename_asp.txt',
comment => 'asp file',
},
{
filename => 'filename.pm',
blockname => 'filename_pm.txt',
comment => 'perl module file',
},
{
filename => 'filename.htm',
blockname => 'filename_htm.txt',
comment => 'htm file',
},
{
filename => 'filename.html',
blockname => 'filename_html.txt',
comment => 'html file',
},
{
filename => 'filename.pm.txt',
blockname => 'filename.pm.txt',
comment => 'internal .pm not touched',
},
{
filename => 'filename.txt.pm',
blockname => 'filename.txt_pm.txt',
comment => 'double extension handled',
},
];
my $fileIconTests = [
{
filename => 'filename',
@ -771,5 +843,5 @@ sub setupDataDrivenTests {
},
];
return ($extensionTests, $fileIconTests)
return ($extensionTests, $fileIconTests, $block_extension_tests);
}