mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2024-12-26 08:51:50 -06:00
ipatests: add a test for stageuser-find with non-posix account
Add a new XMLRPC test with the following scenario: - ldapadd a user without the posixaccount objectclass - call ipa stageuser-find <user> - check that 1 entry is returned Related: https://pagure.io/freeipa/issue/7983 Reviewed-By: Rob Crittenden <rcritten@redhat.com>
This commit is contained in:
parent
e9c4dcdb85
commit
0294ad2133
@ -9,6 +9,7 @@ Test the `ipaserver/plugins/stageuser.py` module.
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
import six
|
import six
|
||||||
|
import unittest
|
||||||
|
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from ipalib import api, errors
|
from ipalib import api, errors
|
||||||
@ -20,6 +21,13 @@ from ipatests.test_xmlrpc.tracker.user_plugin import UserTracker
|
|||||||
from ipatests.test_xmlrpc.tracker.group_plugin import GroupTracker
|
from ipatests.test_xmlrpc.tracker.group_plugin import GroupTracker
|
||||||
from ipatests.test_xmlrpc.tracker.stageuser_plugin import StageUserTracker
|
from ipatests.test_xmlrpc.tracker.stageuser_plugin import StageUserTracker
|
||||||
|
|
||||||
|
try:
|
||||||
|
from ipaserver.plugins.ldap2 import ldap2
|
||||||
|
except ImportError:
|
||||||
|
have_ldap2 = False
|
||||||
|
else:
|
||||||
|
have_ldap2 = True
|
||||||
|
|
||||||
if six.PY3:
|
if six.PY3:
|
||||||
unicode = str
|
unicode = str
|
||||||
|
|
||||||
@ -115,6 +123,12 @@ def stageduser4(request):
|
|||||||
return tracker.make_fixture(request)
|
return tracker.make_fixture(request)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(scope='class')
|
||||||
|
def stageduser_notposix(request):
|
||||||
|
tracker = StageUserTracker(u'notposix', u'notposix', u'notposix')
|
||||||
|
return tracker.make_fixture(request)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope='class')
|
@pytest.fixture(scope='class')
|
||||||
def user(request):
|
def user(request):
|
||||||
tracker = UserTracker(u'auser1', u'active', u'user')
|
tracker = UserTracker(u'auser1', u'active', u'user')
|
||||||
@ -294,6 +308,31 @@ class TestStagedUser(XMLRPC_test):
|
|||||||
uidnumber=[uid], gidnumber=[gid]))
|
uidnumber=[uid], gidnumber=[gid]))
|
||||||
stageduser.retrieve()
|
stageduser.retrieve()
|
||||||
|
|
||||||
|
def test_without_posixaccount(self, stageduser_notposix):
|
||||||
|
"""Test stageuser-find when the staged user is not a posixaccount.
|
||||||
|
"""
|
||||||
|
stageduser_notposix.ensure_missing()
|
||||||
|
|
||||||
|
# Directly create the user using ldapmod
|
||||||
|
# without the posixaccount objectclass
|
||||||
|
if not have_ldap2:
|
||||||
|
raise unittest.SkipTest('server plugin not available')
|
||||||
|
ldap = ldap2(api)
|
||||||
|
ldap.connect()
|
||||||
|
ldap.create(
|
||||||
|
dn=stageduser_notposix.dn,
|
||||||
|
objectclass=[u'inetorgperson', u'organizationalperson', u'person'],
|
||||||
|
uid=stageduser_notposix.uid,
|
||||||
|
sn=stageduser_notposix.sn,
|
||||||
|
givenname=stageduser_notposix.givenname,
|
||||||
|
cn=stageduser_notposix.uid
|
||||||
|
)
|
||||||
|
# Check that stageuser-find correctly finds the user
|
||||||
|
command = stageduser_notposix.make_find_command(
|
||||||
|
uid=stageduser_notposix.uid)
|
||||||
|
result = command()
|
||||||
|
assert result['count'] == 1
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.tier1
|
@pytest.mark.tier1
|
||||||
class TestCreateInvalidAttributes(XMLRPC_test):
|
class TestCreateInvalidAttributes(XMLRPC_test):
|
||||||
|
Loading…
Reference in New Issue
Block a user