URL: https://github.com/freeipa/freeipa/pull/140
Author: mirielka
 Title: #140: Tests: Remove invalid certplugin tests
Action: synchronized

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/140/head:pr140
git checkout pr140
From b6afcc5b56f471b06fdd64a0c1e0d996b4a07f08 Mon Sep 17 00:00:00 2001
From: Lenka Doudova <ldoud...@redhat.com>
Date: Thu, 6 Oct 2016 08:51:03 +0200
Subject: [PATCH 1/2] Tests: Remove invalid certplugin tests

A bunch of certplugin tests were testing number of revoked certificates with
various revocation reasons. Since existence of revoked certificates often
depends on other parts of IdM than IPA, it is not really valid to check their
presence unless creation of revoked certificate is intentionally tested.

https://fedorahosted.org/freeipa/ticket/6349
---
 ipatests/test_xmlrpc/test_cert_plugin.py | 75 +-------------------------------
 1 file changed, 1 insertion(+), 74 deletions(-)

diff --git a/ipatests/test_xmlrpc/test_cert_plugin.py b/ipatests/test_xmlrpc/test_cert_plugin.py
index 4537002..e527886 100644
--- a/ipatests/test_xmlrpc/test_cert_plugin.py
+++ b/ipatests/test_xmlrpc/test_cert_plugin.py
@@ -292,80 +292,7 @@ def test_0006_find_this_short_host_exact(self):
         res = api.Command['cert_find'](subject=self.short, exactly=True)
         assert 'count' in res and res['count'] == 0
 
-    def test_0007_find_revocation_reason_0(self):
-        """
-        Find all certificates with revocation reason 0
-        """
-        res = api.Command['cert_find'](revocation_reason=0)
-        assert 'count' in res and res['count'] == 0
-
-    def test_0008_find_revocation_reason_1(self):
-        """
-        Find all certificates with revocation reason 1
-        """
-        res = api.Command['cert_find'](revocation_reason=1)
-        assert 'count' in res and res['count'] == 0
-
-    def test_0009_find_revocation_reason_2(self):
-        """
-        Find all certificates with revocation reason 2
-        """
-        res = api.Command['cert_find'](revocation_reason=2)
-        assert 'count' in res and res['count'] == 0
-
-    def test_0010_find_revocation_reason_3(self):
-        """
-        Find all certificates with revocation reason 3
-        """
-        res = api.Command['cert_find'](revocation_reason=3)
-        assert 'count' in res and res['count'] == 0
-
-    def test_0011_find_revocation_reason_4(self):
-        """
-        Find all certificates with revocation reason 4
-
-        There is no way to know in advance how many revoked certificates
-        we'll have but in the context of make-test we'll have at least one.
-        """
-        res = api.Command['cert_find'](revocation_reason=4)
-        assert 'count' in res and res['count'] >= 1
-
-    def test_0012_find_revocation_reason_5(self):
-        """
-        Find all certificates with revocation reason 5
-        """
-        res = api.Command['cert_find'](revocation_reason=5)
-        assert 'count' in res and res['count'] == 0
-
-    def test_0013_find_revocation_reason_6(self):
-        """
-        Find all certificates with revocation reason 6
-        """
-        res = api.Command['cert_find'](revocation_reason=6)
-        assert 'count' in res and res['count'] == 0
-
-    # There is no revocation reason #7
-
-    def test_0014_find_revocation_reason_8(self):
-        """
-        Find all certificates with revocation reason 8
-        """
-        res = api.Command['cert_find'](revocation_reason=8)
-        assert 'count' in res and res['count'] == 0
-
-    def test_0015_find_revocation_reason_9(self):
-        """
-        Find all certificates with revocation reason 9
-        """
-        res = api.Command['cert_find'](revocation_reason=9)
-        assert 'count' in res and res['count'] == 0
-
-    def test_0016_find_revocation_reason_10(self):
-        """
-        Find all certificates with revocation reason 10
-        """
-        res = api.Command['cert_find'](revocation_reason=10)
-        assert 'count' in res and res['count'] == 0
+    # tests 0007 to 0016 removed
 
     def test_0017_find_by_issuedon(self):
         """

From 0232ec23bcbc23c4cccdeef1dc20e75839c5832c Mon Sep 17 00:00:00 2001
From: Lenka Doudova <ldoud...@redhat.com>
Date: Tue, 11 Oct 2016 11:33:16 +0200
Subject: [PATCH 2/2] Tests: Certificate revocation

Providing tests for certificate revocation to replace deleted tests from
test_cert_find.

https://fedorahosted.org/freeipa/ticket/6349
---
 ipatests/test_xmlrpc/test_cert_plugin.py | 80 ++++++++++++++++++++++++++++++--
 1 file changed, 75 insertions(+), 5 deletions(-)

diff --git a/ipatests/test_xmlrpc/test_cert_plugin.py b/ipatests/test_xmlrpc/test_cert_plugin.py
index e527886..cb5175d 100644
--- a/ipatests/test_xmlrpc/test_cert_plugin.py
+++ b/ipatests/test_xmlrpc/test_cert_plugin.py
@@ -78,12 +78,11 @@ def is_db_configured():
 # running as the lite-server.
 
 
-@pytest.mark.tier1
-class test_cert(XMLRPC_test):
+class BaseCert(XMLRPC_test):
 
     @classmethod
     def setup_class(cls):
-        super(test_cert, cls).setup_class()
+        super(BaseCert, cls).setup_class()
 
         if 'cert_request' not in api.Command:
             raise nose.SkipTest('cert_request not registered')
@@ -128,11 +127,20 @@ def generateCSR(self, subject):
         fp.close()
         return data
 
+    host_fqdn = u'ipatestcert.%s' % api.env.domain
+    service_princ = u'test/%s@%s' % (host_fqdn, api.env.realm)
+
+
+@pytest.mark.tier1
+class test_cert(BaseCert):
+
+    @classmethod
+    def setup_class(cls):
+        super(test_cert, cls).setup_class()
+
     """
     Test the `cert` plugin.
     """
-    host_fqdn = u'ipatestcert.%s' % api.env.domain
-    service_princ = u'test/%s@%s' % (host_fqdn, api.env.realm)
 
     def test_0001_cert_add(self):
         """
@@ -409,3 +417,65 @@ def test_0031_search_on_invalid_date(self):
         Search using invalid date format
         """
         api.Command['cert_find'](issuedon_from=u'xyz')
+
+
+@pytest.mark.tier1
+class test_cert_revocation(BaseCert):
+
+    @classmethod
+    def setup_class(cls):
+        super(test_cert_revocation, cls).setup_class()
+
+    # create CSR, request cert, revoke cert, check cert attributes
+    def revoke_cert(self, reason):
+        # add host
+        assert 'result' in api.Command['host_add'](self.host_fqdn, force=True)
+
+        # generate CSR, request certificate, obtain serial number
+        self.csr = unicode(self.generateCSR(str(self.subject)))
+        res = api.Command['cert_request'](self.csr,
+                                          principal=self.service_princ,
+                                          add=True, all=True)['result']
+        serial_number = res['serial_number']
+
+        # revoke created certificate
+        assert 'result' in api.Command['cert_revoke'](
+            serial_number, revocation_reason=reason)
+
+        # verify that certificate is revoked with correct reason
+        res2 = api.Command['cert_show'](serial_number, all=True)['result']
+        assert res2['revoked']
+        assert res2['revocation_reason'] == reason
+
+        # remove host
+        assert 'result' in api.Command['host_del'](self.host_fqdn)
+
+    def test_revoke_with_reason_0(self):
+        self.revoke_cert(0)
+
+    def test_revoke_with_reason_1(self):
+        self.revoke_cert(1)
+
+    def test_revoke_with_reason_2(self):
+        self.revoke_cert(2)
+
+    def test_revoke_with_reason_3(self):
+        self.revoke_cert(3)
+
+    def test_revoke_with_reason_4(self):
+        self.revoke_cert(4)
+
+    def test_revoke_with_reason_5(self):
+        self.revoke_cert(5)
+
+    def test_revoke_with_reason_6(self):
+        self.revoke_cert(6)
+
+    def test_revoke_with_reason_8(self):
+        self.revoke_cert(8)
+
+    def test_revoke_with_reason_9(self):
+        self.revoke_cert(9)
+
+    def test_revoke_with_reason_10(self):
+        self.revoke_cert(10)
-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to