mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
[ticket/10851] Add unit and functional tests for checking attachments
These tests will make sure that fileuploads now work as expected regarding the check for disallowed content. PHPBB3-10851
This commit is contained in:
parent
e4e3df0b37
commit
91c3ad07ec
3 changed files with 35 additions and 0 deletions
|
@ -76,6 +76,39 @@ class phpbb_functional_fileupload_form_test extends phpbb_functional_test_case
|
||||||
$this->assertEquals($this->lang('DISALLOWED_EXTENSION', 'bif'), $crawler->filter('p.error')->text());
|
$this->assertEquals($this->lang('DISALLOWED_EXTENSION', 'bif'), $crawler->filter('p.error')->text());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function test_disallowed_content()
|
||||||
|
{
|
||||||
|
$this->login();
|
||||||
|
|
||||||
|
$crawler = $this->upload_file('disallowed.jpg', 'image/jpeg');
|
||||||
|
$this->assertEquals($this->lang('DISALLOWED_CONTENT'), $crawler->filter('p.error')->text());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_disallowed_content_no_check()
|
||||||
|
{
|
||||||
|
$this->login();
|
||||||
|
$this->admin_login();
|
||||||
|
$this->add_lang('ucp');
|
||||||
|
$crawler = self::request('GET', 'adm/index.php?sid=' . $this->sid . '&i=acp_attachments&mode=attach');
|
||||||
|
|
||||||
|
$form = $crawler->selectButton('Submit')->form();
|
||||||
|
$values = $form->getValues();
|
||||||
|
|
||||||
|
$values["config[check_attachment_content]"] = 0;
|
||||||
|
$form->setValues($values);
|
||||||
|
$crawler = self::submit($form);
|
||||||
|
|
||||||
|
// Logout and back in for correct URL
|
||||||
|
$this->logout();
|
||||||
|
$this->login();
|
||||||
|
|
||||||
|
$crawler = $this->upload_file('disallowed.jpg', 'image/jpeg');
|
||||||
|
|
||||||
|
// Hitting the UNABLE_GET_IMAGE_SIZE error means we passed the
|
||||||
|
// DISALLOWED_CONTENT check
|
||||||
|
$this->assertEquals($this->lang('UNABLE_GET_IMAGE_SIZE'), $crawler->filter('p.error')->text());
|
||||||
|
}
|
||||||
|
|
||||||
public function test_too_large()
|
public function test_too_large()
|
||||||
{
|
{
|
||||||
$this->create_user('fileupload');
|
$this->create_user('fileupload');
|
||||||
|
|
BIN
tests/functional/fixtures/files/disallowed.jpg
Normal file
BIN
tests/functional/fixtures/files/disallowed.jpg
Normal file
Binary file not shown.
|
@ -143,6 +143,8 @@ class phpbb_filespec_test extends phpbb_test_case
|
||||||
$disallowed_content = explode('|', $this->config['mime_triggers']);
|
$disallowed_content = explode('|', $this->config['mime_triggers']);
|
||||||
$filespec = $this->get_filespec(array('tmp_name' => $this->path . $filename));
|
$filespec = $this->get_filespec(array('tmp_name' => $this->path . $filename));
|
||||||
$this->assertEquals($expected, $filespec->check_content($disallowed_content));
|
$this->assertEquals($expected, $filespec->check_content($disallowed_content));
|
||||||
|
// All files should pass if $disallowed_content is empty
|
||||||
|
$this->assertEquals(true, $filespec->check_content(array()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function clean_filename_variables()
|
public function clean_filename_variables()
|
||||||
|
|
Loading…
Add table
Reference in a new issue