Source
public function testScriptManualInput_InvalidRequests(array $request_params, string $expected_result): void {
<?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/CIntegrationTest.php';
/**
* Test suite for Script Manual Input
*
* @required-components server
* @configurationDataProvider serverConfigurationProvider
* @backup hosts,scripts
*
* @onAfter deleteData
*/
class testScriptManualInput extends CIntegrationTest {
private static $hostid;
private static $hostgroupid;
private static $scriptids;
public function createTestHostData(): bool {
static $initialized = false;
/*
* First, create host group and a host in that group
*
* Calling for a script execution requires a host context,
* regardless of where the script will eventually execute.
*
* Although a default Zabbix installation already defines a host, the
* server itself, we want the tests to be self-contained.
*/
if ($initialized)
return true;
global $DB;
if (!isset($DB['DB']))
DBconnect($error);
$response = CDataHelper::call('hostgroup.create', ['name' => 'Test Hosts']);
self::$hostgroupid = $response['groupids'][0];
$response = CDataHelper::call('host.create', [
'host' => 'Test Host',
'groups' => [
[
'groupid' => self::$hostgroupid
]
]
]);
self::$hostid = $response['hostids'][0];
$initialized = true;
return true;
}
/**
* @depends prepareTestHostData
*/
public function createTestScriptData(): bool {
static $initialized = false;
if ($initialized)
return true;
global $DB;
if (!isset($DB['DB']))
DBconnect($error);
// Create scripts with and without manual input support.
$scripts = [
/*
* See [1] for a reference of these script object descriptions.
*
* Required fields for script creation are:
* name, type, scope
* Required fields when the 'type' is set to 'Script':