Remove all cleanup and exception test references. We expect plugin just to
respond with scanning result constant and notice where applicable.
Add tests for \core\antivirus\manager.
In the initial implementation, infected file cleanup and exception throwing
was done at the plugin level. This is somewhat incorrect from plugin
responsibility perspective. The patch moves cleanup and exception logic to
the manager. Antivirus plugin responsibility is limited to perform scanning
and respond with one of the result statuses defined in the
\core\antivirus\scanner.
Due to configurable nature of scanning method selection, unit test needs to
be updated to always point to commadline method. There is no need to write
separate tests for socket scanning method, as the scanning method needs to
be mocked anyway (i.e. will be identical to commandline scanning from test
perspective).
We are using "stubbing" method to replace real component (clamav) control
points with doubles in order to avoid direct calls to clamav. For more
details, please refer to https://phpunit.de/manual/4.8/en/test-doubles.html
Notice, that while it is possible to use setExpectedException in the tests,
this does not seem play correctly with consecutive assertions in the same
test after exception is thrown (they seem omitted). Explicit try/catch
construction has been used in testing instead.
To run just this test, use:
vendor/bin/phpunit antivirus_clamav_scanner_testcase lib/antivirus/clamav/tests/scanner_test.php
This implements the use of class autoloading for antivirus plugin. Base
abstract class, exception class and manager are using namespace
core\antivirus, this is because all three class files are located in
/lib/classes/antivirus/ (see \core_component::classloader for convention
details).
This patch moves existing scanning functionality to plugin level. It does
not add anything new, just refactors the existing functionality.
AMOS BEGIN
MOV [clamemailsubject,core],[emailsubject,antivirus]
MOV [clamfailed,core],[clamfailed,antivirus_clamav]
MOV [clamlost,core],[invalidpathtoclam,antivirus_clamav]
MOV [clamunknownerror,core],[unknownerror,antivirus_clamav]
MOV [virusfounduser,core],[virusfounduser,antivirus]
AMOS END
This also removes runclamonupload config setting. It is implied that files
will be scanned if plugin is enabled, no need to have a separate setting.
In addition to that, some language strings are updated. It is 'ClamAV', not
'clam AV' (see http://www.clamav.net/index.html).