Source
'expected_error' => 'Cannot delete user group "ldap provision group", because it is used by LDAP userdirectory "ldap provision".'
<?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 __DIR__.'/../include/helpers/CTestDataHelper.php';
/**
* @onBefore prepareTestData
* @onAfter cleanTestData
*
* @backup usrgrp, userdirectory, mfa
*/
class testUserGroup extends CAPITest {
public static $data = [
'usrgrpid' => [],
'userdirectoryid' => [],
'mfaid' => []
];
/**
* Create data to be used in tests.
*/
public function prepareTestData(): void {
$response = CDataHelper::call('userdirectory.create', [[
'name' => 'API LDAP #1',
'idp_type' => IDP_TYPE_LDAP,
'host' => 'ldap.forumsys.com',
'port' => 389,
'base_dn' => 'dc=example,dc=com',
'search_attribute' => 'uid'
]]);
$this->assertArrayHasKey('userdirectoryids', $response);
self::$data['userdirectoryid'] = array_combine(['API LDAP #1'], $response['userdirectoryids']);
$mfa = CDataHelper::call('mfa.create', [[
'type' => MFA_TYPE_TOTP,
'name' => 'MFA TOTP method',
'hash_function' => TOTP_HASH_SHA1,
'code_length' => TOTP_CODE_LENGTH_8
]]);
$this->assertArrayHasKey('mfaids', $mfa);
self::$data['mfaid'] = array_combine(['MFA TOTP method'], $mfa['mfaids']);
// usergroup.update
CTestDataHelper::createObjects([
'user_groups' => [
['name' => 'user group 1']