From 1e836d2d0c8916f5b8a352cc8395048f1147554d Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Wed, 19 Dec 2012 04:25:24 -0500 Subject: Switch client to JSON-RPC Modify ipalib.rpc to support JSON-RPC in addition to XML-RPC. This is done by subclassing and extending xmlrpclib, because our existing code relies on xmlrpclib internals. The URI to use is given in the new jsonrpc_uri env variable. When it is not given, it is generated from xmlrpc_uri by replacing /xml with /json. The rpc_json_uri env variable existed before, but was unused, undocumented and not set the install scripts. This patch removes it in favor of jsonrpc_uri (for consistency with xmlrpc_uri). Add the rpc_protocol env variable to control the protocol IPA uses. rpc_protocol defaults to 'jsonrpc', but may be changed to 'xmlrpc'. Make backend.Executioner and tests use the backend specified by rpc_protocol. For compatibility with unwrap_xml, decoding JSON now gives tuples instead of lists. Design: http://freeipa.org/page/V3/JSON-RPC Ticket: https://fedorahosted.org/freeipa/ticket/3299 --- ipatests/test_xmlrpc/test_dns_plugin.py | 4 ++-- ipatests/test_xmlrpc/test_external_members.py | 4 ++-- ipatests/test_xmlrpc/test_trust_plugin.py | 4 ++-- ipatests/test_xmlrpc/xmlrpc_test.py | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) (limited to 'ipatests/test_xmlrpc') diff --git a/ipatests/test_xmlrpc/test_dns_plugin.py b/ipatests/test_xmlrpc/test_dns_plugin.py index 1bfaee71..81e8e4ed 100644 --- a/ipatests/test_xmlrpc/test_dns_plugin.py +++ b/ipatests/test_xmlrpc/test_dns_plugin.py @@ -63,8 +63,8 @@ class test_dns(Declarative): def setUpClass(cls): super(test_dns, cls).setUpClass() - if not api.Backend.xmlclient.isconnected(): - api.Backend.xmlclient.connect(fallback=False) + if not api.Backend.rpcclient.isconnected(): + api.Backend.rpcclient.connect(fallback=False) try: api.Command['dnszone_add'](dnszone1, idnssoamname = dnszone1_mname, diff --git a/ipatests/test_xmlrpc/test_external_members.py b/ipatests/test_xmlrpc/test_external_members.py index 112470dc..a2128cb7 100644 --- a/ipatests/test_xmlrpc/test_external_members.py +++ b/ipatests/test_xmlrpc/test_external_members.py @@ -45,8 +45,8 @@ class test_external_members(Declarative): @classmethod def setUpClass(cls): super(test_external_members, cls).setUpClass() - if not api.Backend.xmlclient.isconnected(): - api.Backend.xmlclient.connect(fallback=False) + if not api.Backend.rpcclient.isconnected(): + api.Backend.rpcclient.connect(fallback=False) trusts = api.Command['trust_find']() if trusts['count'] == 0: diff --git a/ipatests/test_xmlrpc/test_trust_plugin.py b/ipatests/test_xmlrpc/test_trust_plugin.py index 0223e8b3..5260b406 100644 --- a/ipatests/test_xmlrpc/test_trust_plugin.py +++ b/ipatests/test_xmlrpc/test_trust_plugin.py @@ -41,8 +41,8 @@ class test_trustconfig(Declarative): @classmethod def setUpClass(cls): super(test_trustconfig, cls).setUpClass() - if not api.Backend.xmlclient.isconnected(): - api.Backend.xmlclient.connect(fallback=False) + if not api.Backend.rpcclient.isconnected(): + api.Backend.rpcclient.connect(fallback=False) try: api.Command['trustconfig_show'](trust_type=u'ad') except errors.NotFound: diff --git a/ipatests/test_xmlrpc/xmlrpc_test.py b/ipatests/test_xmlrpc/xmlrpc_test.py index 2d12bcb3..04d69475 100644 --- a/ipatests/test_xmlrpc/xmlrpc_test.py +++ b/ipatests/test_xmlrpc/xmlrpc_test.py @@ -86,8 +86,8 @@ def fuzzy_set_ci(s): return Fuzzy(test=lambda other: set(x.lower() for x in other) == set(y.lower() for y in s)) try: - if not api.Backend.xmlclient.isconnected(): - api.Backend.xmlclient.connect(fallback=False) + if not api.Backend.rpcclient.isconnected(): + api.Backend.rpcclient.connect(fallback=False) res = api.Command['user_show'](u'notfound') except errors.NetworkError: server_available = False @@ -163,8 +163,8 @@ class XMLRPC_test(object): (cls.__module__, api.env.xmlrpc_uri)) def setUp(self): - if not api.Backend.xmlclient.isconnected(): - api.Backend.xmlclient.connect(fallback=False) + if not api.Backend.rpcclient.isconnected(): + api.Backend.rpcclient.connect(fallback=False) def tearDown(self): """ -- cgit