summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Kosek <mkosek@redhat.com>2011-10-11 10:54:34 +0200
committerMartin Kosek <mkosek@redhat.com>2011-10-11 15:15:15 +0200
commit070bc7f725dc33e61bf421b9973292721ae6fbfa (patch)
treeca887167f6d7074c6bd19bf35af7777cc3eef168
parent2916ad4ac2ba8bee3cd66e6c6f30e3cdcb913b06 (diff)
downloadfreeipa-070bc7f725dc33e61bf421b9973292721ae6fbfa.zip
freeipa-070bc7f725dc33e61bf421b9973292721ae6fbfa.tar.gz
freeipa-070bc7f725dc33e61bf421b9973292721ae6fbfa.tar.xz
Fix dnszone-add name_from_ip server validation
Ticket 1627 contained a (temporary hack-ish) fix for dnszone-add name_from_ip validation which works fine for CLI. However, when the command is not proceeded via CLI and sent directly to the RPC server, the server throws Internal Server Error. Make sure that the server returns a reasonable error. Also implement 2 unit cases testing this option https://fedorahosted.org/freeipa/ticket/1941
-rw-r--r--ipaserver/rpcserver.py9
-rw-r--r--tests/test_xmlrpc/test_dns_plugin.py48
2 files changed, 56 insertions, 1 deletions
diff --git a/ipaserver/rpcserver.py b/ipaserver/rpcserver.py
index 39cdbcc..35a1092 100644
--- a/ipaserver/rpcserver.py
+++ b/ipaserver/rpcserver.py
@@ -231,7 +231,14 @@ class WSGIExecutioner(Executioner):
finally:
os.environ['LANG'] = lang
if name:
- params = self.Command[name].args_options_2_params(*args, **options)
+ try:
+ params = self.Command[name].args_options_2_params(*args, **options)
+ except Exception, e:
+ self.info(
+ 'exception %s caught when converting options: %s', e.__class__.__name__, str(e)
+ )
+ # get at least some context of what is going on
+ params = options
if error:
self.info('%s: %s(%s): %s', context.principal, name, ', '.join(self.Command[name]._repr_iter(**params)), e.__class__.__name__)
else:
diff --git a/tests/test_xmlrpc/test_dns_plugin.py b/tests/test_xmlrpc/test_dns_plugin.py
index f9bce61..679f285 100644
--- a/tests/test_xmlrpc/test_dns_plugin.py
+++ b/tests/test_xmlrpc/test_dns_plugin.py
@@ -29,6 +29,7 @@ from xmlrpc_test import Declarative, fuzzy_digits, fuzzy_uuid
dnszone1 = u'dnszone.test'
dnszone2 = u'dnszone2.test'
revdnszone1 = u'15.142.80.in-addr.arpa.'
+revdnszone1_ip = u'80.142.15.0/24'
dnsres1 = u'testdnsres'
class test_dns(Declarative):
@@ -551,6 +552,53 @@ class test_dns(Declarative):
dict(
+ desc='Try to create a reverse zone from invalid IP',
+ command=(
+ 'dnszone_add', [], {
+ 'name_from_ip': u'foo',
+ 'idnssoamname': u'ns1.%s' % dnszone1,
+ 'idnssoarname': u'root.%s' % dnszone1,
+ 'ip_address' : u'1.2.3.4',
+ }
+ ),
+ expected=errors.ValidationError(name='name_from_ip', error='invalid format'),
+ ),
+
+
+ dict(
+ desc='Create reverse from IP %s zone using name_from_ip option' % revdnszone1_ip,
+ command=(
+ 'dnszone_add', [], {
+ 'name_from_ip': revdnszone1_ip,
+ 'idnssoamname': u'ns1.%s' % dnszone1,
+ 'idnssoarname': u'root.%s' % dnszone1,
+ 'ip_address' : u'1.2.3.4',
+ }
+ ),
+ expected={
+ 'value': revdnszone1,
+ 'summary': None,
+ 'result': {
+ 'dn': lambda x: DN(x) == \
+ DN(('idnsname',revdnszone1),('cn','dns'),api.env.basedn),
+ 'idnsname': [revdnszone1],
+ 'idnszoneactive': [u'TRUE'],
+ 'idnssoamname': [u'ns1.%s.' % dnszone1],
+ 'nsrecord': [u'ns1.%s.' % dnszone1],
+ 'idnssoarname': [u'root.%s.' % dnszone1],
+ 'idnssoaserial': [fuzzy_digits],
+ 'idnssoarefresh': [fuzzy_digits],
+ 'idnssoaretry': [fuzzy_digits],
+ 'idnssoaexpire': [fuzzy_digits],
+ 'idnssoaminimum': [fuzzy_digits],
+ 'idnsallowdynupdate': [u'FALSE'],
+ 'objectclass': [u'top', u'idnsrecord', u'idnszone'],
+ },
+ },
+ ),
+
+
+ dict(
desc='Delete zone %r' % dnszone1,
command=('dnszone_del', [dnszone1], {}),
expected={