40fe76feb8
Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
86 lines
3.5 KiB
Diff
86 lines
3.5 KiB
Diff
From 3adc0a2fac5f7f1f30f6b1f75f098d4b50e7cf35 Mon Sep 17 00:00:00 2001
|
|
From: Sumit Bose <sbose@redhat.com>
|
|
Date: Mon, 5 Mar 2018 12:29:58 +0100
|
|
Subject: [PATCH 02/15] intg: enhance netgroups test
|
|
|
|
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
|
|
---
|
|
src/tests/intg/sssd_netgroup.py | 9 ++++++---
|
|
src/tests/intg/test_netgroup.py | 26 ++++++++++++++++++++++++++
|
|
2 files changed, 32 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/src/tests/intg/sssd_netgroup.py b/src/tests/intg/sssd_netgroup.py
|
|
index 3668d2e29..4c34ea61f 100644
|
|
--- a/src/tests/intg/sssd_netgroup.py
|
|
+++ b/src/tests/intg/sssd_netgroup.py
|
|
@@ -209,9 +209,12 @@ class NetgroupRetriever(object):
|
|
|
|
if result_p[0].type == NetgroupType.TRIPLE_VAL:
|
|
triple = result_p[0].val.triple
|
|
- result.append((triple.host.decode('utf-8'),
|
|
- triple.user.decode('utf-8'),
|
|
- triple.domain.decode('utf-8')))
|
|
+ result.append((triple.host and triple.host.decode('utf-8')
|
|
+ or "",
|
|
+ triple.user and triple.user.decode('utf-8')
|
|
+ or "",
|
|
+ triple.domain and triple.domain.decode('utf-8')
|
|
+ or ""))
|
|
|
|
res, errno, result_p = self._getnetgrent_r(result_p, buff,
|
|
buff_len)
|
|
diff --git a/src/tests/intg/test_netgroup.py b/src/tests/intg/test_netgroup.py
|
|
index 3cf5dac2e..06a1cfafd 100644
|
|
--- a/src/tests/intg/test_netgroup.py
|
|
+++ b/src/tests/intg/test_netgroup.py
|
|
@@ -106,6 +106,8 @@ def format_basic_conf(ldap_conn, schema):
|
|
services = nss
|
|
disable_netlink = true
|
|
|
|
+ [nss]
|
|
+
|
|
[domain/LDAP]
|
|
{schema_conf}
|
|
id_provider = ldap
|
|
@@ -222,6 +224,14 @@ def add_tripled_netgroup(request, ldap_conn):
|
|
ent_list.add_netgroup("adv_tripled_netgroup", ["(host1,user1,domain1)",
|
|
"(host2,user2,domain2)"])
|
|
|
|
+ ent_list.add_netgroup("tripled_netgroup_no_domain", ["(host,user,)"])
|
|
+
|
|
+ ent_list.add_netgroup("tripled_netgroup_no_user", ["(host,,domain)"])
|
|
+
|
|
+ ent_list.add_netgroup("tripled_netgroup_no_host", ["(,user,domain)"])
|
|
+
|
|
+ ent_list.add_netgroup("tripled_netgroup_none", ["(,,)"])
|
|
+
|
|
create_ldap_fixture(request, ldap_conn, ent_list)
|
|
conf = format_basic_conf(ldap_conn, SCHEMA_RFC2307_BIS)
|
|
create_conf_fixture(request, conf)
|
|
@@ -243,6 +253,22 @@ def test_add_tripled_netgroup(add_tripled_netgroup):
|
|
assert sorted(netgrps) == sorted([("host1", "user1", "domain1"),
|
|
("host2", "user2", "domain2")])
|
|
|
|
+ res, _, netgrps = sssd_netgroup.get_sssd_netgroups("tripled_netgroup_no_domain")
|
|
+ assert res == sssd_netgroup.NssReturnCode.SUCCESS
|
|
+ assert netgrps == [("host", "user", "")]
|
|
+
|
|
+ res, _, netgrps = sssd_netgroup.get_sssd_netgroups("tripled_netgroup_no_user")
|
|
+ assert res == sssd_netgroup.NssReturnCode.SUCCESS
|
|
+ assert netgrps == [("host", "", "domain")]
|
|
+
|
|
+ res, _, netgrps = sssd_netgroup.get_sssd_netgroups("tripled_netgroup_no_host")
|
|
+ assert res == sssd_netgroup.NssReturnCode.SUCCESS
|
|
+ assert netgrps == [("", "user", "domain")]
|
|
+
|
|
+ res, _, netgrps = sssd_netgroup.get_sssd_netgroups("tripled_netgroup_none")
|
|
+ assert res == sssd_netgroup.NssReturnCode.SUCCESS
|
|
+ assert netgrps == [("", "", "")]
|
|
+
|
|
|
|
@pytest.fixture
|
|
def add_mixed_netgroup(request, ldap_conn):
|
|
--
|
|
2.14.3
|
|
|