Source
$this->assertEquals((HOST_ENCRYPTION_PSK|HOST_ENCRYPTION_NONE), CDBHelper::getValue('SELECT autoreg_tls_accept FROM config'));
<?php
/*
** Zabbix
** Copyright (C) 2001-2022 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
require_once dirname(__FILE__) . '/../include/CWebTest.php';
/**
* @backup config
*/
class testFormAdministrationGeneralAutoregistration extends CWebTest {
/**
* Check the default state of page elements, when first time open Autoregistration.
*/
public function testFormAdministrationGeneralAutoregistration_checkDefaultState() {
// Navigate to autoregistration page from dashboard page.
$this->page->login()->open('zabbix.php?action=gui.edit');
$this->query('id:page-title-general')->asPopupButton()->one()->select('Autoregistration');
// Check elements default state.
$form = $this->query('id:autoreg-form')->asForm()->one();
$this->assertEquals(['No encryption'], $form->getField('Encryption level')->getValue());
$this->assertFalse($form->query('id:tls_psk_identity')->one()->isDisplayed());
$this->assertFalse($form->query('id:tls_psk')->one()->isDisplayed());
}
/**
* Check PSK field values, when PSK encryption is set and unset.
*/
public function testFormAdministrationGeneralAutoregistration_PskValues() {
$data = [
'Encryption level' => ['PSK'],
'PSK identity' => 'PSK004',
'PSK' => '07df83bf21bf0be663090bb8d4128558ab9b95fba66a6dbf834f8b91ae5e08ae'
];
$this->page->login()->open('zabbix.php?action=autoreg.edit');
$form = $this->query('id:autoreg-form')->asForm()->one();
$form->fill($data);
// Check entered PSK values.
$this->assertEquals($data['PSK identity'], $form->getField('PSK identity')->getValue());
$this->assertEquals($data['PSK'], $form->getField('PSK')->getValue());
// Uncheck PSK. PSK fields are hidden.
$form->getField('Encryption level')->set('PSK', false);
$this->assertFalse($form->query('id:tls_psk_identity')->one()->isDisplayed());