freeipa/ipatests/test_install/test_install_checks.py
Christian Heimes 172df673dd Refuse PORT, HOST in /etc/openldap/ldap.conf
OpenLDAP has deprecated PORT and HOST stanzes in ldap.conf. The presence
of either option causes FreeIPA installation to fail. Refuse
installation when a deprecated and unsupported option is present.

Fixes: https://pagure.io/freeipa/issue/7418
Signed-off-by: Christian Heimes <cheimes@redhat.com>
Reviewed-By: Florence Blanc-Renaud <frenaud@redhat.com>
2018-05-29 15:30:37 +02:00

38 lines
1.0 KiB
Python

# Copyright (C) 2018 FreeIPA Contributors see COPYING for license
from __future__ import absolute_import
import tempfile
import pytest
from ipaclient.install.client import check_ldap_conf
from ipapython.admintool import ScriptError
@pytest.mark.parametrize("lines,expected", [
(["PORT 389"], "PORT"),
(["HOST example.org"], "HOST"),
(["HOST example.org", "# PORT 389"], "HOST"),
(["\tHOST example.org", "# PORT 389"], "HOST"),
(["HOST example.org", "PORT 389"], "HOST, PORT"),
(["# HOST example.org", "# PORT 389"], None),
(["URI PORT"], None),
([], None),
])
def test_check_ldap(lines, expected):
with tempfile.NamedTemporaryFile('w+') as f:
for line in lines:
f.write(line)
f.write('\n')
f.write('\n')
f.flush()
if expected is None:
assert check_ldap_conf(f.name) is True
else:
with pytest.raises(ScriptError) as e:
check_ldap_conf(f.name)
msg = e.value.msg
assert msg.endswith(expected)