From ca87913d0e6a27844f56b2397b7568943e621c38 Mon Sep 17 00:00:00 2001 From: cb-govcms Date: Tue, 10 Feb 2026 17:51:16 +1100 Subject: [PATCH 1/2] test that file upload fails when there is no httpav service to scan file --- .../Security/Functional/HttpavServiceTest.php | 86 +++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 phpunit/integration/GovCMS/Security/Functional/HttpavServiceTest.php diff --git a/phpunit/integration/GovCMS/Security/Functional/HttpavServiceTest.php b/phpunit/integration/GovCMS/Security/Functional/HttpavServiceTest.php new file mode 100644 index 0000000..8accf9f --- /dev/null +++ b/phpunit/integration/GovCMS/Security/Functional/HttpavServiceTest.php @@ -0,0 +1,86 @@ +drupalCreateUser([]); + $this->drupalLogin($account); + + $this->testFile = $this->govcmsGenerateTestFile('image_1.png', $this->randomString());; + } + + /** + * {@inheritdoc} + */ + #[\Override] + protected function tearDown(): void { + // Delete all test file. + unlink($this->testFile); + + parent::tearDown(); + } + + /** + * Tests that file uploads fail if the HTTPAV service is unavailble. + */ + public function testMissingHttpavService() { + $file = $this->testFile; + + $edit = [ + 'files[file_test_upload][]' => $file, + ]; + // Go to the file upload test form provided by govcms_file_test module. + $this->drupalGet('govcms-file-test/save_upload_from_form_test'); + $this->submitForm($edit, 'Submit'); + + $this->assertSession()->pageTextContains('The anti-virus scanner could not check the file, the file cannot be uploaded.'); + $this->assertSession()->pageTextContains('Epic upload FAIL!'); + $this->assertFileDoesNotExist('temporary://' . basename((string) $file)); + } + +} From ecce942ab4e66507c4f953ffa80dddfdab1d9345 Mon Sep 17 00:00:00 2001 From: cb-govcms Date: Wed, 4 Mar 2026 17:24:01 +1100 Subject: [PATCH 2/2] edit typo --- .../GovCMS/Security/Functional/HttpavServiceTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpunit/integration/GovCMS/Security/Functional/HttpavServiceTest.php b/phpunit/integration/GovCMS/Security/Functional/HttpavServiceTest.php index 8accf9f..8b7ec28 100644 --- a/phpunit/integration/GovCMS/Security/Functional/HttpavServiceTest.php +++ b/phpunit/integration/GovCMS/Security/Functional/HttpavServiceTest.php @@ -59,7 +59,7 @@ protected function setUp(): void { */ #[\Override] protected function tearDown(): void { - // Delete all test file. + // Delete test file. unlink($this->testFile); parent::tearDown();