A text field has been added for specifying external user, host, and
service for HBAC testing.

Ticket #388

--
Endi S. Dewata
From 441a96d27c0862a3f0eabd05bcef982727a92434 Mon Sep 17 00:00:00 2001
From: Endi Sukma Dewata <edew...@redhat.com>
Date: Mon, 21 Nov 2011 18:58:38 -0600
Subject: [PATCH] Added external fields for HBAC Test.

A text field has been added for specifying external user, host, and
service for HBAC testing.

Ticket #388
---
 install/ui/facet.js    |    6 +++-
 install/ui/hbactest.js |   64 +++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 68 insertions(+), 2 deletions(-)

diff --git a/install/ui/facet.js b/install/ui/facet.js
index 4ffd43dcdbd61553ed8d010019b7942ecd577d55..0680c1502b0a6135907e42c759b2a6ad6548afa5 100644
--- a/install/ui/facet.js
+++ b/install/ui/facet.js
@@ -602,9 +602,13 @@ IPA.table_facet = function(spec) {
         batch.execute();
     };
 
+    that.get_selected_values = function() {
+        return that.table.get_selected_values();
+    };
+
     that.select_changed = function() {
 
-        that.selected_values = that.table.get_selected_values();
+        that.selected_values = that.get_selected_values();
 
         if (that.remove_button) {
             if (that.selected_values.length === 0) {
diff --git a/install/ui/hbactest.js b/install/ui/hbactest.js
index b195c796bfedbc4d78f5e653d79c9721c6a3d25b..4d35942e67e06af83392e932fc43839b6e3aaa07 100644
--- a/install/ui/hbactest.js
+++ b/install/ui/hbactest.js
@@ -195,6 +195,35 @@ IPA.hbac.test_facet = function(spec) {
 
         container.append('<br/>');
 
+        var id = that.entity.name+'-'+that.name+'-external';
+        var pkey_name = that.managed_entity.metadata.primary_key;
+
+        that.external_radio = $('<input/>', {
+            id: id,
+            type: 'radio',
+            name: pkey_name,
+            value: '__external__',
+            click: function() {
+                that.selected_values = [ that.external_radio.val() ];
+            }
+        }).appendTo(container);
+
+        $('<label/>', {
+            text: 'Specify external '+that.managed_entity.metadata.label_singular+':',
+            'for': id
+        }).appendTo(container);
+
+        container.append(' ');
+
+        that.external_text = $('<input/>', {
+            name: 'external',
+            focus: function() {
+                that.external_radio.click();
+            }
+        }).appendTo(container);
+
+        container.append('<br/>');
+
         that.create_buttons(container);
     };
 
@@ -311,13 +340,42 @@ IPA.hbac.test_facet = function(spec) {
         command.execute();
     };
 
+    that.get_selected_values = function() {
+        var values = that.table.get_selected_values();
+        if (values && values.length) return values;
+
+        if (that.external_radio && that.external_radio.is(':checked')) {
+            return [ that.external_radio.val() ];
+        }
+
+        return [];
+    };
+
     that.reset = function() {
         that.table.set_values([]);
+        that.external_radio.attr('checked', false);
+    };
+
+    that.load_records = function(records) {
+        that.table.empty();
+        for (var i=0; i<records.length; i++) {
+            that.table.add_record(records[i]);
+        }
+        if (that.selected_values[0] === '__external__') {
+            that.external_radio.attr('checked', true);
+        } else {
+            that.table.set_values(that.selected_values);
+        }
     };
 
     that.save = function(record) {
         if (that.selected_values && that.selected_values.length) {
-            record[that.name] = that.selected_values[0];
+            var value = that.selected_values[0];
+            if (value === that.external_radio.val()) {
+                record[that.name] = that.external_text.val();
+            } else {
+                record[that.name] = value;
+            }
         }
     };
 
@@ -380,6 +438,10 @@ IPA.hbac.test_rules_facet = function(spec) {
         that.create_buttons(container);
     };
 
+    that.get_selected_values = function() {
+        return that.table.get_selected_values();
+    };
+
     that.reset = function() {
         that.table.set_values([]);
         if (that.enabled) that.enabled.attr('checked', false);
-- 
1.7.5.1

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

Reply via email to