1 file.test | public FileValidateTest::testInsecureExtensions() |
Tests hard-coded security check in file_validate().
File
- core/
modules/ simpletest/ tests/ file.test, line 2331 - This provides SimpleTests for the core file handling functionality. These include FileValidateTest and FileSaveTest.
Class
- FileValidateTest
- Tests the file_validate() function..
Code
public function testInsecureExtensions() {
$file = $this->createFile('test.php', 'Invalid PHP');
// Test that file_validate() will check for insecure extensions by default.
$errors = file_validate($file, array());
$this->assertEqual('For security reasons, your upload has been rejected.', $errors[0]);
$this->assertFileHooksCalled(array('validate'));
file_test_reset();
// Test that the 'allow_insecure_uploads' is respected.
$GLOBALS['settings']['allow_insecure_uploads'] = 1;
$errors = file_validate($file, array());
$this->assertEqual(array(), $errors);
$this->assertFileHooksCalled(array('validate'));
}