1) Add support of new options in dnsconfig

dnsconfig was extended of new attributes, so reflecting it in UI.

New attributes:
  * idnsForwardPolicy
  * idnsAllowSyncPTR
  * idnsZoneRefresh

https://fedorahosted.org/freeipa/ticket/2489

2) DNS forwarder's value can consist of IP address and a port.

The syntax is '<IP ADDRESS> port <PORT>'. A new validator was created for this purpose. It is based on IP address validator.

https://fedorahosted.org/freeipa/ticket/2490
--
Petr Vobornik
From 852f62746f1a72c272dded430ecaf29dd5af52b7 Mon Sep 17 00:00:00 2001
From: Petr Vobornik <pvobo...@redhat.com>
Date: Wed, 7 Mar 2012 09:28:54 +0100
Subject: [PATCH] Add support of new options in dnsconfig

dnsconfig was extended of new attributes, so reflecting it in UI.

New attributes:
  * idnsForwardPolicy
  * idnsAllowSyncPTR
  * idnsZoneRefresh

 https://fedorahosted.org/freeipa/ticket/2489
---
 install/ui/dns.js                        |   13 ++++++++++++-
 install/ui/test/data/dnsconfig_mod.json  |    9 +++++++++
 install/ui/test/data/dnsconfig_show.json |    9 +++++++++
 3 files changed, 30 insertions(+), 1 deletions(-)

diff --git a/install/ui/dns.js b/install/ui/dns.js
index 4cc6d4c533fb7c81429a58cf81cfe132812ca2ed..6d147300b75531a8f2b1d8258c3c2fcdf587d0da 100644
--- a/install/ui/dns.js
+++ b/install/ui/dns.js
@@ -43,10 +43,21 @@ IPA.dns.config_entity = function(spec) {
                     label: IPA.messages.objects.dnsconfig.options,
                     fields: [
                         {
+                            type: 'checkbox',
+                            name: 'idnsallowsyncptr'
+                        },
+                        {
                             type: 'multivalued',
                             name: 'idnsforwarders',
                             validators: [IPA.ip_address_validator()]
-                        }
+                        },
+                        {
+                            type: 'checkboxes',
+                            name: 'idnsforwardpolicy',
+                            mutex: true,
+                            options: IPA.create_options(['only', 'first'])
+                        },
+                        'idnszonerefresh'
                     ]
                 }
             ],
diff --git a/install/ui/test/data/dnsconfig_mod.json b/install/ui/test/data/dnsconfig_mod.json
index e82e0735ed89439e29fed19c188f088e22cc0bc9..d6e1b8c2d4c2cf7085281d0be5658a18026d855b 100644
--- a/install/ui/test/data/dnsconfig_mod.json
+++ b/install/ui/test/data/dnsconfig_mod.json
@@ -17,9 +17,18 @@
             "cn": [
                 "dns"
             ],
+            "idnsallowsyncptr": [
+                "FALSE"
+            ],
             "idnsforwarders": [
                 "2001:beef::1"
             ],
+            "idnsforwardpolicy": [
+                "first"
+            ],
+            "idnszonerefresh": [
+                "20"
+            ],
             "objectclass": [
                 "idnsConfigObject",
                 "nsContainer",
diff --git a/install/ui/test/data/dnsconfig_show.json b/install/ui/test/data/dnsconfig_show.json
index e663abcc8b4c63d3a99e6de6f4e40a93e127ab1b..4ee15cd2f0ba290f747dbd7fb739c780e89d9667 100644
--- a/install/ui/test/data/dnsconfig_show.json
+++ b/install/ui/test/data/dnsconfig_show.json
@@ -18,9 +18,18 @@
                 "dns"
             ],
             "dn": "cn=dns,dc=dev,dc=example,dc=com",
+            "idnsallowsyncptr": [
+                "FALSE"
+            ],
             "idnsforwarders": [
                 "2001:beef::1"
             ],
+            "idnsforwardpolicy": [
+                "first"
+            ],
+            "idnszonerefresh": [
+                "20"
+            ],
             "objectclass": [
                 "idnsConfigObject",
                 "nsContainer",
-- 
1.7.7.6

From 070d1c4085e531e8e84b1ae4e16cd0ab65cb46f5 Mon Sep 17 00:00:00 2001
From: Petr Vobornik <pvobo...@redhat.com>
Date: Wed, 7 Mar 2012 14:42:59 +0100
Subject: [PATCH] DNS forwarder validator

DNS forwarder's value can consist of IP address and a port.

The syntax is '<IP ADDRESS> port <PORT>'. A new validator was created for this purpose. It is based on IP address validator.

https://fedorahosted.org/freeipa/ticket/2490
---
 install/ui/dns.js                  |   37 +++++++++++++++++++++++++++++++++--
 install/ui/test/data/ipa_init.json |    1 +
 ipalib/plugins/internal.py         |    1 +
 3 files changed, 36 insertions(+), 3 deletions(-)

diff --git a/install/ui/dns.js b/install/ui/dns.js
index 6d147300b75531a8f2b1d8258c3c2fcdf587d0da..4212f1d2446eff0d29e0b57225339e79765017fc 100644
--- a/install/ui/dns.js
+++ b/install/ui/dns.js
@@ -49,7 +49,7 @@ IPA.dns.config_entity = function(spec) {
                         {
                             type: 'multivalued',
                             name: 'idnsforwarders',
-                            validators: [IPA.ip_address_validator()]
+                            validators: [IPA.dnsforwarder_validator()]
                         },
                         {
                             type: 'checkboxes',
@@ -167,7 +167,7 @@ IPA.dns.zone_entity = function(spec) {
                     {
                         type: 'multivalued',
                         name: 'idnsforwarders',
-                        validators: [IPA.ip_address_validator()]
+                        validators: [IPA.dnsforwarder_validator()]
                     },
                     {
                         type: 'checkboxes',
@@ -2170,7 +2170,6 @@ IPA.dns.ptr_redirection_dialog = function(spec) {
     return that;
 };
 
-
 IPA.ip_address_validator = function(spec) {
 
     spec = spec || {};
@@ -2202,6 +2201,8 @@ IPA.ip_address_validator = function(spec) {
                 (that.address_type === 'IPv6' && net_type === 'v6'));
     };
 
+    that.ip_address_validate = that.validate;
+
     return that;
 };
 
@@ -2221,6 +2222,36 @@ IPA.ip_v6_address_validator = function(spec) {
     return IPA.ip_address_validator(spec);
 };
 
+IPA.dnsforwarder_validator = function(spec) {
+
+    spec = spec || {};
+    var that = IPA.ip_address_validator(spec);
+
+    that.validate = function(value) {
+
+        var address_part = value;
+
+        if (value.indexOf(' ') > - 1) {
+            var parts = value.split(' ');
+
+            if (parts.length !== 3 || parts[1] !== 'port') return that.false_result();
+
+            address_part = parts[0];
+            var port = parts[2];
+
+            if (!port.match(/^[1-9]\d*$|^0$/) || port < 0 || port > 65535) {
+                var message = IPA.messages.widget.validation.port;
+                message = message.replace('${port}', port);
+                return that.false_result(message);
+            }
+        }
+
+        return that.ip_address_validate(address_part);
+    };
+
+    return that;
+};
+
 IPA.network_validator = function(spec) {
 
     spec = spec || {};
diff --git a/install/ui/test/data/ipa_init.json b/install/ui/test/data/ipa_init.json
index 0182aab733a5541d3149ea582bd975faf04db10a..c0a4202c01baf838b7ab4074b33da2695d723518 100644
--- a/install/ui/test/data/ipa_init.json
+++ b/install/ui/test/data/ipa_init.json
@@ -442,6 +442,7 @@
                             "max_value": "Maximum value is ${value}",
                             "min_value": "Minimum value is ${value}",
                             "net_address": "Not a valid network address",
+                            "port": "'${port}' is not a valid port",
                             "required": "Required field",
                             "unsupported": "Unsupported value"
                         }
diff --git a/ipalib/plugins/internal.py b/ipalib/plugins/internal.py
index deff866eee1c073f3f786686fd2e74f9261ba6b4..135a0308c4594408b19782a189c2dca2d384a437 100644
--- a/ipalib/plugins/internal.py
+++ b/ipalib/plugins/internal.py
@@ -581,6 +581,7 @@ class i18n_messages(Command):
                 "max_value": _("Maximum value is ${value}"),
                 "min_value": _("Minimum value is ${value}"),
                 "net_address": _("Not a valid network address"),
+                "port": _("'${port}' is not a valid port"),
                 "required": _("Required field"),
                 "unsupported": _("Unsupported value"),
             },
-- 
1.7.7.6

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to