Source
'expected_error' => 'Invalid parameter "/tls_psk": another tls_psk value is already associated with given tls_psk_identity.'
<?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';
/**
* @onBefore prepareTestData
* @onAfter cleanTestData
*/
class testAutoregistration extends CAPITest {
public static $data = [
'hostgroup' => [],
'host' => [],
'proxy' => []
];
public static function prepareTestData(): void {
$hostgroups = [];
// dataProviderInvalidAutoregistrationWithHostEncryptionUpdate
$hostgroups[] = ['name' => 'API autoregistration tests hosts group'];
$result = CDataHelper::call('hostgroup.create', $hostgroups);
self::$data['hostgroup'] = array_combine(array_column($hostgroups, 'name'), $result['groupids']);
$hosts = [];
// dataProviderInvalidAutoregistrationWithHostEncryptionUpdate
$hosts[] = [
'host' => 'test.example.com',
'groups' => [['groupid' => ':hostgroup:API autoregistration tests hosts group']],
'tls_accept' => HOST_ENCRYPTION_PSK,
'tls_psk_identity' => 'hostidentity',
'tls_psk' => '0d59887b3a4f2a2e6866985491699034'
];
$result = CDataHelper::call('host.create', self::resolveIds($hosts));
self::$data['host'] = array_combine(array_column($hosts, 'host'), $result['hostids']);
$proxies = [];
// dataProviderInvalidAutoregistrationWithHostEncryptionUpdate
$proxies[] = [
'name' => 'test.example.com',
'operating_mode' => PROXY_OPERATING_MODE_ACTIVE,
'tls_accept' => HOST_ENCRYPTION_PSK,
'tls_psk_identity' => 'proxyidentity',
'tls_psk' => '486a9e7b43740b3619e42636cb1c24bf'
];
$result = CDataHelper::call('proxy.create', $proxies);
self::$data['proxy'] = array_combine(array_column($proxies, 'name'), $result['proxyids']);
CDataHelper::call('autoregistration.update', [
'tls_accept' => HOST_ENCRYPTION_NONE,