Source
<?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__.'/../common/testFormApiTokens.php';
require_once __DIR__.'/../../include/helpers/CDataHelper.php';
/**
* @backup token
*
* @onBefore prepareUserTokenData
*/
class testFormApiTokensUserSettings extends testFormApiTokens {
public $url = 'zabbix.php?action=user.token.list';
/**
* Function creates the given API tokens in the test branch.
*/
public static function prepareUserTokenData() {
$response = CDataHelper::call('token.create', [
[
'name' => 'Admin reference token',
'userid' => 1,
'description' => 'admin token to be used in update scenarios',
'status' => '0',
'expires_at' => '1798754399'
],
[
'name' => 'Token to be deleted',
'userid' => 1,
'description' => 'Token to be deleted in the delete scenario',
'status' => '0',
'expires_at' => '1798754399'
],
[
'name' => 'Token for cancel or simple update',
'userid' => 1,
'description' => 'Token for testing cancelling',
'status' => '0',
'expires_at' => '1798754399'
]
]);
// Generate token strings for the created tokens.
foreach ($response['tokenids'] as $tokenid) {
CDataHelper::call('token.generate', ['tokenids' => $tokenid]);
}
self::$update_token = 'Admin reference token';
}