xmlrpc tests: add test renaming user or group with setattr

Add a new test renaming user or group using --setattr.
The new name must be validated and invalid names must be
refused.

Related: https://pagure.io/freeipa/issue/9396

Signed-off-by: Florence Blanc-Renaud <flo@redhat.com>
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
This commit is contained in:
Florence Blanc-Renaud authored and Rob Crittenden committed 2023-06-16 15:19:10 -04:00
1 parent 794b2c32f6
commit ae6549ffae
2 files changed
+36

No files matched your search

+23
View File
@@ -39,6 +39,7 @@ from ipatests.util import assert_deepequal, get_group_dn
notagroup = u'notagroup'
renamedgroup1 = u'renamedgroup'
invalidgroup1 = u'+tgroup1'
invalidgroup2 = u'1234'
external_sid1 = u'S-1-1-123456-789-1'
@@ -193,6 +194,28 @@ class TestGroup(XMLRPC_test):
)):
testgroup.create()
def test_rename_setattr_to_invalid_groupname(self, group):
""" Try to rename group using an invalid name with settatr cn= """
group.ensure_exists()
command = group.make_update_command(
updates=dict(setattr='cn=%s' % invalidgroup1))
with raises_exact(errors.ValidationError(
name='cn',
error=ERRMSG_GROUPUSER_NAME.format('group'),
)):
command()
def test_rename_setattr_to_numeric_only_groupname(self, group):
""" Try to rename using an invalid numeric only name with setattr"""
group.ensure_exists()
command = group.make_update_command(
updates=dict(setattr='cn=%s' % invalidgroup2))
with raises_exact(errors.ValidationError(
name='cn',
error=ERRMSG_GROUPUSER_NAME.format('group'),
)):
command()
@pytest.mark.tier1
class TestFindGroup(XMLRPC_test):
+13
View File
@@ -53,6 +53,7 @@ admin_group = u'admins'
invaliduser1 = u'+tuser1'
invaliduser2 = u''.join(['a' for n in range(256)])
invaliduser3 = u'1234'
sshpubkey = (u'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDGAX3xAeLeaJggwTqMjxNwa6X'
'HBUAikXPGMzEpVrlLDCZtv00djsFTBi38PkgxBJVkgRWMrcBsr/35lq7P6w8KGI'
@@ -507,6 +508,18 @@ class TestUpdate(XMLRPC_test):
error=ERRMSG_GROUPUSER_NAME.format('user'))):
command()
def test_rename_setattr_to_numeric_only_username(self, user):
""" Try to change name to name with only numeric chars with setattr"""
user.ensure_exists()
command = user.make_update_command(
updates=dict(setattr='uid=%s' % invaliduser3)
)
with raises_exact(errors.ValidationError(
name='uid',
error=ERRMSG_GROUPUSER_NAME.format('user'),
)):
command()
def test_add_radius_username(self, user):
""" Test for ticket 7569: Try to add --radius-username """
user.ensure_exists()