Added one more test, resolved the pep8 issues

On 10/19/2016 12:32 PM, Oleg Fayans wrote:
Hi Martin,

As you suggested, I've extended the
test_xmlrpc/test_add_remove_cert_cmd.py to contain basic tests for certs
in idoverrides.
The integration part still needs some polishing in the part related to
user lookup by cert

On 10/14/2016 03:57 PM, Martin Babinsky wrote:
On 10/14/2016 03:48 PM, Oleg Fayans wrote:
So, did I understand correctly, that there would be 2 patches: one
containing test for basic idoverrides functionality without
AD-integration, and the second one - with AD-integration and an sssd
check, correct?
I guess, the
freeipa-ofayans-0050.1-Automated-test-for-certs-in-idoverrides-feature.patch


might be a good candidate for the first one, I only have to change the
filename to test_idviews.py, right?


Oleg, we already have XMLRPC tests for idoverrides:

ipatests/test_xmlrpc/test_idviews_plugin.py

Is there any particular reason why not to extend them with add
cert/remove cert operations?

Even better, you can extend
`ipatests/test_xmlrpc/test_add_remove_cert_cmd.py` suite by doing the
same set of tests on idoverrideuser objects.

Or am I missing something?

On 09/15/2016 10:32 AM, Martin Basti wrote:


On 15.09.2016 10:10, Oleg Fayans wrote:
Hi Martin,

The file was renamed. Did I understand correctly that for now we are
leaving the test as is and are planning to extend it later?

I would like to have there SSSD check involved, please use what Summit
recommends. No new test cases.

And this can be done by separate patch, I want to have API/CLI
certificate override tests for non-AD idview (extending current tests I
posted in this thread)

Martin^2

On 09/15/2016 09:49 AM, Martin Basti wrote:


On 14.09.2016 18:53, Sumit Bose wrote:
On Wed, Sep 14, 2016 at 06:03:37PM +0200, Martin Basti wrote:

On 14.09.2016 17:53, Alexander Bokovoy wrote:
On Wed, 14 Sep 2016, Martin Basti wrote:

On 14.09.2016 17:41, Alexander Bokovoy wrote:
On Wed, 14 Sep 2016, Martin Basti wrote:
1)
I still don't see the reason why AD trust is needed. Default
trust ID view is added just by ipa-adtrust-install, adding
trust is not needed for current implementation. You don't
need AD for this, IDviews is generic feature not just for
AD. Is that user configured on AD side?
You cannot add non-AD user to 'default trust view', so you will
not be
able to set up certificates to ID override which does not exist.

For non-'default trust view' you can add both IPA and AD users,
so using
some other view and then assign certificate for a ID override in
that
one.

Ok then, but anyway I would like to see API/CLI tests for this
feature with proper output validation.


How can be this tested with SSSD?
You need to log into the system with a certificate...
Is this possible from test? We are logged remotely as root, is
there any
cmdline util which allows us to test certificate against AD user?

You can use 'sss_ssh_authorizedkeys aduser@ad.domain' which should
return the ssh key derived from the public key in the certificate.
This
should work for certificate stored in AD as well as for overrides.

You can also you the DBus lookup by certificate as described in
https://fedorahosted.org/sssd/wiki/DesignDocs/LookupUsersByCertificate


.

HTH

bye,
Sumit

Thank you Alexander and Summit for hints.

Oleg I realized we don't have any other idviews integration tests

So I propose to rename test file you are adding to
test_idviews.py. We
can add more testcases for idviews there later

Martin^2
Martin^2

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














--
Oleg Fayans
Quality Engineer
FreeIPA team
RedHat.
From 91a14f2604370c2fc314af6768ddaa112b9b0649 Mon Sep 17 00:00:00 2001
From: Oleg Fayans <ofay...@redhat.com>
Date: Fri, 21 Oct 2016 10:53:19 +0200
Subject: [PATCH] tests: Added basic tests for certs in idoverrides

https://fedorahosted.org/freeipa/ticket/6412
---
 ipatests/test_xmlrpc/test_add_remove_cert_cmd.py | 91 ++++++++++++++++++++++++
 1 file changed, 91 insertions(+)

diff --git a/ipatests/test_xmlrpc/test_add_remove_cert_cmd.py b/ipatests/test_xmlrpc/test_add_remove_cert_cmd.py
index edc97f07b0bf7d621bf9313a8ba20b4071b9e394..cc190329416dd001dc7435737b33c696a9f9ac7e 100644
--- a/ipatests/test_xmlrpc/test_add_remove_cert_cmd.py
+++ b/ipatests/test_xmlrpc/test_add_remove_cert_cmd.py
@@ -352,3 +352,94 @@ class TestCertManipCmdService(CertManipCmdTestBase):
             api.Command.host_del(TestCertManipCmdHost.entity_pkey)
         except errors.NotFound:
             pass
+
+
+@pytest.mark.tier1
+class TestCertManipIdOverride(XMLRPC_test):
+    idview = u'testview'
+    testuser = u'testuser'
+    entity_subject = testuser
+    entity_principal = testuser
+
+    cert_add_cmd = api.Command.idoverrideuser_add_cert
+    cert_del_cmd = api.Command.idoverrideuser_remove_cert
+
+    def del_cert_from_idoverride(self, username, view_name, cert):
+        result = self.cert_del_cmd(view_name,
+                                   username,
+                                   "--certificate=%s" % cert)
+        return dict(
+            usercertificate=result['result'].get('usercertificate', []),
+            value=result.get('value'),
+            summary=result.get('summary')
+        )
+
+    def add_cert_to_idoverride(self, username, view_name, cert):
+        result = self.cert_add_cmd(view_name,
+                                   username,
+                                   usercertificate=cert)
+        return dict(
+            usercertificate=result['result'].get('usercertificate', []),
+            value=result.get('value'),
+            summary=result.get('summary')
+        )
+
+    @classmethod
+    def teardown_class(cls):
+        api.Command.user_del(cls.testuser)
+        api.Command.idview_del(cls.idview)
+        super(TestCertManipIdOverride, cls).teardown_class()
+
+    @classmethod
+    def setup_class(cls):
+        # Create an idview
+        api.Command.idview_add(cls.idview)
+        # Create a user
+        api.Command.user_add(cls.testuser, givenname=u'Bob', sn=u'Dylan')
+        # Add the user to the idview
+        api.Command.idoverrideuser_add(cls.idview, cls.testuser)
+        # Create certificates
+        cls.certs = [
+            get_testcert(DN(('CN', cls.entity_subject)), cls.entity_principal)
+            for _i in range(2)
+        ]
+        cls.cert1 = cls.certs[0]
+        cls.cert2 = cls.certs[1]
+
+        super(TestCertManipIdOverride, cls).setup_class()
+
+    def test_00_add_cert_to_idoverride(self):
+        assert_deepequal(
+            dict(usercertificate=(base64.b64decode(self.cert1),),
+                 summary="Added certificates to"
+                         " idoverrideuser \"%s\"" % self.testuser,
+                 value=self.testuser,
+                 ),
+            self.add_cert_to_idoverride(self.testuser,
+                                        self.idview,
+                                        self.cert1)
+        )
+
+    def test_01_add_second_cert_to_idoverride(self):
+        assert_deepequal(
+            dict(
+                usercertificate=(base64.b64decode(self.cert1),
+                                 base64.b64decode(self.cert2)),
+                summary="Added certificates to"
+                        " idoverrideuser \"%s\"" % self.testuser,
+                value=self.testuser,
+            ),
+            self.add_cert_to_idoverride(self.testuser, self.idview, self.cert2)
+        )
+
+    def test_02_add_the_same_cert_to_idoverride(self):
+        raises(errors.ExecutionError,
+               self.add_cert_to_idoverride,
+               self.testuser, self.idview, self.cert1)
+
+    def test_04_user_show_displays_cert(self):
+        result = api.Command.idoverrideuser_show(self.idview, self.testuser)
+        assert_deepequal((base64.b64decode(self.cert1),
+                          base64.b64decode(self.cert2)),
+                         result['result']['usercertificate']
+                         )
-- 
2.7.4

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