More guardbanding tests for root.
No more dumping files into /
This commit is contained in:
parent
72ed431fb4
commit
076694eff3
1 changed files with 40 additions and 34 deletions
|
|
@ -103,36 +103,36 @@ cmp_deeply(
|
||||||
my $tempDirectory = tempdir('webguiXXXXX', CLEANUP => 1);
|
my $tempDirectory = tempdir('webguiXXXXX', CLEANUP => 1);
|
||||||
my $inaccessibleDirectory = Path::Class::Dir->new($tempDirectory, 'unwritable');
|
my $inaccessibleDirectory = Path::Class::Dir->new($tempDirectory, 'unwritable');
|
||||||
|
|
||||||
SKIP: {
|
SKIP: {
|
||||||
skip 'Root will cause this test to fail since it does not obey file permissions', 4
|
skip 'Root will cause this test to fail since it does not obey file permissions', 4
|
||||||
if $< == 0;
|
if $< == 0;
|
||||||
chmod 0000, $tempDirectory;
|
chmod 0000, $tempDirectory;
|
||||||
$config->set('exportPath', $inaccessibleDirectory->stringify);
|
$config->set('exportPath', $inaccessibleDirectory->stringify);
|
||||||
|
|
||||||
eval { WebGUI::Asset->exportCheckPath($session) };
|
eval { WebGUI::Asset->exportCheckPath($session) };
|
||||||
$e = Exception::Class->caught();
|
$e = Exception::Class->caught();
|
||||||
isa_ok($e, 'WebGUI::Error', "exportCheckPath throws if it can't create the directory it needs");
|
isa_ok($e, 'WebGUI::Error', "exportCheckPath throws if it can't create the directory it needs");
|
||||||
cmp_deeply(
|
cmp_deeply(
|
||||||
$e,
|
$e,
|
||||||
methods(
|
methods(
|
||||||
error => "can't create exportPath $inaccessibleDirectory",
|
error => "can't create exportPath $inaccessibleDirectory",
|
||||||
),
|
),
|
||||||
"exportCheckPath throws if it can't create the directory it needs"
|
"exportCheckPath throws if it can't create the directory it needs"
|
||||||
);
|
);
|
||||||
|
|
||||||
chmod 0444, $tempDirectory;
|
chmod 0444, $tempDirectory;
|
||||||
$config->set('exportPath', $tempDirectory);
|
$config->set('exportPath', $tempDirectory);
|
||||||
eval { WebGUI::Asset->exportCheckPath($session) };
|
eval { WebGUI::Asset->exportCheckPath($session) };
|
||||||
$e = Exception::Class->caught();
|
$e = Exception::Class->caught();
|
||||||
isa_ok($e, 'WebGUI::Error', "exportCheckPath throws if it can't access the exportPath for writing");
|
isa_ok($e, 'WebGUI::Error', "exportCheckPath throws if it can't access the exportPath for writing");
|
||||||
cmp_deeply(
|
cmp_deeply(
|
||||||
$e,
|
$e,
|
||||||
methods(
|
methods(
|
||||||
error => "can't access $tempDirectory",
|
error => "can't access $tempDirectory",
|
||||||
),
|
),
|
||||||
"exportCheckPath throws if we can't access the exportPath"
|
"exportCheckPath throws if we can't access the exportPath"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
# we're finished making sure that the code explodes on bad stuff, so let's make
|
# we're finished making sure that the code explodes on bad stuff, so let's make
|
||||||
# sure that it really works when it's really supposed to.
|
# sure that it really works when it's really supposed to.
|
||||||
|
|
@ -918,13 +918,19 @@ is($@, '', "exportAsHtml catches undefined exportPath exception");
|
||||||
is($success, 0, "exportAsHtml returns 0 for undefined exportPath");
|
is($success, 0, "exportAsHtml returns 0 for undefined exportPath");
|
||||||
is($message, 'exportPath must be defined and not ""', "exportAsHtml returns correct message for undefined exportPath");
|
is($message, 'exportPath must be defined and not ""', "exportAsHtml returns correct message for undefined exportPath");
|
||||||
|
|
||||||
# inaccessible exportPath
|
SKIP: {
|
||||||
$config->set('exportPath', Path::Class::Dir->new('')->stringify);
|
skip 'Root will cause this test to fail since it does not obey file permissions', 3
|
||||||
|
if $< == 0;
|
||||||
|
|
||||||
eval { ($success, $message) = $home->exportAsHtml( { userId => 3, depth => 99 } ) };
|
# inaccessible exportPath
|
||||||
is($@, '', "exportAsHtml catches inaccessible exportPath ");
|
chmod 0000, $tempDirectory;
|
||||||
is($success, 0, "exportAsHtml returns 0 for inaccessible exportPath");
|
$config->set('exportPath', $inaccessibleDirectory->stringify);
|
||||||
is($message, "can't access " . Path::Class::Dir->new('')->stringify, "exportAsHtml returns correct message for inaccessible exportPath");
|
|
||||||
|
eval { ($success, $message) = $home->exportAsHtml( { userId => 3, depth => 99 } ) };
|
||||||
|
is($@, '', "exportAsHtml catches inaccessible exportPath ");
|
||||||
|
is($success, 0, "exportAsHtml returns 0 for inaccessible exportPath");
|
||||||
|
is($message, "can't access " . $inaccessibleDirectory->stringify, "exportAsHtml returns correct message for inaccessible exportPath");
|
||||||
|
}
|
||||||
|
|
||||||
# exportPath is a file, not a directory
|
# exportPath is a file, not a directory
|
||||||
$config->set('exportPath', $exportPathFile);
|
$config->set('exportPath', $exportPathFile);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue