Source
'expected_error' => 'Invalid parameter "/1/overrides/1/operations/1/operator": value must be one of '.implode(', ', [CONDITION_OPERATOR_EQUAL, CONDITION_OPERATOR_NOT_EQUAL, CONDITION_OPERATOR_LIKE, CONDITION_OPERATOR_NOT_LIKE, CONDITION_OPERATOR_REGEXP, CONDITION_OPERATOR_NOT_REGEXP]).'.'
<?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 dirname(__FILE__).'/../include/CAPITest.php';
require_once dirname(__FILE__).'/../../include/classes/parsers/CConditionFormula.php';
require_once dirname(__FILE__).'/../../include/classes/helpers/CConditionHelper.php';
/**
* @backup items
*/
class testDiscoveryRule extends CAPITest {
public static function discoveryrule_create_data_invalid() {
return [
'Test invalid permissions to host' => [
'discoveryrule' => [
'name' => 'API LLD rule invalid permissions',
'key_' => 'apilldruleinvalidpermissions',
'hostid' => '1',
'type' => ITEM_TYPE_ZABBIX,
'interfaceid' => '50022',
'delay' => '30s'
],
'expected_error' => 'No permissions to referred object or it does not exist!'
],
'Test invalid interface ID' => [
'discoveryrule' => [
'name' => 'API LLD rule invalid interface',
'key_' => 'apilldruleinvalidinterface',
'hostid' => '50009',
'type' => ITEM_TYPE_ZABBIX,
'interfaceid' => '1',
'delay' => '30s'
],
'expected_error' => 'Invalid parameter "/1/interfaceid": cannot be the host interface ID from another host.'
],
'Test if LLD rule name and key already exists' => [
'discoveryrule' => [
'name' => 'API LLD rule 4',
'key_' => 'apilldrule4',
'hostid' => '50009',
'type' => ITEM_TYPE_ZABBIX,
'interfaceid' => '50022',
'delay' => '30s'
],
'expected_error' => 'An LLD rule with key "apilldrule4" already exists on the host "API Host".'
],
'Test without update interval for mqtt.get key of Agent type' => [
'discoveryrule' => [
'name' => 'API mqtt.get',
'key_' => 'mqtt.get[test]',
'hostid' => '50009',
'type' => ITEM_TYPE_ZABBIX,
'interfaceid' => '50022'
],
'expected_error' => 'Invalid parameter "/1": the parameter "delay" is missing.'
],
'Test 0 update interval for mqtt.get key of Agent type' => [
'discoveryrule' => [
'name' => 'API mqtt.get',
'key_' => 'mqtt.get[test]',
'hostid' => '50009',
'type' => ITEM_TYPE_ZABBIX,
'interfaceid' => '50022',
'delay' => '0'
],
'expected_error' => 'Invalid parameter "/1/delay": cannot be equal to zero without custom intervals.'
],
'Test 0 update interval for wrong mqtt key of Active agent type' => [
'discoveryrule' => [
'name' => 'API mqtt.get',
'key_' => 'mqt.get[test]',
'hostid' => '50009',
'type' => ITEM_TYPE_ZABBIX_ACTIVE,
'delay' => '0'
],
'expected_error' => 'Invalid parameter "/1/delay": cannot be equal to zero without custom intervals.'
],
'Test LLD rule with unsupported item type' => [