diff --git a/ipatests/test_xmlrpc/test_user_plugin.py b/ipatests/test_xmlrpc/test_user_plugin.py index f867b042d..a8b46d629 100644 --- a/ipatests/test_xmlrpc/test_user_plugin.py +++ b/ipatests/test_xmlrpc/test_user_plugin.py @@ -32,6 +32,7 @@ import re from ipalib import api, errors from ipaplatform.constants import constants as platformconstants +from ipapython import ipautil from ipatests.test_xmlrpc import objectclasses from ipatests.util import ( assert_deepequal, assert_equal, assert_not_equal, raises) @@ -786,6 +787,86 @@ class TestUserWithGroup(XMLRPC_test): ) +@pytest.mark.tier1 +class TestUserWithUPGDisabled(XMLRPC_test): + """ Tests with UPG plugin disabled """ + + @classmethod + def managed_entries_upg(cls, action='enable'): + """ Change the UPG plugin state """ + assert action in ('enable', 'disable') + ipautil.run(['ipa-managed-entries', '-e', 'UPG Definition', action]) + + @classmethod + def setup_class(cls): + super(TestUserWithUPGDisabled, cls).setup_class() + cls.managed_entries_upg(action='disable') + + @classmethod + def teardown_class(cls): + cls.managed_entries_upg(action='enable') + super(TestUserWithUPGDisabled, cls).teardown_class() + + def test_create_without_upg(self): + """ Try to create user without User's Primary GID + + As the UPG plugin is disabled, the user gets assigned to the Default + Group for new users (ipausers) which is not POSIX and the command + is expected to fail + """ + testuser = UserTracker( + name=u'tuser1', givenname=u'Test', sn=u'Tuser1' + ) + command = testuser.make_create_command() + with raises_exact(errors.NotFound( + reason=u'Default group for new users is not POSIX')): + command() + + def test_create_without_upg_with_gid_set(self): + """ Create user without User's Primary GID with GID set + + The UPG plugin is disabled, but the user is provided with a group + """ + testuser = UserTracker( + name=u'tuser1', givenname=u'Test', sn=u'Tuser1', + gidnumber=1000 + ) + testuser.track_create() + del testuser.attrs['mepmanagedentry'] + testuser.attrs.update(gidnumber=[u'1000']) + testuser.attrs.update( + description=[], + objectclass=add_oc(objectclasses.user_base, u'ipantuserattrs') + ) + command = testuser.make_create_command() + result = command() + testuser.check_create(result, [u'description']) + testuser.delete() + + def test_create_where_managed_group_exists(self, user, group): + """ Create a managed group and then try to create user + with the same name the group has + + As the UPG plugin is disabled, there is no conflict + """ + group.create() + testuser = UserTracker( + name=group.cn, givenname=u'Test', sn=u'Tuser1', + gidnumber=1000 + ) + testuser.track_create() + del testuser.attrs['mepmanagedentry'] + testuser.attrs.update(gidnumber=[u'1000']) + testuser.attrs.update( + description=[], + objectclass=add_oc(objectclasses.user_base, u'ipantuserattrs') + ) + command = testuser.make_create_command() + result = command() + testuser.check_create(result, [u'description']) + testuser.delete() + + @pytest.mark.tier1 class TestManagers(XMLRPC_test): def test_assign_nonexistent_manager(self, user, user2):