Source
$this->assertTrue($db_media['Media #1'] === $db_media_updated['Media #1'], 'Property userdirectory_mediaid should not change after update operation if where passed');
<?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';
/**
* @onBefore prepareTestData
*
* @onAfter cleanTestData
* @backup userdirectory
*/
class testUserDirectory extends CAPITest {
public static $data = [
'usrgrpid' => [],
'userdirectoryid' => []
];
public static function createValidDataProvider() {
return [
'Create LDAP userdirectories' => [
'userdirectories' => [
['name' => 'LDAP #1', 'idp_type' => IDP_TYPE_LDAP, 'host' => 'ldap.forumsys.com', 'port' => 389, 'base_dn' => 'dc=example,dc=com', 'search_attribute' => 'uid'],
['name' => 'LDAP #2', 'idp_type' => IDP_TYPE_LDAP, 'host' => 'ldap.forumsys.com', 'port' => 389, 'base_dn' => 'dc=example,dc=com', 'search_attribute' => 'uid']
],
'expected_error' => null
],
'Create LDAP userdirectories with provisioning groups and media' => [
'userdirectories' => [[
'name' => 'LDAP #3',
'idp_type' => IDP_TYPE_LDAP,
'host' => 'ldap.forumsys.com',
'port' => 389,
'base_dn' => 'dc=example,dc=com',
'search_attribute' => 'uid',
'provision_status' => JIT_PROVISIONING_ENABLED,
'provision_groups' => [
['name' => 'zabbix-devs', 'roleid' => 1, 'user_groups' => [['usrgrpid' => 7]]],
['name' => 'zabbix-marketing', 'roleid' => 1, 'user_groups' => [['usrgrpid' => 7]]],
['name' => 'zabbix-qa', 'roleid' => 1, 'user_groups' => [['usrgrpid' => 7]]],
['name' => 'zabbix-sales', 'roleid' => 1, 'user_groups' => [['usrgrpid' => 7]]]
],
'provision_media' => [
['name' => 'SMS', 'mediatypeid' => 1, 'attribute' => 'attr_sms'],
['name' => 'Email', 'mediatypeid' => 1, 'attribute' => 'attr_email']
]
]],
'expected_error' => null
],
'Create LDAP userdirectories with provisioning groups and media with additional fields' => [
'userdirectories' => [[
'name' => 'LDAP #4',
'idp_type' => IDP_TYPE_LDAP,
'host' => 'ldap.forumsys.com',
'port' => 389,
'base_dn' => 'dc=example,dc=com',
'search_attribute' => 'uid',
'provision_status' => JIT_PROVISIONING_ENABLED,
'provision_groups' => [
['name' => 'zabbix-devs', 'roleid' => 1, 'user_groups' => [['usrgrpid' => 7]]]
],
'provision_media' => [
['name' => 'Media #1', 'mediatypeid' => 1, 'attribute' => 'active, severity, period set default'],
['name' => 'Media #2', 'mediatypeid' => 1, 'attribute' => 'attr_media2', 'active' => MEDIA_STATUS_ACTIVE],
['name' => 'Media #3', 'mediatypeid' => 1, 'attribute' => 'attr_media3', 'severity' => 3],
['name' => 'Media #4', 'mediatypeid' => 1, 'attribute' => 'attr_media4', 'period' => '2-5,09:00-15:00'],
['name' => 'Media #5', 'mediatypeid' => 1, 'attribute' => 'attr_media5', 'period' => '{$MACRO}'],
['name' => 'Media #6', 'mediatypeid' => 1, 'attribute' => 'attr_media6', 'period' => '{$MACRO:A}'],
['name' => 'Media #7', 'mediatypeid' => 1, 'attribute' => 'attr_media7', 'period' => '{{$MACRO}.func()}']
]
]],
'expected_error' => null
]
];
}
public static function createInvalidDataProvider() {
return [