aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/functional/fileupload_form_test.php33
-rw-r--r--tests/functional/fixtures/files/disallowed.jpgbin0 -> 559 bytes
-rw-r--r--tests/upload/filespec_test.php2
3 files changed, 35 insertions, 0 deletions
diff --git a/tests/functional/fileupload_form_test.php b/tests/functional/fileupload_form_test.php
index c291712c71..eaa6d634a5 100644
--- a/tests/functional/fileupload_form_test.php
+++ b/tests/functional/fileupload_form_test.php
@@ -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());
}
+ 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()
{
$this->create_user('fileupload');
diff --git a/tests/functional/fixtures/files/disallowed.jpg b/tests/functional/fixtures/files/disallowed.jpg
new file mode 100644
index 0000000000..06a437585a
--- /dev/null
+++ b/tests/functional/fixtures/files/disallowed.jpg
Binary files differ
diff --git a/tests/upload/filespec_test.php b/tests/upload/filespec_test.php
index 87cd00197f..492f31cee6 100644
--- a/tests/upload/filespec_test.php
+++ b/tests/upload/filespec_test.php
@@ -143,6 +143,8 @@ class phpbb_filespec_test extends phpbb_test_case
$disallowed_content = explode('|', $this->config['mime_triggers']);
$filespec = $this->get_filespec(array('tmp_name' => $this->path . $filename));
$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()