require_once dirname(__FILE__).'/../include/CAPITest.php';
class testAuthentication extends CAPITest {
public const TEST_DATA_TO_RESOLVE = [
'disabled_usrgrpid' => 'Disabled user group for API tests',
'ldap_userdirectoryid' => 'Used in LDAP settings',
'mfaid' => 'Default MFA method'
'disabled_usrgrpid' => null,
'ldap_userdirectoryid' => null,
public static function authentication_get_data() {
'Test getting authentication general data' => [
'output' => ['authentication_type', 'http_auth_enabled', 'http_login_form', 'http_strip_domains',
'http_case_sensitive', 'ldap_auth_enabled', 'ldap_case_sensitive', 'saml_auth_enabled',
'saml_case_sensitive', 'passwd_min_length', 'passwd_check_rules', 'jit_provision_interval',
'saml_jit_status', 'ldap_jit_status', 'disabled_usrgrpid', 'mfa_status'
'authentication_type' => [ZBX_AUTH_INTERNAL, ZBX_AUTH_LDAP],
'passwd_min_length' => ['min' => 1, 'max' => 70],
'passwd_check_rules' => [
'max' => (PASSWD_CHECK_CASE | PASSWD_CHECK_DIGITS | PASSWD_CHECK_SPECIAL | PASSWD_CHECK_SIMPLE)
'http_auth_enabled' => [ZBX_AUTH_HTTP_DISABLED, ZBX_AUTH_HTTP_ENABLED],
'http_login_form' => [ZBX_AUTH_FORM_ZABBIX, ZBX_AUTH_FORM_HTTP],
'http_strip_domains' => '',
'http_case_sensitive' => [ZBX_AUTH_CASE_INSENSITIVE, ZBX_AUTH_CASE_SENSITIVE],
'ldap_auth_enabled' => [ZBX_AUTH_LDAP_DISABLED, ZBX_AUTH_LDAP_ENABLED],
'ldap_case_sensitive' => [ZBX_AUTH_CASE_INSENSITIVE, ZBX_AUTH_CASE_SENSITIVE],
'ldap_jit_status' => [JIT_PROVISIONING_DISABLED, JIT_PROVISIONING_ENABLED],
'jit_provision_interval' => '1h',
'saml_auth_enabled' => [ZBX_AUTH_SAML_DISABLED, ZBX_AUTH_SAML_ENABLED],
'saml_case_sensitive' => [ZBX_AUTH_CASE_INSENSITIVE, ZBX_AUTH_CASE_SENSITIVE],
'saml_jit_status' => [JIT_PROVISIONING_DISABLED, JIT_PROVISIONING_ENABLED],
'mfa_status' => [MFA_DISABLED, MFA_ENABLED]
public function testAuthentication_Get($authentication, $get_result, $expected_error) {
$result = $this->call('authentication.get', $authentication);
if ($expected_error === null) {
$result = $result['result'];
$this->assertContains($result['authentication_type'], $get_result['authentication_type']);
$this->assertGreaterThanOrEqual($get_result['passwd_min_length']['min'], $result['passwd_min_length']);