On 04/05/2016 09:31 AM, Martin Babinsky wrote:
On 04/01/2016 12:02 PM, Milan Kubík wrote:

Patches attached.



https://fedorahosted.org/freeipa/ticket/5733







Hi Milan,



I would be more happy if you could send a separate patch for the context
manager fix, since the issue is orthogonal to the added test case (even
if the test suite explodes without it).



Otherwise LGTM.






Done. Patch 0035 now applies to all branches, context manager fix needs separate patch for ipa-4-2.

--
Milan Kubik

From eebad5ad31107f3383b4b2755a97929a75170d6f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Milan=20Kub=C3=ADk?= <mku...@redhat.com>
Date: Tue, 5 Apr 2016 10:04:03 +0200
Subject: [PATCH 1/2] ipatests: Add test case for requesting a certificate with
 full principal.

https://fedorahosted.org/freeipa/ticket/5733
---
 ipatests/test_xmlrpc/test_caacl_profile_enforcement.py | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/ipatests/test_xmlrpc/test_caacl_profile_enforcement.py b/ipatests/test_xmlrpc/test_caacl_profile_enforcement.py
index dca4151d614a4c2e2f5a09455426d117da4c1c80..a0b8d614cf6dd42b18eb03100a318e4a3fbfb4e0 100644
--- a/ipatests/test_xmlrpc/test_caacl_profile_enforcement.py
+++ b/ipatests/test_xmlrpc/test_caacl_profile_enforcement.py
@@ -130,6 +130,14 @@ class TestCertSignMIME(XMLRPC_test):
             api.Command.cert_request(csr, principal=smime_user,
                                      profile_id=smime_profile.name)
 
+    @pytest.mark.xfail(strict=True, reason='freeipa ticket 5733')
+    def test_sign_smime_csr_full_principal(self, smime_profile, smime_user):
+        csr = generate_user_csr(smime_user)
+        smime_user_principal = '@'.join((smime_user, api.env.realm))
+        with change_principal(smime_user, SMIME_USER_PW):
+            api.Command.cert_request(csr, principal=smime_user_principal,
+                                     profile_id=smime_profile.name)
+
 
 @pytest.mark.tier1
 class TestSignWithDisabledACL(XMLRPC_test):
-- 
2.8.0

From a9c7fe8b5a2f477e5dd6e70496e878c373183747 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Milan=20Kub=C3=ADk?= <mku...@redhat.com>
Date: Tue, 5 Apr 2016 10:04:37 +0200
Subject: [PATCH 2/2] ipatests: fix for change_principal context manager

The context manager was leaving API object disconnected when
an exception was raised inside of it. This led to resource leak
in the tests.
---
 ipatests/util.py | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/ipatests/util.py b/ipatests/util.py
index 6aefe74d34fd7b1bd063c4b17c98af4840d6f042..118c47a12e0d97907cb559d716989a9ca6c5f304 100644
--- a/ipatests/util.py
+++ b/ipatests/util.py
@@ -696,17 +696,18 @@ def change_principal(user, password, client=None, path=None):
 
     client.Backend.rpcclient.disconnect()
 
-    with private_ccache(ccache_name):
-        kinit_password(user, password, ccache_name)
+    try:
+        with private_ccache(ccache_name):
+            kinit_password(user, password, ccache_name)
+            client.Backend.rpcclient.connect()
+
+            try:
+                yield
+            finally:
+                client.Backend.rpcclient.disconnect()
+    finally:
         client.Backend.rpcclient.connect()
 
-        try:
-            yield
-        finally:
-            client.Backend.rpcclient.disconnect()
-
-    client.Backend.rpcclient.connect()
-
 def get_group_dn(cn):
     return DN(('cn', cn), api.env.container_group, api.env.basedn)
 
-- 
2.8.0

From 3923b51494cd5336a5a9cd9c2120d6d639f6b9ae Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Milan=20Kub=C3=ADk?= <mku...@redhat.com>
Date: Tue, 5 Apr 2016 10:04:37 +0200
Subject: [PATCH] ipatests: fix for change_principal context manager

The context manager was leaving API object disconnected when
an exception was raised inside of it. This led to resource leak
in the tests.
---
 ipatests/util.py | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/ipatests/util.py b/ipatests/util.py
index 4d99ff6e0a505cd3f75053f97caca9edbc802bcf..56b731407b3544b3b922f1831df4bc59845486d1 100644
--- a/ipatests/util.py
+++ b/ipatests/util.py
@@ -687,13 +687,14 @@ def change_principal(user, password, client=None, path=None):
 
     client.Backend.rpcclient.disconnect()
 
-    with private_ccache(ccache_name):
-        kinit_password(user, password, ccache_name)
+    try:
+        with private_ccache(ccache_name):
+            kinit_password(user, password, ccache_name)
+            client.Backend.rpcclient.connect()
+
+            try:
+                yield
+            finally:
+                client.Backend.rpcclient.disconnect()
+    finally:
         client.Backend.rpcclient.connect()
-
-        try:
-            yield
-        finally:
-            client.Backend.rpcclient.disconnect()
-
-    client.Backend.rpcclient.connect()
-- 
2.8.0

-- 
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