blob: dfd7cca9c0bf3e59fc4bed42076d8819ca0d4d5f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2021 Robin Appelman <robin@icewind.nl>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Files_Antivirus\Tests\Scanner;
use OCA\Files_Antivirus\AppConfig;
use OCA\Files_Antivirus\Scanner\ICAP;
use OCA\Files_Antivirus\Scanner\ScannerBase;
use OCA\Files_Antivirus\StatusFactory;
use Psr\Log\LoggerInterface;
/**
* @group DB
*/
class ICAPTest extends ScannerBaseTest {
protected function getScanner(): ScannerBase {
if (!getenv('ICAP_HOST') || !getenv('ICAP_PORT') || !getenv('ICAP_REQUEST') || !getenv('ICAP_HEADER')) {
$this->markTestSkipped("Set ICAP_HOST, ICAP_PORT, ICAP_REQUEST and ICAP_HEADER to enable icap tests");
}
$logger = $this->createMock(LoggerInterface::class);
$config = $this->createPartialMock(AppConfig::class, ['getter']);
$config->method('getter')
->willReturnCallback(function ($key) {
switch ($key) {
case 'av_host':
return getenv('ICAP_HOST');
case 'av_port':
return getenv('ICAP_PORT');
case 'av_icap_request_service':
return getenv('ICAP_REQUEST');
case 'av_icap_response_header':
return getenv('ICAP_HEADER');
case 'av_stream_max_length':
return '26214400';
case 'av_icap_chunk_size':
return '1048576';
case 'av_icap_connect_timeout':
return '5';
}
});
return new ICAP($config, $logger, \OC::$server->get(StatusFactory::class));
}
}
|