21de49
From 489ac5a5da034394c09043d6c26700e4ae049b78 Mon Sep 17 00:00:00 2001
21de49
From: Florence Blanc-Renaud <flo@redhat.com>
21de49
Date: Fri, 23 Nov 2018 10:23:40 +0100
21de49
Subject: [PATCH] ipatests: add xmlrpc test for user|host-find --certificate
21de49
21de49
There were no xmlrpc tests for ipa user-find --certificate
21de49
or ipa host-find --certificate.
21de49
The commit adds tests for these commands.
21de49
21de49
Related to https://pagure.io/freeipa/issue/7770
21de49
21de49
Reviewed-By: Christian Heimes <cheimes@redhat.com>
21de49
Reviewed-By: Christian Heimes <cheimes@redhat.com>
21de49
---
21de49
 ipatests/test_xmlrpc/test_host_plugin.py |  5 ++++
21de49
 ipatests/test_xmlrpc/test_user_plugin.py | 31 ++++++++++++++++++++++++
21de49
 2 files changed, 36 insertions(+)
21de49
21de49
diff --git a/ipatests/test_xmlrpc/test_host_plugin.py b/ipatests/test_xmlrpc/test_host_plugin.py
21de49
index 8255296d1794bfa19c1f4642bb4bfb9212567b1e..1bcc90b0c48c811356ec93813834d6aa6805a921 100644
21de49
--- a/ipatests/test_xmlrpc/test_host_plugin.py
21de49
+++ b/ipatests/test_xmlrpc/test_host_plugin.py
21de49
@@ -251,6 +251,11 @@ class TestCRUD(XMLRPC_test):
21de49
                         valid_not_after=fuzzy_date,
21de49
                     ))
21de49
         host.retrieve()
21de49
+        # test host-find with --certificate
21de49
+        command = host.make_find_command(
21de49
+            fqdn=host.fqdn, usercertificate=host_cert)
21de49
+        res = command()['result']
21de49
+        assert len(res) == 1
21de49
 
21de49
     def test_try_rename(self, host):
21de49
         host.ensure_exists()
21de49
diff --git a/ipatests/test_xmlrpc/test_user_plugin.py b/ipatests/test_xmlrpc/test_user_plugin.py
21de49
index af825f79daf21720e164dd8cd01576167fb440c4..8e54d04bd79888c447368250c3a2e182029a3b44 100644
21de49
--- a/ipatests/test_xmlrpc/test_user_plugin.py
21de49
+++ b/ipatests/test_xmlrpc/test_user_plugin.py
21de49
@@ -25,6 +25,7 @@ Test the `ipaserver/plugins/user.py` module.
21de49
 """
21de49
 
21de49
 import pytest
21de49
+import base64
21de49
 import datetime
21de49
 import ldap
21de49
 import re
21de49
@@ -220,6 +221,36 @@ class TestUser(XMLRPC_test):
21de49
         user.check_update(result)
21de49
         user.delete()
21de49
 
21de49
+    def test_find_cert(self, user):
21de49
+        """ Add a usercertificate and perform a user-find --certificate """
21de49
+        user_cert = (
21de49
+            u"MIICszCCAZugAwIBAgICM24wDQYJKoZIhvcNAQELBQAwIzEUMBIGA1UEChML\r\n"
21de49
+            "RVhBTVBMRS5PUkcxCzAJBgNVBAMTAkNBMB4XDTE3MDExOTEwMjUyOVoXDTE3M\r\n"
21de49
+            "DQxOTEwMjUyOVowFjEUMBIGA1UEAxMLc3RhZ2V1c2VyLTEwggEiMA0GCSqGSI\r\n"
21de49
+            "b3DQEBAQUAA4IBDwAwggEKAoIBAQCq03FRQQBvq4HwYMKP8USLZuOkKzuIs2V\r\n"
21de49
+            "Pt8k/+nO1dADrzMogKDiUDjCwYoG2UM/sj6P+PJUUCNDLh5eRRI+aR5VE5y2a\r\n"
21de49
+            "K95iCsj1ByDWrugAUXgr8GUUr+UbaGc0XxHCMnQBkYhzbXY3u91KYRRh5l3lx\r\n"
21de49
+            "RSICcVeJFJ/tiMS14Vsor1DWykHGz1wm0Zjwg1XDV3oea+uwrSz5Pa6RNPlgC\r\n"
21de49
+            "+GGW6B7+8qC2XdSSEwvY7y1SAGgqyOxN/FLwvqqMDNU0uX7fww587uZ57IfYz\r\n"
21de49
+            "b8Xn5DAprRFNk40FDc46rMlkPBT+Tij1I0jedD8h2e6WEa7JRU6SGToYDbRm4\r\n"
21de49
+            "RL9xAgMBAAEwDQYJKoZIhvcNAQELBQADggEBAHqm1jXzYer9oSjYs9qh1jWpM\r\n"
21de49
+            "vTcN+0/z1uuX++Wezh3lG7IzYtypbZNxlXDECyrkUh+9oxzMJqdlZ562ko2br\r\n"
21de49
+            "uK6X5csbbM9uVsUva8NCsPPfZXDhrYaMKFvQGFY4pO3uhFGhccob037VN5Ifm\r\n"
21de49
+            "aKGM8aJ40cw2PQh38QPDdemizyVCThQ9Pcr+WgWKiG+t2Gd9NldJRLEhky0bW\r\n"
21de49
+            "2fc4zWZVbGq5nFXy1k+d/bgkHbVzf255eFZOKKy0NgZwig+uSlhVWPJjS4Z1w\r\n"
21de49
+            "LbpBKxTZp/xD0yEARs0u1ZcCELO/BkgQM50EDKmahIM4mdCs/7j1B/DdWs2i3\r\n"
21de49
+            "5lnbjxYYiUiyA=")
21de49
+        user.ensure_exists()
21de49
+        user.update(dict(usercertificate=user_cert),
21de49
+                    expected_updates=dict(
21de49
+                        usercertificate=[base64.b64decode(user_cert)])
21de49
+                    )
21de49
+        command = user.make_find_command(uid=user.name,
21de49
+                                         usercertificate=user_cert)
21de49
+        res = command()['result']
21de49
+        assert len(res) == 1
21de49
+        user.delete()
21de49
+
21de49
 
21de49
 @pytest.mark.tier1
21de49
 class TestFind(XMLRPC_test):
21de49
-- 
21de49
2.17.2
21de49