summaryrefslogtreecommitdiffstats
path: root/ipatests/test_cmdline
diff options
context:
space:
mode:
authorAna Krivokapic <akrivoka@redhat.com>2013-06-10 18:57:08 -0400
committerPetr Viktorin <pviktori@redhat.com>2013-06-24 14:30:06 +0200
commit91a5d3349be3a8c6044684405a4e66f4ed1dd543 (patch)
treec8d6ee3bbe7eaa81e25ab2b576f6db20345c3090 /ipatests/test_cmdline
parent2775dec3bec3499c69de60d5bb581ffad7615cef (diff)
downloadfreeipa-91a5d3349be3a8c6044684405a4e66f4ed1dd543.tar.gz
freeipa-91a5d3349be3a8c6044684405a4e66f4ed1dd543.tar.xz
freeipa-91a5d3349be3a8c6044684405a4e66f4ed1dd543.zip
Require rid-base and secondary-rid-base in idrange-add after ipa-adtrust-install
Add a new API command 'adtrust_is_enabled', which can be used to determine whether ipa-adtrust-install has been run on the system. This new command is not visible in IPA CLI. Use this command in idrange_add to conditionally require rid-base and secondary-rid-base options. Add tests to cover the new functionality https://fedorahosted.org/freeipa/ticket/3634
Diffstat (limited to 'ipatests/test_cmdline')
-rw-r--r--ipatests/test_cmdline/test_cli.py74
1 files changed, 74 insertions, 0 deletions
diff --git a/ipatests/test_cmdline/test_cli.py b/ipatests/test_cmdline/test_cli.py
index fe411b703..fe5ffacd1 100644
--- a/ipatests/test_cmdline/test_cli.py
+++ b/ipatests/test_cmdline/test_cli.py
@@ -325,3 +325,77 @@ class TestCLIParsing(object):
force=False,
version=API_VERSION
)
+
+ def test_idrange_add(self):
+ """
+ Test idrange-add with interative prompt
+ """
+ def test_with_interactive_input():
+ with self.fake_stdin('5\n500000\n'):
+ self.check_command(
+ 'idrange_add range1 --base-id=1 --range-size=1',
+ 'idrange_add',
+ cn=u'range1',
+ ipabaseid=u'1',
+ ipaidrangesize=u'1',
+ ipabaserid=5,
+ ipasecondarybaserid=500000,
+ all=False,
+ raw=False,
+ version=API_VERSION
+ )
+
+ def test_with_command_line_options():
+ self.check_command(
+ 'idrange_add range1 --base-id=1 --range-size=1 '
+ '--rid-base=5 --secondary-rid-base=500000',
+ 'idrange_add',
+ cn=u'range1',
+ ipabaseid=u'1',
+ ipaidrangesize=u'1',
+ ipabaserid=u'5',
+ ipasecondarybaserid=u'500000',
+ all=False,
+ raw=False,
+ version=API_VERSION
+ )
+
+ def test_without_options():
+ self.check_command(
+ 'idrange_add range1 --base-id=1 --range-size=1',
+ 'idrange_add',
+ cn=u'range1',
+ ipabaseid=u'1',
+ ipaidrangesize=u'1',
+ all=False,
+ raw=False,
+ version=API_VERSION
+ )
+
+ adtrust_dn = 'cn=ADTRUST,cn=%s,cn=masters,cn=ipa,cn=etc,%s' % \
+ (api.env.host, api.env.basedn)
+ adtrust_is_enabled = api.Command['adtrust_is_enabled']()['result']
+ mockldap = None
+
+ if not adtrust_is_enabled:
+ # ipa-adtrust-install not run - no need to pass rid-base
+ # and secondary-rid-base
+ test_without_options()
+
+ # Create a mock service object to test against
+ adtrust_add = dict(
+ ipaconfigstring='enabledService',
+ objectclass=['top', 'nsContainer', 'ipaConfigObject']
+ )
+
+ mockldap = util.MockLDAP()
+ mockldap.add_entry(adtrust_dn, adtrust_add)
+
+ # Pass rid-base and secondary-rid-base interactively
+ test_with_interactive_input()
+
+ # Pass rid-base and secondary-rid-base on the command-line
+ test_with_command_line_options()
+
+ if not adtrust_is_enabled:
+ mockldap.del_entry(adtrust_dn)