$this->assertEquals($data['db_check'], CDBHelper::getAll('SELECT authentication_type, disabled_usrgrpid, passwd_min_length,'.
require_once dirname(__FILE__).'/../../include/CWebTest.php';
require_once dirname(__FILE__).'/../behaviors/CMessageBehavior.php';
class testUsersAuthentication extends CWebTest {
public function getBehaviors() {
return ['class' => CMessageBehavior::class];
public function testUsersAuthentication_Layout() {
$this->page->login()->open('zabbix.php?action=authentication.edit');
$this->page->assertTitle('Configuration of authentication');
$this->page->assertHeader('Authentication');
$form = $this->query('id:authentication-form')->asForm()->one();
$auth_radio = $form->getField('Default authentication')->asSegmentedRadio();
$this->assertEquals(['Internal', 'LDAP'], $auth_radio->getLabels()->asText());
$form->checkValue(['Deprovisioned users group' => '']);
$form->query('button:Select')->waitUntilClickable()->one()->click();
$dialog = COverlayDialogElement::find()->waitUntilReady()->one();
$this->assertEquals('User groups', $dialog->getTitle());
$footer = $dialog->getFooter();
$this->assertEquals(1, $footer->query('xpath:.//button')->all()->count());
$this->assertTrue($footer->query('button:Cancel')->one()->isClickable());
$this->assertEquals(['Disabled'], $dialog->query('class:list-table')->asTable()->waitUntilVisible()->one()
$this->assertTrue($form->query('xpath:.//h4[text()="Password policy"]')->exists());
$this->assertEquals(2, $form->getField('Minimum password length')->getAttribute('maxlength'));
'Deprovisioned users group' => 'Only disabled group can be set for deprovisioned users.',
'Password must contain' => "Password requirements:".
"\nmust contain at least one lowercase and one uppercase Latin letter (A-Z, a-z)".
"\nmust contain at least one digit (0-9)".
"\nmust contain at least one special character ( !\"#$%&'()*+,-./:;<=>?@[\]^_`{|}~)",
'Avoid easy-to-guess passwords' => "Password requirements:".
"\nmust not contain user's name, surname or username".
"\nmust not be one of common or context-specific passwords"
foreach ($hintboxes as $field => $text) {
$form->getLabel($field)->query('xpath:./button[@data-hintbox]')->one()->waitUntilClickable()->click();
$hint = $this->query('xpath://div[@class="overlay-dialogue wordbreak"]')->asOverlayDialog()->waitUntilPresent()->one();
$this->assertEquals($text, $hint->getText());
'Default authentication' => 'Internal',
'Deprovisioned users group' => '',
'Minimum password length' => 8,
'id:passwd_check_rules_case' => false,
'id:passwd_check_rules_digits' => false,