summaryrefslogtreecommitdiffstats
path: root/ipatests
diff options
context:
space:
mode:
authorGanna Kaihorodova <gkaihoro@redhat.com>2016-11-02 15:02:30 +0100
committerMartin Basti <mbasti@redhat.com>2017-01-19 17:36:46 +0100
commita336de630e9d1ef95a507cc3ee9200c001ab9193 (patch)
tree117f81aba92ae00f27f531d463a6d27506a4ebb3 /ipatests
parente04b75cb9e71fb2b9faa49aea7f2244b01fddbcb (diff)
downloadfreeipa-a336de630e9d1ef95a507cc3ee9200c001ab9193.tar.gz
freeipa-a336de630e9d1ef95a507cc3ee9200c001ab9193.tar.xz
freeipa-a336de630e9d1ef95a507cc3ee9200c001ab9193.zip
Tests: Stage User Tracker implementation
Fix provide possibility of creation stage user with minimal values, with uid not specified and check for non-empty unicode string for attributes requested in init method https://fedorahosted.org/freeipa/ticket/6448 Reviewed-By: Lenka Doudova <ldoudova@redhat.com> Reviewed-By: Stanislav Laznicka <slaznick@redhat.com>
Diffstat (limited to 'ipatests')
-rw-r--r--ipatests/test_xmlrpc/tracker/stageuser_plugin.py38
1 files changed, 30 insertions, 8 deletions
diff --git a/ipatests/test_xmlrpc/tracker/stageuser_plugin.py b/ipatests/test_xmlrpc/tracker/stageuser_plugin.py
index 4f87163ce..27f56d360 100644
--- a/ipatests/test_xmlrpc/tracker/stageuser_plugin.py
+++ b/ipatests/test_xmlrpc/tracker/stageuser_plugin.py
@@ -61,23 +61,45 @@ class StageUserTracker(Tracker):
find_keys = retrieve_keys - {u'has_keytab', u'has_password'}
find_all_keys = retrieve_all_keys - {u'has_keytab', u'has_password'}
- def __init__(self, name, givenname, sn, **kwargs):
+ def __init__(self, name=None, givenname=None, sn=None, **kwargs):
+ """ Check for non-empty unicode string for the required attributes
+ in the init method """
+
+ if not (isinstance(givenname, six.string_types) and givenname):
+ raise ValueError(
+ "Invalid first name provided: {!r}".format(givenname)
+ )
+ if not (isinstance(sn, six.string_types) and sn):
+ raise ValueError("Invalid second name provided: {!r}".format(sn))
+
super(StageUserTracker, self).__init__(default_version=None)
- self.uid = name
- self.givenname = givenname
- self.sn = sn
+ self.uid = unicode(name)
+ self.givenname = unicode(givenname)
+ self.sn = unicode(sn)
self.dn = DN(
('uid', self.uid), api.env.container_stageuser, api.env.basedn)
self.kwargs = kwargs
def make_create_command(self, options=None):
- """ Make function that creates a staged user using stageuser-add """
+ """ Make function that creates a staged user using stageuser-add
+ with all set of attributes and with minimal values,
+ where uid is not specified """
+
if options is not None:
self.kwargs = options
- return self.make_command('stageuser_add', self.uid,
- givenname=self.givenname,
- sn=self.sn, **self.kwargs)
+ if self.uid is not None:
+ return self.make_command(
+ 'stageuser_add', self.uid,
+ givenname=self.givenname,
+ sn=self.sn, **self.kwargs
+ )
+ else:
+ return self.make_command(
+ 'stageuser_add',
+ givenname=self.givenname,
+ sn=self.sn, **self.kwargs
+ )
def make_delete_command(self):
""" Make function that deletes a staged user using stageuser-del """