Imported Upstream version 4.8.10
This commit is contained in:
@@ -18,27 +18,21 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
"""
|
||||
Test the `ipalib/plugins/netgroup.py` module.
|
||||
Test the `ipaserver/plugins/netgroup.py` module.
|
||||
"""
|
||||
|
||||
import nose
|
||||
import krbV
|
||||
|
||||
from ipalib import api
|
||||
from ipalib import errors
|
||||
from ipaserver.plugins.ldap2 import ldap2
|
||||
from xmlrpc_test import (Declarative, fuzzy_digits, fuzzy_uuid,
|
||||
fuzzy_netgroupdn)
|
||||
from ipatests.test_xmlrpc.xmlrpc_test import (Declarative, fuzzy_digits,
|
||||
fuzzy_uuid, fuzzy_netgroupdn)
|
||||
from ipatests.test_xmlrpc import objectclasses
|
||||
from ipapython.dn import DN
|
||||
from ipatests.test_xmlrpc.test_user_plugin import get_user_result
|
||||
import pytest
|
||||
|
||||
# Global so we can save the value between tests
|
||||
netgroup_dn = None
|
||||
|
||||
# See if our LDAP server is up and we can talk to it over GSSAPI
|
||||
ccache = krbV.default_context().default_ccache().name
|
||||
|
||||
netgroup1 = u'netgroup1'
|
||||
netgroup2 = u'netgroup2'
|
||||
netgroup_single = u'a'
|
||||
@@ -67,6 +61,8 @@ invalidnisdomain1=u'domain1,domain2'
|
||||
invalidnisdomain2=u'+invalidnisdomain'
|
||||
invalidhost=u'+invalid&host'
|
||||
|
||||
|
||||
@pytest.mark.tier1
|
||||
class test_netgroup(Declarative):
|
||||
"""
|
||||
Test the `netgroup` plugin.
|
||||
@@ -235,6 +231,7 @@ class test_netgroup(Declarative):
|
||||
description=[u'Test host 1'],
|
||||
l=[u'Undisclosed location 1'],
|
||||
krbprincipalname=[u'host/%s@%s' % (host1, api.env.realm)],
|
||||
krbcanonicalname=[u'host/%s@%s' % (host1, api.env.realm)],
|
||||
objectclass=objectclasses.host,
|
||||
ipauniqueid=[fuzzy_uuid],
|
||||
managedby_host=[host1],
|
||||
@@ -323,6 +320,8 @@ class test_netgroup(Declarative):
|
||||
member=dict(
|
||||
group=tuple(),
|
||||
user=tuple(),
|
||||
service=tuple(),
|
||||
idoverrideuser=tuple(),
|
||||
),
|
||||
),
|
||||
result={
|
||||
@@ -410,8 +409,9 @@ class test_netgroup(Declarative):
|
||||
|
||||
|
||||
dict(
|
||||
desc='Search for netgroups using no_user',
|
||||
command=('netgroup_find', [], dict(no_user=user1)),
|
||||
desc='Search for netgroups using no_user with members',
|
||||
command=('netgroup_find', [], dict(
|
||||
no_user=user1, no_members=False)),
|
||||
expected=dict(
|
||||
count=2,
|
||||
truncated=False,
|
||||
@@ -435,6 +435,32 @@ class test_netgroup(Declarative):
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
dict(
|
||||
desc='Search for netgroups using no_user',
|
||||
command=('netgroup_find', [], dict(no_user=user1)),
|
||||
expected=dict(
|
||||
count=2,
|
||||
truncated=False,
|
||||
summary=u'2 netgroups matched',
|
||||
result=[
|
||||
{
|
||||
'dn': fuzzy_netgroupdn,
|
||||
'cn': [netgroup1],
|
||||
'description': [u'Test netgroup 1'],
|
||||
'nisdomainname': [u'%s' % api.env.domain],
|
||||
},
|
||||
{
|
||||
'dn': fuzzy_netgroupdn,
|
||||
'cn': [netgroup2],
|
||||
'description': [u'Test netgroup 2'],
|
||||
'nisdomainname': [u'%s' % api.env.domain],
|
||||
},
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
dict(
|
||||
desc="Check %r doesn't match when searching for %s" % (netgroup1, user1),
|
||||
command=('netgroup_find', [], dict(user=user1)),
|
||||
@@ -856,8 +882,9 @@ class test_netgroup(Declarative):
|
||||
),
|
||||
|
||||
dict(
|
||||
desc='Search for %r' % netgroup1,
|
||||
command=('netgroup_find', [], dict(cn=netgroup1)),
|
||||
desc='Search for %r with members' % netgroup1,
|
||||
command=('netgroup_find', [], dict(
|
||||
cn=netgroup1, no_members=False)),
|
||||
expected=dict(
|
||||
count=1,
|
||||
truncated=False,
|
||||
@@ -879,6 +906,53 @@ class test_netgroup(Declarative):
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
dict(
|
||||
desc='Search for %r' % netgroup1,
|
||||
command=('netgroup_find', [], dict(cn=netgroup1)),
|
||||
expected=dict(
|
||||
count=1,
|
||||
truncated=False,
|
||||
summary=u'1 netgroup matched',
|
||||
result=[
|
||||
{
|
||||
'dn': fuzzy_netgroupdn,
|
||||
'cn': [netgroup1],
|
||||
'description': [u'Test netgroup 1'],
|
||||
'nisdomainname': [u'%s' % api.env.domain],
|
||||
'externalhost': [unknown_host],
|
||||
},
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
dict(
|
||||
desc='Search for %r using user with members' % netgroup1,
|
||||
command=('netgroup_find', [], dict(
|
||||
user=user1, no_members=False)),
|
||||
expected=dict(
|
||||
count=1,
|
||||
truncated=False,
|
||||
summary=u'1 netgroup matched',
|
||||
result=[
|
||||
{
|
||||
'dn': fuzzy_netgroupdn,
|
||||
'memberhost_host': (host1,),
|
||||
'memberhost_hostgroup': (hostgroup1,),
|
||||
'memberuser_user': (user1,),
|
||||
'memberuser_group': (group1,),
|
||||
'member_netgroup': (netgroup2,),
|
||||
'cn': [netgroup1],
|
||||
'description': [u'Test netgroup 1'],
|
||||
'nisdomainname': [u'%s' % api.env.domain],
|
||||
'externalhost': [unknown_host],
|
||||
},
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
dict(
|
||||
desc='Search for %r using user' % netgroup1,
|
||||
command=('netgroup_find', [], dict(user=user1)),
|
||||
@@ -889,11 +963,6 @@ class test_netgroup(Declarative):
|
||||
result=[
|
||||
{
|
||||
'dn': fuzzy_netgroupdn,
|
||||
'memberhost_host': (host1,),
|
||||
'memberhost_hostgroup': (hostgroup1,),
|
||||
'memberuser_user': (user1,),
|
||||
'memberuser_group': (group1,),
|
||||
'member_netgroup': (netgroup2,),
|
||||
'cn': [netgroup1],
|
||||
'description': [u'Test netgroup 1'],
|
||||
'nisdomainname': [u'%s' % api.env.domain],
|
||||
@@ -903,9 +972,11 @@ class test_netgroup(Declarative):
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
dict(
|
||||
desc='Search for all netgroups using empty member user',
|
||||
command=('netgroup_find', [], dict(user=None)),
|
||||
desc=('Search for all netgroups using empty member user with '
|
||||
'members'),
|
||||
command=('netgroup_find', [], dict(user=None, no_members=False)),
|
||||
expected=dict(
|
||||
count=2,
|
||||
truncated=False,
|
||||
@@ -934,6 +1005,33 @@ class test_netgroup(Declarative):
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
dict(
|
||||
desc='Search for all netgroups using empty member user',
|
||||
command=('netgroup_find', [], dict(user=None)),
|
||||
expected=dict(
|
||||
count=2,
|
||||
truncated=False,
|
||||
summary=u'2 netgroups matched',
|
||||
result=[
|
||||
{
|
||||
'dn': fuzzy_netgroupdn,
|
||||
'cn': [netgroup1],
|
||||
'description': [u'Test netgroup 1'],
|
||||
'nisdomainname': [u'%s' % api.env.domain],
|
||||
'externalhost': [unknown_host],
|
||||
},
|
||||
{
|
||||
'dn': fuzzy_netgroupdn,
|
||||
'cn': [netgroup2],
|
||||
'description': [u'Test netgroup 2'],
|
||||
'nisdomainname': [u'%s' % api.env.domain],
|
||||
},
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
dict(
|
||||
desc='Update %r' % netgroup1,
|
||||
command=('netgroup_mod', [netgroup1],
|
||||
@@ -1297,13 +1395,15 @@ class test_netgroup(Declarative):
|
||||
# """
|
||||
# # Do an LDAP query to the compat area and verify that the entry
|
||||
# # is correct
|
||||
# conn = ldap2(shared_instance=False, ldap_uri=api.env.ldap_uri, base_dn=api.env.basedn)
|
||||
# conn.connect(ccache=ccache)
|
||||
# conn = ldap2(api)
|
||||
# conn.connect()
|
||||
# try:
|
||||
# entries = conn.find_entries('cn=%s' % self.ng_cn,
|
||||
# base_dn='cn=ng,cn=compat,%s' % api.env.basedn)
|
||||
# except errors.NotFound:
|
||||
# raise nose.SkipTest('compat and nis are not enabled, skipping test')
|
||||
# pytest.skip(
|
||||
# 'compat and nis are not enabled, skipping test'
|
||||
# )
|
||||
# finally:
|
||||
# conn.disconnect()
|
||||
# triples = entries[0][0]['nisnetgrouptriple']
|
||||
|
||||
Reference in New Issue
Block a user