Source
'expected_error' => 'Invalid parameter "/output/1": value must be one of "proxyid", "name", "proxy_groupid", "local_address", "local_port", "operating_mode", "allowed_addresses", "address", "port", "description", "tls_connect", "tls_accept", "tls_issuer", "tls_subject", "custom_timeouts", "timeout_zabbix_agent", "timeout_simple_check", "timeout_snmp_agent", "timeout_external_check", "timeout_db_monitor", "timeout_http_agent", "timeout_ssh_agent", "timeout_telnet_agent", "timeout_script", "timeout_browser", "lastaccess", "version", "compatibility", "state".'
<?php
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** 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, version 3.
**
** 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 <https://www.gnu.org/licenses/>.
**/
require_once __DIR__.'/../include/CAPITest.php';
/**
* @backup ids
*
* @onBefore prepareTestData
* @onAfter clearData
*/
class testProxy extends CAPITest {
/**
* Non-existent ID, type, status etc.
*/
private const INVALID_NUMBER = 999999;
/**
* @var array
*/
private static array $data = [
'proxy_groupids' => [],
'proxyids' => [],
'groupids' => [],
'hostids' => [],
'actionids' => [],
'druleids' => [],
// Created proxies during proxy.create test (deleted at the end).
'created' => []
];
/**
* Prepare data for tests. Create proxy groups, proxies, host groups, hosts, actions, discovery rules.
*/
public function prepareTestData(): void {
$this->prepareTestDataProxyGroups();
$this->prepareTestDataProxies();
$this->prepareTestDataHostGroups();
$this->prepareTestDataHosts();
$this->prepareTestDataActions();
$this->prepareTestDataDiscoveryRules();
}
/**
* Create proxy groups.
*/
private function prepareTestDataProxyGroups(): void {
$proxy_groups = [
'empty' => [
'name' => 'API test proxy - empty'
],
'with_1_proxy' => [
'name' => 'API test proxy - with 1 proxy'
],
'with_3_proxies' => [
'name' => 'API test proxy - with 3 proxies'
]
];
$db_proxy_groups = CDataHelper::call('proxygroup.create', array_values($proxy_groups));
$this->assertArrayHasKey('proxy_groupids', $db_proxy_groups,
__FUNCTION__.'() failed: Could not create proxy groups.'
);
self::$data['proxy_groupids'] = array_combine(array_keys($proxy_groups), $db_proxy_groups['proxy_groupids']);
}
/**
* Create proxies.
*/
private function prepareTestDataProxies(): void {
$proxies = [
'active_defaults' => [
'name' => 'API test proxy - active with defaults',
'operating_mode' => PROXY_OPERATING_MODE_ACTIVE
],
'active_psk' => [