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