pgreco / rpms / ipa

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