Patch 0311: one-liner (or one-byter) to fix the last certinstall test

Patch 0312 adds tests for http://www.freeipa.org/page/V3/ipa-server-certinstall_CLI_cleanup

--
PetrĀ³
From 709f0d2963adc1ff2633b6bbcb9ea463d63658c7 Mon Sep 17 00:00:00 2001
From: Petr Viktorin <pvikt...@redhat.com>
Date: Wed, 9 Oct 2013 16:55:10 +0200
Subject: [PATCH] test_caless.TestCertInstall: Fix 'test_no_ds_password' test
 case

The test installed the HTTP cert instead of the DS one.
---
 ipatests/test_integration/test_caless.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ipatests/test_integration/test_caless.py b/ipatests/test_integration/test_caless.py
index 158c2efdbb4636e6a13b12a6080c7cd6b2e0ca45..ed0554c6f5502e21d766b59617774313a1dac5d0 100644
--- a/ipatests/test_integration/test_caless.py
+++ b/ipatests/test_integration/test_caless.py
@@ -1435,5 +1435,5 @@ def test_no_http_password(self):
     def test_no_ds_password(self):
         "Install new DS certificate with no PKCS#12 password"
 
-        result = self.certinstall('w', 'ca1/server', pin='', p12_pin='')
+        result = self.certinstall('d', 'ca1/server', pin='', p12_pin='')
         assert result.returncode == 0
-- 
1.8.3.1

From 05cd3378a8e2b9c1c12b3c7d94b7c43c67882e21 Mon Sep 17 00:00:00 2001
From: Petr Viktorin <pvikt...@redhat.com>
Date: Wed, 9 Oct 2013 16:56:17 +0200
Subject: [PATCH] Use new CLI options in certinstall tests

The --pin and --dirman-password options simplified ipa-certinstall
usage. Use them in tests.

Also add tests for the old way of calling the command.

https://fedorahosted.org/freeipa/ticket/3869
http://www.freeipa.org/page/V3/ipa-server-certinstall_CLI_cleanup
---
 ipatests/test_integration/test_caless.py | 45 +++++++++++++++++++++++---------
 1 file changed, 33 insertions(+), 12 deletions(-)

diff --git a/ipatests/test_integration/test_caless.py b/ipatests/test_integration/test_caless.py
index ed0554c6f5502e21d766b59617774313a1dac5d0..9866705bd8d8d063aa3e0bb4d5c5c8f929473915 100644
--- a/ipatests/test_integration/test_caless.py
+++ b/ipatests/test_integration/test_caless.py
@@ -1235,24 +1235,21 @@ def install(cls):
 
     def certinstall(self, mode, cert_nick=None, cert_exists=True,
                     filename='server.p12', pin=_DEFAULT, stdin_text=None,
-                    p12_pin=None):
+                    p12_pin=None, args=None):
         if cert_nick:
             self.export_pkcs12(cert_nick, password=p12_pin)
         if pin is _DEFAULT:
             pin = self.cert_password
         if cert_exists:
             self.copy_cert(self.master, filename)
-        args = ['ipa-server-certinstall',
-                '-%s' % mode, filename]
-        if pin is not None:
-            option = {'w': '--http_pin', 'd': '--dirsrv_pin'}[mode]
-            args += [option, pin]
-        if mode == 'd':
-            if stdin_text:
-                stdin_text = '%s\n%s' % (self.master.config.dirman_password,
-                                         stdin_text)
-            else:
-                stdin_text = self.master.config.dirman_password + '\n'
+        if not args:
+            args = ['ipa-server-certinstall',
+                    '-%s' % mode, filename]
+            if pin is not None:
+                args += ['--pin', pin]
+            if mode == 'd':
+                args += ['--dirman-password',
+                         self.master.config.dirman_password]
         return self.master.run_command(args,
                                        raiseonerr=False,
                                        stdin_text=stdin_text)
@@ -1437,3 +1434,27 @@ def test_no_ds_password(self):
 
         result = self.certinstall('d', 'ca1/server', pin='', p12_pin='')
         assert result.returncode == 0
+
+    def test_http_old_options(self):
+        "Install new valid DS certificate using pre-v3.3 CLI options"
+        # http://www.freeipa.org/page/V3/ipa-server-certinstall_CLI_cleanup
+
+        args = ['ipa-server-certinstall',
+                '-w', 'server.p12',
+                '--http_pin', self.cert_password]
+
+        result = self.certinstall('w', 'ca1/server', args=args)
+        assert result.returncode == 0
+
+    def test_ds_old_options(self):
+        "Install new valid DS certificate using pre-v3.3 CLI options"
+        # http://www.freeipa.org/page/V3/ipa-server-certinstall_CLI_cleanup
+
+        args = ['ipa-server-certinstall',
+                '-d', 'server.p12',
+                '--dirsrv_pin', self.cert_password]
+        stdin_text = self.master.config.dirman_password + '\n'
+
+        result = self.certinstall('d', 'ca1/server',
+                                  args=args, stdin_text=stdin_text)
+        assert result.returncode == 0
-- 
1.8.3.1

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to